I have a PDF document and I want to print it using my python application.
I tried the solution in here (print a PDF document using python win32print module?) , But when I install Ghostscript 9.15, which is the actual version, it does not have gsprint.exe
The way I use this work is the os.startfile('PDFfile.pdf', "print")
command os.startfile('PDFfile.pdf', "print")
, but it opens the default viewer (mine is Adobe Reader), and after printing has been opened, try kill the process with os.system("TASKKILL /F /IM AcroRD32.exe")
kills other open windows, but I donβt want this.
At the next command, it also prints, but it also allows you to open Adobe Reader
currentprinter = win32print.GetDefaultPrinter() win32api.ShellExecute(0, "print", 'PDFfile.pdf', '/d:"%s"' % currentprinter, ".", 0)
I saw this answer , but they recommend using gsprint.exe
again
Does anyone have a gsprint.exe
file or any other solution?
NOTE. . When I used another default program to open PDF files, such as Chrome or Windows Reader, I always get an exception when executing the commands above '(31, 'ShellExecute', 'A device attached to the system is not functioning.')'
Or [Error 1155] No application is associated with the specified file for this operation: 'PDFfile.pdf'
using the startfile
command