2 Replies Latest reply on Jun 25, 2014 9:49 PM by hasvi

    Table text frame width adjustment by script

    hasvi Level 1

      Hi,


      I have to capture my table cells within ‘Text Frame Width’ option with ‘Distribute Column Evenly’ , when it’s going to beyond the ‘Text Frame Width’. Is this possible by script?


      by

      hasvi

        • 1. Re: Table text frame width adjustment by script
          Chinnadk Level 4

          Hi Hasvi,

           

          Try this.

           

          var doc = app.activeDocument,
              _tables = doc.stories.everyItem().tables.everyItem().getElements(),
              _tfwidth, _cells, finalwidthofcell;
          
          for(var i =0;i<_tables.length;i++)
          {
                  var currentwidth = 0;
                  _tfwidth = _tables[i].parent.geometricBounds[3] - _tables[i].parent.geometricBounds[1];
                  _cells = _tables[i].rows[0].cells;
                  for(var j=0;j<_cells.length;j++)
                  {
                          currentwidth +=_cells[j].width;
                      }
                  if(currentwidth > _tfwidth)
                  {
                          finalwidthofcell = _tfwidth/_cells.length;
                          for(var k=0;k<_cells.length;k++)
                          {
                                  _cells[k].width =finalwidthofcell;
                              }
                      }
              }
          

           

          Regards,

          Chinna