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.
Document,
DocListener| Modifier and Type | Field and Description |
|---|---|
protected boolean |
open
Is the writer open for writing?
|
protected OutputStreamCounter |
os
The outputstream of this writer.
|
| Modifier | Constructor and Description |
|---|---|
protected |
DocWriter() |
protected |
DocWriter(Document document,
OutputStream os)
Constructs a
DocWriter. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(Element element)
Signals that an
Element was added to the Document. |
void |
close()
Signals that the
Document was closed and that no other
Elements will be added. |
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 |
resetFooter()
Resets the footer of this document.
|
void |
resetHeader()
Resets the header of this document.
|
void |
resetPageCount()
Sets the page number to 0.
|
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)
Parameter that allows you to do left/right margin mirroring (odd/even pages)
|
boolean |
setMarginMirroringTopBottom(boolean MarginMirroring)
Parameter that allows you to do top/bottom margin mirroring (odd/even pages)
|
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 OutputStreamCounter os
protected boolean open
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.public boolean add(Element element) throws DocumentException
Element was added to the Document.
This method should be overridden in the specific DocWriter classes
derived from this abstract class.
add in interface ElementListenerelement - A high level object to addfalseDocumentException - when a document isn't open yet, or has been closedpublic void open()
Document was opened.open in interface DocListenerpublic boolean setPageSize(Rectangle pageSize)
setPageSize in interface DocListenerpageSize - the new pagesizebooleanpublic 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 bottomfalsepublic boolean newPage()
This does nothing. Has to be overridden if needed.
newPage in interface DocListenertrue if the page was added, false if not.public void setHeader(HeaderFooter header)
This method should be overridden in the specific DocWriter classes
derived from this abstract class if they actually support the use of
headers.
setHeader in interface DocListenerheader - the new headerpublic void resetHeader()
This method should be overridden in the specific DocWriter classes
derived from this abstract class if they actually support the use of
headers.
resetHeader in interface DocListenerpublic void setFooter(HeaderFooter footer)
This method should be overridden in the specific DocWriter classes
derived from this abstract class if they actually support the use of
footers.
setFooter in interface DocListenerfooter - the new footerpublic void resetFooter()
This method should be overridden in the specific DocWriter classes
derived from this abstract class if they actually support the use of
footers.
resetFooter in interface DocListenerpublic void resetPageCount()
This method should be overridden in the specific DocWriter classes
derived from this abstract class if they actually support the use of
pagenumbers.
resetPageCount in interface DocListenerpublic void setPageCount(int pageN)
This method should be overridden in the specific DocWriter classes
derived from this abstract class if they actually support the use of
pagenumbers.
setPageCount in interface DocListenerpageN - the new page numberpublic 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 convertedpublic boolean isPaused()
true if writing temporarily has to be paused, false otherwise.public boolean isCloseStream()
public void setCloseStream(boolean closeStream)
closeStream - true if the stream is closed on document closepublic boolean setMarginMirroring(boolean MarginMirroring)
DocListenersetMarginMirroring in interface DocListenerMarginMirroring - MarginDocListener.setMarginMirroring(boolean)public boolean setMarginMirroringTopBottom(boolean MarginMirroring)
DocListenersetMarginMirroringTopBottom in interface DocListenerMarginMirroring - MarginDocListener.setMarginMirroring(boolean)Copyright © 2021. All rights reserved.