Page 1 of 1

Automate OCR and Compression with PDFpen Pro

PostPosted: Mon Apr 28, 2025 12:18 pm
by ApapAJP
I have the following script. It seems as though it is only completing the ocr. Not the compression. Can someone help?
[code]tell application "PDFpenPro"
-- Open the incoming file
open theFile as alias

-- Check if the document needs OCR
set needsOCR to needs ocr of document 1
if needsOCR then
tell document 1
-- Perform OCR
ocr
repeat while performing ocr
delay 1
end repeat
delay 1

-- Compress the PDF after OCR
create optimized PDF
delay 1

-- Save and close
close with saving
end tell

-- Quit PDFpenPro if no documents remain
if name of window 1 is "Preferences" then
tell application "PDFpenPro" to quit
end if
else
-- Document already has text layer or OCR not needed
tell document 1 to close without saving

-- Quit PDFpenPro if no documents remain
if name of window 1 is "Preferences" then
tell application "PDFpenPro" to quit
end if
end if
end tell
/code]

Re: Automate OCR and Compression with PDFpen Pro

PostPosted: Mon Apr 28, 2025 1:11 pm
by ApapAJP
I noticed the issue. The downloaded PDFs are secured bank statements. When ocr'd they do not pick up the account number either. If I manually print to pdf (to remove the secured part) then manually ocr with my windows pc program foxit pro. I get the ocr and small size as well as hazel to pick up the account number.

Can this be done in a script (print to pdf to remove security, then ocr then compress) ?

Re: Automate OCR and Compression with PDFpen Pro

PostPosted: Tue Apr 29, 2025 8:57 am
by Mr_Noodle
You might want to look into Shortcuts, Automator or AppleScript for that.