1 Reply Latest reply on Sep 19, 2013 3:12 PM by Laubender

    Paragraph Geometric Bounds?

    AgentRed485

      Is there any way to get the dimensions of an individual pargraph inside a text frame? So if a text frame contains five paragraphs, I would like to draw a rectangle around each one.

        • 1. Re: Paragraph Geometric Bounds?
          Laubender Adobe Community Professional & MVP

          There are several solutions to this problem:

           

          1. Solution:

          Use the properties horizontalOffset of several insertion points and the ascent of characters to calculate a rectangle, maybe also use the calculated width of the text frame.

           

          2. Solution:

          Duplicate the paragraph and transform all characters of the paragraph to outlines.

          Read out the geometric or the visual bounds of that objects to get the geometry of the needed rectangle.

           

          Then:

          Add a new rectangle object and anchor it to the first insertion point of the paragraph.

           

          If the text frame, that holds the paragraphs, is rotated or skewed, the calculations get a bit nasty.

          You can read about it here:

           

          Marc Autret
          Work Around the Width/Height Gap

          http://www.indiscripts.com/post/2009/10/work-around-the-width-height-gaphttp://

           

           

          3. Solution:

          You could "cheat" a little bit and add a one cell table to your selected paragraph and move your paragraph into the cell.

           

          Here a code snippet [ExtendScript (JavaScript)] that is working with a selected paragraph.

          The paragraph sign must be selected, too!

           

          var myText = app.selection[0];
          var myTable = myText.tables.add({columnCount:1,bodyRowCount:1});
          myTable.cells[0].autoGrow = true;
          
          myText.characters.itemByRange(0,-2).move(LocationOptions.AFTER, myTable.cells[0].insertionPoints[0]);
          

           

          If you predefined a cell style for border color, inset values etc.pp., you could apply that cell style to the cell as well.

           

          Uwe