Printing forms and labels in Python

Mel mwilson at the-wire.com
Sun Jun 13 09:14:56 EDT 2010


Monte Milanuk wrote:

> I realized today that one thing I have never seen covered in any Python
> tutorial is how to format and print things to a physical printer.  I did
> a little bit of searching and didn't come up with much... either I'm
> really not using the right search terms, or physical printing is a black
> hole/art...?

It's massively device-specific...

What I did when I needed precision printing was have my Python programs 
generate PostScript code, then run that through ghostscript to do the actual 
printing.  PostScript was designed to control printers down to the pixel.  
It's possible to streamline the production run by running ghostscript using 
the subprocess module.  Of course you have to learn PostScript to do this, 
which is not really simple.

The other possibility that I'm aware of might be to get a graphics package 
(the one built in to wx is the one I'm familiar with) and  set up your 
printable text and graphics in a appropriate device context suitable for 
your printer.

	Mel.




More information about the Python-list mailing list