我试图用模块win32print从python打印一个pdf文件,但是我可以成功打印的唯一方法是文本。在hPrinter = win32print.OpenPrinter("\\\\Server\Printer")
filename = "test.pdf"
try:
hJob = win32print.StartDocPrinter(hPrinter, 1, ('PrintJobName',None,'RAW'))
try:
win32api.ShellExecute(0, "print", filename, None, ".", 0)
win32print.StartPagePrinter(hPrinter)
win32print.WritePrinter(hPrinter, "test") #Instead of raw text is there a way to print PDF File ?
win32print.EndPagePrinter(hPrinter)
finally:
win32print.EndDocPrinter(hPrinter)
finally:
win32print.ClosePrinter(hPrinter)
所以我不需要打印文本,而是要打印“测试.pdf“文件。在
我也试过使用win32api.ShellExecute(0, "print", filename, None, ".", 0)但是没有工作,经过一些测试,比如(getprinter,getdefault,setprinter,setdefaultprinter)它似乎没有连接打印机。这样我就不能工作了。在
这就是我用过的密码!在
^{pr2}$