Created
March 7, 2023 20:18
-
-
Save jswright61/e038e30655ef66c70eb7e1fa8e87eccf to your computer and use it in GitHub Desktop.
AppleScript to OCR a PDF using PDFPenPro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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