blob: c61f486bfa72cdbd096174d1ec02cc323a1efd3f [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
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$ -->
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.3//EN" "http://forrest.apache.org/dtd/document-v13.dtd">
<document>
<header>
<title>Apache™ FOP Development: RTFLib (jfor)</title>
<version>$Revision$</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 Apache™ 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>Name</th>
<th>Class.Method where created</th>
<th>Attribute Set(s)</th>
<th>Valid children</th>
</tr>
<tr>
<td>Document Area</td>
<td>RtfFile.startDocumentArea()</td>
<td>Information Group, Document Formatting</td>
<td>Section</td>
</tr>
<tr>
<td>Section</td>
<td>RtfDocumentArea.newSection()</td>
<td>Section Formatting</td>
<td>Paragraph, ParagraphKeepTogether, Image, List, Before (Page Heading), After (Page Footer), JforCmd</td>
</tr>
<tr>
<td>Paragraph</td>
<td>RtfSection.newParagraph()</td>
<td>Paragraph Formatting, Character Formatting</td>
<td>Text</td>
</tr>
<tr>
<td>ParagraphKeepTogether</td>
<td>RtfSection.newParagraphKeepTogether</td>
<td>.</td>
<td>.</td>
</tr>
<tr>
<td>Image</td>
<td>RtfSection.newImage</td>
<td>.</td>
<td>.</td>
</tr>
<tr>
<td>Table</td>
<td>RtfSection.newTable</td>
<td>.</td>
<td>.</td>
</tr>
<tr>
<td>List</td>
<td>RtfSection.newList</td>
<td>.</td>
<td>.</td>
</tr>
<tr>
<td>Before (Page Heading)</td>
<td>RtfSection.newBefore</td>
<td>.</td>
<td>.</td>
</tr>
<tr>
<td>After (Page Footer)</td>
<td>RtfSection.newAfter</td>
<td>.</td>
<td>.</td>
</tr>
<tr>
<td>JforCmd</td>
<td>RtfSection.newJforCmd</td>
<td>.</td>
<td>.</td>
</tr>
<tr>
<td>Text</td>
<td>RtfParagraph.newText()</td>
<td>Character Formatting</td>
<td>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>Description</th>
<th>Attribute Name</th>
<th>Attribute Value</th>
<th>RTF Control Word</th>
</tr>
<tr>
<td colspan="4">.</td>
</tr>
<tr>
<th>Alignment</th>
<th colspan="3">.</th>
</tr>
<tr>
<td>Align Left</td>
<td>RtfText.ALIGN_LEFT</td>
<td>N/A (boolean)</td>
<td>\ql</td>
</tr>
<tr>
<td>Align Right</td>
<td>RtfText.ALIGN_RIGHT</td>
<td>N/A (boolean)</td>
<td>\qr</td>
</tr>
<tr>
<td>Align Centered</td>
<td>RtfText.ALIGN_CENTER</td>
<td>N/A (boolean)</td>
<td>\qc</td>
</tr>
<tr>
<td>Align Justified</td>
<td>RtfText.ALIGN_JUSTIFIED</td>
<td>N/A (boolean)</td>
<td>\qj</td>
</tr>
<tr>
<td>Align Distributed</td>
<td>RtfText.ALIGN_DISTRIBUTED</td>
<td>N/A (boolean)</td>
<td>\qd</td>
</tr>
<tr>
<td>Kashida justification</td>
<td>not implemented</td>
<td>0-20 (integer)</td>
<td>\qkN</td>
</tr>
<tr>
<td>Thai Distributed justification</td>
<td>not implemented</td>
<td>N/A (boolean)</td>
<td>\qt</td>
</tr>
<tr>
<th>Indentation</th>
<th colspan="3">.</th>
</tr>
<tr>
<td>Left indent body</td>
<td>RtfText.LEFT_INDENT_BODY</td>
<td>(int) "hundredths of a character unit" (?)</td>
<td>\li</td>
</tr>
<tr>
<td>Left indent first</td>
<td>RtfText.LEFT_INDENT_FIRST</td>
<td>(int) "hundredths of a character unit" (?)</td>
<td>\fi</td>
</tr>
<tr>
<th>Borders</th>
<th colspan="3">.</th>
</tr>
<tr>
<td>Bottom single border</td>
<td>RtfText.BDR_BOTTOM_SINGLE</td>
<td>Boolean?</td>
<td>brdrb\\brsp40\\brdrs</td>
</tr>
<tr>
<td>Bottom double border</td>
<td>RtfText.BDR_BOTTOM_DOUBLE</td>
<td>Boolean?</td>
<td>brdrb\\brsp40\\brdrdb</td>
</tr>
<tr>
<td>Bottom embossed border</td>
<td>RtfText.BDR_BOTTOM_EMBOSS</td>
<td>Boolean?</td>
<td>brdrb\\brsp40\\brdremboss</td>
</tr>
<tr>
<td>bottom dotted border</td>
<td>RtfText.BDR_BOTTOM_DOTTED</td>
<td>Boolean?</td>
<td>brdrb\\brsp40\\brdrdot</td>
</tr>
<tr>
<td>bottom dashed border</td>
<td>RtfText.BDR_BOTTOM_DASH</td>
<td>Boolean?</td>
<td>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>Description</th>
<th>Attribute Name</th>
<th>Attribute Value</th>
<th>RTF Control Word</th>
</tr>
<tr>
<td>Bold</td>
<td>RtfText.ATTR_BOLD</td>
<td>N/A (boolean)</td>
<td>\b</td>
</tr>
<tr>
<td>Italic</td>
<td>RtfText.ATTR_ITALIC</td>
<td>N/A (boolean)</td>
<td>\i</td>
</tr>
<tr>
<td>Underline</td>
<td>RtfText.ATTR_UNDERLINE</td>
<td>N/A (boolean), or (int) 0 to turn underlining off</td>
<td>\ul</td>
</tr>
<tr>
<td>Font Size</td>
<td>RtfText.ATTR_FONT_SIZE</td>
<td>(int) font size in half-points</td>
<td>\fs</td>
</tr>
<tr>
<td>Font Family</td>
<td>RtfText.ATTR_FONT_FAMILY</td>
<td>(int) entry in document font-table</td>
<td>\f</td>
</tr>
<tr>
<td>Font Color</td>
<td>RtfText.ATTR_FONT_COLOR</td>
<td>(int) entry in document color-table</td>
<td>\cf</td>
</tr>
<tr>
<td>Background Color</td>
<td>RtfText.ATTR_BACKGROUND_COLOR</td>
<td>(int) entry in document color-table</td>
<td>\chcbpat</td>
</tr>
</table>
</section>
</section>
</section>
</body>
</document>