Textile-Conversion: Can create Table with Style applied, but need to have it in separate Textfield
Aloha everyone
I'm in need of a bit of help. So I'm working on a Textile-conversion script and I'm almost done (with a lot of thanks to you guys), That last bit concerns tables. And all I need to do is basically take it out of the main text field and make a separate one.
So this is a table with one header row as seen in Textile.
|_. name |_. age |_. sex |
| joan | 24 | f |
| archie | 29 | m |
| bella | 45 | f |
And from this, I produce a table with the style "RedTable2" using this code.
// current selection
var curSel = app.selection[0];
// reset searchparameters
app.findGrepPreferences = app.changeGrepPreferences = null;
// set search parameters
app.findGrepPreferences.findWhat = "(\\|.+\\r)+\\|.+";
var result = curSel.findGrep( true );
app.findGrepPreferences = null;
// loop through findings
for ( var f = 0; f < result.length; f++ ) {
// last finding
var curRes = result
; // convert to table
var curTable = curRes.convertToTable("|");
// delete first and last row
curTable.columns[0].remove();
curTable.columns[-1].remove();
// fit table to frame (doesn't always quite work)
var tFrame = curTable.parent;
var fWidth = tFrame.geometricBounds[3] - tFrame.geometricBounds[1];
curTable.width = fWidth;
// make first table a header row
curTable.rows[0].rowType = RowTypes.headerRow;
// add Style
curTable.appliedTableStyle = "RedTable2";
// delete formatting that doesn't fit RedTable2
curTable.clearTableStyleOverrides( true );
// Delete Textile Header Row formatting
app.findGrepPreferences.findWhat = "\\s+$|^\\s+";
app.changeGrepPreferences.changeTo = "";
curTable.changeGrep();
app.findGrepPreferences.findWhat = "_\\. ";
app.changeGrepPreferences.changeTo = "";
curTable.changeGrep();
}
app.findGrepPreferences = null;
Now, that last bit I need is this.
- The converted table should be in a new Text Field, separate from the source text I can find.
- Can I set the text wrap of that new text field to Jump Object and add a top and bottom offset of 7mm?
