adobe acrobat javascript check to see if a file is open

Explorer ,
Nov 13, 2018

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.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

243

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 acrobat javascript check to see if a file is open

Explorer ,
Nov 13, 2018

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.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

244

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
Nov 13, 2018 0
Most Valuable Participant ,
Nov 13, 2018

Copy link to clipboard

Copied

Any file? A specific file?

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...
Nov 13, 2018 0
Adobe Community Professional ,
Nov 13, 2018

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.

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...
Nov 13, 2018 0