Skip to content

Instantly share code, notes, and snippets.

@johnksv
Last active May 15, 2024 11:52
Show Gist options
  • Save johnksv/bb6f028da1dc27c65fb8a8e1eba6ebb3 to your computer and use it in GitHub Desktop.
Save johnksv/bb6f028da1dc27c65fb8a8e1eba6ebb3 to your computer and use it in GitHub Desktop.
Adobe acrobat DC - Add footer with bookmark text
var aRect = [];
//Hard coded values for bottom left corner of A4 page
aRect[0] = 24.218078613281250;
aRect[1] = 45.985595703125;
aRect[2] = 485.0216979980469;
aRect[3] = 10.20367431640625;
//Page number that bookmark maps to
var a = [];
//Bookmark name, corresponding to array a
var b = [];
for(var i = 0; i < this.bookmarkRoot.children.length; i++){
this.bookmarkRoot.children[i].execute();
a.push(this.pageNum);
b.push(this.bookmarkRoot.children[i].name);
}
//Jump back to first bookmark page
this.bookmarkRoot.children[0].execute();
var markNr;
var mark;
var nextNr = a.shift();
var nextMark = b.shift();
for (var p = 0; p < this.numPages; p++) {
if(p >= nextNr){
markNr = nextNr;
mark = nextMark;
if(a.length > 0) {
nextNr = a.shift();
nextMark = b.shift();
}
}
var f = this.addField("footerPage"+p, "text", p, aRect )
f.delay = true;
f.borderStyle = border.s;
f.lineWidth = 0;
f.readonly = true;
f.value = mark;
f.doNotSpellCheck = true;
f.textSize = 10; // Auto-sized
f.delay = false;
}
@cape-t
Copy link

cape-t commented May 15, 2024

When I paste this in to the Adobe debug console I get an error 'undefined'. How is this code to be used? Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment