jRtfApi

Mission statement

The jRtfApi was developed to provide a small, easy to use pure java interface to writing RTF files which can be read by most modern word processing programs. This includes, but is not limited to, OpenOffice, WordPerfect and MS-Word. This enables the Java programmer to generate reports or business letters in RTF which can then be viewed, edited and printed from these word processors. Unlike most other word processing document formats, RTF is a publicly documented format. The specifications for RTF can be downloaded e.g. from the Microsoft web site.

Status

jRtfApi implements most of the basic items present in RTF.

Header, Footer, Table, Frames and Styles have been implemented and can be used to produce nice looking documents. However, the style support is not complete yet.

Missing Functionality

The jRtfApi implementation is not yet complete. There are a number of RTF features which have not been implemented, mainly because the functionality was not needed. The library has been used successfully in several projects for major banks and in the social sector. If you need a feature that has not been implemented yet, please send an email to the mailing list, and I'll try to implement it as soon as possible. Bear in mind, however, that this is a fun project, so I can't guarantee any turnaround times, unless a separate arrangement has been made.

Documentation

As with most other open source projects, the documentation is not complete at the time the software is released. I've added a few examples in a test package to show how the jRtfApi can be used. I think that the API should be straigh forward to use, especially after having a look at the exmaples. I do acknowledge that javadoc comments sometimes help, so I plan on adding them in the not so distant future :-)

I tried to model all main features available in RTF as objects. The most important objects being RtfDocument, RtfSection, RtfParagraph and RtfString. These objects can then be arranged like a tree using the provided methods on each object. The famous hello world example would be implemented by creating an instance for each one of the mentioned classes, set the text of the RtfString to "Hello World" and then add the RtfString to the RtfParagraph, add the RtfParagraph to the RtfSection and finally adding the RtfSection to the RtfDocument. Then call rtfDocument.write(OutputStream) to write the generated RTF to an OutputStream.

jRtfApi is currently only able to create RTF documents, i.e..it cannot be used to read any RTF documents. Support for this can be added later.

One last remark about a general design prinyiple I applied. Whenever objects are added to other object, e.g. an RtfString gets added to an RtfParagraph, the RtfParagraph object will remember all information from that RtfString object. Any changes done to this RtfString object after it was added do not have an affect on what was previously added to the RtfParagraph object. If they do then please report this as a bug :-)