public class RtfWriter extends DocWriter implements DocListener
DocWriter
class for Rich Text Files (RTF).
A RtfWriter
can be added as a DocListener
to a certain Document
by getting an instance.
Every Element
added to the original Document
will be written to the OutputStream
of this RtfWriter
.
Example:
// creation of the document with a certain size and certain margins Document document = new Document(PageSize.A4, 50, 50, 50, 50); try { // this will write RTF to the Standard OutputStream RtfWriter.getInstance(document, System.out); // this will write Rtf to a file called text.rtf RtfWriter.getInstance(document, new FileOutputStream("text.rtf")); // this will write Rtf to for instance the OutputStream of a HttpServletResponse-object RtfWriter.getInstance(document, response.getOutputStream()); } catch(DocumentException de) { System.err.println(de.getMessage()); } // this will close the document and all the OutputStreams listening to it document.close();
LIMITATIONS
There are currently still a few limitations on what the RTF Writer can do:
Modifier and Type | Field and Description |
---|---|
static byte[] |
alignCenter
Deprecated.
Text alignment center tag.
|
static byte[] |
alignJustify
Deprecated.
Text alignment justify tag.
|
static byte[] |
alignLeft
Deprecated.
Text alignment left tag.
|
static byte[] |
alignRight
Deprecated.
Text alignment right tag.
|
private static byte[] |
annotation
Deprecated.
Annotation text tag.
|
private static byte[] |
annotationAuthor
Deprecated.
Annotation Author tag.
|
private static byte[] |
annotationID
Deprecated.
Annotation ID tag.
|
private static byte[] |
ansi
Deprecated.
RTF encoding.
|
private static byte[] |
ansiCodepage
Deprecated.
RTF encoding codepage.
|
protected static byte |
bold
Deprecated.
Bold tag.
|
static byte |
closeGroup
Deprecated.
This is the character for closing a group.
|
private static byte[] |
colorBlue
Deprecated.
Blue value tag.
|
private static byte[] |
colorGreen
Deprecated.
Green value tag.
|
private java.util.ArrayList |
colorList
Deprecated.
This
ArrayList contains all colours used in the document. |
private static byte[] |
colorRed
Deprecated.
Red value tag.
|
private static byte[] |
colorTable
Deprecated.
Begin colour table tag.
|
private static byte |
commaDelimiter
Deprecated.
This is another delimiter between RTF tags and normal text.
|
private java.io.ByteArrayOutputStream |
content
Deprecated.
This
ByteArrayOutputStream contains the main body of the document. |
private int |
currentListID
Deprecated.
Current list ID.
|
private static byte[] |
day
Deprecated.
Day tag.
|
private static byte[] |
defaultFont
Deprecated.
Default Font.
|
protected static byte |
delimiter
Deprecated.
This is the delimiter between RTF tags and normal text.
|
private static byte[] |
docBegin
Deprecated.
RTF begin and version.
|
private static byte[] |
endSuperSub
Deprecated.
End super/sub script.
|
static byte |
escape
Deprecated.
This is the escape character which introduces RTF tags.
|
private static byte[] |
extendedEscape
Deprecated.
This is another escape character which introduces RTF tags.
|
private static byte[] |
facingPages
Deprecated.
Facing pages tag
|
protected static byte[] |
field
Deprecated.
Begin field tag
|
protected static byte[] |
fieldContent
Deprecated.
Content fo the field
|
protected static byte[] |
fieldDisplay
Deprecated.
Last page number (not used)
|
protected static byte[] |
fieldHyperlink
Deprecated.
HYPERLINK field
|
protected static byte[] |
fieldPage
Deprecated.
PAGE numbers
|
private static byte[] |
firstIndent
Deprecated.
First indent tag.
|
private static byte[] |
fontArial
Deprecated.
Font Arial tag.
|
private static byte[] |
fontCharset
Deprecated.
Font charset tag.
|
protected static byte[] |
fontColor
Deprecated.
Font color tag.
|
private static byte[] |
fontCourier
Deprecated.
Font Courier tag.
|
private java.util.ArrayList |
fontList
Deprecated.
This
ArrayList contains all fonts used in the document. |
private static byte[] |
fontModern
Deprecated.
Modern font tag.
|
protected static byte |
fontNumber
Deprecated.
Font number tag.
|
private static byte[] |
fontRoman
Deprecated.
Roman font tag.
|
protected static byte[] |
fontSize
Deprecated.
Font size tag.
|
private static byte[] |
fontSwiss
Deprecated.
Swiss font tag.
|
private static byte[] |
fontSymbol
Deprecated.
Font Symbol tag.
|
private static byte[] |
fontTable
Deprecated.
Begin the font table tag.
|
private static byte[] |
fontTech
Deprecated.
Tech font tag.
|
private static byte[] |
fontTimesNewRoman
Deprecated.
Font Times New Roman tag.
|
private static byte[] |
fontWindings
Deprecated.
Font Windings tag.
|
private HeaderFooter |
footer
Deprecated.
Document footer.
|
private static byte[] |
footerBegin
Deprecated.
Begin footer group tag.
|
private static byte[] |
footerfBegin
Deprecated.
|
private static byte[] |
footerlBegin
Deprecated.
|
private static byte[] |
footerrBegin
Deprecated.
|
private boolean |
hasTitlePage
Deprecated.
Special title page
|
private HeaderFooter |
header
Deprecated.
Document header.
|
private static byte[] |
headerBegin
Deprecated.
Begin header group tag.
|
private static byte[] |
headerfBegin
Deprecated.
|
private static byte[] |
headerlBegin
Deprecated.
|
private static byte[] |
headerrBegin
Deprecated.
|
private static byte[] |
hour
Deprecated.
Hour tag.
|
private static byte[] |
hybridList
Deprecated.
RTF Writer outputs hybrid lists
|
private java.io.ByteArrayOutputStream |
info
Deprecated.
This
ByteArrayOutputStream contains the information group. |
private static byte[] |
infoBegin
Deprecated.
Begin the info group tag.
|
private boolean |
inHeaderFooter
Deprecated.
Currently writing either Header or Footer
|
private boolean |
inTable
Deprecated.
Currently writing a Table
|
protected static byte |
italic
Deprecated.
Italic tag.
|
private boolean |
landscape
Deprecated.
Landscape or Portrait Document
|
private static byte[] |
landscapeTag1
Deprecated.
Document Landscape tag 1.
|
private static byte[] |
landscapeTag2
Deprecated.
Document Landscape tag 2.
|
private static byte[] |
listBegin
Deprecated.
Actual list begin
|
private static byte[] |
listBulletOld
Deprecated.
Old Bullet Style
|
private static byte[] |
listCurrentLevel
Deprecated.
Current list level
|
private static byte[] |
listDefinition
Deprecated.
Begin a List definition
|
private static byte[] |
listID
Deprecated.
Current List ID
|
private java.util.ArrayList |
listIds
Deprecated.
List of current Lists.
|
private static byte[] |
listIndent
Deprecated.
Left indent tag.
|
private int |
listLevel
Deprecated.
Current List Level.
|
private static byte[] |
listLevelAlignNew
Deprecated.
Level alignment (new)
|
private static byte[] |
listLevelAlignOld
Deprecated.
Level alignment (old)
|
private static byte[] |
listLevelDefinition
Deprecated.
Current List level
|
private static byte[] |
listLevelNumbers
Deprecated.
Filler for Level Numbers
|
private static byte[] |
listLevelNumbersDefinition
Deprecated.
Level Numbers Definition
|
private static byte[] |
listLevelStartAt
Deprecated.
Level starting number
|
private static byte[] |
listLevelTextDefinition
Deprecated.
Level text group
|
private static byte[] |
listLevelTextLength
Deprecated.
Filler for Level Text Length
|
private static byte[] |
listLevelTextStyleBullet
Deprecated.
Level Text Bullet Style
|
private static byte[] |
listLevelTextStyleNumbers
Deprecated.
Level Text Numbering Style
|
private static byte[] |
listLevelTypeNew
Deprecated.
Level numbering (new)
|
private static byte[] |
listLevelTypeOld
Deprecated.
Level numbering (old)
|
private java.io.ByteArrayOutputStream |
listoverride
Deprecated.
This
ByteArrayOutputStream contains the list override table. |
private static byte[] |
listOverride
Deprecated.
List override
|
private static byte[] |
listOverrideCount
Deprecated.
Number of overrides
|
private static byte[] |
listoverridetableGroup
Deprecated.
Begin the List Override Table
|
private java.io.ByteArrayOutputStream |
listtable
Deprecated.
This
ByteArrayOutputStream contains the list table. |
private static byte[] |
listtableGroup
Deprecated.
Begin the List Table
|
private static byte[] |
listTemplateID
Deprecated.
List Template ID
|
private static byte[] |
listTextOld
Deprecated.
List text group for older browsers
|
private int |
marginBottom
Deprecated.
Bottom margin.
|
private int |
marginLeft
Deprecated.
Left margin.
|
private int |
marginRight
Deprecated.
Right margin.
|
private int |
marginTop
Deprecated.
Top margin.
|
private int |
maxListLevel
Deprecated.
Current maximum List Level.
|
private static byte[] |
metaAuthor
Deprecated.
Author tag.
|
private static byte[] |
metaCreationDate
Deprecated.
Creation Date tag.
|
private static byte[] |
metaKeywords
Deprecated.
Keywords tag.
|
private static byte[] |
metaProducer
Deprecated.
Producer tag.
|
private static byte[] |
metaSubject
Deprecated.
Subject tag.
|
private static byte[] |
metaTitle
Deprecated.
Title tag.
|
private static byte[] |
minute
Deprecated.
Minute tag.
|
private static byte[] |
month
Deprecated.
Month tag.
|
private static byte[] |
newPage
Deprecated.
New Page tag.
|
static byte |
openGroup
Deprecated.
This is the character for beginning a new group.
|
private int |
pageHeight
Deprecated.
Page height.
|
private int |
pageWidth
Deprecated.
Page width.
|
static byte[] |
paragraph
Deprecated.
Begin new paragraph tag.
|
static byte[] |
paragraphDefaults
Deprecated.
Reset paragraph defaults tag.
|
private static byte[] |
picture
Deprecated.
Begin the picture tag
|
private static byte[] |
pictureBMP
Deprecated.
BMP Image
|
private static byte[] |
pictureGroup
Deprecated.
Begin the main Picture group tag
|
private static byte[] |
pictureHeight
Deprecated.
Picture height
|
private static byte[] |
pictureJPEG
Deprecated.
JPEG Image
|
private static byte[] |
picturePNG
Deprecated.
PNG Image
|
private static byte[] |
pictureScaleX
Deprecated.
Picture scale horizontal percent
|
private static byte[] |
pictureScaleY
Deprecated.
Picture scale vertical percent
|
private static byte[] |
pictureWidth
Deprecated.
Picture width
|
private static byte[] |
pictureWMF
Deprecated.
WMF Image
|
private static byte[] |
rightIndent
Deprecated.
Right indent tag.
|
private static byte[] |
rtfMarginBottom
Deprecated.
Margin bottom tag.
|
private static byte[] |
rtfMarginLeft
Deprecated.
Margin left tag.
|
private static byte[] |
rtfMarginRight
Deprecated.
Margin right tag.
|
private static byte[] |
rtfMarginTop
Deprecated.
Margin top tag.
|
private static byte[] |
rtfPaperHeight
Deprecated.
Paper height tag.
|
private static byte[] |
rtfPaperWidth
Deprecated.
Paper width tag.
|
private static byte[] |
second
Deprecated.
Second tag.
|
private static byte[] |
section
Deprecated.
Begin new section tag.
|
private static byte[] |
sectionDefaults
Deprecated.
Reset section defaults tag.
|
static byte[] |
sectionPageHeight
Deprecated.
Page height of a section.
|
static byte[] |
sectionPageWidth
Deprecated.
Page width of a section.
|
private static byte[] |
startSub
Deprecated.
Start subscript.
|
private static byte[] |
startSuper
Deprecated.
Start superscript.
|
protected static byte[] |
strikethrough
Deprecated.
Strikethrough tag.
|
private static byte[] |
tab
Deprecated.
Tab
|
private static byte[] |
tabStop
Deprecated.
Tab Stop
|
private static byte[] |
titlePage
Deprecated.
Title Page tag
|
static double |
TWIPSFACTOR
Deprecated.
Factor to use when converting.
|
protected static byte[] |
underline
Deprecated.
Underline tag.
|
private boolean |
writeTOC
Deprecated.
Write a TOC
|
private static byte[] |
year
Deprecated.
Year tag.
|
Modifier | Constructor and Description |
---|---|
protected |
RtfWriter(Document doc,
java.io.OutputStream os)
Deprecated.
Constructs a
RtfWriter . |
Modifier and Type | Method and Description |
---|---|
boolean |
add(Element element)
Deprecated.
Signals that an
Element was added to the Document . |
protected int |
addColor(java.awt.Color newColor)
Deprecated.
Add a new
Color to the list of colours. |
protected boolean |
addElement(Element element,
java.io.ByteArrayOutputStream out)
Deprecated.
Adds an
Element to the Document . |
protected int |
addFont(Font newFont)
Deprecated.
Add a new
Font to the list of fonts. |
private void |
addHeaderFooterFontColor(HeaderFooter hf)
Deprecated.
|
void |
close()
Deprecated.
Signals that the
Document was closed and that no other
Elements will be added. |
static java.lang.String |
filterSpecialChar(java.lang.String str,
boolean useHex)
Deprecated.
Replaces special characters with their unicode values
|
boolean |
getGeneratingTOCEntries()
Deprecated.
Gets the current setting of writeTOC
|
boolean |
getHasTitlePage()
Deprecated.
Gets the current setting of hasTitlePage
|
static RtfWriter |
getInstance(Document document,
java.io.OutputStream os)
Deprecated.
Gets an instance of the
RtfWriter . |
boolean |
getLandscape()
Deprecated.
Returns the current landscape setting
|
private int |
getRandomInt()
Deprecated.
Get a random integer.
|
private void |
initDefaults()
Deprecated.
Initialise all helper classes.
|
boolean |
newPage()
Deprecated.
Tells the
RtfWriter that a new page is to be begun. |
void |
open()
Deprecated.
Signals that the
Document has been opened and that
Elements can be added. |
private boolean |
parseFormat(Rectangle pageSize,
boolean rotate)
Deprecated.
This method tries to fit the
Rectangle pageSize to one of the predefined PageSize rectangles. |
private void |
processHeaderFooter(HeaderFooter hf)
Deprecated.
|
private boolean |
rectEquals(Rectangle rect1,
Rectangle rect2)
Deprecated.
This method compares to Rectangles.
|
void |
resetFooter()
Deprecated.
Resets the footer.
|
void |
resetHeader()
Deprecated.
Resets the header.
|
void |
setFooter(HeaderFooter footer)
Deprecated.
Adds the footer to the bottom of the
Document . |
void |
setGenerateTOCEntries(boolean writeTOC)
Deprecated.
This method controls whether TOC entries are automatically generated
|
void |
setHasTitlePage(boolean hasTitlePage)
Deprecated.
This method controls whether the first page is a title page
|
void |
setHeader(HeaderFooter header)
Deprecated.
Adds the header to the top of the
Document . |
void |
setLandscape(boolean landscape)
Deprecated.
Explicitly sets the page format to use.
|
boolean |
setMarginMirroring(boolean MarginMirroring)
Deprecated.
Parameter that allows you to do left/right margin mirroring (odd/even pages)
|
boolean |
setMargins(float marginLeft,
float marginRight,
float marginTop,
float marginBottom)
Deprecated.
Sets the page margins
|
boolean |
setPageSize(Rectangle pageSize)
Deprecated.
Sets the page size
|
private void |
writeAnchor(Anchor anchor,
java.io.ByteArrayOutputStream out)
Deprecated.
Write an
Anchor . |
private void |
writeAnnotation(Annotation annotationElement,
java.io.ByteArrayOutputStream out)
Deprecated.
Write an
Annotation |
private void |
writeChunk(Chunk chunk,
java.io.ByteArrayOutputStream out)
Deprecated.
Write a
Chunk and all its font properties. |
private void |
writeColorList()
Deprecated.
Write the colour list to the final
ByteArrayOutputStream |
private boolean |
writeDocument()
Deprecated.
Merge all the different
ArrayList s and ByteArrayOutputStream s
to the final ByteArrayOutputStream |
private void |
writeDocumentFormat()
Deprecated.
Write the
Document 's Paper and Margin Size
to the final ByteArrayOutputStream |
private void |
writeDocumentIntro()
Deprecated.
Write the Rich Text file settings
|
protected void |
writeFinishingFontSignature(java.io.OutputStream out,
Chunk chunk)
Deprecated.
|
private void |
writeFontList()
Deprecated.
Write the font list to the final
ByteArrayOutputStream |
private void |
writeFormatedDateTime(java.lang.String date)
Deprecated.
Writes a date.
|
private void |
writeHeaderFooter(HeaderFooter headerFooter,
byte[] hfType,
java.io.ByteArrayOutputStream target)
Deprecated.
Write a
HeaderFooter to a ByteArrayOutputStream |
void |
writeHeadersFooters(java.io.ByteArrayOutputStream os)
Deprecated.
Write the current header and footer to a
ByteArrayOutputStream |
private void |
writeImage(Image image,
java.io.ByteArrayOutputStream out)
Deprecated.
Write an
Image . |
private void |
writeInfoGroup()
Deprecated.
Write the Information Group to the final
ByteArrayOutputStream |
protected void |
writeInitialFontSignature(java.io.OutputStream out,
Chunk chunk)
Deprecated.
|
static void |
writeInt(java.io.OutputStream out,
int i)
Deprecated.
Write an integer
|
private void |
writeList()
Deprecated.
Write the listtable and listoverridetable to the final
ByteArrayOutputStream |
private void |
writeList(List list,
java.io.ByteArrayOutputStream out)
Deprecated.
Write a
List |
private void |
writeListElement(ListItem listItem,
java.io.ByteArrayOutputStream out)
Deprecated.
Write a
ListItem |
private void |
writeMeta(byte[] metaName,
Meta meta)
Deprecated.
Add a
Meta element. |
private void |
writeParagraph(Paragraph paragraphElement,
java.io.ByteArrayOutputStream out)
Deprecated.
Write the beginning of a new
Paragraph |
private void |
writePhrase(Phrase phrase,
java.io.ByteArrayOutputStream out)
Deprecated.
Write a
Phrase . |
private void |
writeSection(Section sectionElement,
java.io.ByteArrayOutputStream out)
Deprecated.
Write the beginning of a new
Section |
private void |
writeSectionDefaults(java.io.ByteArrayOutputStream out)
Deprecated.
Writes the default values for the current Section
|
private void |
writeTable(Table table,
java.io.ByteArrayOutputStream out)
Deprecated.
Write a
Table . |
boolean |
writeTOC(java.lang.String tocTitle,
Font titleFont,
boolean showTOCasEntry,
Font showTOCEntryFont)
Deprecated.
Write the table of contents.
|
boolean |
writingHeaderFooter()
Deprecated.
Returns whether we are currently writing a header or footer
|
addTabs, flush, getISOBytes, isCloseStream, isPaused, pause, resetPageCount, resume, setCloseStream, setMarginMirroringTopBottom, setPageCount, write, write, writeEnd, writeEnd, writeMarkupAttributes, writeStart
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
resetPageCount, setMarginMirroringTopBottom, setPageCount
public static final byte escape
private static final byte[] extendedEscape
protected static final byte delimiter
private static final byte commaDelimiter
public static final byte openGroup
public static final byte closeGroup
private static final byte[] docBegin
private static final byte[] ansi
private static final byte[] ansiCodepage
private static final byte[] fontTable
protected static final byte fontNumber
protected static final byte[] fontSize
protected static final byte[] fontColor
private static final byte[] fontModern
private static final byte[] fontSwiss
private static final byte[] fontRoman
private static final byte[] fontTech
private static final byte[] fontCharset
private static final byte[] fontCourier
private static final byte[] fontArial
private static final byte[] fontSymbol
private static final byte[] fontTimesNewRoman
private static final byte[] fontWindings
private static final byte[] defaultFont
private static final byte[] firstIndent
private static final byte[] listIndent
private static final byte[] rightIndent
private static final byte[] sectionDefaults
private static final byte[] section
public static final byte[] paragraphDefaults
public static final byte[] paragraph
public static final byte[] sectionPageWidth
public static final byte[] sectionPageHeight
private static final byte[] listtableGroup
private static final byte[] listoverridetableGroup
private static final byte[] listDefinition
private static final byte[] listTemplateID
private static final byte[] hybridList
private static final byte[] listLevelDefinition
private static final byte[] listLevelTypeOld
private static final byte[] listLevelTypeNew
private static final byte[] listLevelAlignOld
private static final byte[] listLevelAlignNew
private static final byte[] listLevelStartAt
private static final byte[] listLevelTextDefinition
private static final byte[] listLevelTextLength
private static final byte[] listLevelTextStyleNumbers
private static final byte[] listLevelTextStyleBullet
private static final byte[] listLevelNumbersDefinition
private static final byte[] listLevelNumbers
private static final byte[] tabStop
private static final byte[] listBegin
private static final byte[] listCurrentLevel
private static final byte[] listTextOld
private static final byte[] tab
private static final byte[] listBulletOld
private static final byte[] listID
private static final byte[] listOverride
private static final byte[] listOverrideCount
protected static final byte bold
protected static final byte italic
protected static final byte[] underline
protected static final byte[] strikethrough
public static final byte[] alignLeft
public static final byte[] alignCenter
public static final byte[] alignRight
public static final byte[] alignJustify
private static final byte[] colorTable
private static final byte[] colorRed
private static final byte[] colorGreen
private static final byte[] colorBlue
private static final byte[] infoBegin
private static final byte[] metaAuthor
private static final byte[] metaSubject
private static final byte[] metaKeywords
private static final byte[] metaTitle
private static final byte[] metaProducer
private static final byte[] metaCreationDate
private static final byte[] year
private static final byte[] month
private static final byte[] day
private static final byte[] hour
private static final byte[] minute
private static final byte[] second
private static final byte[] startSuper
private static final byte[] startSub
private static final byte[] endSuperSub
private static final byte[] titlePage
private static final byte[] facingPages
private static final byte[] headerBegin
private static final byte[] footerBegin
private static final byte[] headerlBegin
private static final byte[] footerlBegin
private static final byte[] headerrBegin
private static final byte[] footerrBegin
private static final byte[] headerfBegin
private static final byte[] footerfBegin
private static final byte[] rtfPaperWidth
private static final byte[] rtfPaperHeight
private static final byte[] rtfMarginLeft
private static final byte[] rtfMarginRight
private static final byte[] rtfMarginTop
private static final byte[] rtfMarginBottom
private static final byte[] newPage
private static final byte[] landscapeTag1
private static final byte[] landscapeTag2
private static final byte[] annotationID
private static final byte[] annotationAuthor
private static final byte[] annotation
private static final byte[] pictureGroup
private static final byte[] picture
private static final byte[] picturePNG
private static final byte[] pictureJPEG
private static final byte[] pictureBMP
private static final byte[] pictureWMF
private static final byte[] pictureWidth
private static final byte[] pictureHeight
private static final byte[] pictureScaleX
private static final byte[] pictureScaleY
protected static final byte[] field
protected static final byte[] fieldContent
protected static final byte[] fieldPage
protected static final byte[] fieldHyperlink
protected static final byte[] fieldDisplay
private java.util.ArrayList fontList
ArrayList
contains all fonts used in the document.private java.util.ArrayList colorList
ArrayList
contains all colours used in the document.private java.io.ByteArrayOutputStream content
ByteArrayOutputStream
contains the main body of the document.private java.io.ByteArrayOutputStream info
ByteArrayOutputStream
contains the information group.private java.io.ByteArrayOutputStream listtable
ByteArrayOutputStream
contains the list table.private java.io.ByteArrayOutputStream listoverride
ByteArrayOutputStream
contains the list override table.private HeaderFooter header
private HeaderFooter footer
private int marginLeft
private int marginRight
private int marginTop
private int marginBottom
private int pageWidth
private int pageHeight
public static final double TWIPSFACTOR
private int currentListID
private java.util.ArrayList listIds
private int listLevel
private int maxListLevel
private boolean writeTOC
private boolean hasTitlePage
private boolean inHeaderFooter
private boolean inTable
private boolean landscape
protected RtfWriter(Document doc, java.io.OutputStream os)
RtfWriter
.doc
- The Document
that is to be written as RTFos
- The OutputStream
the writer has to write to.public void setGenerateTOCEntries(boolean writeTOC)
writeTOC
- boolean value indicating whether a TOC is to be generatedpublic boolean getGeneratingTOCEntries()
public void setHasTitlePage(boolean hasTitlePage)
hasTitlePage
- boolean value indicating whether the first page is a title pagepublic boolean getHasTitlePage()
public void setLandscape(boolean landscape)
landscape
- boolean value indicating whether we are using landscape format or notpublic boolean getLandscape()
public static RtfWriter getInstance(Document document, java.io.OutputStream os)
RtfWriter
.document
- The Document
that has to be writtenos
- The OutputStream
the writer has to write to.RtfWriter
public void open()
Document
has been opened and that
Elements
can be added.open
in interface DocListener
open
in class DocWriter
public void close()
Document
was closed and that no other
Elements
will be added.
The content of the font table, color table, information group, content, header, footer are merged into the final
OutputStream
close
in interface DocListener
close
in class DocWriter
public void setFooter(HeaderFooter footer)
Document
.setFooter
in interface DocListener
setFooter
in class DocWriter
footer
- public void setHeader(HeaderFooter header)
Document
.setHeader
in interface DocListener
setHeader
in class DocWriter
header
- public void resetFooter()
resetFooter
in interface DocListener
resetFooter
in class DocWriter
public void resetHeader()
resetHeader
in interface DocListener
resetHeader
in class DocWriter
public boolean newPage()
RtfWriter
that a new page is to be begun.newPage
in interface DocListener
newPage
in class DocWriter
true
if a new Page was begun.public boolean setMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)
setMargins
in interface DocListener
setMargins
in class DocWriter
marginLeft
- The left marginmarginRight
- The right marginmarginTop
- The top marginmarginBottom
- The bottom margintrue
if the page margins were set.public boolean setPageSize(Rectangle pageSize)
setPageSize
in interface DocListener
setPageSize
in class DocWriter
pageSize
- A Rectangle
specifying the page sizetrue
if the page size was setpublic boolean writeTOC(java.lang.String tocTitle, Font titleFont, boolean showTOCasEntry, Font showTOCEntryFont)
tocTitle
- The title that will be displayed above the TOCtitleFont
- The Font
that will be used for the tocTitleshowTOCasEntry
- Set this to true if you want the TOC to appear as an entry in the TOCshowTOCEntryFont
- Use this Font
to specify what Font to use when showTOCasEntry is truetrue
if the TOC was added.public boolean add(Element element) throws DocumentException
Element
was added to the Document
.add
in interface ElementListener
add
in class DocWriter
element
- A high level object to addtrue
if the element was added, false
if not.DocumentException
- if a document isn't open yet, or has been closedprotected boolean addElement(Element element, java.io.ByteArrayOutputStream out) throws DocumentException
Element
to the Document
.element
- the high level element to addout
- the outputstream to which the RTF data is senttrue
if the element was added, false
if not.DocumentException
- if a document isn't open yet, or has been closedprivate void writeSection(Section sectionElement, java.io.ByteArrayOutputStream out) throws java.io.IOException, DocumentException
Section
sectionElement
- The Section
be writtenout
- The ByteArrayOutputStream
to write tojava.io.IOException
DocumentException
private void writeParagraph(Paragraph paragraphElement, java.io.ByteArrayOutputStream out) throws java.io.IOException
Paragraph
paragraphElement
- The Paragraph
to be writtenout
- The ByteArrayOutputStream
to write tojava.io.IOException
private void writePhrase(Phrase phrase, java.io.ByteArrayOutputStream out) throws java.io.IOException
Phrase
.phrase
- The Phrase
item to be writtenout
- The ByteArrayOutputStream
to write tojava.io.IOException
private void writeAnchor(Anchor anchor, java.io.ByteArrayOutputStream out) throws java.io.IOException
Anchor
. Anchors are treated like Phrases.anchor
- The Chunk
item to be writtenout
- The ByteArrayOutputStream
to write tojava.io.IOException
private void writeChunk(Chunk chunk, java.io.ByteArrayOutputStream out) throws java.io.IOException, DocumentException
Chunk
and all its font properties.chunk
- The Chunk
item to be writtenout
- The ByteArrayOutputStream
to write tojava.io.IOException
DocumentException
protected void writeInitialFontSignature(java.io.OutputStream out, Chunk chunk) throws java.io.IOException
java.io.IOException
protected void writeFinishingFontSignature(java.io.OutputStream out, Chunk chunk) throws java.io.IOException
java.io.IOException
private void writeListElement(ListItem listItem, java.io.ByteArrayOutputStream out) throws java.io.IOException, DocumentException
ListItem
listItem
- The ListItem
to be writtenout
- The ByteArrayOutputStream
to write tojava.io.IOException
DocumentException
private void writeList(List list, java.io.ByteArrayOutputStream out) throws java.io.IOException, DocumentException
List
list
- The List
to be writtenout
- The ByteArrayOutputStream
to write tojava.io.IOException
DocumentException
private void writeTable(Table table, java.io.ByteArrayOutputStream out) throws java.io.IOException, DocumentException
Table
.table
- The table
to be writtenout
- The ByteArrayOutputStream
to write to
Currently no nesting of tables is supported. If a cell contains anything but a Cell Object it is ignored.java.io.IOException
DocumentException
private void writeImage(Image image, java.io.ByteArrayOutputStream out) throws java.io.IOException, DocumentException
Image
.image
- The image
to be writtenout
- The ByteArrayOutputStream
to write to
At the moment only PNG and JPEG Images are supported.java.io.IOException
DocumentException
private void writeAnnotation(Annotation annotationElement, java.io.ByteArrayOutputStream out) throws java.io.IOException
Annotation
annotationElement
- The Annotation
to be writtenout
- The ByteArrayOutputStream
to write tojava.io.IOException
private void writeMeta(byte[] metaName, Meta meta) throws java.io.IOException
Meta
element. It is written to the Inforamtion Group
and merged with the main ByteArrayOutputStream
when the
Document is closed.metaName
- The type of Meta
element to be addedmeta
- The Meta
element to be added
Currently only the Meta Elements Author, Subject, Keywords, Title, Producer and CreationDate are supported.java.io.IOException
private void writeFormatedDateTime(java.lang.String date) throws java.io.IOException
date
- The date to be writtenjava.io.IOException
protected int addFont(Font newFont)
Font
to the list of fonts. If the Font
already exists in the list of fonts, then it is not added again.newFont
- The Font
to be addedFont
in the font listprotected int addColor(java.awt.Color newColor)
Color
to the list of colours. If the Color
already exists in the list of colours, then it is not added again.newColor
- The Color
to be addedcolor
in the colour listprivate boolean writeDocument()
ArrayList
s and ByteArrayOutputStream
s
to the final ByteArrayOutputStream
true
if all information was sucessfully written to the ByteArrayOutputStream
private void writeDocumentIntro() throws java.io.IOException
java.io.IOException
private void writeFontList() throws java.io.IOException
ByteArrayOutputStream
java.io.IOException
private void writeColorList() throws java.io.IOException
ByteArrayOutputStream
java.io.IOException
private void writeInfoGroup() throws java.io.IOException
ByteArrayOutputStream
java.io.IOException
private void writeList() throws java.io.IOException
ByteArrayOutputStream
java.io.IOException
public static final void writeInt(java.io.OutputStream out, int i) throws java.io.IOException
out
- The OuputStream
to which the int
value is to be writteni
- The int
value to be writtenjava.io.IOException
private int getRandomInt()
int
value.public void writeHeadersFooters(java.io.ByteArrayOutputStream os) throws java.io.IOException
ByteArrayOutputStream
os
- The ByteArrayOutputStream
to which the header and footer will be written.java.io.IOException
private void writeHeaderFooter(HeaderFooter headerFooter, byte[] hfType, java.io.ByteArrayOutputStream target) throws java.io.IOException
HeaderFooter
to a ByteArrayOutputStream
headerFooter
- The HeaderFooter
object to be written.hfType
- The type of header or footer to be added.target
- The ByteArrayOutputStream
to which the HeaderFooter
will be written.java.io.IOException
private void writeDocumentFormat() throws java.io.IOException
Document
's Paper and Margin Size
to the final ByteArrayOutputStream
java.io.IOException
private void initDefaults()
ByteArrayOutputStream
'sprivate void writeSectionDefaults(java.io.ByteArrayOutputStream out) throws java.io.IOException
out
- The ByteArrayOutputStream
to be written tojava.io.IOException
private boolean parseFormat(Rectangle pageSize, boolean rotate)
Rectangle pageSize
to one of the predefined PageSize rectangles.
If a match is found the pageWidth and pageHeight will be set according to values determined from files
generated by MS Word2000 and OpenOffice 641. If no match is found the method will try to match the rotated
Rectangle by calling itself with the parameter rotate set to true.pageSize
- a rectangle defining the size of the pagerotate
- portrait or lanscape?private boolean rectEquals(Rectangle rect1, Rectangle rect2)
rect1
- rect2
- public boolean writingHeaderFooter()
public static final java.lang.String filterSpecialChar(java.lang.String str, boolean useHex)
str
- The original String
useHex
- private void addHeaderFooterFontColor(HeaderFooter hf)
private void processHeaderFooter(HeaderFooter hf)
public boolean setMarginMirroring(boolean MarginMirroring)
DocListener
setMarginMirroring
in interface DocListener
setMarginMirroring
in class DocWriter
DocListener.setMarginMirroring(boolean)