Re: Printing in GTK+

would printing to a spooler be cross platform?  I mean would this process
you describe be similar if I wanted to print in win32 as it is in Linux?


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.


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