Python silent print PDF to specific printer

Finally after hours and hours of searching for the right files, i have found the answer to my problem.

You can download the GSPRINT in HERE

You can download the Ghostscript GPL in HERE

With this extracted files in your PC (Windows) you can print your PDF with this command

GHOSTSCRIPT_PATH = "C:\\path\\to\\GHOSTSCRIPT\\bin\\gswin32.exe"
GSPRINT_PATH = "C:\\path\\to\\GSPRINT\\gsprint.exe"

# YOU CAN PUT HERE THE NAME OF YOUR SPECIFIC PRINTER INSTEAD OF DEFAULT
currentprinter = win32print.GetDefaultPrinter()

win32api.ShellExecute(0, 'open', GSPRINT_PATH, '-ghostscript "'+GHOSTSCRIPT_PATH+'" -printer "'+currentprinter+'" "PDFFile.pdf"', '.', 0)

The GhostScript can also be found in the Official page HERE

I found the gsprint.exe for 64bits HERE

I hope this helps.

Leave a Comment