edit children bookmarks

New Here ,
Nov 15, 2017

Copy link to clipboard

Copied

Hello,

I am trying to delete all of the second level bookmarks from my pdf.

I am able to delete the first top level bookmark and it's child with the following code:

if (this.bookmarkRoot.children != null && this.bookmarkRoot.children.length > 0) {

      for (var i = 0; i < this.bookmarkRoot.children.length; i++) {

            this.bookmarkRoot.children.remove();

      }

   }

However, but i am not sure how to change the code to only delete the second level (children of the children?) book marks.

Any help would be much appreciated.

Adobe Community Professional
Correct answer by Thom Parker | Adobe Community Professional

Here's a real simple way to remove all the top level bookmarks

this.bookmarkRoot,remove();

That's all you need.

Now for the 2nd level bookmarks, the code has to dig down into the second level

for (var i = 0; i < this.bookmarkRoot.children.length; i++)

{

     var bkmk = this.bookmarkRoot.children;

     if(bkmk.children)   bkmk.children.forEach(function(a){a.remove()});

}

TOPICS
Acrobat SDK and JavaScript, Windows

Views

184

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

edit children bookmarks

New Here ,
Nov 15, 2017

Copy link to clipboard

Copied

Hello,

I am trying to delete all of the second level bookmarks from my pdf.

I am able to delete the first top level bookmark and it's child with the following code:

if (this.bookmarkRoot.children != null && this.bookmarkRoot.children.length > 0) {

      for (var i = 0; i < this.bookmarkRoot.children.length; i++) {

            this.bookmarkRoot.children.remove();

      }

   }

However, but i am not sure how to change the code to only delete the second level (children of the children?) book marks.

Any help would be much appreciated.

Adobe Community Professional
Correct answer by Thom Parker | Adobe Community Professional

Here's a real simple way to remove all the top level bookmarks

this.bookmarkRoot,remove();

That's all you need.

Now for the 2nd level bookmarks, the code has to dig down into the second level

for (var i = 0; i < this.bookmarkRoot.children.length; i++)

{

     var bkmk = this.bookmarkRoot.children;

     if(bkmk.children)   bkmk.children.forEach(function(a){a.remove()});

}

TOPICS
Acrobat SDK and JavaScript, Windows

Views

185

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 15, 2017 0
Adobe Community Professional ,
Nov 15, 2017

Copy link to clipboard

Copied

Here's a real simple way to remove all the top level bookmarks

this.bookmarkRoot,remove();

That's all you need.

Now for the 2nd level bookmarks, the code has to dig down into the second level

for (var i = 0; i < this.bookmarkRoot.children.length; i++)

{

     var bkmk = this.bookmarkRoot.children;

     if(bkmk.children)   bkmk.children.forEach(function(a){a.remove()});

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 15, 2017 0
New Here ,
Nov 15, 2017

Copy link to clipboard

Copied

perfect thank you!!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 15, 2017 0