Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


JavaScript console not allowing app.openDoc

Community Beginner ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

I'm using Adobe Acrobat X Version 10.1.16.

Acrobat JavaScript Debugger Functions Version 10.0
Acrobat EScript Built-in Functions Version 10.0
Acrobat SOAP 10.0

 

I paste and run the following code in my JavaScript console. API.pdf is a JavaScript Acrobat API file, and TestFldr is an empty folder with just that file.

app.openDoc("C:\TestFldr\API.pdf");

I receive the following output in the console.

NotAllowedError: Security settings prevent access to this property or method.
App.openDoc:1:Console undefined:Exec

Furthermore, this code doesn't work in my privileged user folder when saved as a JavaScript file, Config.js. My privileged user folder is as follows.

C:\Users\Trey\AppData\Roaming\Adobe\Acrobat\Privileged\10.0\JavaScripts\Config.js

How can I get around this?

TOPICS
How to, JavaScript

Views

483

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
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , May 26, 2021 May 26, 2021
Your file-path syntax is incorrect. Use this: app.openDoc("/C/TestFldr/API.pdf");

Likes

Translate

Translate
Adobe Community Professional ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

Your file-path syntax is incorrect.

Use this:

 

app.openDoc("/C/TestFldr/API.pdf");

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
community guidelines
Community Beginner ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

Thank you. I was indeed using the wrong syntax. This fixes the JavaScript console problem. I'm able to open the pdf directly from the console. However, the script in my Config.js now gives the following response.

NotAllowedError: Security settings prevent access to this property or method.
App.openDoc:1:Folder-Level:User:Config.js

 How do I get Acrobat to permit this operation?

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
community guidelines
Adobe Community Professional ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

Please provide the complete code used in the Config.js file. 

 

Are you using a trusted function?

https://www.pdfscripting.com/public/Using-Trusted-Functions.cfm

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
community guidelines
Community Beginner ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

Wow, hi Thom! I can't believe I'm hearing from the legend himself. I've been watching alot of your videos (full member) at PDFScripting.com. They've been very informative.  I was doing everything in Acrobat the painful way before I heard about your site. I'm a complete noob with JavaScript/Acrobat scripting so please excuse my ignorance.

 

Here is the code in my Config.js file. I am not using a trusted function. This is the first folder-level script I've tried from here (https://acrobatusers.com/tutorials/folder_level_scripts/), and I was just isolating the app.openDoc method for testing. Please note that if I uncomment the addMenuItem script, everything works as expected. I was just wondering why app.openDoc is not allowed (although I admit opening a file directly from startup is inelegant). 

app.openDoc('/C/TestFldr/API.pdf');

// Adds JS Ref item to Help Menu.
//app.addMenuItem({ 
//  cName: "JS Ref", 
//  cParent: "Help",
//  cExec: "app.openDoc('/C/TestFldr/API.pdf');",
//  cEnable: "event.rc = (event.target != null);",
//  nPos: 0
//});

//color.purple = [ "RGB", 0.5, 0, 0.5 ];
//color.turquoise = [ "RGB", 0, 0.75, 1 ];

Much appreciated,

Trey 

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
community guidelines
Adobe Community Professional ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

Thank you very much for the endorsement.

 

Opening a PDF directly in a folder level script may not be possible because these scripts load before Acrobat is fully initialized. Folder level scripts are used for initializing variables and functions that are used at a later time. Not for performing any specific actions. 

 

To test the app.openDoc script I would stronly suggest putting it in a trusted function, and then calling the trusted function from a document. 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
community guidelines
Community Beginner ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

LATEST

Perfect, thanks!

Trey

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
community guidelines