Windows Printing using win32print

Alan Miller ajm at enteract.com
Tue Jun 26 13:03:06 EDT 2001


Timothy Grant (tjg at hyperlinq.net) wrote:
>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.
>
>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)

I'm not sure of the details because StartDocPrinter and EndDocPrinter 
appear to be new additions to win32print and they aren't covered in the 
documentation on the web site.

In a VB program I did some time ago, I wasn't initializing the data type 
(you're passing 'RAW') and had no problems at all.  Looking at some of 
the online docs from MS, it's not clear that anything other than an 
empty string is required - they have examples that theoretically do the 
same thing, but some pass RAW and some pass an empty string.

I'd try passing an empty string in that tuple.

ajm



More information about the Python-list mailing list