Dynamic Alignment Using Style

This recipe demonstrates how to implement dynamic alignment using style.
Create a tabular report template (DynamicAlignmentUsingStyle.rml).

Define the following parameter in the “Report > Parameters” page:

Name=Locale, Value=${Locale#choice(Arabic,French)#Arabic}

Enter the following script into “Report Properties > Scripts” page:

if (Properties.getProperty(“Locale”) == “French”) {
align = “Left”;
font = “Arial”;
}
else {
align = “Right”;
font = “Arabic Transparent”;
}

importClass(Packages.com.elixirtech.report2.raw.model.StyleItem);
var newStyle = getStyle(“Test”);
var alignItem = new StyleItem();
var fontItem = new StyleItem();

alignItem.setName(“TextElement.TextAlign”);
alignItem.setValue(align);

fontItem.setName(“TextElement.FontName”);
fontItem.setValue(font);

newStyle.addStyleItem(alignItem);
newStyle.addStyleItem(fontItem);

To download the necessary files for this recipe, refer to the attached ZIP package.
DynamicAlignmentUsingStyle.zip (4.3 KB)