6 Replies Latest reply on Jul 14, 2009 11:51 PM by JessicaLampe

    .createTOC() every time use createBookmarks = true

    JessicaLampe Level 1

      Hello @all,

       

      I have a problem with the following code to auto-update my TOCs in InDesign CS4:

       

      var myDocument = app.activeDocument;

      alert("createBookmarks: " + myDocument.tocStyles.itemByName("Kapitel 1").createBookmarks);  // --> this show me "false"

      var myStory = myDocument.createTOC(myDocument.tocStyles.itemByName("Kapitel 1"), true /*replacing*/);

       

      After this action I have entries from the TOC ("Kapitel 1") in my pdf bookmark? Why?

       

      I also tried for test purpose the following:

      myDocument.tocStyles.itemByName("Kapitel 1").duplicate();

       

      This copy of my TOC has the option "pdf bookmars" on "true"?!

       

      How can I force, that I get NO createBookmarks for this TOCs?

      If I use manually "layout-->toc-formats-->update TOC" it works fine for me.

       

      Regards,
      Jessi

        • 1. Re: .createTOC() every time use createBookmarks = true
          A.Held Level 1

          Hi Jessi,

           

          hope helps you.

           

          var myDocument = app.activeDocument;
          myTocName = "Kapitel 1";

           

          try{
              myToc = myDocument.tocStyles.itemByName( myTocName );
              myToc.name;
              }
          catch (myError){
              myToc = myDocument.tocStyles.add({name:myTocName});
              myToc.createBookmarks = false; // false = No Bookmarks
              }

           

           

          Greeting, Andi

          • 2. Re: .createTOC() every time use createBookmarks = true
            JessicaLampe Level 1

            Hi Andi,

             

            your code only create a new TOC, if it does not exist (with the .add-function), but I will update every TOC in my document.

            It makes no difference if I use .itemByName(myTocName) or .item() f.e.

             

            var myDocument = app.activeDocument;

            var IHV = myDocument.tocStyles;

             

            for ( var i=0; i<IHV.count(); i++) {
              myTocName = IHV.item(i).name;

              alert("refresh TOC: " + myTocName + "\ncreateBookmarks: " + myDocument.tocStyles.item(i).createBookmarks);

              // --> is only for the "[Standard]"-TOC "true", for the other TOCs "false".

             

              var myStory = myDocument.createTOC(myDocument.tocStyles.item(i), true /*replacing*/);

            }

             

            But if I create all TOCs with this script, it creates also for the other TOCs bookmarks in the pdf-document.

            I don't know why? It seems like every time the bookmark option get's activated (also if I forced it with myToc.createBookmarks = false;).

             

            Can someone explain me the correct way?

             

            Regards,

            Jessi

            • 3. Re: .createTOC() every time use createBookmarks = true
              A.Held Level 1

              Hi,

               

               

              var myDocument = app.activeDocument;

              for( i = 0; i < myDocument.tocStyles.length; i++ ) {
                  myToc = myDocument.tocStyles.item( i );
                  myToc.createBookmarks = false;
                  }

               

              Update or create? This Script removes all bookmark settings in the TOCs.

               

              Greetings, Andi

              • 4. Re: .createTOC() every time use createBookmarks = true
                JessicaLampe Level 1

                Hi Andi,

                 

                thank you for your new answer.

                 

                You are right, with your new code I can refresh the TOCs in my CS4-InDesign document.

                But...I don't know why (perhaps a bug in my version), I have in my new-created pdf document bookmarks for all TOCs.

                 

                So I had a look in the menu (layout -> toc formats).

                There are 3 TOCs, one is the default and the other has the names "Kapitel 1" and "Anhang".

                 

                Before running your script code there is an entry "create pdf bookmarks" only for the default TOC (this is ok).

                After running your script all pdf bookmarks for alle 3 TOCs in this menu are de-activated...but after creating the new pdf output, I have bookmarks for all TOCs.

                 

                So I refresh the 3 TOCs manually (after running your scripts) with the menu entry...and after it, I have no bookmark in my pdf.

                 

                I don't know why, but there seems to be a difference between update/refresh my TOCs with your code and the manually refresh action.

                 

                Do you have the same problem?

                 

                What can I do?

                 

                Greetings,

                Jessi

                • 5. Re: .createTOC() every time use createBookmarks = true
                  A.Held Level 1

                  Hi,

                   

                   

                  this is Magic :-) Hmmm... very strangely!!

                  Always use you the same pdf export options? Deactivate in the pdf options “Include of bookmark” or so similarly. Sorry, I has only the German version. If I deactivate it, I have no bookmark in the pdf.

                   

                  Greetings, Andi

                  • 6. Re: .createTOC() every time use createBookmarks = true
                    JessicaLampe Level 1

                    Hi Andi,

                     

                    I have also the german version of InDesign CS4 ;o)

                    No...I can't deactivate the export option, because I want bookmarks from the default TOC (name is "[Standard]").

                    Only the other 2 TOCs should not have bookmarks.

                     

                    If you have some time, could you test it with 3 TOCs (1 with bookmarks and 2 without bookmarks) and than run your scripts to re-fresh the TOCs?

                     

                    If you want, you can write me also an e-mail to: jessicalampe at gmx.de.

                     

                    Thanks!

                    Jessi