[Gambas-user] PRINTER

David Villalobos Cambronero david_villalobos_c at ...43...
Fri Mar 9 20:08:19 CET 2007


thanks Leo, it seems to solve my problem, i´ll try and tell you... but any way... thanks a lot...

David

Leonardo Miliani <leonardo at ...1237...> wrote: David Villalobos Cambronero ha scritto:
> Hi, I´m new in Gambas, beside, I´m from Costa Rica and my english is not good at all, but my question is, does somebody know if there is another way to create/print database reports whitout have to create and html file.
> 
> Regards,
> 
> David Villalobos.

I've used the printing functions a lot because a project of mine needed
to create several documents.
You have to use the draw method, creating your document as an image
(with line, squares, and textlines) and then print it.

So, your code could be like this:
PRIVATE SUB Print_Text(Text_Report as string)

  'this is needed to let the user to choose the printer
  IF Printer.SetUp() = TRUE THEN
    RETURN  'the user clicked on the Cancel button
  END IF
  'but you could do using the code below
  'Printer.Name = ""  <-- here you can put the system printer name
  Printer.Copies = Number_of_copies
  'don't select the number of copies from the Setup panel
  'because it is an unsupported feature

  Draw.Begin(Printer) 'you just begin creating your page
  'i.e. you can create a squared text
  Draw.Rect (500,500,1000,1000)
  Draw.Text (Text_Report,600,600)
  Draw.End 'this command closes the document and prints it

END

But I can tell you some extra words....
I'm unhappy to say that the printing functions don't work very well
under my system (Suse 10.2): I don't know if this is a problem of the
system or a bug in Gambas but in my program I needed to print some
copies of a document and a lot of times I didn't get any result using
the above procedure... I saw that a document was created but a lot of
times it contained no pages.... Very very strange...
So I solved in this way:
- I first choosed a file name, then I set up the document using the code
Printer.Copies = xxx
Printer.Name = ""   'tell the component to not use a real printer
Printer.File = name_of_file 'so Gambas created for me a PostScript document
Draw.Begin(Printer)
....
....
....
Draw.End

At the end of this process, I printed the document using this method:
hPrint = SHELL ("lpr " & Application.Path & "/name_file.ps") WAIT
or, if I needed a video preview before:
hPrint = SHELL ("kghostview " & Application.Path & "/namefile.ps" & " &")

(hPrint is a Process declared with DIM hPrint as PROCESS)


-- 
Ciao.
Leo.

Web: www.leonardomiliani.com
E-mail: leonardo at ...1237...
Scegli software opensource - Choose opensource software

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Gambas-user mailing list
Gambas-user at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


 	 
---------------------------------
Looking for earth-friendly autos? 
 Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.  



More information about the User mailing list