I have been searching all over for a way to do this. Most suggestions say to use addField()
and add a form field to the PDF and set a footer that way. However, I do see that Acrobat has the ability to manually add a footer. (Document > Header & Footer > Add). Is there someway that I can do the equivalent in acrobat Javascript?
Attached a script with the add field method. More you will find in this discussion: https://forums.adobe.com/message/1166404#1166404 Enjoy, Reinhard
function setPageNoAsFooter {
var Box2Width = 50
for (var p = 0; p < this.numPages; p++) {
var aRect = this.getPageBox("Crop",p);
var TotWidth = aRect[2] - aRect[0]
var bStart=(TotWidth/2)-(Box2Width/2)
var bEnd=((TotWidth/2)+(Box2Width/2))
var fp = this.addField(String("xftPage"+p+1), "text", p, [bStart,30,bEnd,15]);
fp.value = "Page: " + String(p+1)+ "/" + this.numPages;
fp.textSize = 6;
fp.readonly = true;
fp.alignment="center";
}
}
function RemoveFooter() {
for (var p = 0; p < this.numPages; p++) {
var x = this.removeField(String("xftPage"+p+1));
}
}