print pdf file to network printer using python

scrimp scrimp212 at yahoo.com
Thu Jul 21 16:24:28 EDT 2005


I just tried it and all that printed out was garbage. I found another
way to do it. It all depends on what you wanna do. If u want to print
to the default printer (easiest way) then just use this line:

win32api.ShellExecute(0, "print", file_path, None, ".", 0)

file_path of course being the full path of the file

Now, if u wanna print to another printer then u have to add a line:

win32print.SetDefaultPrinter(printer_name)
win32api.ShellExecute(0, "print", file_path, None, ".", 0)

printer_name being the NAME of the printer that is installed on the
machine not the path of the printer

Everything works good and the PDF file comes out perfect. The only
problem I have is that ShellExecute command starts up a blank session
of Acrobat Reader. I need that Acrobat to be terminated. I think by
using ShellExecute it does not provide the correct handle that python
needs to terminate the process. Any suggestions?




More information about the Python-list mailing list