March 9th, 2013, 08:34 AM
Printing within Python prog (win32print)
I've tried several approaches to print from python. One of which was using subprocess. Subprocess works from the interactive window but not within my prog, gives no errors that I can use for debug. I scarped that method.
Upon goggling I went in a diff direction using win32print. The following code is what I found but doesn't work from the interactive window. It gives no errors.
printer_name = win32print.GetDefaultPrinter ()
p = win32print.OpenPrinter (printer_name)
job = win32print.StartDocPrinter (p, 1, ("test of raw data", None, "RAW"))
win32print.WritePrinter (p, "data to print")
I verify that the parameters look reasonable:
printer_name = 'Brother HL-2280DW Printer'
job = 13L
p = <PyPrinterHANDLE:5992788>
win32print.WritePrinter returns 13L
When I do the 'WritePrinter' I look at the printer visual screen and there's no indication that there's been comm with the printer.
At this point there's no indication of what the issue might be. All data leading up to the 'WritePrinter' looks normal.
Any ideas on what I could do next?