Skip to main content
Participant
Mar 27, 2021 5:07 AM UTC
Answered

Need to delete all child bookmarks

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

thanks

 

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Mar 27, 2021 8:36 AM UTC

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();
			}
		}
	}
}

3 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Mar 27, 2021 8:36 AM UTC

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();
			}
		}
	}
}
Translate
Participant
Mar 27, 2021 4:07 PM UTC

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.) 

Translate
try67
Community Expert
Community Expert
Mar 27, 2021 5:24 PM UTC

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

Translate