6 Replies Latest reply on Aug 3, 2009 6:57 AM by franzi_ska

    CS4/JS: generate index problems

    franzi_ska

      Hello scripters,

       

      I actually have a problem with generating my index.

      The index itself already exists, the only thing to do with the script is to generate and place it.

      When running the script, I receive the following error message:

      invalid parameter in line: myIndex.generate(myIndexPage, [myY1, myX1, myY2, myX2], myLayer, true, true);

       

      function generateIndex() {
              var myIndex = myDocument.indexes[0];
              var myMasterSpread = myDocument.masterSpreads.item("A-Mustervorlage");
              var myIndexPage = myDocument.pages.add(LocationOptions.AT_END, myMasterSpread);
              var myLayer = myDocument.activeLayer;
              var myBounds = myGetBounds (myDocument, myIndexPage);
              var myY1 = Math.round(myBounds[0]);
              var myX1 = Math.round(myBounds[1]);
              var myY2 = Math.round(myBounds[2]);
              var myX2 = Math.round(myBounds[3]);
              myIndex.generate(myIndexPage, [myY1, myX1, myY2, myX2], myLayer, true, true);

      }

       

      I checked all parameters, they are right.

      What else could be wrong?

       

      Thanks in advance for any help.

        • 1. Re: CS4/JS: generate index problems
          Martin Fischer Level 2

          Hi Franziska,

           

          you need to set a place point with an array of two values instead of setting geometric bounds with an array of four values - like you did:

           

           

          var myStory = myIndex.generate(myIndexPage, [myY1, myX1], myLayer, true, true);

           

          This generates a new index story.

          Afterwards you can do something with the textContainers of the new index stories (e.g. specify their geometric bounds).

           

           

          Martin

          • 2. Re: CS4/JS: generate index problems
            franzi_ska Level 1

            Hi Martin,

             

            it works, thank you very much!

            • 3. Re: CS4/JS: generate index problems
              franzi_ska Level 1

              Hello,

               

              I am trying to place the index on the last page and autoflow it.

              What's happening is that it always places the index textFrame on the right page (also if there is no right page).

              How to avoid this?

               

              Thanks in advance!

              • 4. Re: CS4/JS: generate index problems
                Dave Saunders Level 4

                Are you using spread, spine or page rulers? If you're using spread or spine coordinates then that's why the index is appearing on the right page because those coordinates point there.

                 

                Dave

                • 5. Re: CS4/JS: generate index problems
                  franzi_ska Level 1

                  Hello Dave,

                   

                  in my script I am doing this:

                  var myIndexPage = myDocument.pages.add(LocationOptions.AT_END);

                  after defining the index paramter:

                  myIndex.generate(myIndexPage, [myTypeAreaHeight, myTypeAreaWidth], myLayer, false, true);

                  var myIndexFrame = myDocument.textFrames.lastItem();

                  myIndexFrame.geometricBounds = myGetBounds (myDocument, myDocument.pages.lastItem());

                   

                  I am also wondering why the TextFrame does not take the full height of my TypeArea and always is placed in the middle of the page and not at the beginning.

                   

                  Thanks in advance for any help.

                  • 6. Re: CS4/JS: generate index problems
                    franzi_ska Level 1

                    I just found the problem.

                    There must be something wrong with the measurement units.

                    I entered the values like that [20, 20] - which should be the x, y coordinates of the left upper corner.

                    With those values it works - but in real the values are [20, 40] - where could these discrepancies come from?

                    (it is important to know to set those values dynamically from the typearea).

                    I am using an Indesign-Template - so I think the units must be right...

                     

                    Thanks...