Re: Printing in GTK+



Roger Leigh wrote:
"Carl B. Constantine" <duckwing duckwing ca> writes:


I have some data I want to print out in my application. How do I do it?
To make things a little different, I *might* print to one of those POS
type printers (USB) not a regular printer.

Pointers? Which classes do I need to use?


GTK+ itself doesn't currently offer any printing support, so the
question doesn't really involve GTK+ directly.  You need to either

1) Open the printer device (e.g. /dev/usb/lp0) and write data to it.
2) Open a pipe to the printer spooler (e.g. lpr -P queuename)
   and then write the job data and close the connection.

By a POS printer, I take that to mean a 40 col receipt printer sort of
thing.  These are basic devices which are basically ASCII thermal
printers plus some additional control codes and possibly some extra
bitmap raster graphics mode.  For these you just send the control
codes inline with the text you're printing to either (1) or (2) above.
Your program is entirely responsible for the formatting, layout and
cutting etc.


For the work I do, I send jobs to a receipt printer via CUPS.  After
completion of a transaction, the receipt gets printed after a barely
noticeable delay (< 0.5s).


Your best bet is to use a spooler.  This also makes networked
operation totally transparent, and is far more flexible.  You can use
libcups, lpc or lpstat etc. to get a list of all available printers if
the user needs to choose one.

It's really quite easy to generate and output postscript, which can
then be printed to any postscript printer or non postscript printer
via ghostscript. Look for the postscript "blue book" and "red book".
HP PCL 5 might be an option too.

IIRC, there's some new way of printing from X windows directly (Xprt).

Stay away from win gdi printers.

http://linuxfinances.info/info/printing.html
http://members.tripod.com/rpragana/gdiprinters.html
http://www-cdf.fnal.gov/offline/PostScript/AdobePS.html
http://www-cdf.fnal.gov/offline/PostScript/AdobePS.html#SamplePostScriptfiles



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]