DocWriter
DocWriter Public class
Description
An abstract Writer class for documents.
Diagram
flowchart LR
classDef interfaceStyle stroke-dasharray: 5 5;
classDef abstractStyle stroke-width:4px
subgraph iTextSharp.text
iTextSharp.text.DocWriter[[DocWriter]]
class iTextSharp.text.DocWriter abstractStyle;
iTextSharp.text.IDocListener[[IDocListener]]
class iTextSharp.text.IDocListener interfaceStyle;
iTextSharp.text.IElementListener[[IElementListener]]
class iTextSharp.text.IElementListener interfaceStyle;
end
subgraph System
System.IDisposable[[IDisposable]]
end
iTextSharp.text.IDocListener --> iTextSharp.text.DocWriter
iTextSharp.text.IElementListener --> iTextSharp.text.IDocListener
System.IDisposable --> iTextSharp.text.IDocListener
Members
Properties
Public properties
| Type | Name | Methods |
|---|---|---|
bool | CloseStream | get, set |
int | PageCountSets the page number. | set |
Methods
Public methods
| Returns | Name |
|---|---|
bool | Add(IElement 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. |
void | Dispose() |
void | Flush()Flushes the Stream. |
bool | IsPaused() |
bool | 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 | ResetPageCount()Sets the page number to 0. |
void | Resume()Let the writer know that writing may be resumed. |
bool | SetMarginMirroring(bool marginMirroring) |
bool | SetMarginMirroringTopBottom(bool MarginMirroring) |
bool | SetMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)Sets the margins. |
bool | SetPageSize(Rectangle pageSize)Sets the pagesize. |
Protected methods
| Returns | Name |
|---|---|
void | AddTabs(int indent)Writes a number of tabs. |
void | Write(...)Writes a string to the stream. |
void | WriteEnd(...)Writes an endtag to the stream. |
bool | WriteMarkupAttributes(Properties markup)Writes the markup attributes of the specified MarkupAttributes object to the stream. |
void | WriteStart(string tag)Writes a starttag to the stream. |
Public Static methods
| Returns | Name |
|---|---|
byte``[] | GetISOBytes(string text)Converts a string into a Byte array according to the ISO-8859-1 codepage. |
Details
Summary
An abstract Writer class for documents.
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.
Inheritance
-
IDocListener -
IElementListener IDisposable
Constructors
DocWriter [1/2]
Source codeprotected DocWriter()
DocWriter [2/2]
Source codeprotected DocWriter(Document document, Stream os)
Arguments
| Type | Name | Description |
|---|---|---|
Document | document | The Document that has to be written |
Stream | os | The Stream the writer has to write to. |
Summary
Constructs a DocWriter.
Methods
Add
Source codepublic virtual bool Add(IElement element)
Arguments
| Type | Name | Description |
|---|---|---|
IElement | element |
Summary
Signals that an Element was added to the Document.
Remarks
This method should be overriden in the specific DocWriter classes derived from this abstract class.
Returns
false
Open
Source codepublic virtual void Open()
Summary
Signals that the Document was opened.
SetPageSize
Source codepublic virtual bool SetPageSize(Rectangle pageSize)
Arguments
| Type | Name | Description |
|---|---|---|
Rectangle | pageSize | the new pagesize |
Summary
Sets the pagesize.
Returns
a boolean
SetMargins
Source codepublic virtual bool SetMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)
Arguments
| Type | Name | Description |
|---|---|---|
float | marginLeft | the margin on the left |
float | marginRight | the margin on the right |
float | marginTop | the margin on the top |
float | marginBottom | the margin on the bottom |
Summary
Sets the margins.
Remarks
This does nothing. Has to be overridden if needed.
Returns
NewPage
Source codepublic virtual bool NewPage()
Summary
Signals that an new page has to be started.
Remarks
This does nothing. Has to be overridden if needed.
Returns
true if the page was added, false if not.
ResetPageCount
Source codepublic virtual void ResetPageCount()
Summary
Sets the page number to 0.
Remarks
This method should be overriden in the specific DocWriter classes derived from this abstract class if they actually support the use of pagenumbers.
Close
Source codepublic virtual void Close()
Summary
Signals that the Document was closed and that no other Elements will be added.
GetISOBytes
Source codepublic static byte GetISOBytes(string text)
Arguments
| Type | Name | Description |
|---|---|---|
string | text | the text to be converted |
Summary
Converts a string into a Byte array according to the ISO-8859-1 codepage.
Returns
the conversion result
Pause
Source codepublic virtual void Pause()
Summary
Let the writer know that all writing has to be paused.
IsPaused
Source codepublic virtual bool IsPaused()
Resume
Source codepublic virtual void Resume()
Summary
Let the writer know that writing may be resumed.
Flush
Source codepublic virtual void Flush()
Summary
Flushes the Stream.
Write [1/2]
Source codeprotected virtual void Write(string str)
Arguments
| Type | Name | Description |
|---|---|---|
string | str | the string to write |
Summary
Writes a string to the stream.
AddTabs
Source codeprotected virtual void AddTabs(int indent)
Arguments
| Type | Name | Description |
|---|---|---|
int | indent | the number of tabs to add |
Summary
Writes a number of tabs.
Write [2/2]
Source codeprotected virtual void Write(string key, string value)
Arguments
| Type | Name | Description |
|---|---|---|
string | key | the name of an attribute |
string | value | the value of an attribute |
Summary
Writes a key-value pair to the stream.
WriteStart
Source codeprotected virtual void WriteStart(string tag)
Arguments
| Type | Name | Description |
|---|---|---|
string | tag | the name of the tag |
Summary
Writes a starttag to the stream.
WriteEnd [1/2]
Source codeprotected virtual void WriteEnd(string tag)
Arguments
| Type | Name | Description |
|---|---|---|
string | tag | the name of the tag |
Summary
Writes an endtag to the stream.
WriteEnd [2/2]
Source codeprotected virtual void WriteEnd()
Summary
Writes an endtag to the stream.
WriteMarkupAttributes
Source codeprotected virtual bool WriteMarkupAttributes(Properties markup)
Arguments
| Type | Name | Description |
|---|---|---|
Properties | markup |
Summary
Writes the markup attributes of the specified MarkupAttributes object to the stream.
Returns
SetMarginMirroring
Source codepublic virtual bool SetMarginMirroring(bool marginMirroring)
Arguments
| Type | Name | Description |
|---|---|---|
bool | marginMirroring |
SetMarginMirroringTopBottom
Source codepublic virtual bool SetMarginMirroringTopBottom(bool MarginMirroring)
Arguments
| Type | Name | Description |
|---|---|---|
bool | MarginMirroring |
Dispose
Source codepublic virtual void Dispose()
Properties
PageCount
public virtual int PageCount { set; }
Summary
Sets the page number.
Remarks
This method should be overriden in the specific DocWriter classes derived from this abstract class if they actually support the use of pagenumbers.
CloseStream
public virtual bool CloseStream { get; set; }
Generated with ModularDoc