Copy link to clipboard
Copied
I am trying to create a function that opens PDFs using an array with the filenames :
var listDocs = ["KOOS.pdf", "OKS.pdf"]
var arrayLength = listDocs.length;
for (var i = 0; i < arrayLength; i++) {
var otherDoc = app.openDoc(listDocs, this);
otherDoc.getField("Serial").value=otherDoc.getField("Serial").value+1;
var pp = otherDoc.getPrintParams();
otherDoc.print(pp);
}
I am getting the error
NotAllowedError: Security settings prevent access to this property or method
It works if I just have a variable :
var listDocs = "KOOS.pdf"
and don't use the loop. It also works if I have an array with only one filename in it.
Thanks for your help
1. Change this line:
var otherDoc = app.openDoc(listDocs, this);
To:
var otherDoc = app.openDoc(listDocs, this);
Also, you should not be using the "this" keyword as it might change to point to the current file you're opening in your loop.
Instead, create a variable that points to the original file at the start of your code and use it instead of "this".
So add this line at the top:
var oldDoc = this;
And then replace all instances of "this" with "oldDoc".
And you might want to add a command that closes th
...Copy link to clipboard
Copied
1. Change this line:
var otherDoc = app.openDoc(listDocs, this);
To:
var otherDoc = app.openDoc(listDocs, this);
Also, you should not be using the "this" keyword as it might change to point to the current file you're opening in your loop.
Instead, create a variable that points to the original file at the start of your code and use it instead of "this".
So add this line at the top:
var oldDoc = this;
And then replace all instances of "this" with "oldDoc".
And you might want to add a command that closes the file after printing it.
Copy link to clipboard
Copied
Fantatsic. Thanks try67
Find more inspiration, events, and resources on the new Adobe Community
Explore Now