Skip to main content
Skip table of contents

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
TypeNameMethods
boolCloseStreamget, set
intPageCount
Sets the page number.
set

Methods

Public methods
ReturnsName
boolAdd(IElement element)
Signals that an Element was added to the Document.
voidClose()
Signals that the Document was closed and that no other
Elements will be added.
voidDispose()
voidFlush()
Flushes the Stream.
boolIsPaused()
boolNewPage()
Signals that an new page has to be started.
voidOpen()
Signals that the Document was opened.
voidPause()
Let the writer know that all writing has to be paused.
voidResetPageCount()
Sets the page number to 0.
voidResume()
Let the writer know that writing may be resumed.
boolSetMarginMirroring(bool marginMirroring)
boolSetMarginMirroringTopBottom(bool MarginMirroring)
boolSetMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)
Sets the margins.
boolSetPageSize(Rectangle pageSize)
Sets the pagesize.
Protected methods
ReturnsName
voidAddTabs(int indent)
Writes a number of tabs.
voidWrite(...)
Writes a string to the stream.
voidWriteEnd(...)
Writes an endtag to the stream.
boolWriteMarkupAttributes(Properties markup)
Writes the markup attributes of the specified MarkupAttributes
object to the stream.
voidWriteStart(string tag)
Writes a starttag to the stream.
Public Static methods
ReturnsName
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

Constructors

DocWriter [1/2]

Source code

protected DocWriter()
DocWriter [2/2]

Source code

protected DocWriter(Document document, Stream os)
Arguments
TypeNameDescription
DocumentdocumentThe Document that has to be written
StreamosThe Stream the writer has to write to.
Summary

Constructs a DocWriter.

Methods

Add

Source code

public virtual bool Add(IElement element)
Arguments
TypeNameDescription
IElementelement
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 code

public virtual void Open()
Summary

Signals that the Document was opened.

SetPageSize

Source code

public virtual bool SetPageSize(Rectangle pageSize)
Arguments
TypeNameDescription
RectanglepageSizethe new pagesize
Summary

Sets the pagesize.

Returns

a boolean

SetMargins

Source code

public virtual bool SetMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)
Arguments
TypeNameDescription
floatmarginLeftthe margin on the left
floatmarginRightthe margin on the right
floatmarginTopthe margin on the top
floatmarginBottomthe margin on the bottom
Summary

Sets the margins.

Remarks

This does nothing. Has to be overridden if needed.

Returns
NewPage

Source code

public 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 code

public 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 code

public virtual void Close()
Summary

Signals that the Document was closed and that no other Elements will be added.

GetISOBytes

Source code

public static byte GetISOBytes(string text)
Arguments
TypeNameDescription
stringtextthe 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 code

public virtual void Pause()
Summary

Let the writer know that all writing has to be paused.

IsPaused

Source code

public virtual bool IsPaused()
Resume

Source code

public virtual void Resume()
Summary

Let the writer know that writing may be resumed.

Flush

Source code

public virtual void Flush()
Summary

Flushes the Stream.

Write [1/2]

Source code

protected virtual void Write(string str)
Arguments
TypeNameDescription
stringstrthe string to write
Summary

Writes a string to the stream.

AddTabs

Source code

protected virtual void AddTabs(int indent)
Arguments
TypeNameDescription
intindentthe number of tabs to add
Summary

Writes a number of tabs.

Write [2/2]

Source code

protected virtual void Write(string key, string value)
Arguments
TypeNameDescription
stringkeythe name of an attribute
stringvaluethe value of an attribute
Summary

Writes a key-value pair to the stream.

WriteStart

Source code

protected virtual void WriteStart(string tag)
Arguments
TypeNameDescription
stringtagthe name of the tag
Summary

Writes a starttag to the stream.

WriteEnd [1/2]

Source code

protected virtual void WriteEnd(string tag)
Arguments
TypeNameDescription
stringtagthe name of the tag
Summary

Writes an endtag to the stream.

WriteEnd [2/2]

Source code

protected virtual void WriteEnd()
Summary

Writes an endtag to the stream.

WriteMarkupAttributes

Source code

protected virtual bool WriteMarkupAttributes(Properties markup)
Arguments
TypeNameDescription
Propertiesmarkup
Summary

Writes the markup attributes of the specified MarkupAttributes object to the stream.

Returns
SetMarginMirroring

Source code

public virtual bool SetMarginMirroring(bool marginMirroring)
Arguments
TypeNameDescription
boolmarginMirroring
SetMarginMirroringTopBottom

Source code

public virtual bool SetMarginMirroringTopBottom(bool MarginMirroring)
Arguments
TypeNameDescription
boolMarginMirroring
Dispose

Source code

public 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

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.