Back To Index button per bookmarked page

New Here ,
Aug 02, 2018 Aug 02, 2018

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!

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

91

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 02, 2018 Aug 02, 2018

Copy link to clipboard

Copied

LATEST

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines