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
[email protected]
https://mail.python.org/mailman/listinfo/python-win32