|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.lowagie.text.DocWriter
An abstract Writer class for documents.
DocWriter is the abstract class of several writers such
as PdfWriter and HtmlWriter.
A DocWriter can be added as a DocListener
to a certain Document by getting an instance (see method
getInstance() in the specific writer-classes).
Every Element added to the original Document
will be written to the OutputStream of the listening
DocWriter.
Document,
DocListener| Field Summary | |
protected boolean |
closeStream
Closes the stream on document close |
protected Document |
document
This is the document that has to be written. |
static byte |
EQUALS
This is some byte that is often used. |
static byte |
FORWARD
This is some byte that is often used. |
static byte |
GT
This is some byte that is often used. |
static byte |
LT
This is some byte that is often used. |
static byte |
NEWLINE
This is some byte that is often used. |
protected boolean |
open
Is the writer open for writing? |
protected OutputStreamCounter |
os
The outputstream of this writer. |
protected Rectangle |
pageSize
The pageSize. |
protected boolean |
pause
Do we have to pause all writing actions? |
static byte |
QUOTE
This is some byte that is often used. |
static byte |
SPACE
This is some byte that is often used. |
static byte |
TAB
This is some byte that is often used. |
| Constructor Summary | |
protected |
DocWriter()
|
protected |
DocWriter(Document document,
OutputStream os)
Constructs a DocWriter. |
| Method Summary | |
boolean |
add(Element element)
Signals that an Element was added to the Document.
|
boolean |
add(Watermark watermark)
Sets the Watermark.
|
protected void |
addTabs(int indent)
Writes a number of tabs. |
void |
clearTextWrap()
Clears text wrapping around images (if applicable). |
void |
close()
Signals that the Document was closed and that no other
Elements will be added. |
void |
flush()
Flushes the BufferedOutputStream. |
static byte[] |
getISOBytes(String text)
Converts a String into a Byte array
according to the ISO-8859-1 codepage. |
protected static boolean |
hasMarkupAttributes(Element element)
Returns true if the specified Element implements
MarkupAttributes and has one or more attributes to write. |
boolean |
isCloseStream()
Checks if the stream is to be closed on document close |
boolean |
newPage()
Signals that an new page has to be started. |
void |
open()
Signals that the Document was opened. |
void |
pause()
Let the writer know that all writing has to be paused. |
void |
removeWatermark()
Removes the Watermark (if there is one). |
void |
resetFooter()
Resets the footer of this document. |
void |
resetHeader()
Resets the header of this document. |
void |
resetPageCount()
Sets the page number to 0. |
void |
resume()
Let the writer know that writing may be resumed. |
void |
setCloseStream(boolean closeStream)
Sets the close state of the stream after document close |
void |
setFooter(HeaderFooter footer)
Changes the footer of this document. |
void |
setHeader(HeaderFooter header)
Changes the header of this document. |
boolean |
setMargins(float marginLeft,
float marginRight,
float marginTop,
float marginBottom)
Sets the margins. |
void |
setPageCount(int pageN)
Sets the page number. |
boolean |
setPageSize(Rectangle pageSize)
Sets the pagesize. |
protected void |
write(String string)
Writes a String to the OutputStream. |
protected void |
write(String key,
String value)
Writes a key-value pair to the outputstream. |
protected void |
writeEnd()
Writes an endtag to the outputstream. |
protected void |
writeEnd(String tag)
Writes an endtag to the outputstream. |
protected boolean |
writeMarkupAttributes(MarkupAttributes mAtt)
Writes the markup attributes of the specified MarkupAttributes
object to the OutputStream. |
protected void |
writeStart(String tag)
Writes a starttag to the outputstream. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final byte NEWLINE
public static final byte TAB
public static final byte LT
public static final byte SPACE
public static final byte EQUALS
public static final byte QUOTE
public static final byte GT
public static final byte FORWARD
protected Rectangle pageSize
protected Document document
protected OutputStreamCounter os
protected boolean open
protected boolean pause
protected boolean closeStream
| Constructor Detail |
protected DocWriter()
protected DocWriter(Document document,
OutputStream os)
DocWriter.
document - The Document that has to be writtenos - The OutputStream the writer has to write to.| Method Detail |
public boolean add(Element element)
throws DocumentException
Element was added to the Document.
This method should be overriden in the specific
DocWriter classes
derived from this abstract class.
add in interface ElementListener
false
DocumentException - when a document isn't open yet, or has been closed
public void open()
Document was opened.
open in interface DocListenerpublic boolean setPageSize(Rectangle pageSize)
setPageSize in interface DocListenerpageSize - the new pagesize
booleanpublic boolean add(Watermark watermark)
Watermark.
This method should be overriden in the specific
DocWriter classes
derived from this abstract class if they actually support the use of
a Watermark.
add in interface DocListener
false (because watermarks aren't supported by default).
public void removeWatermark()
Watermark (if there is one).
removeWatermark in interface DocListener
public boolean setMargins(float marginLeft,
float marginRight,
float marginTop,
float marginBottom)
This does nothing. Has to be overridden if needed.
setMargins in interface DocListenermarginLeft - the margin on the leftmarginRight - the margin on the rightmarginTop - the margin on the topmarginBottom - the margin on the bottom
false
public boolean newPage()
throws DocumentException
This does nothing. Has to be overridden if needed.
newPage in interface DocListenertrue if the page was added, false if not.
DocumentException - when a document isn't open yet, or has been closedpublic void setHeader(HeaderFooter header)
This method should be overriden in the specific
DocWriter classes
derived from this abstract class if they actually support the use of
headers.
setHeader in interface DocListener
header - the new header
public void resetHeader()
This method should be overriden in the specific
DocWriter classes
derived from this abstract class if they actually support the use of
headers.
resetHeader in interface DocListener
public void setFooter(HeaderFooter footer)
This method should be overriden in the specific
DocWriter classes
derived from this abstract class if they actually support the use of
footers.
setFooter in interface DocListener
footer - the new footer
public void resetFooter()
This method should be overriden in the specific
DocWriter classes
derived from this abstract class if they actually support the use of
footers.
resetFooter in interface DocListener
public void resetPageCount()
This method should be overriden in the specific
DocWriter classes
derived from this abstract class if they actually support the use of
pagenumbers.
resetPageCount in interface DocListener
public void setPageCount(int pageN)
This method should be overriden in the specific
DocWriter classes
derived from this abstract class if they actually support the use of
pagenumbers.
setPageCount in interface DocListener
pageN - the new page number
public void close()
Document was closed and that no other
Elements will be added.
close in interface DocListenerpublic static final byte[] getISOBytes(String text)
String into a Byte array
according to the ISO-8859-1 codepage.
text - the text to be converted
public void pause()
public void resume()
public void flush()
BufferedOutputStream.
protected void write(String string)
throws IOException
String to the OutputStream.
string - the String to write
IOException
protected void addTabs(int indent)
throws IOException
indent - the number of tabs to add
IOException
protected void write(String key,
String value)
throws IOException
key - the name of an attributevalue - the value of an attribute
IOException
protected void writeStart(String tag)
throws IOException
tag - the name of the tag
IOException
protected void writeEnd(String tag)
throws IOException
tag - the name of the tag
IOException
protected void writeEnd()
throws IOException
IOException
protected boolean writeMarkupAttributes(MarkupAttributes mAtt)
throws IOException
MarkupAttributes
object to the OutputStream.
mAtt - the MarkupAttributes to write.
IOExceptionprotected static boolean hasMarkupAttributes(Element element)
true if the specified Element implements
MarkupAttributes and has one or more attributes to write.
element - the Element to check.
boolean.public boolean isCloseStream()
public void setCloseStream(boolean closeStream)
closeStream - true if the stream is closed on document close
public void clearTextWrap()
throws DocumentException
DocListener
clearTextWrap in interface DocListenerDocumentExceptionDocListener.clearTextWrap()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||