0

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?

It's okay to change to resize the entire column. First I run this script to make sure every cell has just 1 line:

doc = app.activeDocument;
var table = doc.textFrames[0].tables[0]; //auto resize (beta)
for (var i = 0; i < table.columns.length; i++)
{
    var column = table.columns[i];
    for (var a = 0; a < column.cells.length; a++)
    {
        var cell = column.cells[a];
        cell.contents = cell.contents.replace(/&nbsp;|\s+/g, " ")
        var lines = cell.lines.length;
        while (lines > 1)
        {
            cell.width++;
            lines = cell.lines.length;
        }
    }
}

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.

Andrea
  • 11,801
  • 17
  • 65
  • 72
  • Asking for 'any' help, with no effort shown, is "too broad" for Stack Overflow – see the [help/on-topic]. As a new user, you probably want to read the [introductory Tour](http://stackoverflow.com/tour) some time soon. Anyhow, your task is less obvious than you realize: you cannot resize individual *cells*, you need to resize entire columns. – Jongware Sep 28 '15 at 09:10
  • Please use comments to ask for more information or suggest improvements. You can use [edit] to add your code to your post. (Don't forget to properly format it. The Edit field has an extensive help available.) – Jongware Sep 28 '15 at 10:16
  • @Jongware i have seen your post earlier this day on https://indesignsecrets.com/tackling-tables-through-scripting.php but i can't transform your script to make i work for me.. i'm just desperate of trying.. any help please? – Jake van Dongen Sep 28 '15 at 13:50

0 Answers0