PTC ALD in Arbortext Styler > Components of Documents and Templates > Style Components > Block Level Styling > Creating Blocks and Applying Style
  
Creating Blocks and Applying Style
To create a simple block, use this code inside a JavaScript function:
var b = new fBlock;

formatting.blockStart(b);
To end the block use this code, usually in the onExit code of an element:
formatting.blockEnd();
This function ends the current open block. There is no way to end a specific block. Ensuring that all blocks opened are closed properly reduces the risk of formatting errors.
This example code sets some default styling properties on the text contained by the block:
var b = new fBlock;
s = b.defaultStyle;
p = b.defaultParagraph;

s.height = "24pt";
s.color = "yellow";

p.textAlign = fParagraph.ALIGN_RIGHT;

formatting.blockStart(b);
In this example, the default properties for text within the block, and within its descendents, are set to a text height of 24pt and a color of yellow. The default text alignment for all paragraphs within the block and its descendents is right aligned.
This example code adds some columns to the block:
var b = new fBlock;
b.numColumns = 3;

//Column 1
var bcw1 = new fColumnWidth;
bcw1.relative = 1;

var bc1 = new fBlockColumn;
bc1.width = bcw1;
bc1.gutter = "6pt";

//Column 2
var bcw2 = new fColumnWidth;
bcw2.relative = 2;

var bc2 = new fBlockColumn;
bc2.width = bcw2;
bc2.gutter = "12pt";

//Column 3
var bcw3 = new fColumnWidth;
bcw3.relative = 3;

var bc3 = new fBlockColumn;
bc3.width = bcw3;

//Set block columns
b.columns[0] = bc1;
b.columns[1] = bc2;
b.columns[2] = bc3;


formatting.blockStart(b);
This example gives the block three columns of relative widths 1*, 2*, and 3*. There is a 6pt gutter between column 1 and 2, and a 12pt gutter between columns 2 and 3.
This example code adds a rule to the block:
var b = new fBlock;

var r = new fRule;
r.lineColor = "blue";
r.thickness = "2pt";
r.sides = fRule.SIDE_TOP + fRule.SIDE_BOTTOM;
r.lineStyle = fRuleLine.LINE_DOT;

b.rules.addRule(r);

formatting.blockStart(b);
This example adds a 2pt dotted rule to the top and bottom of the block. Refer to Rules for further information about rules.