HTML Box

An HTML Box displays an image of an HTML document in the report.

HTML Box (HTMLBox type) is a layout container, found in the Drawable group in the Tool Box view.

Note: The content of an HTML box cannot span pages.

Properties

Select the object on the Report Design page to display its properties in the Properties View.

Use the Location property to specify the file name and path of the HTML document.

Embedding HTML

To embed a resource, use the "data" URL type, which allows the data to be encoded in the body of the URL text. The full syntax of data URLs is:

data:[<MIME-type>][;charset=<encoding>][;base64],<data>

See data URI scheme (Wikipedia link) for a complete description of the concept and the syntax.

For our purposes, it is sufficient to support a simplified subset that omits the charset and assumes that characters are encoded in UTF-8. Image data is always encoded in base64 (Wikipedia link) while other data such as HTML content is typically “Percent encoded” (Wikipedia link).

For HTML content, a URL has the form “data:text/html,<data>. To embed HTML, use the data protocol syntax in the Location property of the HTMLBOX element:
data:text/html, followed by the percent encoded data of the html document

To automatically construct this URL, click the ... button for the Location property. Choose the file and select the Embed in document check box.

Figure: Embed in document checkbox


The figure is a screenshot showing the Embed in document checkbox, which allows you to embed an HTML document in a report.

Populating HTML content from text variables

Enter the code in the Expression Editor for the Location property of the HTML Box, including the name of the text variable.

Figure: RTL Expression


The figure shows a method of populating HTML content from text variables using the RTL Expression: "data:text/html,"+htmldescription.urlEncode().

To encode the data using percent encoding, use the function String.urlEncode().