0

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.

TheMaster
  • 45,448
  • 6
  • 62
  • 85
ctb
  • 3
  • 1

1 Answers1

1

The activate command does not return an app reference. Try this:

acrobat = app('Adobe Acrobat Pro')
acrobat.activate()
acrobat.open(fileURL)
Ned Deily
  • 83,389
  • 16
  • 128
  • 151
  • Good to hear. By the way, on StackOverflow when you pose a question, you should either mark an answer as accepted or keep refining your question until you get an acceptable answer. – Ned Deily Apr 08 '11 at 06:07
  • Thanks again, Ned. Fixed that too. – ctb Apr 08 '11 at 18:16