Skip to main content
Participant
May 21, 2019
Question

Merged PDF's ungroup bookmarks by filename.

  • May 21, 2019
  • 2 replies
  • 1067 views

Hi All,

I need to merge the bookmarks as well under one parent root. Right now it puts bookmarks below the filenames of the merged documents. I am using InsertPages API to merge the pdf's. Any inputs will be appreciated.

This topic has been closed for replies.

2 replies

Thom Parker
Community Expert
Community Expert
May 21, 2019

This is pretty easy with a script. You could do something similar with the outline structure, but this is easier.

var bkRoot = this.bookmarkRoot

var nTop = bkRoot.children.length

var bkList = [];

// Collect all 2nd Level bookmarks

for(i=0;i<nTop;i++)

    bkList = bkList.concat(bkRoot.children.children);

//Now insert 2nd level into top level

for(i=0;i<bkList.length;i++)

    bkRoot.insertChild(bkList,i);

var nLen = bkRoot.children.length;

// Remove old top level

for(i=nLen-1 ;i>=nLen -nTop ;i--)

    bkRoot.children.remove();

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
deeparaoAuthor
Participant
May 24, 2019

Thank you so much for the code. I am looking for VBScript code.

Also does this work with Acrobat Professional XI. My machine has Adobe Acrobat Professional XI. I was trying to run this code and it was throwing me error object not found. Not sure if it is missing any reference? Can you please tell what DLL this requires.

Any help will be appreciated.

Legend
May 24, 2019

Run the code in the JavaScript console, to test and debug it. This is not VB code. Once you have it working you can work on how to call JavaScript from VB, but learn JavaScript basics first.

lrosenth
Adobe Employee
Adobe Employee
May 21, 2019

That is how the InsertPages feature works.

However, assuming you are using the C/C++ APIs, can then manipulate the bookmarks after insertion…

deeparaoAuthor
Participant
May 24, 2019

Thanks for your reply.