Skip to main content
Participant
March 27, 2021
Answered

Need to delete all child bookmarks

  • March 27, 2021
  • 1 reply
  • 1567 views

Hi, please, i need to delete all child bookmarks, can you share a working javascript script that can do that please?

thanks

 

This topic has been closed for replies.
Correct answer try67

You can use this code to do it:

 

if (this.bookmarkRoot.children!=null) {
	for (var i=0; i<this.bookmarkRoot.children.length; i++) {
		var bkm = this.bookmarkRoot.children[i];
		if (bkm.children!=null) {
			for (var j=bkm.children.length-1; j>=0; j--) {
				bkm.children[j].remove();
			}
		}
	}
}

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
March 27, 2021

You can use this code to do it:

 

if (this.bookmarkRoot.children!=null) {
	for (var i=0; i<this.bookmarkRoot.children.length; i++) {
		var bkm = this.bookmarkRoot.children[i];
		if (bkm.children!=null) {
			for (var j=bkm.children.length-1; j>=0; j--) {
				bkm.children[j].remove();
			}
		}
	}
}
Participant
March 27, 2021

thank you sir, you are the best. Please, how can i know what variables do i need to use, where can i see that please? (bookmarRoot, etc.) 

try67
Community Expert
Community Expert
March 27, 2021

It's all in the JS for Acrobat API Reference, which is a part of the Acrobat SDK, available here: http://www.adobe.com/devnet/acrobat.html