title: Is it possible to auto resize column width to content with extendscript in indesign
body: <p>I'm looking for a solution to make the cell width fit to it's content due a script in Extendscript. anyone who can help me with this?</p>
  
  <p>It's okay to change to resize the entire column. First I run this script to make sure every cell has just 1 line:</p>
  
  <pre class="lang-js prettyprint-override"><code>doc = app.activeDocument;
  var table = doc.textFrames[0].tables[0]; //auto resize (beta)
  for (var i = 0; i &lt; table.columns.length; i++)
  {
      var column = table.columns[i];
      for (var a = 0; a &lt; column.cells.length; a++)
      {
          var cell = column.cells[a];
          cell.contents = cell.contents.replace(/&amp;nbsp;|\s+/g, " ")
          var lines = cell.lines.length;
          while (lines &gt; 1)
          {
              cell.width++;
              lines = cell.lines.length;
          }
      }
  }
  </code></pre>
  
  <p>But after that iI want to resize the column width to it's minimum width. When this is done I will make the table fit to the document.</p>