0 Replies Latest reply on Jun 4, 2013 2:14 PM by mkaladar

    Script to split bookmarks gives up for large no of files but works for few

    mkaladar

      Hi, I've about 144 pdf files to combine and split/ create new bookmarks based on a split character "*". After I combine about 28 of them by "right click -> combine supported files in acrobat"; I then run the script shown below. Now, this works well as shown in the pictures below but if I combine any more than 28, and then run the same script it gives up and shows this error in the javascript console "TypeError: splitbm.name is undefined 4:Menu:Exec". Any ideas on how to proceed?

       

       

      before.JPGafter.JPG

       

      function newbrk(splitbm)

      {

                // * is the authors choice for the split character, you may change it

                     if (splitbm.name.indexOf('*') != -1)

                     split(splitbm);

                //split if the bookmark name has the ^ charater

                     if (splitbm.children != null)

                     for (var i=0;i< splitbm.children.length;i++)

                     newbrk(splitbm.children[i]);

                // split all the children bookmarks of mybm

      }

      function split(bm)

      {

           var bmname=bm.name;

           var splitat=bmname.indexOf('*');

       

           // The user can change the * , remember to change the previous function as well

                var topname=bmname.substring(0,splitat);

                var botname=bmname.substring(splitat+1,bmname.length);

                var thisdoc=bm.doc;

                bm.execute();

                app.execMenuItem("NewBookmark");

                var thisdoc=bm.doc;

                var rootlen=thisdoc.bookmarkRoot.children.length;

                var newbm=thisdoc.bookmarkRoot.children[rootlen-1];

                newbm.name=botname;

                bm.name=topname;

           // make all [childbookmarks of mybm] newbm's children

                if (bm.children != null)

                {

                     var endpos=bm.children.length;

                     for(a=0;a<endpos;a++)

                     newbm.insertChild(bm.children[0]);

                }

           //make newbm mybm's child

                bm.insertChild(newbm);

      }

      app.addMenuItem({cName:"SplitBookmarks",cParent:"Edit",cExec:"newbrk(this.bookmarkRoot);", nPos:1});