3 Replies Latest reply on Sep 3, 2014 3:17 AM by Marc Autret

    Is there a way to determine why TextFrame.overflows is set to true?

    azimmon

      The TextFrame.overflows boolean will be set to true when there is too much text.  That is obvious...  But it will also be set to true when there is a very long unbreakable  word, or URL, or set of words with non-breaking spaces.  I would like to know that when TextFrame.overflows is true, whether it was because there was too much text or because a line could not be broken.  Is there a way to determine this?

      Andy

        • 1. Re: Is there a way to determine why TextFrame.overflows is set to true?
          Jump_Over Level 5

          Hi,

           

          It can be many more reasons, like text is playing with a table, anchored item, paragraph before/after space, textWraps, big amount of textFrame egdes' inset..., etc

               ==>     so you can try to detect the reason or just alert first hidden word and decide what's going on while seeing it.

           

          If we talk about mTextFrame (which is overset)

               alert( mTextFrame.parentStory.words.nextItem(mTextFrame.words[-1]).contents )

           

          Jarek

          • 2. Re: Is there a way to determine why TextFrame.overflows is set to true?
            azimmon Level 1

            Jarek,

             

            Thanks for the reply.  That would work if I were doing this from InDesign desktop but this script is running in the background by InDesign Server so I cannot look at it to make a decision, I need to know programmatically what to do when there is a line that I cannot break.

             

            Thanks,
            Andy

            • 3. Re: Re: Is there a way to determine why TextFrame.overflows is set to true?
              Marc Autret Level 4

              Hi Andy,

               

              As noted by Jarek there are many possible reasons why TextFrame.overflows is TRUE—not to mention baseline grid constraints, keep options, wrapping, and so many more.

               

              Going back to your original question, it's worth noting that "a line that cannot be broken" is, in fact, a meaningless concept, for the line in question does not actually exist! As long as the overset text is not framed in a visual container, you're just talking about a virtual line and therefore you have no clue (such as location, width, height…) for solving your problem.

               

              So you should rephrase the question in more specific terms, or at least with additional conditions: Given a specific text frame that overflows, would it still overflow if…

              In your case, it seems to me that the implicit problem is to determine whether the frame width, in itself, is the reason why your hypothetical line does not appear. Which leads to an indirect test: all things being equal, what if the frame height was increased to make as much room as needed for, say, the whole story? Would it still overflows? If the answer is YES, then one can strongly suspect that the width is involved in the issue, i.e. the text "cannot be broken" the way you expect in that context.

               

              Practically, we could just check what happens if we temporarily multiply the frame height by 2:

               

              const CS_INNER = +CoordinateSpaces.innerCoordinates,
                    AP_TOP_LEFT = +AnchorPoint.topLeftAnchor,
                    RM_MULT = +ResizeMethods.multiplyingCurrentDimensionsBy;
              
              var tf = app.selection[0], // assumed a TextFrame is selected
                  msg = "No issue.";     // default message
              
              if( tf.overflows )
                  {
                  tf.resize(CS_INNER, AP_TOP_LEFT, RM_MULT, [1,2]);
                  msg = "The selected frame overflows because of:\r" +
                      (tf.overflows ? "Unbreakable line." : "Some other reason.");
                  tf.resize(CS_INNER, AP_TOP_LEFT, RM_MULT, [1,.5]);
                  }
              
              alert( msg );
              

               

              Hope that helps.

               

              @+

              Marc