Search Apache XML Graphics

ApacheCon N. America

ApacheCon Europe

The Apache™ FOP Project

Apache™ FOP Development: RTFLib (jfor)

General Information

Introduction

The RTFLib package is an open-source, independent package suitable for writing RTF files in a java environment. By independent we mean:

Although it is used by Apache™ FOP to generate FOP's RTF output, it is not dependent on FOP for any of its functionality.

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.

The FOP development team intends to keep the RTFLib package independent so that it can be used for other purposes.

History

RTFLib was originally developed by Bertrand Delacrétaz and the jfor 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.

Status

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 line of FOP development.
This documentation is a work in progress. If you see errors or omissions, please report them to the fop-dev mailing list.

User Documentation

Overview

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 viewed online. A quick look at the Abstract TestDocument class, and one of the Concrete subclasses, SimpleDocument will provide the basics of how to use the package.

There are two basic concepts you will need to understand in order to use RTFLib:

Documents are created by filling bigger containers with successively smaller containers, and eventually with content.

Attributes may be set for each container or content as it is created

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.

Document Structure

This section is very incomplete.
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.

The following table summarizes the various containers that can be created:

Attributes

This section is very incomplete.
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.