I am trying to print a pdf file to the "Adobe pdf" printer from within python 2.7.5 script. By doing so, the file size is drastically reduced.
File name and path is:
pdfdoc = theDir + "\" + clientName + "-Stats.pdf"
Suggestions as to how to approach this?
I tried the following code but since it is printing to the "Adobe pdf" printer, I get a "save as" dialog box, which I don't want.
from subprocess import call
acrobat = "C:\Program Files (x86)\Adobe\Acrobat 10.0\Acrobat\Acrobat.exe"
pdfdoc = theDir + "\\" + clientName + "-Stats.pdf"
printer = "Adobe pdf"
call([acrobat, "/T", pdfdoc, printer])
答案 0 :(得分:0)
我解决这个问题的方法是打开Adobe PDF驱动程序的打印机首选项(控制面板\硬件和声音\设备和打印机)并手动设置Adobe PDF输出文件夹。请参见下面的屏幕截图链接:
Adobe PDF Driver Printer Preferences
我也取消了选择"查看结果"但这是可选的。
您可能还需要重命名新的PDF文件。我使用shutil完成了这个并重命名,同时将文件移动到另一个目录,但你也可以使用os.rename()。我不知道如何通过Python访问Adobe以在打印期间输入新的文件名,但我怀疑这是可能的。
希望这有帮助。