adobe acrobat javascript check to see if a file is open
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Any file? A specific file?
Copy link to clipboard
Copied
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.
Use the Acrobat JavaScript Reference early and often

