【发布时间】:2016-01-29 14:28:25
【问题描述】:
我正在尝试打印 PDF 文件,但我不知道如何指定页面格式。我想以 A5 格式打印我所有的 PDF。有人可以帮帮我吗?
# this code works and prints the PDF File, but not in the A5 Format
import subprocess
printer='MyPrinter' # name of the printer
pdffile=r"C:\Desktop\pdf_test\pdfFile.pdf" # path to PDF
acroread=r"C:\Program Files (x86)\Adobe\Acrobat 10.0\Acrobat\Acrobat.exe" # path to Acrobat Reader
# print the file
cmd='"%s" /N /T "%s" "%s"' % (acroread, pdffile, printer)
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr=proc.communicate()
exit_code=proc.wait()
另一种打印PDF文件的方式,这里也不知道如何指定格式。
import win32api
pdffile=r"C:\Desktop\pdf_test\pdfFile.pdf" # path to PDF
printer_name = 'MyPrinter' # name of the printer
out = '/d:"%s"' % (printer_name)
### print the PDF to the proper Printer
win32api.ShellExecute(0, "print", pdffile, out, ".", 0)
【问题讨论】:
-
你想缩放还是裁剪,还是什么?
标签: python pdf subprocess