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?
Copy link to clipboard
Copied
Your file-path syntax is incorrect.
Use this:
app.openDoc("/C/TestFldr/API.pdf");
Copy link to clipboard
Copied
Your file-path syntax is incorrect.
Use this:
app.openDoc("/C/TestFldr/API.pdf");
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?
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
Use the Acrobat JavaScript Reference early and often
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
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.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Perfect, thanks!
Trey

