Your mileage may vary, but while using setprinter.exe for a similar task (many years ago) I found that the different trays can sometimes be large values like 260…
Your best bet might be to set the tray manually in the UI, and then try to look at those values via something like setprinter.exe The values from setprinter.exe show dmDefaultSource instead of DefaultSource, but it’s all the same If you need setprinter.exe it should be easily downloadable from sourceforge. HTH Steven From: python-win32 <python-win32-bounces+steven=manross....@python.org> On Behalf Of Michael Litvin Sent: Thursday, January 18, 2024 1:07 PM To: python-win32@python.org Subject: [python-win32] PyWin32 Advanced Options Hello, I am trying to print from python using the bypass tray on my printer, but I cannot seem to get it working and it always prints from tray 1. Here is my code: image = Image.open(file_path) printer_handle = win32print.OpenPrinter(printer_name) p_info = win32print.GetPrinter(printer_handle, 2) devmode = p_info["pDevMode"] devmode.PaperWidth = 3550 devmode.PaperLength = 8510 devmode.DefaultSource = 4 # bins = win32print.DeviceCapabilities(printer_name, devmode.DeviceName, win32con.DC_BINS) # bin_names = win32print.DeviceCapabilities(printer_name, devmode.DeviceName, win32con.DC_BINNAMES) # for bin, bin_name in zip(bins, bin_names): # print(f"Bin number: {bin}, Bin name: {bin_name}") hDC = win32ui.CreateDC() hDC.CreatePrinterDC(printer_name) hDC.StartDoc(file_path) hDC.StartPage() dib = ImageWin.Dib(image) dib.draw(hDC.GetHandleOutput(), (0, 0, image.size[0],image.size[1])) hDC.EndPage() hDC.EndDoc() hDC.DeleteDC()
_______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32