These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

delete only one bookmark

svelasco
Registered: May 8 2007
Posts: 27
Answered

I recently recieved a really good tip on how to create a bookmark for showing the path to the pdf file (http://www.acrobatusers.com/forums/aucb … p?id=12939). It works great.

I have set it up as follows:

this.bookmarkRoot.createChild({cName: "path to report", cExpr: "console.show();console.clear();console.println(this.path);", nIndex: -1});

(although it doesn't go to the bottom of my existing bookmark list, but oh well...)

and saved it to a batch process.

Now i've been trying to create a batch process to do the reverse, i.e. remove the bookmark - if later we find we don't need this functionality any more.

I've read and read and read and tried various versions of a javascript without any luck - and maybe it's not even possible, but I though I would ask.

I know there is a method for removing ALL bookmarks at once:

this.bookmarkRoot.remove()

I only need to get rid of one... Why doesn't this work ?

this.bookmarkRoot.remove("path to report");

or this,

this.bookmarkRoot.remove({cName: "Path to report"})

Any tips / help ?

Thanks so much.

My Product Information:
Acrobat Pro 8.1.2, Windows
ChrisFreeman
Registered: May 6 2007
Posts: 19
To place the new bookmark at the end of the bookmark list try:

// Get index for last child of bookmarkRoot
var nLastIndex = (this.bookmarkRoot.children == null) ? 0 : this.bookmarkRoot.children.length;

// Create new last-child bookmark
this.bookmarkRoot.createChild({cName: "path to report", cExpr: "console.show();console.clear();console.println(this.path);", nIndex: nLastIndex});

//Delete last child index
// check first if last child is desired target
if(this.bookmarkRoot.children !=null && this.bookmarkRoot.children[this.bookmarkRoot.children.length - 1].name == "Path to report")
this.bookmarkRoot.children[this.bookmarkRoot.children.length - 1].remove();

If target bookmark is not guaranteed to be the last child of bookmarkRoot then you will have to search for it with a loop:

if(this.bookmarkRoot.children !=null)
for (var i=0; i
svelasco
Registered: May 8 2007
Posts: 27
Thank you !

The script (both actually) worked exactly as I had hoped, plus I learned a lot about how this sort of javascript should be implemented.

Thanks again !