com.lowagie.text
public abstract class DocWriter extends Object implements DocListener
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
.
See Also: 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 .
|
protected void | addTabs(int indent)
Writes a number of tabs.
|
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. |
boolean | isCloseStream() Checks if the stream is to be closed on document close |
boolean | isPaused()
Checks if writing is paused.
|
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 | 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 | setMarginMirroring(boolean MarginMirroring) |
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(String tag)
Writes an endtag to the outputstream.
|
protected void | writeEnd()
Writes an endtag to the outputstream. |
protected boolean | writeMarkupAttributes(Properties markup)
Writes the markup attributes of the specified MarkupAttributes
object to the OutputStream . |
protected void | writeStart(String tag)
Writes a starttag to the outputstream.
|
DocWriter
.
Parameters: document The Document
that has to be written os The OutputStream
the writer has to write to.
Element
was added to the Document
.
This method should be overridden in the specific Parameters: element A high level object to add Returns: Throws: DocumentException when a document isn't open yet, or has been closed DocWriter
classes
derived from this abstract class.
false
Parameters: indent the number of tabs to add
Throws: IOException
Document
was closed and that no other
Elements
will be added.BufferedOutputStream
.String
into a Byte
array
according to the ISO-8859-1 codepage.Parameters: text the text to be converted
Returns: the conversion result
Returns: true if the stream is closed on document close
Returns: true
if writing temporarily has to be paused, false
otherwise.
This does nothing. Has to be overridden if needed.
Returns: true
if the page was added, false
if not.
Throws: DocumentException when a document isn't open yet, or has been closed
Document
was opened.
This method should be overridden in the specific DocWriter
classes
derived from this abstract class if they actually support the use of
footers.
This method should be overridden in the specific DocWriter
classes
derived from this abstract class if they actually support the use of
headers.
This method should be overridden in the specific DocWriter
classes
derived from this abstract class if they actually support the use of
pagenumbers.
Parameters: closeStream true if the stream is closed on document close
This method should be overridden in the specific Parameters: footer the new footer DocWriter
classes
derived from this abstract class if they actually support the use of
footers.
This method should be overridden in the specific Parameters: header the new header DocWriter
classes
derived from this abstract class if they actually support the use of
headers.
See Also: DocListener
This does nothing. Has to be overridden if needed.
Parameters: marginLeft the margin on the left marginRight the margin on the right marginTop the margin on the top marginBottom the margin on the bottom
Returns: false
This method should be overridden in the specific Parameters: pageN the new page number DocWriter
classes
derived from this abstract class if they actually support the use of
pagenumbers.
Parameters: pageSize the new pagesize
Returns: a boolean
String
to the OutputStream
.
Parameters: string the String
to write
Throws: IOException
Parameters: key the name of an attribute value the value of an attribute
Throws: IOException
Parameters: tag the name of the tag
Throws: IOException
Throws: IOException
MarkupAttributes
object to the OutputStream
.Parameters: markup a Properties
collection to write.
Returns: true, if writing the markup attributes succeeded
Throws: IOException
Parameters: tag the name of the tag
Throws: IOException