Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 87055

Re: Autosize for a table column based on the maximum text length

$
0
0

Hi Harald,

 

Try this.

 

var doc = app.activeDocument,    _selection = app.selection[0];   
if(_selection instanceof Table)
{        var _columns = _selection.columns;        for(var i =0;i<_columns.length;i++)        {                var _cells = _columns[i].cells,                    max = [];                for(var j=0;j<_cells.length;j++)                {                        var width = [],                            _lines = _cells[j].lines;                        for(var k =0;k<_lines.length;k++)                        {                                width.push(_lines[k].endHorizontalOffset - _lines[k].horizontalOffset + (_cells[j].leftInset + _cells[j].rightInset));                            }                        max.push(Math.max.apply(null,width));                    }                _columns[i].width = Math.max.apply(null,max)            }    }
else
{        alert("Select a table")    }

 

Regards,

Chinna


Viewing all articles
Browse latest Browse all 87055

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>