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.
Page Layout SoftwareAdobe AcrobatJavaScript
Last Comment
SharonBernal
8/22/2022 - Mon
SharonBernal
ASKER
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((bmToCheck.name.indexOf("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
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((bmToCheck.name.indexOf
{
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.c
}
// Add this to the array of bookmarks to be deleted later
bmToDeleteArray[bmToDelete
}
}
// Iterate through the array of 'filename' bookmarks to delete
// and delete them
for (var i = 0; i < bmToDeleteArray.length; i++)
{
// Delete bookmark
bmToDeleteArray[i].remove(
}
// Finally remove the array as a nicety
delete bmToDeleteArray;