[Tutor] Outputting Data to Printer

Alan Gauld alan.gauld at btinternet.com
Fri Nov 20 09:43:06 CET 2009


"Ken G." <beachkid at insightbb.com> wrote

> Is there a Python command to send data to printer? 
> 
> I have a Canon MX300 hooked up by USB.   I can print from Firefox and 
> Thunderbird.  I am using Ubuntu 9.04 and Python 2.6.2.

There is no universal easy way to print stuff unfortunately.
In console mode on Unix its not too bad, you can send data
to lpr, just as you would from the shell.

You can also format your data using fmt or groff and send that 
to lpr as you would from the shell.

Finally, the route I tend to use nowadays is to format 
the output as html and print that via the browser.

If you are working inside a GUI and want to preserve 
formatting then it gets a whole lot harder and reaklly 
depends on the GUI framework that you are using.

> I could print to a file and then use gedit to print out the content of 
> the file but I was wondering if there was an easily way to do this.

That sounds like your needs are fairly simple so the 
lpr route is probably your best bet.

HTH,

Alan G.



More information about the Tutor mailing list