9 Replies Latest reply on Jul 12, 2009 7:16 PM by Jo_2005

    Create Bookmark and Set Page Destination Script

    Jo_2005 Level 1

      Greetings,

       

      I have created a Batch Processing Script which will create child bookmarks and set the page destination.

       

      The Bookmarks are listed in the script in the order in which they are to appear in ascending order.  (eg Name1, Name2, Name3, Name4)

       

      However after the script is run, the bookmarks are inserted in descending order. eg (Name4, Name3, Name2, Name1).

       

      Can anyone please advise how to get the script to create the bookmarks in ascending order as indicated in the script?

       

      var bm =
      this.bookmarkRoot.createChild("Name1","this.pageNum=0");
      this.bookmarkRoot.createChild("Name2", "this.pageNum=1");
      this.bookmarkRoot.createChild("Name3", "this.pageNum=2");
      this.bookmarkRoot.createChild("Name4", "this.pageNum=3");

      var bm = this.bookmarkRoot.children[0];

      bm.color = color.red;

       

      The script also needs to be modified to color all of the bookmarks red.  The script to color the bookmarks only works on the first bookmark.  Any assistance to modify the script for this would be most appreciated as well? 

       

      Thank you.

       

        • 1. Re: Create Bookmark and Set Page Destination Script
          try67 MVP & Adobe Community Professional

          You have several problems in your script, but the one that causes the order to be reversed is becuase you're not specifiying the nIndex parameter, so the default (0) is used. This script should achieve what you want:

           

          for (i=0; i<4; i++) {
              bm= this.bookmarkRoot.createChild("Name"+(i+1),"this.pageNum="+i,i);
              bm.color = color.red;
          }

          1 person found this helpful
          • 2. Re: Create Bookmark and Set Page Destination Script
            Jo_2005 Level 1

            Thank you very much for your assistance with the script provided.

             

            The javascript bugger has picked up an error that the "bm has no properties".

             

            Name1 is the only bookmark to be created.

             

            The script I originally posted is an example of what is required.  Once the script is working properly Name1 to Name 4 is going to be replaced with 90 actual people's names.   Eg Bill Smith.

             

            This was why each bookmark was listed separately in the script.

             

            Can you please revise script to list bookmarks in ascending order and color red.

             

            I am unsure of how to specifiy the nIndex parameter in this case?

             

            Sorry to cause any inconvenience, I should have made my script clearer the first time.

             

             

            var bm =
            this.bookmarkRoot.createChild("Bill Smith","this.pageNum=0");
            this.bookmarkRoot.createChild("David Smith", "this.pageNum=1");
            this.bookmarkRoot.createChild("James Smith", "this.pageNum=2");
            this.bookmarkRoot.createChild("Anne Smith", "this.pageNum=3");
            var bm = this.bookmarkRoot.children[0];

            bm.color = color.red;

             

            Thank you.

            • 3. Re: Create Bookmark and Set Page Destination Script
              Bernd Alheit Adobe Community Professional & MVP

              Use something like this:

               

              var bm;

              this.bookmarkRoot.createChild("Bill Smith","this.pageNum=0", 0);

              bm = this.bookmarkRoot.children[0];

              bm.color = color.red;

              this.bookmarkRoot.createChild("David Smith", "this.pageNum=1", 1);

              bm = this.bookmarkRoot.children[1];

              bm.color = color.red;

              • 4. Re: Create Bookmark and Set Page Destination Script
                Jo_2005 Level 1

                Thank you very much for your response Bernd.

                 

                The script works perfectly and the bookmark names are now listed in ascending order, goes to the page set destination and colored red.

                 

                Your help is very much appreciated.

                 

                 

                • 5. Re: Create Bookmark and Set Page Destination Script
                  Jo_2005 Level 1

                  Hello Bernd,

                   

                  I have added another name to the script which is how the bookmarks should appear in ascending order.

                   

                  However after running the script the name William Smith is the first bookmark when it should appear as the third bookmark.

                   

                  The names Bill Smith and William Smith have the page set destination to Page 1 and the Name David Smith has the page set destination on Page 2.

                   

                  Is there a way to modify the script to achieve this?

                   

                  Any assistance will be most appreciated.

                   

                   

                  var bm;
                  this.bookmarkRoot.createChild("Bill Smith","this.pageNum=0", 0);

                  bm = this.bookmarkRoot.children[0];

                  bm.color = color.red;


                  this.bookmarkRoot.createChild("David Smith", "this.pageNum=1", 1);

                  bm = this.bookmarkRoot.children[1];

                  bm.color = color.red;

                  this.bookmarkRoot.createChild("William Smith", "this.pageNum=0", 0);

                  bm = this.bookmarkRoot.children[0];

                  bm.color = color.red;

                  • 6. Re: Create Bookmark and Set Page Destination Script
                    try67 MVP & Adobe Community Professional

                    Replace:

                    this.bookmarkRoot.createChild("William Smith", "this.pageNum=0", 0);

                    With:

                    this.bookmarkRoot.createChild("William Smith", "this.pageNum=0", 2);

                    1 person found this helpful
                    • 7. Re: Create Bookmark and Set Page Destination Script
                      Jo_2005 Level 1

                      Thank you very much for your valuable assistance,

                       

                      I really appreciate the help from people such as yourself in this forum in helping me to get the scripts to work.

                       

                      The  script now creates the bookmarks in ascending order, sets the page destination and colors the bookmarks with a custom color in bold.

                       

                      I have included the script as follows for reference:

                       

                      var bm;
                      this.bookmarkRoot.createChild("A Name","this.pageNum=3", 0);
                      bm = this.bookmarkRoot.children[0];
                      bm.color = color.red = new Array("RGB", 1, 0.5, 0);
                      bm.style = 2
                      this.bookmarkRoot.createChild("B Name","this.pageNum=2", 1);
                      bm = this.bookmarkRoot.children[1];
                      bm.color = color.red = new Array("RGB", 1, 0.5, 0);
                      bm.style = 2
                      this.bookmarkRoot.createChild("C Name","this.pageNum=0", 2);
                      bm = this.bookmarkRoot.children[2];
                      bm.color = color.red = new Array("RGB", 1, 0.5, 0);
                      bm.style = 2
                      this.bookmarkRoot.createChild("D Name","this.pageNum=3", 3);
                      bm = this.bookmarkRoot.children[3];
                      bm.color = color.red = new Array("RGB", 1, 0.5, 0);
                      bm.style = 2
                      this.bookmarkRoot.createChild("E Name","this.pageNum=1", 4);
                      bm = this.bookmarkRoot.children[4];
                      bm.color = color.red = new Array("RGB", 1, 0.5, 0);
                      bm.style = 2
                      this.bookmarkRoot.createChild("F Name","this.pageNum=3", 5);
                      bm = this.bookmarkRoot.children[5];
                      bm.color = color.red = new Array("RGB", 1, 0.5, 0);
                      bm.style = 2
                      this.bookmarkRoot.createChild("G Name","this.pageNum=3", 6);
                      bm = this.bookmarkRoot.children[6];
                      bm.color = color.red = new Array("RGB", 1, 0.5, 0);
                      bm.style = 2
                      this.bookmarkRoot.createChild("H Name","this.pageNum=2", 7);
                      bm = this.bookmarkRoot.children[7];
                      bm.color = color.red = new Array("RGB", 1, 0.5, 0);
                      bm.style = 2
                      this.bookmarkRoot.createChild("I Name","this.pageNum=2", 8);
                      bm = this.bookmarkRoot.children[8];
                      bm.color = color.red = new Array("RGB", 1, 0.5, 0);

                       

                       

                      • 8. Re: Create Bookmark and Set Page Destination Script
                        try67 MVP & Adobe Community Professional

                        What's the purpose of this line?

                        bm.color = color.red = new Array("RGB", 1, 0.5, 0);

                         

                        If you want to color the bookmark red use just:

                        bm.color = color.red;

                         

                        If you want to give it a custom color use just:

                        bm.color = new Array("RGB", 1, 0.5, 0);

                         

                        There's no point in using one and then the other.

                        • 9. Re: Create Bookmark and Set Page Destination Script
                          Jo_2005 Level 1

                          Thank you very much for your input.

                           

                          I have revised the script for a custom color and removed the reference to color the bookmark red:

                           

                          var bm;
                          this.bookmarkRoot.createChild("A Name","this.pageNum=3", 0);
                          bm = this.bookmarkRoot.children[0];
                          bm.color =  new Array("RGB", 1, 0.5, 0);
                          bm.style = 2
                          this.bookmarkRoot.createChild("B Name","this.pageNum=2", 1);
                          bm = this.bookmarkRoot.children[1];
                          bm.color =  new Array("RGB", 1, 0.5, 0);
                          bm.style = 2
                          this.bookmarkRoot.createChild("C Name","this.pageNum=0", 2);
                          bm = this.bookmarkRoot.children[2];
                          bm.color = new Array("RGB", 1, 0.5, 0);
                          bm.style = 2
                          this.bookmarkRoot.createChild("D Name","this.pageNum=3", 3);
                          bm = this.bookmarkRoot.children[3];
                          bm.color = new Array("RGB", 1, 0.5, 0);
                          bm.style = 2
                          this.bookmarkRoot.createChild("E Name","this.pageNum=1", 4);
                          bm = this.bookmarkRoot.children[4];
                          bm.color = new Array("RGB", 1, 0.5, 0);
                          bm.style = 2
                          this.bookmarkRoot.createChild("F Name","this.pageNum=3", 5);
                          bm = this.bookmarkRoot.children[5];
                          bm.color = new Array("RGB", 1, 0.5, 0);
                          bm.style = 2
                          this.bookmarkRoot.createChild("G Name","this.pageNum=3", 6);
                          bm = this.bookmarkRoot.children[6];
                          bm.color =  new Array("RGB", 1, 0.5, 0);
                          bm.style = 2
                          this.bookmarkRoot.createChild("H Name","this.pageNum=2", 7);
                          bm = this.bookmarkRoot.children[7];
                          bm.color = new Array("RGB", 1, 0.5, 0);
                          bm.style = 2
                          this.bookmarkRoot.createChild("I Name","this.pageNum=2", 8);
                          bm = this.bookmarkRoot.children[8];
                          bm.color =Array("RGB", 1, 0.5, 0);