Skip to content

Instantly share code, notes, and snippets.

@hrsano645
Created July 2, 2015 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrsano645/a16c3f35deac04b2b4d9 to your computer and use it in GitHub Desktop.
Save hrsano645/a16c3f35deac04b2b4d9 to your computer and use it in GitHub Desktop.
Printing PDF File at windows and python. Use subprocess module and Adobe Acrobat Commandline Option Silent Mode
# coding: utf-8
from __future__ import division, print_function, absolute_import, unicode_literals
import subprocess
import sys
# ref: https://geonet.esri.com/thread/59446
# ref: https://helpx.adobe.com/jp/acrobat/kb/510705.html
def main(pdffile, printer_name):
# acroread = r'C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe'
acrobat = r'C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\Acrobat.exe'
# '"%s"'is to wrap double quotes around paths
# as subprocess will use list2cmdline internally if we pass it a list
# which escapes double quotes and Adobe Reader doesn't like that
cmd = '"{}" /N /T "{}" "{}"'.format(acrobat, pdffile, printer_name)
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = proc.communicate()
exit_code = proc.wait()
if __name__ == '__main__':
pdffile = sys.argv[1]
printer_name = sys.argv[2]
main(pdffile, printer_name)
@ilcorvo
Copy link

ilcorvo commented Jun 27, 2017

From: https://helpx.adobe.com/jp/acrobat/kb/510705.html ...

Issue
What options can I specify when starting Acrobat/Adobe Reader from the command line?

Solutions (resolution Method)
You can use Acrobat/Adobe Reader command-line operations as is, but it is not a supported feature. We do not provide information on the use of technical support. Please understand it before hand.
The following command list is an example of Adobe Reader, but if you use Acrobat, use Acrobat.exe instead of Acrord32.exe.
-Acrord32.exe filename
View PDF files in Adobe Reader

Startup options
/n: Start Acrobat application as another instance when you are already running Acrobat
/s: start acrobat without displaying the splash screen
/o: Launch acrobat without displaying the Open file dialog
/h: Start Acrobat but do not display it (only load it in memory)

-Acrord32.exe/p filename
print PDF files in Adobe Reader
-Acrord32.exe/t path Printername drivername portname
Start Adobe Reader and print a PDF file without displaying the Print dialog box and exit Adobe Reader

Printing options
Path: File path
Printername: Printer Name
DriverName: Printer driver name (checked with printer properties)
PortName: Printer port name (do not include the letter "/")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment