Table of Contents

Class PdfWriter

Namespace
iText.Kernel.Pdf
Assembly
itext.kernel.dll
public class PdfWriter : PdfOutputStream, IDisposable, IAsyncDisposable
Inheritance
PdfWriter
Implements
Inherited Members

Constructors

PdfWriter(FileInfo)

Create a PdfWriter writing to the passed File and with default writer properties.

public PdfWriter(FileInfo file)

Parameters

file FileInfo

File to write to.

PdfWriter(Stream)

Create a PdfWriter writing to the passed outputstream and with default writer properties.

public PdfWriter(Stream os)

Parameters

os Stream

Outputstream to write to.

PdfWriter(Stream, WriterProperties)

public PdfWriter(Stream os, WriterProperties properties)

Parameters

os Stream
properties WriterProperties

PdfWriter(string)

Create a PdfWriter writing to the passed filename and with default writer properties.

public PdfWriter(string filename)

Parameters

filename string

filename of the resulting pdf.

PdfWriter(string, WriterProperties)

Create a PdfWriter writing to the passed filename and using the passed writer properties.

public PdfWriter(string filename, WriterProperties properties)

Parameters

filename string

filename of the resulting pdf.

properties WriterProperties

writerproperties to use.

Fields

isUserWarnedAboutAcroFormCopying

protected bool isUserWarnedAboutAcroFormCopying

Field Value

bool

properties

protected WriterProperties properties

Field Value

WriterProperties

Methods

CopyObject(PdfObject, PdfDocument, bool)

Copies a PdfObject either stand alone or as part of the PdfDocument passed as documentTo.

protected virtual PdfObject CopyObject(PdfObject obj, PdfDocument documentTo, bool allowDuplicating)

Parameters

obj PdfObject

object to copy

documentTo PdfDocument

optional target document

allowDuplicating bool

allow that some objects will become duplicated by this action

Returns

PdfObject

the copies object

CopyObject(PdfObject, PdfDocument, bool, ICopyFilter)

Copies a PdfObject either stand alone or as part of the PdfDocument passed as documentTo.

protected virtual PdfObject CopyObject(PdfObject obj, PdfDocument documentTo, bool allowDuplicating, ICopyFilter copyFilter)

Parameters

obj PdfObject

object to copy

documentTo PdfDocument

optional target document

allowDuplicating bool

allow that some objects will become duplicated by this action

copyFilter ICopyFilter

ICopyFilter a filter to apply while copying arrays and dictionaries

  •         Use
    

NullCopyFilter for no filtering

Returns

PdfObject

the copies object

FlushModifiedWaitingObjects(ICollection<PdfIndirectReference>)

Flushes all modified objects which have not been flushed yet.

protected virtual void FlushModifiedWaitingObjects(ICollection<PdfIndirectReference> forbiddenToFlush)

Parameters

forbiddenToFlush ICollection<PdfIndirectReference>

a of references that are forbidden to be flushed automatically.

Remarks

Flushes all modified objects which have not been flushed yet. Used in case incremental updates.

FlushObject(PdfObject, bool)

Flushes the object.

protected virtual void FlushObject(PdfObject pdfObject, bool canBeInObjStm)

Parameters

pdfObject PdfObject

object to flush.

canBeInObjStm bool

indicates whether object can be placed into object stream.

Remarks

Flushes the object. Override this method if you want to define custom behaviour for object flushing.

FlushWaitingObjects(ICollection<PdfIndirectReference>)

Flushes all objects which have not been flushed yet.

protected virtual void FlushWaitingObjects(ICollection<PdfIndirectReference> forbiddenToFlush)

Parameters

forbiddenToFlush ICollection<PdfIndirectReference>

a of references that are forbidden to be flushed automatically.

GetCompressionLevel()

Gets default compression level for @see PdfStream.

public virtual int GetCompressionLevel()

Returns

int

compression level.

Remarks

Gets default compression level for @see PdfStream. For more details @see DeflaterOutputStream.

GetProperties()

Gets the writer properties.

public virtual WriterProperties GetProperties()

Returns

WriterProperties

The WriterProperties of the current PdfWriter.

InitCryptoIfSpecified(PdfVersion)

protected virtual void InitCryptoIfSpecified(PdfVersion version)

Parameters

version PdfVersion

IsFullCompression()

Indicates if to use full compression mode.

public virtual bool IsFullCompression()

Returns

bool

true if to use full compression, false otherwise.

SetCompressionLevel(int)

Sets default compression level for @see PdfStream.

public virtual PdfWriter SetCompressionLevel(int compressionLevel)

Parameters

compressionLevel int

compression level.

Returns

PdfWriter

this PdfWriter instance

Remarks

Sets default compression level for @see PdfStream. For more details @see DeflaterOutputStream.

SetSmartMode(bool)

Sets the smart mode.

public virtual PdfWriter SetSmartMode(bool smartMode)

Parameters

smartMode bool

True for enabling smart mode.

Returns

PdfWriter

this PdfWriter instance

Remarks

Sets the smart mode.
In smart mode when resources (such as fonts, images,...) are encountered, a reference to these resources is saved in a cache, so that they can be reused. This requires more memory, but reduces the file size of the resulting PDF document.

WriteHeader()

Writes PDF header.

protected virtual void WriteHeader()

WriteToBody(PdfObject)

Writes object to body of PDF document.

protected virtual void WriteToBody(PdfObject pdfObj)

Parameters

pdfObj PdfObject

object to write.