[python-win32] Retreive paper width from printer

Bill Burns billburns at pennswoods.net
Thu Aug 25 05:44:00 CEST 2005


[Roger]
You should be able to get that info from the DEVMODE returned
by win32print.GetPrinter using level 2.  Depending on how your
printer driver handles paper settings, look at either FormName,
PaperSize, DefaultSource, or PaperLength and PaperWidth.

Many printers also have an option to hold jobs if the paper specified
doesn't match the currently mounted form.  (but again this is highly
dependent on the printer driver)

[Bill]
Roger,
Thank you! You sent me right in the direction I needed to go!
With your help and a little 'googling', I put the following method
into my program (just for testing).

def printerProperties(self):
         pHandle = win32print.OpenPrinter(self.currentPrinter())
         properties = win32print.GetPrinter(pHandle, 2)
         pDevModeObj = properties["pDevMode"]
         print pDevModeObj.FormName
         print pDevModeObj.PaperSize
         print pDevModeObj.DefaultSource
         print pDevModeObj.PaperLength
         print pDevModeObj.PaperWidth
         win32print.ClosePrinter(pHandle)

The above prints out the information I wanted (and then some).

Thanks again for your help!

Bill





More information about the Python-win32 mailing list