I have an script in Python that prints PDF files.
The script works using win32api.ShellExecute()
and everything is fine, but now, I need to print PDF files that have double sided content, user manuals in concrete.
I have tried setting the duplex mode in win32print, but nothing works, the printer still print 2 pages on 2 sheets for my PDF instead of two pages on a double sided sheet.
The printer works with this mode in other applications, but with the python script doesn't work well.
This is part of the code I used to print:
name = win32print.GetDefaultPrinter()
printdefaults = {"DesiredAccess": win32print.PRINTER_ALL_ACCESS}
handle = win32print.OpenPrinter(name, printdefaults)
level = 2
attributes = win32print.GetPrinter(handle, level)
attributes['pDevMode'].Duplex
attributes['pDevMode'].Duplex = 1
win32print.SetPrinter(handle, level, attributes, 0)
win32print.GetPrinter(handle, level)['pDevMode'].Duplex
win32api.ShellExecute(0,'print','file.pdf','.','/route',0)
Any idea why this doesn't works? Thanks.