Skip to main content
Participating Frequently
October 6, 2023
Question

NotAllowedError Security settings prevent access to this property or method

  • October 6, 2023
  • 2 replies
  • 10453 views

PLEASE HELP!!!!

 

So, I have this State form that is distributed as an XFA document (original document and my version attached).  As I understand, XFA format has always been a headache to developers.  So here's where I am, I've recreated the document using Print to Abode PDF.  Finally, I've added a button to run some javascript (pasted below).  

I've tried everything I've come across in searched articles, but repeatedly get the message - NotAllowedError: Security settings prevent access to this property or method.  I've checked the Document Security Properties and all say 'Allowed'.  Oh, almost forgot to mention, I CAN manually perform insert pages from a file going through the menu.  I'm open for any/all suggestions. 

 

Thanks a million in advance.

 

app.trustedFunction(function () {
          app.beginPriv();
          this.insertPages ({
               nPage: -1,
               cPath: "/c/temp/AdditionalMember.pdf",
               nStart: 4
          });
          app.endPriv();
     });
app.alert("Additional Member Page Added!");

This topic has been closed for replies.

2 replies

alexeys34302973
New Participant
November 26, 2024

Just enable this option:

Preferencies -> General -> Javascript -> Enable menu item javascript execution privileges.

try67
Adobe Expert
October 6, 2023

 You can't define the trusted function in the button. That would defeat the whole point of having code run from a privileged context. The (generic) function for inserting pages must be placed in a .js file in a specific folder on the local computer for it to work. You then call it from the button.

Participating Frequently
October 9, 2023

Hi, Try67;

 

Thanks a ton!  This is a good start and I am going to give it a try.  However, I can't find any examples of how to make the call to the javascript file from a button.  Any references/examples you can point me to would be greatly appreciated.

 

Thanks

Participating Frequently
October 10, 2023

You put the code in a (named) function, and then call that function from the button.

So in the .js file you have something like this:

 

 

function myTrustedInsertPages(doc, page, docPath, startPage) {

// Place trusted code here

}

 

 

And then you call it like this:

 

 

myTrustedInsertPages(this, -1, "/c/temp/AdditionalMember.pdf", 4);

 


Hi, Try67;

 

Yes, this is exactly what I did try. (I believe).  I created a .js file and saved it under - C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\Javascripts.  The file simply has this:

 

function trustedAddMember(oDoc){
app.beginPriv();
this.insertPages ({
nPage: -1,
cPath: oDoc,
nStart: 4
});
app.endPriv();
}

 

Then, for my button on document.  I added this javascript:

 

trustedAddMember("/c/temp/AdditionalMember.pdf");

app.alert("Additional Member Page Added!");

 

But, yet, I still get this message:

NotAllowedError: Security settings prevent access to this property or method.
App.beginPriv:2:Field Add Member:Mouse Up

 

As, I previously mentioned, I could manually insert a page, and looking at the document properties, there is no security in security method, and everything says "Allowed".  

 

If it helps, I'm using Adobe Acrobat Pro 2023.  I was first attempting to use .duplicate(), but discovered that was either deprecated or only used in another Adobe product.  I feel like I'm close, but just missing something somewhere.  Also, I have a button on the page for deleting a page.  It works fine, and only uses this:

 

if (this.numPages > 10)
{
this.deletePages({nStart: 4, nEnd: 4});
}