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).<
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.