// Balancelastcolumns.jsx // A simple script to balance the columns at the end of a story // To use it, place the cursor (insertion point) into the story // of which the last columns have to be balanced. // Made by Teus de Jong; last version September 28, 2005 if (app.documents.length == 0){ exitAlert('No documents are open'); } if (app.selection.length == 0){ exitAlert('First place the cursor in the story with the columns'); } if (app.version == 3){ theframe = app.selection[0].parentTextFrame.endTextFrame; } else { theframe = app.selection[0].parentTextFrames[0].endTextFrame; } nroflines = theframe.lines.length; nrofcolumns = theframe.textColumns.length; if (nrofcolumns == 0){ exitAlert('This story does not have columns') } halfway = Math.round(nroflines / nrofcolumns); // better not compare floats, so we multiply by 10 if (Math.round((nroflines / nrofcolumns) * 10) > (halfway*10)){ halway += 1; } newbottom = theframe.lines[halfway - 1].baseline; bounds = theframe.geometricBounds; bounds[2] = newbottom; theframe.geometricBounds = bounds; function exitAlert(s){ alert(s); exit() }