<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="en-us" xml:lang="en-us"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="security" content="public" /> <meta name="Robots" content="index,follow" /> <meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' /> <meta name="DC.Type" content="reference" /> <meta name="DC.Title" content="Using HTMLDocument to create XSL FO data" /> <meta name="abstract" content="" /> <meta name="description" content="" /> <meta name="copyright" content="(C) Copyright IBM Corporation 2006" /> <meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" /> <meta name="DC.Format" content="XHTML" /> <meta name="DC.Identifier" content="htmldocumentcreatefo" /> <meta name="DC.Language" content="en-us" /> <!-- All rights reserved. Licensed Materials Property of IBM --> <!-- US Government Users Restricted Rights --> <!-- Use, duplication or disclosure restricted by --> <!-- GSA ADP Schedule Contract with IBM Corp. --> <link rel="stylesheet" type="text/css" href="./ibmdita.css" /> <link rel="stylesheet" type="text/css" href="./ic.css" /> <title>Using HTMLDocument to create XSL FO data</title> </head> <body id="htmldocumentcreatefo"><a name="htmldocumentcreatefo"><!-- --></a> <!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script> <h1 class="topictitle1">Using HTMLDocument to create XSL FO data</h1> <div><p></p> <div class="section"><p>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:</p> <ul><li>Regions function as the highest level container.</li> <li>Block areas represent block level elements, for example, paragraphs or list items.</li> <li>Line areas represent a line of text inside of a block.</li> <li>Inline areas represent parts of a line, for example, a single character, a footnote, or a mathematical equation.</li> </ul> <p>XSL FO tags created by IBM<sup>®</sup> 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:</p> <blockquote><a href="http://www.w3.org/TR/xsl/" target="_blank">Extensible Stylesheet Language (XSL) Version 1.0</a></blockquote> </div> <div class="section"><h4 class="sectiontitle">Generating XSL FO source data</h4><p>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.</p> <p>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.</p> <p>HTMLDocument generates XSL FO source data in two major sections:</p> <ul><li>The first section contains the <fo:root> and <fo:layout-master-set> XSL FO tags that hold general page layout information for page height, page width, and page margins. To specify the values for the layout information, use HTMLDocument set methods to set the values for the associated properties.</li> <li>The second section contains the XSL FO <fo:page-sequence> tag that holds the individual content elements. To specify individual content elements, which are instances of HTML classes, retrieve the corresponding XSL FO tag from the HTML object. Make sure that for your content elements you use only HTML classes that have the getFoTag() method.<div class="note"><span class="notetitle">Note:</span> Trying to retrieve XSL FO tags from HTML classes that do not have the getFoTag() method results in a comment tag.</div> </li> </ul> <p>For more information about the HTML classes that include methods for working with XSL FO tags, see the following Javadoc reference documentation:</p> <blockquote><a href="htmldocumentenabled.htm#htmldocumentenabled">XSL FO-enabled classes</a></blockquote> <p>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.</p> <ul><li>You can use setUseFO() on either the HTMLDocument or the individual HTML objects. When you use setUseFO(), you can retrieve XSL FO tags by using HTMLDocument.getTag().</li> <li>Alternatively, you can use the getFoTag() method on either the HTMLDocument or the individual HTML objects. You might want to use this alternative method when you need to be able to generate both XSL FO and HTML source from the HTMLDocument or the HTML objects.</li> </ul> </div> <div class="section"><h4 class="sectiontitle">Example: Using HTMLDocument</h4><p>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:</p> <blockquote><p><a href="htmldocumenthtmlexmpl.htm">Example: Using HTMLDocument to generate both HTML source and XSL FO source</a></p> <p><a href="htmldocumentfoexmpl.htm">Example: Converting XSL FO source data to a PDF</a></p> </blockquote> </div> <div class="section"><h4 class="sectiontitle">Javadoc reference documentation</h4><p>For more information about the HTMLDocument class, see the following Javadoc reference documentation:</p> <blockquote><a href="javadoc/com/ibm/as400/util/html/HTMLDocument.html">HTMLDocument</a></blockquote> </div> <div class="section"><p>The following disclaimer applies to all of the IBM Toolbox for Java examples:</p> <blockquote><strong>Code example disclaimer</strong> <p>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.</p> <p>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.</p> <p>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.</p> </blockquote> </div> </div> </body> </html>