Class DocWriter
- Namespace
- iTextSharp.text
- Assembly
- iTextSharp.LGPLv2.Core.dll
An abstract Writer class for documents.
public abstract class DocWriter : IDocListener, IElementListener, IDisposable
- Inheritance
-
DocWriter
- Implements
- Derived
- Inherited Members
Remarks
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 stream of the listening DocWriter.
Constructors
DocWriter()
constructor
protected DocWriter()
DocWriter(Document, Stream)
Constructs a DocWriter.
protected DocWriter(Document document, Stream os)
Parameters
document
DocumentThe Document that has to be written
os
StreamThe Stream the writer has to write to.
Fields
Document
This is the document that has to be written.
protected Document Document
Field Value
EQUALS
This is some byte that is often used.
public const byte EQUALS = 61
Field Value
FORWARD
This is some byte that is often used.
public const byte FORWARD = 47
Field Value
GT
This is some byte that is often used.
public const byte GT = 62
Field Value
LT
This is some byte that is often used.
public const byte LT = 60
Field Value
NEWLINE
This is some byte that is often used.
public const byte NEWLINE = 10
Field Value
Os
membervariables
public OutputStreamCounter Os
Field Value
PageSize
The pageSize.
protected Rectangle PageSize
Field Value
QUOTE
This is some byte that is often used.
public const byte QUOTE = 34
Field Value
SPACE
This is some byte that is often used.
public const byte SPACE = 32
Field Value
TAB
This is some byte that is often used.
public const byte TAB = 9
Field Value
closeStream
Closes the stream on document close
protected bool closeStream
Field Value
open
Is the writer open for writing?
protected bool open
Field Value
pause
Do we have to pause all writing actions?
protected bool pause
Field Value
Properties
CloseStream
implementation of the DocListener methods
public virtual bool CloseStream { get; set; }
Property Value
Footer
Changes the footer of this document.
public virtual HeaderFooter Footer { set; }
Property Value
- HeaderFooter
the new footer
Remarks
This method should be overriden in the specific DocWriter classes derived from this abstract class if they actually support the use of footers.
Header
Changes the header of this document.
public virtual HeaderFooter Header { set; }
Property Value
- HeaderFooter
the new header
Remarks
This method should be overriden in the specific DocWriter classes derived from this abstract class if they actually support the use of headers.
PageCount
Sets the page number.
public virtual int PageCount { set; }
Property Value
Remarks
This method should be overriden in the specific DocWriter classes derived from this abstract class if they actually support the use of pagenumbers.
Methods
Add(IElement)
Signals that an Element was added to the Document.
public virtual bool Add(IElement element)
Parameters
element
IElement
Returns
- bool
false
Remarks
This method should be overriden in the specific DocWriter classes derived from this abstract class.
AddTabs(int)
Writes a number of tabs.
protected void AddTabs(int indent)
Parameters
indent
intthe number of tabs to add
Close()
Signals that the Document was closed and that no other Elements will be added.
public virtual void Close()
Dispose()
public void Dispose()
Flush()
Flushes the Stream.
public virtual void Flush()
GetIsoBytes(string)
Converts a string into a Byte array according to the ISO-8859-1 codepage.
public static byte[] GetIsoBytes(string text)
Parameters
text
stringthe text to be converted
Returns
- byte[]
the conversion result
IsPaused()
public bool IsPaused()
Returns
NewPage()
Signals that an new page has to be started.
public virtual bool NewPage()
Returns
- bool
true if the page was added, false if not.
Remarks
This does nothing. Has to be overridden if needed.
Open()
Signals that the Document was opened.
public virtual void Open()
Pause()
methods
public virtual void Pause()
ResetFooter()
Resets the footer of this document.
public virtual void ResetFooter()
Remarks
This method should be overriden in the specific DocWriter classes derived from this abstract class if they actually support the use of footers.
ResetHeader()
Resets the header of this document.
public virtual void ResetHeader()
Remarks
This method should be overriden in the specific DocWriter classes derived from this abstract class if they actually support the use of headers.
ResetPageCount()
Sets the page number to 0.
public virtual void ResetPageCount()
Remarks
This method should be overriden in the specific DocWriter classes derived from this abstract class if they actually support the use of pagenumbers.
Resume()
Checks if writing is paused.
public virtual void Resume()
SetMarginMirroring(bool)
public virtual bool SetMarginMirroring(bool marginMirroring)
Parameters
marginMirroring
bool
Returns
SetMarginMirroringTopBottom(bool)
@see com.lowagie.text.DocListener#setMarginMirroring(boolean) @since 2.1.6
public virtual bool SetMarginMirroringTopBottom(bool marginMirroringTopBottom)
Parameters
marginMirroringTopBottom
bool
Returns
SetMargins(float, float, float, float)
Sets the margins.
public virtual bool SetMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)
Parameters
marginLeft
floatthe margin on the left
marginRight
floatthe margin on the right
marginTop
floatthe margin on the top
marginBottom
floatthe margin on the bottom
Returns
Remarks
This does nothing. Has to be overridden if needed.
SetPageSize(Rectangle)
Sets the pagesize.
public virtual bool SetPageSize(Rectangle pageSize)
Parameters
pageSize
Rectanglethe new pagesize
Returns
- bool
a boolean
Write(string)
Writes a string to the stream.
protected void Write(string str)
Parameters
str
stringthe string to write
Write(string, string)
Writes a key-value pair to the stream.
protected void Write(string key, string value)
Parameters
WriteEnd()
Writes an endtag to the stream.
protected void WriteEnd()
WriteEnd(string)
Writes an endtag to the stream.
protected void WriteEnd(string tag)
Parameters
tag
stringthe name of the tag
WriteMarkupAttributes(Properties)
Writes the markup attributes of the specified MarkupAttributes object to the stream.
protected bool WriteMarkupAttributes(Properties markup)
Parameters
markup
Propertiesthe MarkupAttributes to write.
Returns
WriteStart(string)
Writes a starttag to the stream.
protected void WriteStart(string tag)
Parameters
tag
stringthe name of the tag