Class RtfDocument
java.lang.Object
com.lowagie.text.rtf.RtfElement
com.lowagie.text.rtf.document.RtfDocument
- All Implemented Interfaces:
RtfBasicElement
The RtfDocument stores all document related data and also the main data stream.
INTERNAL CLASS - NOT TO BE USED DIRECTLY
- Since:
- 1.x
- Version:
- $Id: RtfDocument.java 4065 2009-09-16 23:09:11Z psoares33 $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanWhether to automatically generate TOC entries for Chapters and Sections.private RtfDataCacheStores the actual document dataprivate final RtfDocumentHeaderThe RtfDocumentHeader that handles all document header methodsprivate final RtfDocumentSettingsThe RtfDocumentSettings for this RtfDocument.private static final byte[]private static final byte[]private static final byte[]private static final byte[]private static final byte[]private static final byte[]private static final byte[]private static final byte[]private RtfBasicElementThe last RtfBasicElement that was added directly to the RtfDocument.private final RtfMapperThe RtfMapper to use in this RtfDocumentStores integers that have been generated as unique random numbersprivate static final byte[]Constant for the Rtf document startFields inherited from class RtfElement
document, inHeader, inTableFields inherited from interface RtfBasicElement
CLOSE_GROUP, COMMA_DELIMITER, DELIMITER, OPEN_GROUP, TWIPS_FACTOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(RtfBasicElement element) Adds an element to the rtf documentvoidfilterSpecialChar(OutputStream out, String str, boolean useHex, boolean softLineBreaks) Writes the given string to the givenOutputStreamencoding the string characters.booleanGet whether to automatically generate table of contents entriesGets the RtfDocumentHeader of this RtfDocumentGets the RtfDocumentSettings that specify how the rtf document is generated.Gets the last RtfBasicElement that was directly added to the RtfDocument.Gets the RtfMapper object of this RtfDocumentintGenerates a random integer that is unique with respect to the document.voidopen()Opens the RtfDocument and initializes the data cache.final voidoutputDebugLinebreak(OutputStream result) Helper method outputs linebreak in document if debugging is turned on.voidsetAutogenerateTOCEntries(boolean autogenerate) Whether to automagically generate table of contents entries when adding Chapters or Sections.private static booleanReturnstrueif m.length characters in str, starting at offset soff match the bytes in the given array m.voidwriteContent(OutputStream out) unusedvoidWrites the documentMethods inherited from class RtfElement
intToByteArray, isInTable, setInHeader, setInTable, setRtfDocument
-
Field Details
-
data
Stores the actual document data -
mapper
The RtfMapper to use in this RtfDocument -
documentHeader
The RtfDocumentHeader that handles all document header methods -
previousRandomInts
-
autogenerateTOCEntries
private boolean autogenerateTOCEntriesWhether to automatically generate TOC entries for Chapters and Sections. Defaults to false -
documentSettings
The RtfDocumentSettings for this RtfDocument. -
lastElementWritten
The last RtfBasicElement that was added directly to the RtfDocument. -
RTF_DOCUMENT
private static final byte[] RTF_DOCUMENTConstant for the Rtf document start -
FSC_LINE
private static final byte[] FSC_LINE -
FSC_PAR
private static final byte[] FSC_PAR -
FSC_TAB
private static final byte[] FSC_TAB -
FSC_PAGE_PAR
private static final byte[] FSC_PAGE_PAR -
FSC_NEWPAGE
private static final byte[] FSC_NEWPAGE -
FSC_BACKSLASH
private static final byte[] FSC_BACKSLASH -
FSC_HEX_PREFIX
private static final byte[] FSC_HEX_PREFIX -
FSC_UNI_PREFIX
private static final byte[] FSC_UNI_PREFIX
-
-
Constructor Details
-
RtfDocument
public RtfDocument()The default constructor for a RtfDocument
-
-
Method Details
-
writeContent
unused- Specified by:
writeContentin interfaceRtfBasicElement- Specified by:
writeContentin classRtfElement- Parameters:
out- TheOutputStreamto write the content to- Throws:
IOException
-
writeDocument
Writes the document- Parameters:
out- TheOutputStreamto write the RTF document to.
-
open
public void open()Opens the RtfDocument and initializes the data cache. If the data cache is set to CACHE_DISK, but the cache cannot be initialized then the memory cache is used. -
add
Adds an element to the rtf document- Parameters:
element- The element to add
-
getMapper
-
getRandomInt
public int getRandomInt()Generates a random integer that is unique with respect to the document. Will not return a number between -1 and -5 because some values in that range are invalid.- Returns:
- A random int
-
getDocumentHeader
Gets the RtfDocumentHeader of this RtfDocument- Returns:
- The RtfDocumentHeader of this RtfDocument
-
filterSpecialChar
public void filterSpecialChar(OutputStream out, String str, boolean useHex, boolean softLineBreaks) throws IOException Writes the given string to the givenOutputStreamencoding the string characters.- Parameters:
out- destination OutputStreamstr- string to writeuseHex- iftruehex encoding characters is preferred to unicode encoding if possiblesoftLineBreaks- iftruereturn characters are written as soft line breaks- Throws:
IOException
-
subMatch
Returnstrueif m.length characters in str, starting at offset soff match the bytes in the given array m.- Parameters:
str- the string to search for a matchsoff- the starting offset in strm- the array to match- Returns:
trueif there is match
-
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
-
getAutogenerateTOCEntries
public boolean getAutogenerateTOCEntries()Get whether to automatically generate table of contents entries- Returns:
- Whether to automatically generate TOC entries
-
getDocumentSettings
Gets the RtfDocumentSettings that specify how the rtf document is generated.- Returns:
- The current RtfDocumentSettings.
-
getLastElementWritten
Gets the last RtfBasicElement that was directly added to the RtfDocument.- Returns:
- The last RtfBasicElement that was directly added to the RtfDocument.
-
outputDebugLinebreak
Helper method outputs linebreak in document if debugging is turned on.- Parameters:
result- the OutputStream to write the linebreak to.- Throws:
IOException- Since:
- 2.1.3
-