Skip to main content
Inspiring
November 13, 2018
Question

adobe acrobat javascript check to see if a file is open

  • November 13, 2018
  • 2 replies
  • 1049 views

Just need to find out how to check if a file is open using JavaScript:

I have this but it doesn't work

    if (myFile.open) <----This is where I need to check if a file is opened. 

   {

   openDoc.insertPages({cPath : p}); 

   }

   else

   {

   var openDoc = app.openDoc(mFile);

   openDoc.insertPages({cPath : p});

   } 

}

THanks.

This topic has been closed for replies.

2 replies

Thom Parker
Community Expert
Community Expert
November 14, 2018

All of the PDF files open in Acrobat are in the app.activeDocs array. However, this data is only available in a trusted context. Meaning that it can't be accessed from a document script. Here are a couple of articles on the topic:

Trust and Privilege in Acrobat Scripts

https://acrobatusers.com/tutorials/using_trusted_functions

To determine if your document is open you have to know something about it so you can test it, such as the file name and path. But you could use any unique property available from the doc object.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
November 13, 2018

Any file? A specific file?