com.lowagie.text.rtf

Class RtfWriter2

public class RtfWriter2 extends DocWriter

The RtfWriter allows the creation of rtf documents via the iText system Version: $Id: RtfWriter2.java 2623 2007-02-23 22:28:28Z xlv $

Author: Mark Hall (mhall@edu.uni-klu.ac.at)

Field Summary
RtfDocumentrtfDoc
The RtfDocument this RtfWriter is creating
Constructor Summary
protected RtfWriter2(Document doc, OutputStream os)
Constructs a new RtfWriter that listens to the specified Document and writes its output to the OutputStream.
Method Summary
booleanadd(Element element)
Adds an Element to the Document
voidclearTextWrap()
This method is not supported in the RtfWriter
voidclose()
Closes the RtfDocument.
RtfDocumentSettingsgetDocumentSettings()
Gets the RtfDocumentSettings that specify how the rtf document is generated.
static RtfWriter2getInstance(Document doc, OutputStream os)
Static method to generate RtfWriters
voidimportRtfDocument(Reader documentSource)
Adds the complete RTF document to the current RTF document being generated.
voidimportRtfFragment(Reader documentSource, RtfImportMappings mappings)
Adds a fragment of an RTF document to the current RTF document being generated.
booleannewPage()
Adds a page break
voidopen()
Opens the RtfDocument
voidresetFooter()
Resets the footer
voidresetHeader()
Resets the header
voidresetPageCount()
This method is not supported in the RtfWriter
voidsetAutogenerateTOCEntries(boolean autogenerate)
Whether to automagically generate table of contents entries when adding Chapters or Sections.
voidsetDataCacheStyle(int dataCacheStyle)
Sets the rtf data cache style to use.
voidsetFooter(HeaderFooter hf)
Sets the footer to use
voidsetHeader(HeaderFooter hf)
Sets the header to use
booleansetMargins(float left, float right, float top, float bottom)
Sets the page margins
voidsetPageCount(int i)
This method is not supported in the RtfWriter
booleansetPageSize(Rectangle rect)
Sets the size of the page

Field Detail

rtfDoc

private RtfDocument rtfDoc
The RtfDocument this RtfWriter is creating

Constructor Detail

RtfWriter2

protected RtfWriter2(Document doc, OutputStream os)
Constructs a new RtfWriter that listens to the specified Document and writes its output to the OutputStream.

Parameters: doc The Document that this RtfWriter listens to os The OutputStream to write to

Method Detail

add

public boolean add(Element element)
Adds an Element to the Document

Parameters: element The element to be added

Returns: false

Throws: DocumentException

clearTextWrap

public void clearTextWrap()
This method is not supported in the RtfWriter

close

public void close()
Closes the RtfDocument. This causes the document to be written to the specified OutputStream

getDocumentSettings

public RtfDocumentSettings getDocumentSettings()
Gets the RtfDocumentSettings that specify how the rtf document is generated.

Returns: The current RtfDocumentSettings.

getInstance

public static RtfWriter2 getInstance(Document doc, OutputStream os)
Static method to generate RtfWriters

Parameters: doc The Document that this RtfWriter listens to os The OutputStream to write to

Returns: The new RtfWriter

importRtfDocument

public void importRtfDocument(Reader documentSource)
Adds the complete RTF document to the current RTF document being generated. It will parse the font and color tables and correct the font and color references so that the imported RTF document retains its formattings.

Parameters: documentSource The Reader to read the RTF document from.

Throws: IOException On errors reading the RTF document. DocumentException On errors adding to this RTF document.

importRtfFragment

public void importRtfFragment(Reader documentSource, RtfImportMappings mappings)
Adds a fragment of an RTF document to the current RTF document being generated. Since this fragment doesn't contain font or color tables, all fonts and colors are mapped to the default font and color. If the font and color mappings are known, they can be specified via the mappings parameter.

Parameters: documentSource The Reader to read the RTF fragment from. mappings The RtfImportMappings that contain font and color mappings to apply to the fragment.

Throws: IOException On errors reading the RTF fragment. DocumentException On errors adding to this RTF fragment.

newPage

public boolean newPage()
Adds a page break

Returns: false

open

public void open()
Opens the RtfDocument

Throws: IOException

resetFooter

public void resetFooter()
Resets the footer

resetHeader

public void resetHeader()
Resets the header

resetPageCount

public void resetPageCount()
This method is not supported in the RtfWriter

setAutogenerateTOCEntries

public void setAutogenerateTOCEntries(boolean autogenerate)
Whether to automagically generate table of contents entries when adding Chapters or Sections.

Parameters: autogenerate Whether to automatically generate TOC entries

setDataCacheStyle

public void setDataCacheStyle(int dataCacheStyle)

Deprecated: Use RtfWriter2.getDocumentSettings().setDataCacheStyle(...);

Sets the rtf data cache style to use. Valid values are given in the RtfDataCache class.

Parameters: dataCacheStyle The style to use.

Throws: DocumentException If data has already been written into the data cache. IOException If the disk cache could not be initialised.

setFooter

public void setFooter(HeaderFooter hf)
Sets the footer to use

Parameters: hf The HeaderFooter to use

setHeader

public void setHeader(HeaderFooter hf)
Sets the header to use

Parameters: hf The HeaderFooter to use

setMargins

public boolean setMargins(float left, float right, float top, float bottom)
Sets the page margins

Parameters: left The left margin right The right margin top The top margin bottom The bottom margin

Returns: false

setPageCount

public void setPageCount(int i)
This method is not supported in the RtfWriter

Parameters: i Unused

setPageSize

public boolean setPageSize(Rectangle rect)
Sets the size of the page

Parameters: rect A Rectangle representing the page

Returns: false