Skip to main content
epiq.derrick.yeager
Participant
August 2, 2018
Question

Back To Index button per bookmarked page

  • August 2, 2018
  • 1 reply
  • 395 views

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!

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
August 2, 2018

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

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often