Copy link to clipboard
Copied
Hello,
I am attempting to automate the process of adding a "Back to Index" button on the first page of each section of my PDF. All the pages I want to add the button to are bookmarked. I do know that you can duplicate a button on all pages, but really I only want the button on the FIRST page of each section.
I have some coding experience, just not with Adobe javascript. I was thinking of an implementation that loops through all the bookmarks, pulling the page number they reference, and calling an "add button" function.
Is this even possible? If so, could someone guide me along they way with some pre-written scripts?
Or is there an easier way to do this?
I appreciate any help!
Copy link to clipboard
Copied
Code can be written to navigate to every bookmark and add the button onto the current page.
Like this:
function AddButtToBkmk(bk)
{
var rctButton = [...coords of button on page...];
bk.execute();
var fld = this.addField("BackButt","button",this.pageNum, rctButton);
fld.setAction("MouseUp","this.pageNum = 1");
fld.buttonSetCaption("BackToIndex");
}
this.bookmarkRoot.children.forEach(AddButtToBkmk);
You may want to set more button properties, such as the color and border