I tried to execute a simple "do shell script" alone, but if you do that, the second script doesn't wait on the document to finish loading before it attempts to execute the ocr command. Make a separate call to open the file, THEN perform the OCR. I did find a way to resolve the issue though. That fails every time with the same permission error. I tested it multiple ways in ASE and got the same error every time. The other portions of it might (performing the ocr and such) but the error pops up when attempting to use AppleScript to tell PDFpenPro to open the specified file.
PDFPENPRO OCR DOCUMENT CODE
The code you provided does not work in AppleScript Editor. Even using /bin/bash or /bin/python to pass the query to a standalone script (using argv) come up with the same error, so does using osascript from the terminal. It is currently in an NSAppleScript action, but I've tried it as a /bin/osascript too. For testing purposes the file action only accepts one file, but if I can get that to work I'll add support for multiple files. I checked with their support people, and they said that since the script works in AppleScript Editor and Automator, it must be an Alfred problem. The problem I'm having is that PDFPen refuses to open the file because it doesn't have permission. I have an automator service that does it, but I like Alfred better.
I started on a workflow to call PDFPenPro via applescript to run OCR on the selected files.