4 Replies Latest reply on Aug 14, 2015 8:39 PM by BSKTCreation

    myTextFrame.fit(FitOptions.frameToContent); only works in Debug mode

    Ivel97

      This is my code:

              for (i = startDate; i <= endDate; i++) {

                  //Create label     

                  var myTextFrame = myPage.textFrames.add();

                  myTextFrame.contents = i.toString() + " " + monthName;

       

                    //Add it to the array           

                    myDates.push(myTextFrame);

       

                    //Apply style

                    var myTextObject = myTextFrame.parentStory;

                    myTextObject.paragraphs[0].appliedParagraphStyle = myDocument.paragraphStyles.itemByName("Date numbers (Greg)");

       

                    //Place it in position

                    MoveTextFrameToSquareNum(myTextFrame, parseInt(startSquare) + parseInt(i) - parseInt(startDate), 89,3);

               

                    //Fit text frame to content

                    myTextFrame.fit(FitOptions.frameToContent);

                }


      As you can see I loop through some numbers making TextFrames from each one, towards the end I fit the TextFrame to the content.


      Now this all works perfectly in ExtendScript, but as soon as I add as a script to InDesign and run it as a script it starts messing up. Only some get sized properly, the rest not at all. When I tried this code to loop through the textboxes after they have been placed and resize them, it didnt work at all!

       

      Second try:


          for (i = startDate; i <= endDate; i++) {

                  //Create label       

                  var myTextFrame = myPage.textFrames.add();

                  myTextFrame.contents = i.toString() + " " + monthName;

       

                  //Add it to the array           

                  myDates.push(myTextFrame);

       

                  //Apply style

                  var myTextObject = myTextFrame.parentStory;

                  myTextObject.paragraphs[0].appliedParagraphStyle = myDocument.paragraphStyles.itemByName("Date numbers (Greg)");

       

                  //Place it in position

                  MoveTextFrameToSquareNum(myTextFrame, parseInt(startSquare) + parseInt(i) - parseInt(startDate), 89,3);

              }

              var i;

              for(i=0;i<myDates.length;i++){

                  myDates[i].fit(FitOptions.FRAME_TO_CONTENT);

              }


      Is there anyone who understands what the problem is and knows how to fix it?

       

      Thanks, alot.