Skip to main content
Inspiring
Dec 19, 2017 6:31 PM UTC
Answered

Trusted function still giving permission errors.

I wrote a function in a js file in the C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\Javascripts folder.

mySaveAs = app.trustedFunction(function(myForm, path)

{

     app.beginPriv();

     var myForm = event.target;

     return rtn = myForm.saveAs(path);

     app.endPriv();

});

I added a button to the form which calls.

mySaveAs(this, saveAsFile);

The console showsNotAllowedError: Security settings prevent access to this property or method.

App.beginPriv:15:Field Button1:Mouse Up

Is there something I am missing or doing wrong?

This topic is closed to new replies. Start a new post to keep the conversation going.
kennethr3585991Correct answer
Inspiring
Dec 21, 2017 9:58 PM UTC

I put the "trusted function" in a js file under the user folder, as opposed to the app folder and now it is behaving as expected.

8 replies

kennethr3585991AuthorCorrect answer
Inspiring
Dec 21, 2017 9:58 PM UTC

I put the "trusted function" in a js file under the user folder, as opposed to the app folder and now it is behaving as expected.

Translate
Thom Parker
Community Expert
Community Expert
Dec 22, 2017 12:53 AM UTC

That's ridiculous.  I can guarantee you the location of the trusted function is not the issue. Are you sure it wasn't the "path" variable that try pointed out?

I would suggest that you move it to the App folder and see if the issue persists. Make sure its in only one of the two locations.

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Inspiring
Dec 20, 2017 1:59 PM UTC
Bernd Alheit
Community Expert
Community Expert
Dec 19, 2017 6:40 PM UTC

What is the value of saveAsFile?

Remove the line var myForm = event.target;

Translate
Inspiring
Dec 19, 2017 6:56 PM UTC

saveAsFile is a string that is supposed to be the filename.

var saveAsFile = "/c/output/" + getField("LastName").value + ".pdf";

saveAsFile is ok (app.alert shows me what I expect it to be). I got rid of that line and still get

NotAllowedError: Security settings prevent access to this property or method.

The security settings in Adobe is set to "No Security"

Translate
Bernd Alheit
Community Expert
Community Expert
Dec 20, 2017 11:24 AM UTC

Try this:

mySaveAs = app.trustedFunction(function(myForm, path)

{

     app.beginPriv();

     console.show();

     console.println(path);

     myForm.saveAs(path);

     app.endPriv();

});

Translate