Automate OCR and Compression with PDFpen Pro

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Automate OCR and Compression with PDFpen Pro 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]
ApapAJP
 
Posts: 4
Joined: Tue Mar 04, 2025 9:19 pm

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) ?
ApapAJP
 
Posts: 4
Joined: Tue Mar 04, 2025 9:19 pm

You might want to look into Shortcuts, Automator or AppleScript for that.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support