appscript 属性错误
我是编程新手,也是Python新手。我正在尝试在 python 脚本中使用 appscript 来选择 pdf 和新的目标文件夹,在 Adobe Acrobat Pro 中打开 pdf,对其进行 OCR,然后将其保存在新文件夹中。一路测试,在 acrobat 打开 pdf 后,我收到一个 AttributeError 错误,这会在 OCR 发生之前使程序出错。这是代码:
import easygui, os, time, mactypes
from appscript import *
fileURL = easygui.fileopenbox(filetypes=["*.pdf"])
time.sleep(1)
destDir = easygui.diropenbox()
acrobat = app('Adobe Acrobat Pro').activate()
acrobat.open(fileURL)
并且,这是错误回溯:
Traceback (most recent call last):
File "/Users/chadblack/Dropbox/001-DH_Scripts/splitOCRpdf.py", line 19, in <module>
acrobat.open(fileURL)
AttributeError: 'NoneType' object has no attribute 'open'
注意,pdf 确实在 Acrobat 中打开,该属性错误会破坏脚本。
I'm new to programming, and to python. I'm trying to use appscript in a python script to choose a pdf and a new destination folder, open the pdf in Adobe Acrobat Pro, OCR it, and save it in the new folder. Testing along they way, I'm getting an AttributeError after acrobat opens the pdf, which trips the program before the OCR can happen. Here's the code:
import easygui, os, time, mactypes
from appscript import *
fileURL = easygui.fileopenbox(filetypes=["*.pdf"])
time.sleep(1)
destDir = easygui.diropenbox()
acrobat = app('Adobe Acrobat Pro').activate()
acrobat.open(fileURL)
And, here's the error traceback:
Traceback (most recent call last):
File "/Users/chadblack/Dropbox/001-DH_Scripts/splitOCRpdf.py", line 19, in <module>
acrobat.open(fileURL)
AttributeError: 'NoneType' object has no attribute 'open'
Note, the pdf DOES open in Acrobat, that attribute error breaks the script.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
activate
命令不会返回app
引用。试试这个:The
activate
command does not return anapp
reference. Try this: