我想打印出PDF文件,但我不知道如何指定頁面格式。我想用A5格式打印所有的PDF文件。有人可以幫幫我嗎?如何在使用Python打印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)
你想縮放或裁剪,或者是什麼? –