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

this.insertpages causes error

Community Beginner ,
May 10, 2021 May 10, 2021

Copy link to clipboard

Copied

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)
}

}

TOPICS
Windows

Views

230

Likes

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 2 Correct answers

Community Expert , May 10, 2021 May 10, 2021

Likes

Translate

Translate
Community Beginner , May 11, 2021 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 

 

Likes

Translate

Translate
Community Expert ,
May 10, 2021 May 10, 2021

Copy link to clipboard

Copied

Likes

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 ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

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 

 

Likes

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 ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

- 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.

Likes

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 ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

LATEST

Sorry - i didn't mean to sound snarky.  I am grateful for the speedy replies and posts.  I had found those links before I posted to the board.  The disucssion of the trusted folders involved finding the folders using app.getPath("user"... - that does not work - there is no user folder path (it returns undefined) although there is a global path. Searching the drive for glob.js and the other files mentioned turns up nothing.  I suspect in the 13 years since it was written, Adobe has changed a lot.

 

Also, the explanation of how to set up the trusted function was lacking and didn't have very good examples.

 

I learn from looking at others code, importing it and changing it.  There was nothing I could use on the sites.  The link that I posted had some very rudimentary examples that were much clearer on how to structure the trusted function and how to call it.  

 

I do appreciate the attempts at helping though and apologize if I offended.

 

BTW - I am now runnning into a problem where on moderately sized documents, when I run the working code to insert ablank page, it hangs during a "consolidating fonts" event.  My latest quest is how to keep it from consolidating fonts until I'm done replacing the pages.  🙂

 

Thanks again for the assist.

Likes

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