1
Get the Bookmark Object of a Clicked Bookmark by Javascript
Community Beginner
,
/t5/acrobat-sdk-discussions/get-the-bookmark-object-of-a-clicked-bookmark-by-javascript/td-p/12527180
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
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/acrobat-sdk-discussions/get-the-bookmark-object-of-a-clicked-bookmark-by-javascript/m-p/12527190#M88128
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.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
joyance
AUTHOR
Community Beginner
,
/t5/acrobat-sdk-discussions/get-the-bookmark-object-of-a-clicked-bookmark-by-javascript/m-p/12529560#M88139
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!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
/t5/acrobat-sdk-discussions/get-the-bookmark-object-of-a-clicked-bookmark-by-javascript/m-p/12527649#M88131
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.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
joyance
AUTHOR
Community Beginner
,
LATEST
/t5/acrobat-sdk-discussions/get-the-bookmark-object-of-a-clicked-bookmark-by-javascript/m-p/12529561#M88140
Nov 16, 2021
Nov 16, 2021
Copy link to clipboard
Copied
Thank you for your advice.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

