2 Replies Latest reply on Jun 20, 2016 2:47 AM by mechaichezilla

    TextFrame text mixed up on overflow

    mechaichezilla Level 1

      Hi,

       

      I'm filling some lines of text into a textframe, this works fine as long as it fits inside the frame, but as soon as the text overflows, all new lines are inserted in their reverse order.

       

      for( iLine = 0; iLine < myLines.length; iLine ++) {
           myTextFrame.insertionPoints.lastItem().contents = '\n\n' + myLines[iLine];
      }
      

       

      As an example, if the first two lines fit and the other two overflow, the result looks like:

       

      Line one

       

      Line two

       

      Line four

       

      Line three

       

      I already tried this solution:

      https://forums.adobe.com/message/2536811

      This works as long as I only add single lines, but as soon as I add longer text, it falls back to the original problem.

       

      The other solution I tried was:

      myTextFrame.fit(FitOptions.FRAME_TO_CONTENT);
      

       

      That shrinked the textFrame to the size of the first line though and only grew vertically from now on. So I added this:

       

      if( myTextFrame.overflows) {
        myTextFrame.fit(FitOptions.FRAME_TO_CONTENT);
      }
      

       

      This helped a little so the horizontal size only shrinks to the largest line that's been added so far. I am currently considering just using a table instead of a textFrame and add new lines as new rows. Any better ideas?

       

      Thanks a lot!

        • 1. Re: TextFrame text mixed up on overflow
          Jump_Over Level 5

          mechaichezilla napisał(-a):

           

          1. for(iLine=0;iLine<myLines.length;iLine++){
          2. myTextFrame.insertionPoints.lastItem().contents='\n\n'+myLines[iLine];
          3. }

           

          Hi,

          myTextFrame.insertionPoints.lastItem() --> exactly means the last insertionPoint is shown (can be reached by user) in this textFrame.

           

          If your goal is to add some text to the end of story (regardles is shown or hidden) use textFrame.parentStory as a target

           

          Like:

          for(iLine=0;iLine<myLines.length;iLine++){
          myTextFrame.parentStory.insertionPoints.lastItem().contents='\n\n'+myLines[iLine];
          }
          
          

           

          Jarek

          • 2. Re: TextFrame text mixed up on overflow
            mechaichezilla Level 1

            myTextFrame.insertionPoints.lastItem() --> exactly means the last insertionPoint is shown (can be reached by user) in this textFrame.

            Ah, that explains it. And using parentStroy worked as I intended it to, thanks!