Copy link to clipboard
Copied
I’m able to create fields on everypages of a PDF using this:
for (var nPage = 0; nPage < this.numPages ; nPage++) {
var f = this.addField("myField", "text", nPage, [200, 600, 300, 660]);
}
or to a specific pages:
//Page 2
var f = this.addField("myField", "text", 1, [200, 600, 300, 660]);
or all pages except the first or the last.
But now I need to add fields to a specific set of page ex: 2-4, 6. It will probably involve an array with a loop. But I’m lost.
Any clue on how to create an array of pages numbers, and loop the process of creating fields on them? Or any tutorials (simple and clear) on how to create/use arrays and loops would be welcomed.
Thanks!
Copy link to clipboard
Copied
Try this:
for (var nPage in [1, 2, 3, 5]) {
var f = this.addField("myField", "text", nPage, [200, 600, 300, 660]);
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied