0

I am developing a Python application where it is possible to print an image. I was able to modify some document properties through the win32print library with this code:

import win32print

PRINTER_DEFAULTS = {"DesiredAccess":win32print.PRINTER_ALL_ACCESS} 
printer_name = 'DYMO LabelWriter 450'
handle = win32print.OpenPrinter(printer_name, PRINTER_DEFAULTS) 

# Get the default properties for the printer
properties = win32print.GetPrinter(handle, 2)
devmode = properties['pDevMode']

devmode.PaperWidth = 600
devmode.PaperLength = 600
devmode.PaperSize = 0
properties["pDevMode"]=devmode 

win32print.SetPrinter(handle,2,properties,0)

but I don't know how to change advanced properties such as, for example, the document format (A3, A4, ..)

  • it seems that this post has a *ton* of information on the subject, does that help at all? https://stackoverflow.com/questions/64867896/setting-default-printer-custom-page-size-with-python – Random Davis Jan 27 '22 at 16:40
  • yes, unfortunately there are only solutions that do not fit the advanced properties. Only the answer to this question: https://stackoverflow.com/questions/5555453/python-win32print-changing-advanced-printer-options oncerns the problem but does not solve it. – Sante Altamura Jan 27 '22 at 16:48

0 Answers0