1. Printing to a printer
- Posted by Craig Welch <euphoria at welchaviation.org> Jun 05, 2004
- 414 views
I'm trying to print a sequence (using printf, pretty print, print) to a printer (as opposed to standard output or a file). The relevant code is: ============================================================ result = getPrinter() if length(result) then dummy = startDoc( "job" ) dummy = startPage() pretty_print(Printer, kanji, {1,3,1,78,"%x"}) -- or print, or puts, or whatever dummy = endPage() dummy = endDoc() releasePrinter() end if ============================================================ This brings up a printer dialogue, at which I have tried selecting different printers, or leaving it at the default printer. So far, so good. The output is created, and it appears as I would expect it to. Only thing is, despite the printer ejecting a blank page, the output doesn't go to the printer ... it goes to a DOS window ("standard output") as if I had said print(1, kanji). Any ideas? Craig
2. Re: Printing to a printer
- Posted by David <dcuny at lanset.com> Jun 05, 2004
- 445 views
Craig Welch wrote: > Only thing is, despite the printer ejecting a blank page, the output > doesn't go to the printer ... it goes to a DOS window ("standard output") > as if I had said print(1, kanji). You can't use the standard Euphoria print options. Printing to a printer is basically the same as printing graphics onto a window. You need to get the DC (device context) of the printer, and then use Win32Lib's graphic routines to render onto the page. It's up to you to figure out what font to use, how tall and wide a string of text will be, where it should be positioned on the page... Unfortunately, I'm rebuilding my machine, so I don't have any examples handy. But there should be a simple example somewhere in Win32Lib of printing. And perhaps someone's written some routines to make it easier to do? -- David Cuny
3. Re: Printing to a printer
- Posted by irv mullins <irvm at ellijay.com> Jun 05, 2004
- 425 views
Craig Welch wrote: > > > I'm trying to print a sequence (using printf, pretty print, print) > to a printer (as opposed to standard output or a file). > > Only thing is, despite the printer ejecting a blank page, the output > doesn't go to the printer ... it goes to a DOS window ("standard output") > as if I had said print(1, kanji). > > Any ideas? http://www.rapideuphoria.com/usingprinter.zip This contains instructions plus a small include file which makes this easy. It does not cover mixing fonts on a page, but if you need to do that, it would require only a minor code change - let me know if you need help. Regards, Irv
4. Re: Printing to a printer
- Posted by Derek Parnell <ddparnell at bigpond.com> Jun 06, 2004
- 396 views
Craig Welch wrote: > > > I'm trying to print a sequence (using printf, pretty print, print) > to a printer (as opposed to standard output or a file). > > The relevant code is: > ============================================================ > result = getPrinter() > if length(result) then > dummy = startDoc( "job" ) > dummy = startPage() > pretty_print(Printer, kanji, {1,3,1,78,"%x"}) > -- or print, or puts, or whatever > dummy = endPage() > dummy = endDoc() > releasePrinter() > end if > ============================================================ > This brings up a printer dialogue, at which I have tried selecting > different printers, or leaving it at the default printer. So far, so good. > The output is created, and it appears as I would expect it to. > > Only thing is, despite the printer ejecting a blank page, the output > doesn't go to the printer ... it goes to a DOS window ("standard output") > as if I had said print(1, kanji). > > Any ideas? Sure. Firstly, pretty_print only works for output to DOS files, and that includes the console 'files' STDOUT and STDERR. This means that the first parameter to pretty_print MUST be a DOS file handle. Secondly, in Win32lib, the Printer has been allocated the Control Id value of one (1). This is arbitary and might change with different releases. But for now, it means that 'pretty_print(Printer, ...)' is the same as 'pretty_print(1, ...)' which is, of course, the STDOUT DOS file handle (the screen). To fix this, that is to send output to a WINDOWS printer, you need to do it a whole other way. In Windows, you must think of printing in terms of Page Printing. That is, you build up what your page is going to look like, then send that to the printer. This the idea behind the startPage() and endPage() routines. You call startPage() for each new page. This prepares a new page area in memory. You then need to 'draw' your text and lines and images on the page using the normal wPuts(), drawText(), drawLine(), etc... calls. For each of these you need to be aware of where the 'cursor' for the next page drawing command will be. You probably should set the position explictly before each drawing command. This will involve you calculating the X/Y position based on the current font, line thickness, image size, and printer-pixels per inch, etc... Note that you do NOT have to start from the top left-hand edge and work across/down the page. You can draw stuff anywhere on the page, even overlapping stuff already drawn. After you have built up you page, the endPage() routine sends it to the printer. The endDoc() routine tells Windows that the document is complete and the spooler can release the job to the physical printer. Easy, no? -- Derek Parnell Melbourne, Australia
5. Re: Printing to a printer
- Posted by Craig Welch <euphoria at welchaviation.org> Jun 06, 2004
- 393 views
irv mullins wrote: > Craig Welch wrote: > > Any ideas? > > http://www.rapideuphoria.com/usingprinter.zip That's given me all the help I need. Many thanks, -- Craig
6. Re: Printing to a printer
- Posted by Craig Welch <euphoria at welchaviation.org> Jun 06, 2004
- 384 views
Derek Parnell wrote: > Craig Welch wrote: > > I'm trying to print a sequence (using printf, pretty print, print) > > to a printer (as opposed to standard output or a file). > <Stuff to demonstrate to me how much more difficult printing > <is than I thought!> > > Easy, no? Yes. Err, no. OK, I get the picture now. Thanks also to David, Brian, Irv and Wolf. I'm glad that in these uncertain times, the font of such knowledge can still be couriered to me ... -- Craig