Skip to main content
Participant
April 10, 2018
Answered

Adobe Acrobat DC bookmarking issue

  • April 10, 2018
  • 1 reply
  • 1424 views

In DC, when I combine several pdfs into one, I am getting double bookmarks (the file name and the bookmark that was inside each file).  Is there a way to delete either the parent or children bookmarks as a bulk batch after combining the PDFs into one?  I've found Sean Stewart's javascript but that only deletes the parent bookmark if it has the .pdf extension in the bookmark title, which it does not.  I have about 900 bookmarks/files (which created 1800 when combined) and I don't want to manually change each bookmark to have the .pdf extension.  So I would be happy with a js that changes the parent bookmark to include the .pdf and then I can run Sean's js.  I've tested it on a small pdf where I manually added the .pdf to three bookmarks and it works.  But I can't do that to 900 or I would just manually delete the bookmarks.  Looking for a somewhat easier solution.  Even if it's two separate js (one to rename, one to delete etc.)  Thank you so much.  Oh, I'm a noob at js but have been trying to figure this out with a lot of research in the last 3 days.  To no avail...please help!!!

This topic has been closed for replies.
Correct answer try67

This code will remove all the child-bookmarks in a bookmark hierarchy, leaving only the top-level ones:

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

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

        var bkm = this.bookmarkRoot.children;

        if (bkm.children!=null) {

            for (var j=bkm.children.length-1; j>=0; j--) {

                bkm.children.remove();

            }

        }

    }

}

1 reply

Thom Parker
Community Expert
Community Expert
April 10, 2018

It would be easier to write a Action script to adjust the bookmarks to you liking. That way you could change a group of files at the same time. Do you have Acrobat DC Professional?

Please explain the exact action you want. Is is to remove all top level bookmarks, making the child bookmarks the new top level?

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
April 10, 2018

Hi Thom,

Thanks for your reply.  The parent and child bookmark are identical.  It doesn't matter to me which one I delete as they both point to the same document.  I do have Acrobat DC Professional.  I don't know how to write an action script.  The js I was earlier referring to I inputted in the action wizard as an execute javascript.  But it only deletes the parent if it has .pdf in the name.

Any assistance would be greatly appreciated.

Thanks again,

Angel

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
April 10, 2018

This code will remove all the child-bookmarks in a bookmark hierarchy, leaving only the top-level ones:

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

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

        var bkm = this.bookmarkRoot.children;

        if (bkm.children!=null) {

            for (var j=bkm.children.length-1; j>=0; j--) {

                bkm.children.remove();

            }

        }

    }

}