Re: Printing in GTK+



"Carl B. Constantine" <duckwing duckwing ca> writes:

> * Roger Leigh (rleigh whinlatter ukfsn org) wrote:
>> "Carl B. Constantine" <duckwing duckwing ca> writes:
>> 
>> 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.
>
> yes, that's pretty much what I mean. What do I use to do layout and
> formatting before dumping to the printer?

You need to do it as you're generating the output.  For example, if I
want bold text, I might have to send

"\033\005This is bold text\0330\006 and this is plain text\n"

Where "ESC 5" and "ESC 6" turn bold on and off respectively.  The
control codes required are printer-dependent.  It's likely it uses the
Epson EPC/P, ESP/POS or Star control codes.  Your manual should tell
you, and the manufacturer should supply the programmer's manual.

If you intend to support multiple printers, you can abstract the
interface through e.g. a pure virtual base class which provides a
printing interface which derived classes specialise to provide custom
functionality.

> Where would I find information on the extra control codes? I'm sure not
> all printer manufactureres publish this sort of thing. How does that
> work with CUPS?

The manufacturers have to, otherwise it's useless.  Your manual should
say which standards it supports, and the command reference for that
standard should be available.

For CUPS, set up a raw queue (no filter driver) so what you send is
simply queued and piped direct to the printer with no special
processing.

>> 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.
>
> Ok, so I probably will use a print spooler (CUPS), what do I need to do?
> I'll look at the CUPS docs, but some fast direct pointers are nice.

Install it, then have a look at http://localhost:631/
LPRng is also a very good alternative.


If you have other printing questions, the lists on linuxprinting.org,
or comp.os.linux.misc/comp.os.linux.development.apps are good places
to ask (since this is not really a GTK+ topic).


Regards,
Roger

-- 
Roger Leigh

                Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
                GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.



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