Silent printing of a PDF in Python

前端 未结 1 1093
失恋的感觉
失恋的感觉 2020-11-30 05:18

I\'m trying to print a PDF with Python, without opening the PDF viewer application (Adobe, Foxit etc.). I need also to know when printing has finished (to delete the file).<

相关标签:
1条回答
  • 2020-11-30 05:43

    I suggest you install GSView and GSPrint and shell out to gsprint.exe to print the pdf.

    p = subprocess.Popen([r"p:\ath\to\gsprint.exe", "test.pdf"], 
                         stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    stdout, stderr = p.communicate()
    print stdout
    print stderr
    

    I have used this in a industrial label printing solution, works great.

    When the gsprint.exe program exits (i.e. after the call to communicate), you can delete the pdf file.

    0 讨论(0)
提交回复
热议问题