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)
}
}
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
Copy link to clipboard
Copied
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
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.
Copy link to clipboard
Copied
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.