Windows Printing using win32print
Timothy Grant
tjg at hyperlinq.net
Mon Jun 25 18:24:04 EDT 2001
I'm not much of a windows programmer, but I am in a situation
where I need to write a test programme that does a lot of very
small print jobs from a Windows box. I have downloaded
win32all, and cobbled together a little app that I think
should, maybe work, but doesn't.
In my first iteration, I simply wrote a text file, then used
os.system('copy filename lpt1:') to print it. This worked just
fine, but one of the variables I need to test is how an
interaction with the actual Windows printers works. To that end
I started reading up on win32print. I was able to come up with
the following...
import win32print
text2print = """
This is a test to see if I can get this text to actually print\n
It will be multiple lines...\n
Watch and see\n
"""
printer = win32print.OpenPrinter('Tektronix Phaser 600 Extended')
jid = win32print.StartDocPrinter(printer, 1, ('TEST DOC', 'c:\\test\\test.tjg', 'RAW'))
bytes = win32print.WritePrinter(printer, text2print)
win32print.EndDocPrinter(printer)
win32print.ClosePrinter(printer)
print bytes
Now this is where my understanding of how things should work
gets a bit shaky. I have read that the WritePrinter() function
should send printer ready data. So since text2print is not in
ps or pcl native format, I'm curious as to whether I'm even
close.
If I do need to send printer ready data, how do I create the
printer ready data from my print string?
Thanks for any assistance you might be able to provide.
--
Stand Fast,
tjg.
Timothy Grant www.hyperlinq.net
Chief Technology Officer tjg at hyperlinq.net
HyperLINq Technologies, Inc. <>< (503) 246-3630
>>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<<
>>>>This machine was last rebooted: 20 days 22:08 hours ago<<
More information about the Python-list
mailing list