Link to home
Start Free TrialLog in
Avatar of SharonBernal

asked on

Delete child bookmarks in Acrobat Professional 8 Document

I have a rather large pdf made up of several files. The parent bookmark needs to be retained, however I have been tasked with removing all of the child bookmarks.

I have had a hard time finding javascript to allow me to do this, please help. The pdf that I have created has 6500 pages, deleting the child bookmarks manually would be quite a task.
Avatar of SharonBernal


I found this code but it fails at line 41 with an error "missing ; after for loop condition". The problem is that the ; is there.

This script can be used to:
1) moves all subordinated bookmarks up the bookmark tree; and
2) delete the filename bookmark

var bm = this.bookmarkRoot;

// Find the bookmarks which have .PDF and move all their children to the end
// of the bookmark tree. Add each found bookmark to an array so that
// it can be deleted at the conclusion of the process

// Create an array to hold the bookmarks to delete @ a later stage
var bmToDeleteArray = new Array();

// Iterate through each bookmark
var ibmLength = bm.children.length;
for (var i = 0; i < ibmLength; i++)
// Check to see if this is a filename which
// contains sub-ordinate bookmarks
var bmToCheck = bm.children[i];

if(("delete me")!=-1) && (bmToCheck.children!=null))
console.println("found bookmark with children " + i);

// Move all children to the end of the root bookmark tree
// being sure to move the first item in each case
// note: this is because the queue is shrinking as
// we move each item

var ibmChildrenToMoveLength = bmToCheck.children.length;
for(var j=0; j {
console.println("moving bookmark " + j);

bm.insertChild(bmToCheck.children[0], bm.children.length);

// Add this to the array of bookmarks to be deleted later
bmToDeleteArray[bmToDeleteArray.length] = bmToCheck;

// Iterate through the array of 'filename' bookmarks to delete
// and delete them

for (var i = 0; i < bmToDeleteArray.length; i++)
// Delete bookmark

// Finally remove the array as a nicety
delete bmToDeleteArray;

Avatar of Karl Heinz Kremer
Karl Heinz Kremer
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I found a utlity for sale that almost does what I  need.