Copy link to clipboard
Copied
How can I add a text field to all even pages of a pdf document? With the following (:: "text", 1 ::) the text field is added only to the second page of the document.
if ( fld = "undefined" ) {
var f = this.addField("MacroDate", "text", 1, [550,0,50,15]);
f.delay = true;
f.alignment = "center";
f.fillColor = color.transparent;
f.lineWidth = 0;
f.strokeColor = color.black;
f.borderStyle = border.s;
f.textSize = 8;
f.textColor = color.black;
f.textFont = font.Helv;
f.readonly = false;
f.multiline = false;
f.doNotScroll = true;
f.value = util.printd("dd/mm/yyyy", new Date());
f.delay = false;
}
Copy link to clipboard
Copied
You can use this script:
for (var p = 0; p < this.numPages; p++) {
var numb = p+1;
if (numb%2 == 0) {
var f = this.addField("MacroDate", "text", p, [550,0,50,15]);
f.delay = true;
f.alignment = "center";
f.fillColor = color.transparent;
f.lineWidth = 0;
f.strokeColor = color.black;
f.borderStyle = border.s;
f.textSize = 8;
f.textColor = color.black;
f.textFont = font.Helv;
f.readonly = false;
f.multiline = false;
f.doNotScroll = true;
f.value = util.printd("dd/mm/yyyy", new Date());
f.delay = false;
}
}
Copy link to clipboard
Copied
The third parameter of this.addField is the page number.
Copy link to clipboard
Copied
Yes, but with what should I replace to include all even pages of the document?
Copy link to clipboard
Copied
You can use this script:
for (var p = 0; p < this.numPages; p++) {
var numb = p+1;
if (numb%2 == 0) {
var f = this.addField("MacroDate", "text", p, [550,0,50,15]);
f.delay = true;
f.alignment = "center";
f.fillColor = color.transparent;
f.lineWidth = 0;
f.strokeColor = color.black;
f.borderStyle = border.s;
f.textSize = 8;
f.textColor = color.black;
f.textFont = font.Helv;
f.readonly = false;
f.multiline = false;
f.doNotScroll = true;
f.value = util.printd("dd/mm/yyyy", new Date());
f.delay = false;
}
}
Copy link to clipboard
Copied
Thank you! That worked perfect
Copy link to clipboard
Copied
However, you should know that there is an easier and built in way to add a date on all even pages:
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more