Highlighted

Handling file open error in Acrobat

Participant ,
May 28, 2019

Copy link to clipboard

Copied

Hi,

     Sorry... I don't know the correct place to place this so placing here...

     I am opening error pdf file in acrobat using applescript.  Its throwing error as popup window. I want to handle this pop up and check whether pdf file is opened or not and accordingly i need to proceed further process in pdf file.

     I am getting the below error. After that nothing proceeded in code even a alert.  I have modified the extension of html file to pdf to handling error pdfs.

     Error.png

     Code :

set fileName to "PathToPDF"

set POSIXFile to fileName

tell application "Adobe Acrobat Professional"

    activate   

    try

        open POSIXFile

    end try

    display dialog "Document Opened"

   

end tell

Topics

Acrobat SDK and JavaScript, Macintosh

Views

580

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Handling file open error in Acrobat

Participant ,
May 28, 2019

Copy link to clipboard

Copied

Hi,

     Sorry... I don't know the correct place to place this so placing here...

     I am opening error pdf file in acrobat using applescript.  Its throwing error as popup window. I want to handle this pop up and check whether pdf file is opened or not and accordingly i need to proceed further process in pdf file.

     I am getting the below error. After that nothing proceeded in code even a alert.  I have modified the extension of html file to pdf to handling error pdfs.

     Error.png

     Code :

set fileName to "PathToPDF"

set POSIXFile to fileName

tell application "Adobe Acrobat Professional"

    activate   

    try

        open POSIXFile

    end try

    display dialog "Document Opened"

   

end tell

Topics

Acrobat SDK and JavaScript, Macintosh

Views

581

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
May 28, 2019

Copy link to clipboard

Copied

This is an AppleScript issue, not an Acrobat issue.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Participant ,
May 28, 2019

Copy link to clipboard

Copied

Hi,

     Yes its is an applescript issue.  Can we handle this?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
May 29, 2019

Copy link to clipboard

Copied

I don't think so. Acrobat isn't raising any kind of AppleScript exception, it's responding to the request with a message and the task is completed. If you were to use JavaScript you can trap a failure in app.openDoc. There is a bridge from AppleScript to JavaScript described in the Acrobat SDK.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Advocate ,
May 29, 2019

Copy link to clipboard

Copied

The very first question is whether the file really exists. Can you open it manually?

The second question is whether your code is correct. Does it open any valid PDF?

Go in Script Editor and run your code, with the answers activated. Anything strange there?

If you are serious about AppleScript, you might get ScriptDebugger, which has better debugging capabilities (and much more), so that you can verify what really happens.

The error message does come from Acrobat. (although Acrobat has various messages that actually mean that the file does not exist)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Participant ,
Jun 11, 2019

Copy link to clipboard

Copied

Hi,

     Thanks for your reply...

     Valid PDFs are getting open but I want to validate PDF file whether its valid or not. I don't know how to validate so i thought to capture the error in catch but line after the open statement is not executed.

     So i could not able to validate the pdf files and not able to check whether document is opened via code due to pop up.

     Not able to handle this due to line after the open statement is executed until click the ok button of any error popup.

     Actually i want to check pdfdoc and then proceed.

Code :

set fileName to "PathToPDF"

set POSIXFile to fileName

set pdfDoc to null

tell application "Adobe Acrobat Professional"

    activate   

    try

       set pdfDoc to open POSIXFile

    end try

     if pdfDoc = null then

     return

     end if

    display dialog "Document Opened"

   

end tell

     Main reason to handle this is to capture corrupted file and error files (Extensions manually changed)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Jun 13, 2019

Copy link to clipboard

Copied

Opening a PDF in Acrobat is not a foolproof way of determining if the PDF is valid. Because there is so much bad PDF in the world, Acrobat will attempt to fix PDF files that are close but don't quite conform to the specification. It's able to do this quite often and can open a lot of really poorly coded PDF files. However, this does not mean that the PDF same will open in other PDF tools that do not perform this repair operation.

I suggest you rethink your solution.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
Jun 13, 2019

Copy link to clipboard

Copied

Automation using UI based tools is rarely nice. Look for a command line PDF tool. Also, to detect bad renames look first at the first five bytes of the file, it's a quick and easy check.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Resources
One Stop Solution for Acrobat
Edit a PDF
Add a group