I've tried about 5 different ways to make this work but the file just won't get sent to the printer.
I had been trying to output a png file to an Epson TM-C3500 label printer and was getting gibberish printed out on very long labels I promptly ran out of paper for the printer so I switched to a regular Brother printer, and now I don't even get gibberish, just nothing being sent to the printer.
I even tried sending a simple string to be printed and got nothing.
I can print on the printers manually and the image prints fine.
this is the current code I've been trying:
If someone out there could tell me what on earth I'm missing I would be very grateful.
This is basically my first real program in python so I'm a little lost.
I had been trying to output a png file to an Epson TM-C3500 label printer and was getting gibberish printed out on very long labels I promptly ran out of paper for the printer so I switched to a regular Brother printer, and now I don't even get gibberish, just nothing being sent to the printer.
I even tried sending a simple string to be printed and got nothing.
I can print on the printers manually and the image prints fine.
this is the current code I've been trying:
import win32print from PIL import Image # Open the PNG file im = Image.open("barcode.png") # Convert the image to a Windows bitmap bmp = im.convert("RGB").tobytes("raw", "BGR") # Set the printer name printer_name = win32print.GetDefaultPrinter() # Open the printer hPrinter = win32print.OpenPrinter(printer_name) # Set the properties of the document job = win32print.StartDocPrinter(hPrinter, 1, ("test document", None, "RAW")) # Start a page win32print.StartPagePrinter(hPrinter) # Write the image data to the printer win32print.WritePrinter(hPrinter, bmp) # End the page win32print.EndPagePrinter(hPrinter) # End the document win32print.EndDocPrinter(hPrinter) # Close the printer win32print.ClosePrinter(hPrinter)The debugger doesn't show any errors either.....
If someone out there could tell me what on earth I'm missing I would be very grateful.
This is basically my first real program in python so I'm a little lost.
Larz60+ write Dec-18-2022, 06:03 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts.