<?xml version="1.0" encoding="ISO-8859-1"?><!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
--><!-- $Id: rtflib.xml 911792 2010-02-19 12:12:37Z psancho $ --><!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.3//EN" "http://forrest.apache.org/dtd/document-v13.dtd">
<document>
  <header>
    <title>FOP Development: RTFLib (jfor)</title>
    <version>$Revision: 911792 $</version>
  </header>
  <body>
    <section id="general">
      <title>General Information</title>
      <section id="intro">
        <title>Introduction</title>
        <p>The RTFLib package is an open-source, <em>independent</em> package suitable for writing RTF files in a java environment.
By <em>independent</em> we mean:</p>
        <ul>
          <li>Although it is used by FOP to generate FOP's RTF output, it is not dependent on FOP for any of its functionality.</li>
          <li>It does not require FOP as a front-end, nor does it even require XSL-FO for input.
It essentially exposes an API of relatively high-level RTF construction routines to a host program.
This means it can be used anywhere RTF output is required and java is available.</li>
        </ul>
        <p>The FOP development team intends to keep the RTFLib package independent so that it can be used for other purposes.</p>
      </section>
      <section id="history">
        <title>History</title>
        <p>RTFLib was originally developed by <link href="mailto:bdelacretaz@apache.org">Bertrand Delacrétaz</link> and the <link href="http://www.jfor.org">jfor</link> team. jfor was written under an Apache-style license, and the jfor team contributed the code to the Apache Software Foundation in June, 2003. RTFLib is a subset of the original jfor project, which also includes an XSL-FO parsing mechanism for a complete XSL-FO to RTF solution.</p>
      </section>
      <section id="status">
        <title>Status</title>
        <p>Although FOP's implementation of the RTFLib package is very incomplete, the RTFLib package itself is relatively mature. RTFLib is only available in the trunk <link href="index.html#lines">line of FOP development</link>.</p>
        <warning>This documentation is a work in progress. If you see errors or omissions, please report them to the <link href="index.html#mail-fop-dev">fop-dev mailing list</link>.</warning>
      </section>
    </section>
    <section id="userdoc">
      <title>User Documentation</title>
      <section id="userdoc-overview">
        <title>Overview</title>
        <p>Perhaps the easiest way to see how to use RTFLib is by looking at an example. A set of test documents is part of the package, and can be <link href="http://cvs.apache.org/viewcvs.cgi/xml-fop/src/java/org/apache/fop/rtf/rtflib/testdocs/">viewed online</link>.
