Remove specific repeated top level bookmarks

New Here ,
May 18, 2020

Copy link to clipboard

Copied

Hi there!

I'm looking into removing specific bookmarks (repeated) from a bulk invoice PDF which is generated by our e-commerce platform automatically (300 invoices in one PDF file). 

 

Screenshot 2020-05-18 at 18.02.28.png 

 

As you see there are two top level bookmarks in each invoice, I'm trying to figure how to remove all the "Ordered products" bookmarks with a script, so that I could use the Split function to split all 300 invoices by Top Level of Bookmarks.

 

I know: 

this.bookmarkRoot.remove(); would remove everything

and I have tried:

this.bookmarkRoot.remove("Ordered products"); which did not work

 

Anyone could please help me the novice here ? 🙂

 

Thank you so much in advance!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

You can use this code to achieve it:

 

for (var i=this.bookmarkRoot.children.length-1; i>=0; i--) {
	var bkm = this.bookmarkRoot.children[i];
	if (bkm.name=="Ordered products") bkm.remove();
}
TOPICS
Acrobat SDK and JavaScript, Edit and convert PDFs

Views

238

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

Remove specific repeated top level bookmarks

New Here ,
May 18, 2020

Copy link to clipboard

Copied

Hi there!

I'm looking into removing specific bookmarks (repeated) from a bulk invoice PDF which is generated by our e-commerce platform automatically (300 invoices in one PDF file). 

 

Screenshot 2020-05-18 at 18.02.28.png 

 

As you see there are two top level bookmarks in each invoice, I'm trying to figure how to remove all the "Ordered products" bookmarks with a script, so that I could use the Split function to split all 300 invoices by Top Level of Bookmarks.

 

I know: 

this.bookmarkRoot.remove(); would remove everything

and I have tried:

this.bookmarkRoot.remove("Ordered products"); which did not work

 

Anyone could please help me the novice here ? 🙂

 

Thank you so much in advance!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

You can use this code to achieve it:

 

for (var i=this.bookmarkRoot.children.length-1; i>=0; i--) {
	var bkm = this.bookmarkRoot.children[i];
	if (bkm.name=="Ordered products") bkm.remove();
}
TOPICS
Acrobat SDK and JavaScript, Edit and convert PDFs

Views

239

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
May 18, 2020 0
Most Valuable Participant ,
May 18, 2020

Copy link to clipboard

Copied

You can use this code to achieve it:

 

for (var i=this.bookmarkRoot.children.length-1; i>=0; i--) {
	var bkm = this.bookmarkRoot.children[i];
	if (bkm.name=="Ordered products") bkm.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...
May 18, 2020 1
ezzirahc LATEST
New Here ,
May 19, 2020

Copy link to clipboard

Copied

That's so cool, works perfectly! Thank you so much for helping out! 

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...
May 19, 2020 0