Printing PDF files with Python

▼魔方 西西 提交于 2020-12-11 10:11:00

问题


I am trying to open a pdf file, print the file, and close Adobe Acrobat in Python 2.7.

import os

fd = os.startfile("temp.pdf", "print")
os.close(fd)

After running the code, I get the following error on the os.close(fd) line:

TypeError: an integer is required

回答1:


Here's the solution that I came up with:

    os.startfile("temp.pdf", "print")
    sleep(5)
    for p in psutil.process_iter(): #Close Acrobat after printing the PDF
        if 'AcroRd' in str(p):
            p.kill()


来源:https://stackoverflow.com/questions/51385324/printing-pdf-files-with-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!