Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jswright61/e038e30655ef66c70eb7e1fa8e87eccf to your computer and use it in GitHub Desktop.
Save jswright61/e038e30655ef66c70eb7e1fa8e87eccf to your computer and use it in GitHub Desktop.
AppleScript to OCR a PDF using PDFPenPro
tell application "PDFpenPro"
open theFile as alias
-- Does the document need to be OCR'd?
get the needs ocr of document 1
if result is true then
tell document 1
ocr
repeat while performing ocr
delay 1
end repeat
delay 1
close with saving
end tell
else
-- Document was previously OCR'd or is already a text type PDF.
tell document 1
close without saving
end tell
end if
-- In PDFpen, when no documents are open, window 1 is "Preferences"
-- If other documents are open, do not close the App.
if name of window 1 is "Preferences" then
tell application "PDFpenPro"
quit
end tell
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment