1 Reply Latest reply on Jul 3, 2014 4:18 AM by Chinnadk

    Get exact text line width in table cell


      I have a problem in a table, I need to measure exact width of all lines in all cells of the table and get the max line width, in other words if i resize the column to the max line width it will be no overset text or extra line break.

      I tried using horizontalOffset but the result is weird and not accurate.


      My snippet is like

      var LineL = column.cells.everyItem().texts[0].lines.everyItem().characters[0].horizontalOffset;
      var LineR = column.cells.everyItem().texts[0].lines.everyItem().characters[-1].horizontalOffset;
       var LineR2 = column.cells.everyItem().texts[0].lines.everyItem().characters[-2].horizontalOffset;
      var MaxLine = 0;
      for(p =0; p<LineL.length;p++)
               if (LineR[p] == LineL[p])
                  var D = LineR2[p] - LineL[p];
                  var D =  LineR[p] - LineL[p];
              MaxLine = D
        • 1. Re: Get exact text line width in table cell
          Chinnadk Level 4

          Hi  MohamedYousif,


          Try this.


          var _column = app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().getElements(),
          linewidth = [];
          for(var i =0;i<_column.length;i++)
              var _lines = _column[i].lines;
              for(var j=0;j<_lines.length;j++)
                      linewidth.push(_lines[j].endHorizontalOffset - _lines[j].horizontalOffset);