iText Tutorial
|
|
iText, a Free Java-PDF library
by Bruno Lowagie
|
[Home] |
[Previous] |
[TOC] |
[Next] |
[PDF] |
Part II: Other document formats
Chapter 8: RTF
|
The RTF package
The RTF package in iText is a very experimental package that is not a part of the core iText library.
The code is in separate tar.gz, zip and jar-file together with the also experimental XML functionality.
This package was written by Mark Hall.
The RTF package allows you to create RTF files in addition to the PDF files the core iText library generates.
Most of the PDF features are available but there are some features which are not supported in the RTF package.
|
Generating a RTF document
You generate RTF documents the same way you generate PDF documents. The 5 basic steps are the same. The only change is that
you use a RtfWriter instead of the usual PdfWriter in Step 2.
Download the source code for the Hello World example: Chap0801.java
Step 1:
Creates an instance of the com.lowagie.text.Document-object:
Document document = new Document();
Step 2:
Creates a RtfWriter that listens to this document and writes the document to the OutputStream of your choice:
RtfWriter.getInstance(document, new FileOutputStream("Chap0801.rtf"));
Step 3:
Opens the document:
document.open();
Step 4:
Adds content to the document:
document.add(new Paragraph("Hello World"));
Step 5:
Closes the document:
document.close();
Check the result here: Chap0801.rtf.
For help on how to create different objects and adding them to the document please look at the other sections of this tutorial.
|
Features available in the RTF package
The following list of features is not complete. If you do not find the feature you wish to use in the following list,
then the feature is not supported in the RtfWriter.
Document Object:
Available:
- Metadata: addTitle(...), addSubject(...), addKeywords(...), addAuthor(...), addCreator(...), addProducer(...),
addCreationDate(...)
- Headers and Footers
Not Available:
- Metadata: addHeader(...)
- Page size
- Page orientation
- Watermarks
- Viewer preferences
- Encryption
Chunk, Phrase, Paragraph, Font Objects:
Available:
- Chunks with basic fonts
- Phrases with basic fonts
- Paragraphs with basic fonts
- Paragraphs with an alignment
- Paragraphs with a left indentation
Not Available:
- Chunks with embedded fonts
Unknown results
- Phrases with embedded fonts
Unknown results
- Phrases with a leading
The leading will be ignored
- Paragraphs with embedded fonts
Unknown results
- Paragraphs with a right indentation
The right indentation will be ignored
Anchor, List, Annotation Objects:
Available:
- Anchors with a reference to an external URL
- Simple lists
- Nested lists
- Bulleted and numbered lists
- Lists with a left indentation
- Lists with a certain symbol indentation
- Annotations
Not Available:
- Lists with a right indentation
The right indentation will be ignored
- Lists with a certain symbol
The symbol will be ignored
HeaderFooter, Chapter, Section Objects:
Available:
- One HeaderFooter per Document
- Chapters
- Sections
Not Available:
- Chapters and Sections have no results for the actual RTF document structure
Table Object:
Available:
- Simple tables
- Tables with column- and row-spanning
- Tables with borders
- Tables with individual cell borders
- Cells with cellspacing and cellpadding
Not Available:
- Nested tables
The nested table will be ignored
Image Object:
Available:
- PNG images
- JPEG images
- Scaled images
- Images with an alignment
Not Available:
- Other image types
Will throw a document exception
- Rotated images
The rotation will be ignored
|
Examples of using the RtfWriter
|
[Top] |
[Previous] |
[TOC] |
[Next] |
[PDF] |
Page Updated: $Date: 2002/07/02 06:58:44 $
Copyright © 2000, 2001 by Bruno Lowagie
|
Adolf Baeyensstraat 121, 9040 Gent, BELGIUM,
tel +00 32 92 28 10 97 mailto:itext@lowagie.com
|
|