Using HTMLDocument to create XSL FO data

An HTMLDocument functions as a wrapper that holds the information necessary to create either Extensible Stylesheet Language (XSL) Formatting Object (FO) or HTML source data. Generated XSL FO source follows the XSL FO formatting model. The model uses rectangular elements, called areas, to hold the individual content elements, which can be images, text, other XSL FOs, or nothing. The following list describes the four basic types of areas:

XSL FO tags created by IBM® Toolbox for Java™ adhere to the XSL standards described the W3C recommendation. For more information about XSL, XSL FOs, and the W3C recommendation, see the following:

Extensible Stylesheet Language (XSL) Version 1.0

Generating XSL FO source data

When creating XSL FO source, HTMLDocument properties represent XSL FO tags that specify page size, orientation, and margins. Additionally, HTMLDocument retrieves from many HTML classes the corresponding XSL FO tags for that content element.

After you use HTMLDocument to generate the XSL FO source, you can use an XSL formatter (for example, the XSLReportWriter class) to place the content elements on the pages of a document.

HTMLDocument generates XSL FO source data in two major sections:

For more information about the HTML classes that include methods for working with XSL FO tags, see the following Javadoc reference documentation:

XSL FO-enabled classes

After you create an instance of HTMLDocument and set the layout properties, retrieve XSL FO tags from HTML objects by using the setUseFO(), getFoTag(), and getTag() methods.

Example: Using HTMLDocument

After you create XSL FO source data, you need to convert that XSL FO data to a form that your users can view and print. The following examples show how to generate XSL FO source data (and HTML source) and convert the XSL FO source data to a PDF document by using the XSLReportWriter and Context classes:

Example: Using HTMLDocument to generate both HTML source and XSL FO source

Example: Converting XSL FO source data to a PDF

Javadoc reference documentation

For more information about the HTMLDocument class, see the following Javadoc reference documentation:

HTMLDocument

The following disclaimer applies to all of the IBM Toolbox for Java examples:

Code example disclaimer

IBM grants you a nonexclusive copyright license to use all programming code examples from which you can generate similar function tailored to your own specific needs.

All sample code is provided by IBM for illustrative purposes only. These examples have not been thoroughly tested under all conditions. IBM, therefore, cannot guarantee or imply reliability, serviceability, or function of these programs.

All programs contained herein are provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.