|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lowagie.text.DocWriter
com.lowagie.text.rtf.RtfWriter
public class RtfWriter
If you are creating a new project using the rtf part of iText, please
consider using the new RtfWriter2. The RtfWriter is in bug-fix-only mode,
will be deprecated end of 2005 and removed end of 2007.
A 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:
Field Summary | |
---|---|
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. |
protected static byte |
bold
Deprecated. Bold tag. |
static byte |
closeGroup
Deprecated. This is the character for closing a group. |
protected static byte |
delimiter
Deprecated. This is the delimiter between RTF tags and normal text. |
static byte |
escape
Deprecated. This is the escape character which introduces RTF tags. |
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 |
protected static byte[] |
fontColor
Deprecated. Font color tag. |
protected static byte |
fontNumber
Deprecated. Font number tag. |
protected static byte[] |
fontSize
Deprecated. Font size tag. |
protected static byte |
italic
Deprecated. Italic tag. |
static byte |
openGroup
Deprecated. This is the character for beginning a new group. |
static byte[] |
paragraph
Deprecated. Begin new paragraph tag. |
static byte[] |
paragraphDefaults
Deprecated. Reset paragraph defaults tag. |
static byte[] |
sectionPageHeight
Deprecated. Page height of a section. |
static byte[] |
sectionPageWidth
Deprecated. Page width of a section. |
protected static byte[] |
strikethrough
Deprecated. Strikethrough tag. |
static double |
TWIPSFACTOR
Deprecated. Factor to use when converting. |
protected static byte[] |
underline
Deprecated. Underline tag. |
Fields inherited from class com.lowagie.text.DocWriter |
---|
closeStream, document, EQUALS, FORWARD, GT, LT, NEWLINE, open, os, pageSize, pause, QUOTE, SPACE, TAB |
Constructor Summary | |
---|---|
protected |
RtfWriter(Document doc,
OutputStream os)
Deprecated. Constructs a RtfWriter . |
Method Summary | |
---|---|
boolean |
add(Element element)
Deprecated. Signals that an Element was added to the Document . |
protected int |
addColor(Color newColor)
Deprecated. Add a new Color to the list of colours. |
protected boolean |
addElement(Element element,
ByteArrayOutputStream out)
Deprecated. Adds an Element to the Document . |
protected int |
addFont(Font newFont)
Deprecated. Add a new Font to the list of fonts. |
void |
close()
Deprecated. Signals that the Document was closed and that no other
Elements will be added. |
static String |
filterSpecialChar(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,
OutputStream os)
Deprecated. Gets an instance of the RtfWriter . |
boolean |
getLandscape()
Deprecated. Returns the current landscape setting |
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. |
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 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 |
protected void |
writeFinishingFontSignature(OutputStream out,
Chunk chunk)
Deprecated. |
void |
writeHeadersFooters(ByteArrayOutputStream os)
Deprecated. Write the current header and footer to a ByteArrayOutputStream |
protected void |
writeInitialFontSignature(OutputStream out,
Chunk chunk)
Deprecated. |
static void |
writeInt(OutputStream out,
int i)
Deprecated. Write an integer |
boolean |
writeTOC(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 |
Methods inherited from class com.lowagie.text.DocWriter |
---|
add, addTabs, clearTextWrap, flush, getISOBytes, hasMarkupAttributes, isCloseStream, pause, removeWatermark, resetPageCount, resume, setCloseStream, setPageCount, write, write, writeEnd, writeEnd, writeMarkupAttributes, writeStart |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.lowagie.text.DocListener |
---|
add, clearTextWrap, removeWatermark, resetPageCount, setPageCount |
Field Detail |
---|
public static final byte escape
protected static final byte delimiter
public static final byte openGroup
public static final byte closeGroup
protected static final byte fontNumber
protected static final byte[] fontSize
protected static final byte[] fontColor
public static final byte[] paragraphDefaults
public static final byte[] paragraph
public static final byte[] sectionPageWidth
public static final byte[] sectionPageHeight
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
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
public static final double TWIPSFACTOR
Constructor Detail |
---|
protected RtfWriter(Document doc, OutputStream os)
RtfWriter
.
doc
- The Document
that is to be written as RTFos
- The OutputStream
the writer has to write to.Method Detail |
---|
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, 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() throws DocumentException
RtfWriter
that a new page is to be begun.
newPage
in interface DocListener
newPage
in class DocWriter
true
if a new Page was begun.
DocumentException
- if the Document was not open or had been closed.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 margin
true
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 size
true
if the page size was setpublic boolean writeTOC(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 true
true
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 add
true
if the element was added, false
if not.
DocumentException
- if a document isn't open yet, or has been closedprotected boolean addElement(Element element, ByteArrayOutputStream out) throws DocumentException
Element
to the Document
.
element
- the high level element to addout
- the outputstream to which the RTF data is sent
true
if the element was added, false
if not.
DocumentException
- if a document isn't open yet, or has been closedprotected void writeInitialFontSignature(OutputStream out, Chunk chunk) throws IOException
IOException
protected void writeFinishingFontSignature(OutputStream out, Chunk chunk) throws IOException
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 added
Font
in the font listprotected int addColor(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 added
color
in the colour listpublic static final void writeInt(OutputStream out, int i) throws IOException
out
- The OuputStream
to which the int
value is to be writteni
- The int
value to be written
IOException
public void writeHeadersFooters(ByteArrayOutputStream os) throws IOException
ByteArrayOutputStream
os
- The ByteArrayOutputStream
to which the header and footer will be written.
IOException
public boolean writingHeaderFooter()
public static final String filterSpecialChar(String str, boolean useHex)
str
- The original String
useHex
-
public boolean setMarginMirroring(boolean MarginMirroring)
DocListener
setMarginMirroring
in interface DocListener
setMarginMirroring
in class DocWriter
DocListener.setMarginMirroring(boolean)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |