Python win32print modifies advanced printer settings

I am using python 2.7 and win32print. I can successfully change the orientation between portrait and landscape:

PRINTER_DEFAULTS = {"DesiredAccess":win32print.PRINTER_ALL_ACCESS} pHandle = win32print.OpenPrinter('300LN1', PRINTER_DEFAULTS) properties = win32print.GetPrinter(pHandle, 2) pDevModeObj.Orientation = 2 properties["pDevMode"]=pDevModeObj win32print.SetPrinter(pHandle,2,properties,0) 

However, I want to change some custom properties for my printer, but I cannot find where to do it. This is one of the tabs I want to change: http://dl.dropbox.com/u/584330/print.jpg . I believe that these options are available when you enable the "advanced printing features" option.

Additional information (code):

 devmode=pDevModeObj for n in dir(devmode): print "%s\t%s" % (n,getattr(devmode,n)) 

Output:

 BitsPerPel 0 Clear <built-in method Clear of PyDEVMODEA object at 0x028EE750> Collate 1 Color 2 Copies 1 DefaultSource 15 DeviceName 300LN1 DisplayFixedOutput 19660815 DisplayFlags 1 DisplayFrequency 0 DisplayOrientation 65636 DitherType 4294967295 DriverData DINU" DriverExtra 824 DriverVersion 1536 Duplex 1 Fields 92401475 FormName Letter ICMIntent 2 ICMMethod 1 LogPixels 0 MediaType 1 Nup 1 Orientation 2 PanningHeight 0 PanningWidth 0 PaperLength 2794 PaperSize 1 PaperWidth 2159 PelsHeight 0 PelsWidth 0 Position_x 65538 Position_y 141495018 PrintQuality 300 Reserved1 0 Reserved2 0 Scale 100 Size 156 SpecVersion 1025 TTOption 2 YResolution 300 __class__ <type 'PyDEVMODEA'> __delattr__ <method-wrapper '__delattr__' of PyDEVMODEA object at 0x028EE750> __doc__ None __format__ <built-in method __format__ of PyDEVMODEA object at 0x028EE750> __getattribute__ <method-wrapper '__getattribute__' of PyDEVMODEA object at 0x028EE750> __hash__ <method-wrapper '__hash__' of PyDEVMODEA object at 0x028EE750> __init__ <method-wrapper '__init__' of PyDEVMODEA object at 0x028EE750> __new__ <built-in method __new__ of type object at 0x1E7B9970> __reduce__ <built-in method __reduce__ of PyDEVMODEA object at 0x028EE750> __reduce_ex__ <built-in method __reduce_ex__ of PyDEVMODEA object at 0x028EE750> __repr__ <method-wrapper '__repr__' of PyDEVMODEA object at 0x028EE750> __setattr__ <method-wrapper '__setattr__' of PyDEVMODEA object at 0x028EE750> __sizeof__ <built-in method __sizeof__ of PyDEVMODEA object at 0x028EE750> __str__ <method-wrapper '__str__' of PyDEVMODEA object at 0x028EE750> __subclasshook__ <built-in method __subclasshook__ of type object at 0x1E7B9970> 

[edit] I just tried the following code:

 win32print.DocumentProperties(0, pHandle, '300LN1', None, None, 5) 

The properties window that I want to change will appear.

Also, did you know that you can ask the printer to stop printing after clicking 300 pages?

+7
source share
1 answer
 from ctypes import windll windll['winspool.drv'].AdvancedDocumentPropertiesA(None, pHandle.handle, '300LN1', None, None) 
0
source

All Articles