HTML formatting and interpolation
Advanced report design
HTML formatting and interpolation
Text components can render a small subset of inline HTML and can interpolate report expressions inside their text. Both features are controlled by a single property, Is Html, on the component.
Enabling it: the Is Html property
Set the Is Html property of a text component to True. While it is
False (the default), the text is printed verbatim – angle brackets and
{{ }} markers are shown literally. Enabling Is Html turns on
both inline HTML rendering and {{ }} interpolation at the
same time, so existing reports are unaffected and nothing changes unless you
opt in.
Supported HTML tags
The inline parser recognizes the following tags. Everything is laid out as inline text; there is no block layout.
| Tag | Effect |
|---|---|
<b>, <strong> | Bold |
<i>, <em> | Italic |
<u> | Underline |
<s>, <strike>, <del> | Strikethrough |
<br> | Line break |
<font face="Name" size="N" color="#RRGGBB"> | Font family, size and color |
<span style="font-family:Name; font-size:Npt; color:#RRGGBB"> | Font family, size and color |
Colors accept #RRGGBB, #RGB or a color name. The HTML
entities , <, >,
&, " and ' are
decoded.
Interpolating expressions with {{ }}
When Is Html is True, every {{ expression }} found in the text is
replaced by the value of expression, evaluated by the report
expression evaluator. You can use fields and
functions, for example {{CUSTOMER.NAME}} or
{{UPPER(CUSTOMER.CITY)}}. If an expression cannot be evaluated, the
original {{...}} placeholder is left untouched.
Labels and expressions behave differently
Where you place the HTML and the {{ }} markers depends on the
component, because a TRpLabel prints static text while a
TRpExpression first evaluates an expression and then prints the
result.
TRpLabel – write the HTML and the interpolation directly in the label text. For example, set the label text to:
Customer: <b>{{CUSTOMER.NAME}}</b>
TRpExpression – the HTML must be produced by the expression itself, so a field value is inserted in one of two equivalent ways:
- Concatenate the field inside the expression:
'<b>'+CUSTOMER.NAME+'</b>' - Return a string literal that contains the mustaches:
'<b>{{CUSTOMER.NAME}}</b>'
In both cases Is Html must be True. For expressions, the display format is
applied to the evaluated value before the HTML and the {{ }}
interpolation are processed.
Notes
- HTML rendering and interpolation work in the preview, when printing (Windows GDI and Linux) and in PDF output.
- The component font is the base style; the tags add bold, italic, underline and the other effects on top of it. Make sure the chosen font contains the glyphs you need.
- This is different from the HTML output driver,
which exports a whole report to an
.htmlfile. Here the HTML is inline formatting inside a single text component.