var curDoc = app.documents[0];
var allTables = curDoc.stories.everyItem().tables.everyItem().getElements();
for ( var i = 0; i < allTables.length; i++ ) {
var curTable = allTables[i];
if ( curTable.columns.length == 5) {
curTable.columns[-2].verticalJustification = VerticalJustification.CENTER_ALIGN;
//HERE SHOULD BE THE CODE FOR ALIGNING TEXT IN SECOND LAST COLUMN TO RIGHT
}
}
Hello W3Schools community,
I need your help on a final step in my Javascript code for an Adobe InDesign document.
In the InDesign document there are many tables that have all five columns.
My script (.jsx file, executed in InDesign) works fine by vertically aligning all second last columns in every table in the whole document to center. I just tested if it works, the vertical alignment is not needed. I'm glad about this success, because I'm a newbie to JS in InDesign and did a lot of 'try and error' in order to locate and aligning the cells.
What I'm really looking for is to align the text horizontally in all second last columns from left to right alignment. A simple operation certainly, but I'm totally stuck with the correct JS syntax...
I tried all functions I could find at W3Schools and on the web, e.g. 'text-align: right' or 'Justification.RIGHT_ALIGN' referring to the working 'verticalJustification' function but nothing works to align the text in the cells. There are many examples for easy alignment in HTML and it's 'divs', respectively CSS, but nothing seems to work in JS code.
Thank you in advance – i would highly appreciate your help because this script saves a lot of time in my projects!
Regards