OCR with PDFScanner

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

Moderator: Mr_Noodle

OCR with PDFScanner Thu Nov 01, 2018 5:34 pm • by alephtaph@gmail.com
Hi everyone

I try to create a rule to ocr a pdf and then move it to somewhere else.

I looked at the help from PDFScanner and I found this:
https://www.pdfscannerapp.com/applescript/

I'm a absolute beginner in scripting so I adapted it to this:
Code: Select all
tell application "PDFScanner"
   ocr pdf to pdf in language ger
end tell


When I run it, I got a error:
2018-11-01 22:32:23.266 hazelworker[6664] Scan 2018-11-01 13.24.47.pdf: Rule ScannerOCR matched.
2018-11-01 22:32:23.269 hazelworker[6664] [Error] AppleScript failed: Error executing AppleScript on file /Users/marco/xxxxxxxx/OCR_input/Scan 2018-11-01 13.24.47.pdf.
2018-11-01 22:32:23.269 hazelworker[6664] OSAScript error: {
NSLocalizedDescription = "The variable pdf is not defined.";
NSLocalizedFailureReason = "The variable pdf is not defined.";
OSAScriptErrorAppAddressKey = "<NSAppleEventDescriptor: null()>";
OSAScriptErrorBriefMessageKey = "The variable pdf is not defined.";
OSAScriptErrorMessageKey = "The variable pdf is not defined.";
OSAScriptErrorNumberKey = "-2753";
OSAScriptErrorOffendingObjectKey = "<NSAppleEventDescriptor: 'utxt'(\"pdf\")>";
OSAScriptErrorRangeKey = "NSRange: {0, 0}";

Thanks for any help or tricks or even a solution :)

Marco
alephtaph@gmail.com
 
Posts: 9
Joined: Thu Mar 01, 2018 5:07 pm

Re: OCR with PDFScanner Fri Nov 02, 2018 10:08 am • by Mr_Noodle
The problem is the first "ocr" in the original script refers to a variable used in a loop. You don't have the loop in your script. I think you want to use "theFile" instead there as that is the file you want to OCR.
Mr_Noodle
Site Admin
 
Posts: 11230
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: OCR with PDFScanner Sat Nov 03, 2018 7:13 am • by alephtaph@gmail.com
Thank you for your reply.

When I use the script like this:
Code: Select all
tell application "PDFScanner"
   theFile pdf to pdf in language ger
end tell

I get a compiling error.

When I use it like this:
Code: Select all
tell application "PDFScanner"
   ocr theFile to pdf in language ger
end tell


I get this error:
2018-11-03 12:13:25.786 hazelworker[8590] Scan 2018-11-01 13.24.47.pdf: Rule ScannerOCR matched.
2018-11-03 12:13:25.789 hazelworker[8590] [Error] AppleScript failed: Error executing AppleScript on file /Users/marco/Dropbox/OCR_input/Scan 2018-11-01 13.24.47.pdf.
2018-11-03 12:13:25.789 hazelworker[8590] OSAScript error: {
NSLocalizedDescription = "The variable pdf is not defined.";
NSLocalizedFailureReason = "The variable pdf is not defined.";
OSAScriptErrorAppAddressKey = "<NSAppleEventDescriptor: null()>";
OSAScriptErrorBriefMessageKey = "The variable pdf is not defined.";
OSAScriptErrorMessageKey = "The variable pdf is not defined.";
OSAScriptErrorNumberKey = "-2753";
OSAScriptErrorOffendingObjectKey = "<NSAppleEventDescriptor: 'utxt'(\"pdf\")>";
OSAScriptErrorRangeKey = "NSRange: {0, 0}";
}
alephtaph@gmail.com
 
Posts: 9
Joined: Thu Mar 01, 2018 5:07 pm

Re: OCR with PDFScanner Mon Nov 05, 2018 12:14 pm • by Mr_Noodle
Sorry, I meant "pdf", not "ocr". The second example is what I think would be correct but in the end, you need to consult with the authors of PDFScanner. They define the AppleScript commands/syntax in this case.
Mr_Noodle
Site Admin
 
Posts: 11230
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support