Table of Contents

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 Document

The Document that has to be written

os Stream

The Stream the writer has to write to.

Fields

Document

This is the document that has to be written.

protected Document Document

Field Value

Document

EQUALS

This is some byte that is often used.

public const byte EQUALS = 61

Field Value

byte

FORWARD

This is some byte that is often used.

public const byte FORWARD = 47

Field Value

byte

GT

This is some byte that is often used.

public const byte GT = 62

Field Value

byte

LT

This is some byte that is often used.

public const byte LT = 60

Field Value

byte

NEWLINE

This is some byte that is often used.

public const byte NEWLINE = 10

Field Value

byte

Os

membervariables

public OutputStreamCounter Os

Field Value

OutputStreamCounter

PageSize

The pageSize.

protected Rectangle PageSize

Field Value

Rectangle

QUOTE

This is some byte that is often used.

public const byte QUOTE = 34

Field Value

byte

SPACE

This is some byte that is often used.

public const byte SPACE = 32

Field Value

byte

TAB

This is some byte that is often used.

public const byte TAB = 9

Field Value

byte

closeStream

Closes the stream on document close

protected bool closeStream

Field Value

bool

open

Is the writer open for writing?

protected bool open

Field Value

bool

pause

Do we have to pause all writing actions?

protected bool pause

Field Value

bool

Properties

CloseStream

implementation of the DocListener methods

public virtual bool CloseStream { get; set; }

Property Value

bool

Changes the footer of this document.

public virtual HeaderFooter Footer { set; }

Property Value

HeaderFooter

the new footer

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

int

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 int

the 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 string

the text to be converted

Returns

byte[]

the conversion result

IsPaused()

public bool IsPaused()

Returns

bool

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

bool

SetMarginMirroringTopBottom(bool)

@see com.lowagie.text.DocListener#setMarginMirroring(boolean) @since 2.1.6

public virtual bool SetMarginMirroringTopBottom(bool marginMirroringTopBottom)

Parameters

marginMirroringTopBottom bool

Returns

bool

SetMargins(float, float, float, float)

Sets the margins.

public virtual bool SetMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)

Parameters

marginLeft float

the margin on the left

marginRight float

the margin on the right

marginTop float

the margin on the top

marginBottom float

the margin on the bottom

Returns

bool

Remarks

This does nothing. Has to be overridden if needed.

SetPageSize(Rectangle)

Sets the pagesize.

public virtual bool SetPageSize(Rectangle pageSize)

Parameters

pageSize Rectangle

the new pagesize

Returns

bool

a boolean

Write(string)

Writes a string to the stream.

protected void Write(string str)

Parameters

str string

the string to write

Write(string, string)

Writes a key-value pair to the stream.

protected void Write(string key, string value)

Parameters

key string

the name of an attribute

value string

the value of an attribute

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 string

the 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 Properties

the MarkupAttributes to write.

Returns

bool

WriteStart(string)

Writes a starttag to the stream.

protected void WriteStart(string tag)

Parameters

tag string

the name of the tag