Skip to main content
Participating Frequently
April 12, 2026
Answered

Adobe Acrobat Pro JavaScript to detect when a Windows dialog box cancelled

  • April 12, 2026
  • 1 reply
  • 33 views

Using Adobe Acrobat Pro javascript.  Need to detect when user clicks “Cancel” in Windows file dialog box triggered by adobe javascript importAnFDF() command.   

Using this code :

var noCatch = 0;
try{
importAnFDF();

} catch (err) {
app.alert("Import of Saved SGS File Cancelled by USER",3);
noCatch = 1;}

if(noCatch==0){
app.alert("File Imported",3);
}
 

// Code returns “File imported” when user actually cancelled the Windows dialog box.

    Correct answer Anand Sri Bhattacharya

    Hello ​@wes@ESA 

     

    I hope you are doing well, and thank you for reaching out.

    Please note that it is not possible to detect when a user clicks Cancel in the Windows file‑open dialogue triggered by importAnFDF() using Acrobat JavaScript.

    This is expected behaviour of the Acrobat JavaScript API. Please check this article for more information: https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/index.html

     

    I hope this helps.

    Regards,

    Anand Sri.

    1 reply

    Anand Sri Bhattacharya
    Community Manager
    Community Manager
    April 20, 2026

    Hello ​@wes@ESA 

     

    I hope you are doing well, and thank you for reaching out.

    Please note that it is not possible to detect when a user clicks Cancel in the Windows file‑open dialogue triggered by importAnFDF() using Acrobat JavaScript.

    This is expected behaviour of the Acrobat JavaScript API. Please check this article for more information: https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/index.html

     

    I hope this helps.

    Regards,

    Anand Sri.