A quick look at the Abstract <link href="http://cvs.apache.org/viewcvs.cgi/xml-fop/src/java/org/apache/fop/rtf/rtflib/testdocs/TestDocument.java?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup">TestDocument</link> class, and one of the Concrete subclasses, <link href="http://cvs.apache.org/viewcvs.cgi/xml-fop/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleDocument.java?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup">SimpleDocument</link> will provide the basics of how to use the package.</p>
        <p>There are two basic concepts you will need to understand in order to use RTFLib:</p>
        <ul>
          <li>Documents are created by filling bigger containers with successively smaller containers, and eventually with content.</li>
          <li>Attributes may be set for each container or content as it is created</li>
        </ul>
        <p>RTFLib handles the process of converting to and writing the RTF content as the document is created. All you need to do is flush the document at the end to make sure that the last pieces get written.</p>
      </section>
      <section id="userdoc-structure">
        <title>Document Structure</title>
        <warning>This section is very incomplete.</warning>
        <p>The documentation in this section is intended to provide a high-level view of the process of building an RTF document. For more detailed API documentation of the various methods, be sure to consult the Javadocs for RTFLib.</p>
        <p>The following table summarizes the various containers that can be created:</p>
        <table>
          <tr>
            <th colspan="1" rowspan="1">Name</th>
            <th colspan="1" rowspan="1">Class.Method where created</th>
            <th colspan="1" rowspan="1">Attribute Set(s)</th>
            <th colspan="1" rowspan="1">Valid children</th>
          </tr>
          <tr>
            <td colspan="1" rowspan="1">Document Area</td>
            <td colspan="1" rowspan="1">RtfFile.startDocumentArea()</td>
            <td colspan="1" rowspan="1">Information Group, Document Formatting</td>
            <td colspan="1" rowspan="1">Section</td>
          </tr>
          <tr>
            <td colspan="1" rowspan="1">Section</td>
            <td colspan="1" rowspan="1">RtfDocumentArea.newSection()</td>
            <td colspan="1" rowspan="1">Section Formatting</td>
            <td colspan="1" rowspan="1">Paragraph, ParagraphKeepTogether, Image, List, Before (Page Heading), After (Page Footer), JforCmd</td>
          </tr>
          <tr>
            <td colspan="1" rowspan="1">Paragraph</td>
            <td colspan="1" rowspan="1">RtfSection.newParagraph()</td>
            <td colspan="1" rowspan="1">Paragraph Formatting, Character Formatting</td>
            <td colspan="1" rowspan="1">Text</td>
          </tr>
          <tr>
            <td colspan="1" rowspan="1">ParagraphKeepTogether</td>
            <td colspan="1" rowspan="1">RtfSection.newParagraphKeepTogether</td>
            <td colspan="1" rowspan="1">.</td>
            <td colspan="1" rowspan="1">.</td>
          </tr>
          <tr>
            <td colspan="1" rowspan="1">Image</td>
            <td colspan="1" rowspan="1">RtfSection.newImage</td>
            <td colspan="1" rowspan="1">.</td>
            <td colspan="1" rowspan="1">.</td>
          </tr>
          <tr>
            <td colspan="1" rowspan="1">Table</td>
            <td colspan="1" rowspan="1">RtfSection.newTable</td>
            <td colspan="1" rowspan="1">.</td>
            <td colspan="1" rowspan="1">.</td>
          </tr>
          <tr>
            <td colspan="1" rowspan="1">List</td>
            <td colspan="1" rowspan="1">RtfSection.newList</td>
            <td colspan="1" rowspan="1">.</td>
            <td colspan="1" rowspan="1">.</td>
          </tr>
          <tr>
            <td colspan="1" rowspan="1">Before (Page Heading)</td>
            <td colspan="1" rowspan="1">RtfSection.newBefore</td>
            <td colspan="1" rowspan="1">.</td>
            <td colspan="1" rowspan="1">.</td>
          </tr>
          <tr>
            <td colspan="1" rowspan="1">After (Page Footer)</td>
            <td colspan="1" rowspan="1">RtfSection.newAfter</td>
            <td colspan="1" rowspan="1">.</td>
            <td colspan="1" rowspan="1">.</td>
          </tr>
          <tr>
            <td colspan="1" rowspan="1">JforCmd</td>
            <td colspan="1" rowspan="1">RtfSection.newJforCmd</td>
            <td colspan="1" rowspan="1">.</td>
            <td colspan="1" rowspan="1">.</td>
          </tr>
          <tr>
            <td colspan="1" rowspan="1">Text</td>
            <td colspan="1" rowspan="1">RtfParagraph.newText()</td>
            <td colspan="1" rowspan="1">Character Formatting</td>
            <td colspan="1" rowspan="1">N/A</td>
          </tr>
        </table>
      </section>
      <section id="userdoc-attributes">
        <title>Attributes</title>
        <warning>This section is very incomplete.</warning>
        <p>Attributes can be set for each container and piece of content in the document. The general approach is to build an RtfAttributes object containing the various attributes, then pass that RtfAttributes object to the method that creates the new container or content. See the Javadoc API documentation for RtfAttributes for details on the syntax for creating an RtfAttributes object. The following information lists the various attributes that can be set for each type of container.</p>
        <section id="userdoc-attr-ig">
          <title>Information Group</title>
          <p>These attributes are set when creating a Document.</p>
        </section>
        <section id="userdoc-attr-df">
          <title>Document Formatting</title>
          <p>These attributes are set when creating a Document.</p>
        </section>
        <section id="userdoc-attr-sf">
          <title>Section Formatting</title>
          <p>These attributes are set when creating a Section.</p>
        </section>
        <section id="userdoc-attr-pf">
          <title>Paragraph Formatting</title>
          <p>These attributes are set when creating a Paragraph.</p>
          <table>
            <tr>
              <th colspan="1" rowspan="1">Description</th>
              <th colspan="1" rowspan="1">Attribute Name</th>
              <th colspan="1" rowspan="1">Attribute Value</th>
              <th colspan="1" rowspan="1">RTF Control Word</th>
            </tr>
            <tr>
              <td colspan="4" rowspan="1">.</td>
            </tr>
            <tr>
              <th colspan="1" rowspan="1">Alignment</th>
              <th colspan="3" rowspan="1">.</th>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">Align Left</td>
              <td colspan="1" rowspan="1">RtfText.ALIGN_LEFT</td>
              <td colspan="1" rowspan="1">N/A (boolean)</td>
              <td colspan="1" rowspan="1">\ql</td>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">Align Right</td>
              <td colspan="1" rowspan="1">RtfText.ALIGN_RIGHT</td>
              <td colspan="1" rowspan="1">N/A (boolean)</td>
              <td colspan="1" rowspan="1">\qr</td>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">Align Centered</td>
              <td colspan="1" rowspan="1">RtfText.ALIGN_CENTER</td>
              <td colspan="1" rowspan="1">N/A (boolean)</td>
              <td colspan="1" rowspan="1">\qc</td>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">Align Justified</td>
              <td colspan="1" rowspan="1">RtfText.ALIGN_JUSTIFIED</td>
              <td colspan="1" rowspan="1">N/A (boolean)</td>
              <td colspan="1" rowspan="1">\qj</td>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">Align Distributed</td>
              <td colspan="1" rowspan="1">RtfText.ALIGN_DISTRIBUTED</td>
              <td colspan="1" rowspan="1">N/A (boolean)</td>
              <td colspan="1" rowspan="1">\qd</td>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">Kashida justification</td>
              <td colspan="1" rowspan="1">not implemented</td>
              <td colspan="1" rowspan="1">0-20 (integer)</td>
              <td colspan="1" rowspan="1">\qkN</td>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">Thai Distributed justification</td>
              <td colspan="1" rowspan="1">not implemented</td>
              <td colspan="1" rowspan="1">N/A (boolean)</td>
              <td colspan="1" rowspan="1">\qt</td>
            </tr>
            <tr>
              <th colspan="1" rowspan="1">Indentation</th>
              <th colspan="3" rowspan="1">.</th>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">Left indent body</td>
              <td colspan="1" rowspan="1">RtfText.LEFT_INDENT_BODY</td>
              <td colspan="1" rowspan="1">(int) "hundredths of a character unit" (?)</td>
              <td colspan="1" rowspan="1">\li</td>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">Left indent first</td>
              <td colspan="1" rowspan="1">RtfText.LEFT_INDENT_FIRST</td>
              <td colspan="1" rowspan="1">(int) "hundredths of a character unit" (?)</td>
              <td colspan="1" rowspan="1">\fi</td>
            </tr>
            <tr>
              <th colspan="1" rowspan="1">Borders</th>
              <th colspan="3" rowspan="1">.</th>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">Bottom single border</td>
              <td colspan="1" rowspan="1">RtfText.BDR_BOTTOM_SINGLE</td>
              <td colspan="1" rowspan="1">Boolean?</td>
              <td colspan="1" rowspan="1">brdrb\\brsp40\\brdrs</td>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">Bottom double border</td>
              <td colspan="1" rowspan="1">RtfText.BDR_BOTTOM_DOUBLE</td>
              <td colspan="1" rowspan="1">Boolean?</td>
              <td colspan="1" rowspan="1">brdrb\\brsp40\\brdrdb</td>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">Bottom embossed border</td>
              <td colspan="1" rowspan="1">RtfText.BDR_BOTTOM_EMBOSS</td>
              <td colspan="1" rowspan="1">Boolean?</td>
              <td colspan="1" rowspan="1">brdrb\\brsp40\\brdremboss</td>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">bottom dotted border</td>
              <td colspan="1" rowspan="1">RtfText.BDR_BOTTOM_DOTTED</td>
              <td colspan="1" rowspan="1">Boolean?</td>
              <td colspan="1" rowspan="1">brdrb\\brsp40\\brdrdot</td>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">bottom dashed border</td>
              <td colspan="1" rowspan="1">RtfText.BDR_BOTTOM_DASH</td>
              <td colspan="1" rowspan="1">Boolean?</td>
              <td colspan="1" rowspan="1">brdrb\\brsp40\\brdrdash</td>
            </tr>
          </table>
        </section>
        <section id="userdoc-attr-cf">
          <title>Character Formatting</title>
          <p>These attributes are set when creating a Paragraph, or Text.</p>
          <table>
            <tr>
              <th colspan="1" rowspan="1">Description</th>
              <th colspan="1" rowspan="1">Attribute Name</th>
              <th colspan="1" rowspan="1">Attribute Value</th>
              <th colspan="1" rowspan="1">RTF Control Word</th>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">Bold</td>
              <td colspan="1" rowspan="1">RtfText.ATTR_BOLD</td>
              <td colspan="1" rowspan="1">N/A (boolean)</td>
              <td colspan="1" rowspan="1">\b</td>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">Italic</td>
              <td colspan="1" rowspan="1">RtfText.ATTR_ITALIC</td>
              <td colspan="1" rowspan="1">N/A (boolean)</td>
              <td colspan="1" rowspan="1">\i</td>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">Underline</td>
              <td colspan="1" rowspan="1">RtfText.ATTR_UNDERLINE</td>
              <td colspan="1" rowspan="1">N/A (boolean), or (int) 0 to turn underlining off</td>
              <td colspan="1" rowspan="1">\ul</td>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">Font Size</td>
              <td colspan="1" rowspan="1">RtfText.ATTR_FONT_SIZE</td>
              <td colspan="1" rowspan="1">(int) font size in half-points</td>
              <td colspan="1" rowspan="1">\fs</td>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">Font Family</td>
              <td colspan="1" rowspan="1">RtfText.ATTR_FONT_FAMILY</td>
              <td colspan="1" rowspan="1">(int) entry in document font-table</td>
              <td colspan="1" rowspan="1">\f</td>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">Font Color</td>
              <td colspan="1" rowspan="1">RtfText.ATTR_FONT_COLOR</td>
              <td colspan="1" rowspan="1">(int) entry in document color-table</td>
              <td colspan="1" rowspan="1">\cf</td>
            </tr>
            <tr>
              <td colspan="1" rowspan="1">Background Color</td>
              <td colspan="1" rowspan="1">RtfText.ATTR_BACKGROUND_COLOR</td>
              <td colspan="1" rowspan="1">(int) entry in document color-table</td>
              <td colspan="1" rowspan="1">\chcbpat</td>
            </tr>
          </table>
        </section>
      </section>
    </section>
  </body>
</document>