python - 使用 Python 打印 PDF 文件
问题描述
我正在尝试在 Python 2.7 中打开一个 pdf 文件、打印该文件并关闭 Adobe Acrobat。
import os
fd = os.startfile("temp.pdf", "print")
os.close(fd)
运行代码后,出现以下错误os.close(fd)
:
TypeError: an integer is required
解决方案
这是我想出的解决方案:
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()
推荐阅读
- python - 我如何从 python 中的 txt 文件中请求每个令牌
- javascript - 如何垂直对齐输入按钮。引导程序3
- android - com.google.android.exoplayer2.text.SubtitleDecoderException
- javascript - 获取表单数据到 javascript webhook
- reactjs - Vue.config.js - 创建一个 main.js 文件并从 /static/ 提供它
- android - android中的rasa聊天机器人响应错误
- javascript - 使用 Ajax 处理 json HttpResponse
- windows - 使用 EXTRAC32 命令批量闪烁窗口提取警报
- c++ - 线程堆栈大小限制
- javascript - 如何以编程方式清除 Firebase 实时数据库