Skip to main content
Participant
May 10, 2021
Answered

this.insertpages causes error

  • May 10, 2021
  • 1 reply
  • 1400 views

I have a script that is causing an error.  Everything works except one line.  I am trying to insert a page in the document and the document.

The line

this.insertPages({nPage:-1, cPath:"C:\Users\xxxxx\Downloads\Documents\Blank Page PDF.PDF"});

throws an error about security settings prevent access to this method.  How do I run this code in "privleged mode"  It is Acrobat DC.
{
var numWords;

try
{
for (var i = 0; i < this.numPages; i++)
{
numWords = this.getPageNumWords(i);
if (numWords < 300) {
var PageText = "";
for (var j = 0; j < numWords; j++) {
var word = this.getPageNthWord(i,j,false);
PageText += word;
}
var strMatches = PageText.match("This Page Intentionally Left Blank");
if (strMatches != null) {
this.insertPages({nPage:-1, cPath:"C:\Users\xxxxx\Downloads\Documents\Blank Page PDF.PDF"});

}
}
}
}

catch(e)
{
app.alert("Processing error: "+e)
}

}

This topic has been closed for replies.
Correct answer defaultl7qf2n570c8z

I posted the original question and didn't find these links to be helpful at all - so I'm not sure who marked this as the correect answer.

 

These links are 13 years old, contain bad advice and don't link to pages that don't work.  Don't follow these.

 

This link was helpful and explained it better:  https://www.pdfscripting.com/public/Using-Trusted-Functions.cfm 

 

1 reply

defaultl7qf2n570c8zAuthorCorrect answer
Participant
May 11, 2021

I posted the original question and didn't find these links to be helpful at all - so I'm not sure who marked this as the correect answer.

 

These links are 13 years old, contain bad advice and don't link to pages that don't work.  Don't follow these.

 

This link was helpful and explained it better:  https://www.pdfscripting.com/public/Using-Trusted-Functions.cfm 

 

try67
Community Expert
Community Expert
May 11, 2021

- Tried all the links and they all worked.

- What "bad advice"? Care to elaborate a bit?

- Maybe it's a bit old, but it's still relevant. The only thing that changed in this field since it was posted is the location of some of the commands.