Article View: adobe.scripting.indesign
Article #9304JS Scripting Alternating Row Fills in Table
From: Matt_Mariani
Date: Sat, 26 Aug 2006 18:05
Date: Sat, 26 Aug 2006 18:05
62 lines
2549 bytes
2549 bytes
I'm trying to write a script that creates a table out of selected tab-delimited text and then applies various formatting to the resulting table. I can't seem to enable alternating row fills via script. I'm using InDesign CS on Windows XP. Here is the script that works OK, except that the alternating row fills are not implemented. What's the glitch that I'm missing?
textObj = app.selection[0];
mkTableFromText(textObj);
//FUNCTIONS
function mkTableFromText(textObj){
with (textObj){
leftIndent = 0;
spaceBefore = "1p0";
spaceAfter = "1p0";
alignToBaseline = false;
}
iPt = textObj.insertionPoints[-1];
iPt.contents = "\r";
pFrame = iPt.parentTextFrame;
tb = textObj.convertToTable("\t", "\r");
tb.rows.lastItem().remove();
coords = pFrame.geometricBounds;
widOfpFrame = coords[3] - coords[1];
formatTable(tb);
}
function formatTable(tb){
with (tb){
alternatingFills = AlternatingFillsTypes.alternatingRows;
startRowFillColor = app.swatches.item("Black");
startRowFillTint = 10;
startRowFillCount = 1;
skipFirstAlternatingFillRows = 0;
}
for (var i = 0; i < tb.rows.length; i++){
r = tb.rows[i];
with (r){
width = widOfpFrame/tb.columnCount;
bottomEdgeStrokeWeight = 0;
topEdgeStrokeWeight = 0;
leftEdgeStrokeWeight = 0;
rightEdgeStrokeWeight = 0;
innerColumnStrokeWeight = 0;
leftInset = "0p5";
rightInset = "0p5";
topInset = "0p5";
bottomInset = "0p5";
minimumFirstBaselineOffset = "0p0";
}
}
for(var i = 0; i < tb.cells.length; i++){
c = tb.cells[i];
if (c.parentColumn.index == 0) {
c.texts[0].justification = 1818584692; //Justification.leftAlign
c.verticalJustification = VerticalJustification.topAlign;
}
else {
c.texts[0].justification = 1919379572; //Justification.rightAlign
c.verticalJustification = VerticalJustification.bottomAlign;
}
}
}
Any light you can shed on this would be much appreciated. Thanks.
Matthew Mariani
Technical Details
Message-ID:
<3bc168bf.-1@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!news.ecp.fr!news.stben.net!webcrossingShow Full Headers
Complete Article Headers
X-Google-Thread: f939a,9a66a9548287d782,start X-Google-Attributes: gidf939a,public X-Google-Language: ENGLISH,ASCII-7-bit From: Matt_Mariani@adobeforums.com Newsgroups: adobe.scripting.indesign Subject: JS Scripting Alternating Row Fills in Table Message-ID: <3bc168bf.-1@webcrossing.la2eafNXanI> Date: Sat, 26 Aug 2006 11:05:31 -0700 Lines: 67 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!news.ecp.fr!news.stben.net!webcrossing