• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Trusted function still giving permission errors.

Community Beginner ,
Dec 19, 2017 Dec 19, 2017

Copy link to clipboard

Copied

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?

TOPICS
Acrobat SDK and JavaScript , Windows

Views

651

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

Community Beginner , Dec 21, 2017 Dec 21, 2017

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.

Votes

Translate

Translate
Community Expert ,
Dec 19, 2017 Dec 19, 2017

Copy link to clipboard

Copied

What is the value of saveAsFile?

Remove the line var myForm = event.target;

Votes

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 ,
Dec 19, 2017 Dec 19, 2017

Copy link to clipboard

Copied

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"

Votes

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 Expert ,
Dec 20, 2017 Dec 20, 2017

Copy link to clipboard

Copied

Try this:

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

{

     app.beginPriv();

     console.show();

     console.println(path);

     myForm.saveAs(path);

     app.endPriv();

});

Votes

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 Expert ,
Dec 20, 2017 Dec 20, 2017

Copy link to clipboard

Copied

It's not a good idea to have a variable called "path" because there's a built-in property of the Document object with that name. Try using something else.

Votes

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 Expert ,
Dec 20, 2017 Dec 20, 2017

Copy link to clipboard

Copied

The security error is often a misnomer. I've seen this message popup when functions fail because of other reasons.

Did you remove the line of code Bernd suggested? this is an important one.

Are you sure that "myForm" is a document object?

Do you know that "path" is a Safe Path? and that it exists?

Can you do the same save operation from the Console Window, without getting the error message?

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

Votes

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
LEGEND ,
Dec 20, 2017 Dec 20, 2017

Copy link to clipboard

Copied

Votes

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 ,
Dec 21, 2017 Dec 21, 2017

Copy link to clipboard

Copied

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.

Votes

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 Expert ,
Dec 21, 2017 Dec 21, 2017

Copy link to clipboard

Copied

LATEST

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.

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

Votes

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