Send commads to printer
Peter Hansen
peter at engcorp.com
Tue Mar 16 15:53:52 EST 2004
free free wrote:
> i'am writing a python program and now i need to print some stuff. Before
> print i want to set the text to condensed text and to italic, so i have
> to send some esc commads to printer.
>
> my code
>
> pp=open("/dev/lpr","w")
> pp.write(chr(27)+chr(15))
> pp.write("This should be condensed\n")
> pp.write(chr(27)+chr(52))
> pp.write("This should be italic too\n\f")
> pp.close()
>
> what i get is text in normal font. I think chr(27) does not send the ESC
> char to printer.
chr(27) is most certainly ASCII ESCape, so the problem is elsewhere.
Why not try creating a file containing exactly the characters you want
to send, and copy that to the printer as a test? If that works, then
you can try modifying your above program to write to a file instead, for
comparison. If it doesn't work, then clearly you are not dealing with a
Python problem, but with something environment- or printer-specific.
-Peter
More information about the Python-list
mailing list