I need to remove some bookmarks from a bunch of PDFs. For the most part, I need to remove the first bookmark in every file.
I found some JavaScript code on Planet PDF that I modified to change the attributes of the first bookmark. In this case, I modified the first bookmark so that it is bold blue. I then attached that code to a batch sequence so I could modify many PDFs at once. Following is my modified code:
=========================
function GuideTitleBookmark(bm, nLevel)
{
// !!!!! Change 3: Add Conditional Options under this line
var s = "";
for (var i = 0; i < nLevel; i++)
s += " ";
// !!!!! Change 1: This line here with other options.
bm.color = ["RGB",0,0,1];
bm.style = 2;
}
// Start the Program
// !!!!! Change 2: this.bookmarkRoot to alternative
GuideTitleBookmark(this.bookmarkRoot.children[0], 0);
=========================
I was hoping that I could alter this code--probably under Change 1--to include the JavaScript for removing bookmarks--bookmarkRoot.remove();. But so far I haven't been able to make that work. I can run the removal code from the JS console to remove all bookmarks, but I want to specify which
bookmark to remove.
I don't know much about JavaScript, so I may be barking up the wrong tree. Can someone point me in the right direction? Or is there another/better way to remove specific bookmarks en masse? (All the plug-ins I've found remove all bookmarks, not selected ones.)
Rick Henkel
Senior Systems Developer
I found some JavaScript code on Planet PDF that I modified to change the attributes of the first bookmark. In this case, I modified the first bookmark so that it is bold blue. I then attached that code to a batch sequence so I could modify many PDFs at once. Following is my modified code:
=========================
function GuideTitleBookmark(bm, nLevel)
{
// !!!!! Change 3: Add Conditional Options under this line
var s = "";
for (var i = 0; i < nLevel; i++)
s += " ";
// !!!!! Change 1: This line here with other options.
bm.color = ["RGB",0,0,1];
bm.style = 2;
}
// Start the Program
// !!!!! Change 2: this.bookmarkRoot to alternative
GuideTitleBookmark(this.bookmarkRoot.children[0], 0);
=========================
I was hoping that I could alter this code--probably under Change 1--to include the JavaScript for removing bookmarks--bookmarkRoot.remove();. But so far I haven't been able to make that work. I can run the removal code from the JS console to remove all bookmarks, but I want to specify which
bookmark to remove.
I don't know much about JavaScript, so I may be barking up the wrong tree. Can someone point me in the right direction? Or is there another/better way to remove specific bookmarks en masse? (All the plug-ins I've found remove all bookmarks, not selected ones.)
Rick Henkel
Senior Systems Developer