Quantcast
Channel: Adobe Community: Message List - InDesign Scripting
Viewing all articles
Browse latest Browse all 37788

Snap all rows in table/document

$
0
0

I've been working through the book  "Scripting InDesign with JavaScript." The script is originally for snapping columns, but I'm trying to snap all the rows in tables so I've changed the references to "rows." I've worked through to this point, but it still snaps only the row where the cursor is located. I'm not sure what I need to alter in order for it to snap every row.

 

//from Scripting InDesign with JavaScript 
var myStories = app.activeDocument.storiesfor( var i = 0; i < myStories.length; i++ )    for( var j = 0; j < myStories[i].tables.length; j++ )    for( var k = 0; k < myStories[i].tables[j].rows.length; k++ )        snapRow( myStories[i].tables[j].rows[k] ) 
function snapRow( myRow ){// get the size of em space
var em = myRow.cells[0].insertionPoints[0].pointSize;
myRow.height = '2p3';// get horizontal offset of last insertion point in each cell
var myRightPosArray = myRow.cells.everyItem(        ).insertionPoints[-1].horizontalOffset// find the biggest value
var longest = maxArray( myRightPosArray )// get position of left side of Row
var myLeftPos = myRow.cells[0].insertionPoints[0].horizontalOffset// set Row height
myRow.height = (( longest - myLeftPos ) + em )}  
function getRow(){
var mySel = app.selection[0];if( mySel.parent.constructor.name == 'Cell' )return mySel.parent.parentRowelseif( mySel.constructor.name == 'Cell' )return mySel.parentRow;
alert( 'Cursor not in a table\ror illegal selection' );
exit();}  
function maxArray( myArray ){
var temp = 0for( var i in myArray )
temp = Math.max( temp, myArray[i] )return temp} 

Viewing all articles
Browse latest Browse all 37788

Trending Articles



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