• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Get the Bookmark Object of a Clicked Bookmark by Javascript

Community Beginner ,
Nov 16, 2021 Nov 16, 2021

Copy link to clipboard

Copied

I want to make bookmarks as bellow using Javascript.
- Each bookmark has a same name as each layers in pdf.
- Each bookmark has the following action.
  When the bookmark is clicked, the only layer with same name as the bookmark will be displayed.
----------------------------------------------
var layers = this.getOCGs();
for (var j in layers){
    this.bookmarkRoot.createChild(layers[j].name, "xxxxxx");
}

----------------------------------------------

 

I want to enter the following script into "xxxxxx". (cExpr augument of createChild method)
----------------------------------------------
var layers = this.getOCGs();
for (var i in layers){
    if (layers[i].name === bookmark.name){
        layers[i].state = true;
     }
    else{
        layers[i].state = false;
    }
}
----------------------------------------------
This script expression is evaluated when the bookmark is clicked
But I can't find how to get the bookmark Object that is being clicked now...
Please give me an advice.
TOPICS
Acrobat SDK and JavaScript , Windows

Views

459

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
LEGEND ,
Nov 16, 2021 Nov 16, 2021

Copy link to clipboard

Copied

You cannot find the bookmark object last clicked. You'd need to create separate JavaScript for each bookmark, including the name. 

Votes

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
Community Beginner ,
Nov 16, 2021 Nov 16, 2021

Copy link to clipboard

Copied

Your answer was clear and a great help for me.

I resolved it by making another script that generates separate script for each bookmark with each bookmark name.

Thank you!

Votes

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
Community Expert ,
Nov 16, 2021 Nov 16, 2021

Copy link to clipboard

Copied

You should use a function and pass to it the name of the bookmark that triggers each event as a parameter. Since that name is also the name of the layer you could use that to identify the layer and then show it.

Votes

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
Community Beginner ,
Nov 16, 2021 Nov 16, 2021

Copy link to clipboard

Copied

LATEST

Thank you for your advice.

Votes

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