Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

removing a bookmark in a bunch of PDFs

Status
Not open for further replies.

frameuser

Technical User
Jun 13, 2001
109
US
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 += &quot; &quot;;

// !!!!! Change 1: This line here with other options.
bm.color = [&quot;RGB&quot;,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 figured out the code for doing this in my situation.

============================
function LibraryBookmark(bm, nLevel)
{
// !!!!! Change 3: Add Conditional Options under this line
var s = &quot;&quot;;
for (var i = 0; i < nLevel; i++)
s += &quot; &quot;;

// !!!!! Change 1: This line here with other options.
bookmarkRoot.children[0].remove();
}

// Start the Program
// !!!!! Change 2: this.bookmarkRoot to alternative
LibraryBookmark(this.bookmarkRoot.children[0], 0);

============================

This worked for me because the regular bookmarks for my guide aren't children of the bookmark that I wanted to remove.


Rick Henkel
Senior Systems Developer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top