[Tutor] Printing txt files in landscape from python

Christopher Arndt chris.arndt at web.de
Thu Feb 1 17:40:24 CET 2007


János Juhász schrieb:
> do you have any idea, how I can send a txt file to the default printer in 
> landscape view with python on windows.

I assume that by "txt file", you mean a file containing ASCII text?

> I wanted to set up just the char size and the orientation of the printout.

Printers normally don't understand ASCII file sent to them, unless you
configure them (with some status codes) to do so.

Normally, the OS converts a text file sent to its printing system to
something the printer understands, like PostScript or PL5/6, and allows
you to set other options, e.g. setting landscape mode or choosing the
paper tray. Under windows, this is what the printer drivers are for,
under MAC OS X and Linux, this is done by the CUPS system.

Unfortunately, the specifics depend highly on the system, the printer
driver, the printer and the application that sends the file to the print
system.

> thinking about
>         os.system('notepad.exe /pt "%%%s"' % filename)

So this is actually your safest bet, but will only work under windows
obviously. Under Linux, you could try to use the 'a2ps' programm, but it
is not installed everywhere.

Chris


More information about the Tutor mailing list