What I'm trying to achieve is to print a file with win32print, so that I can inform the user about the job that is actually being printed.
It is sufficient to print the file name to standard output with print
function.
I have this code taken from here to illustrate the problem.
from win32 import win32print
import subprocess
printer_name = win32print.GetDefaultPrinter()
print("Printer: %s" % (printer_name))
hPrinter = win32print.OpenPrinter(printer_name)
try:
hJob = win32print.StartDocPrinter(hPrinter, 1, ("test of raw data", None, "RAW"))
try:
f = open("test2.ps", "r")
win32print.StartPagePrinter(hPrinter)
win32print.WritePrinter(hPrinter, bytes(f.read(), "utf-8"))
win32print.EndPagePrinter(hPrinter)
finally:
win32print.EndDocPrinter(hPrinter)
finally:
print("Printing: %s" % (hJob))
win32print.ClosePrinter(hPrinter)
How would you notify the user about what is being printed (detect starting new job)?
Here are the status codes.
e.g. 0x00000400 means the printer is printing . I can't find how to get job actually being printed.