Table of Contents

Class PdfDocument

Namespace
iText.Kernel.Pdf
Assembly
itext.kernel.dll

Main enter point to work with PDF document.

public class PdfDocument : IEventDispatcher, IDisposable
Inheritance
PdfDocument
Implements
Derived
Inherited Members

Constructors

PdfDocument(PdfReader)

Open PDF document in reading mode.

public PdfDocument(PdfReader reader)

Parameters

reader PdfReader

PDF reader.

PdfDocument(PdfReader, DocumentProperties)

Open PDF document in reading mode.

public PdfDocument(PdfReader reader, DocumentProperties properties)

Parameters

reader PdfReader

PDF reader.

properties DocumentProperties

document properties

PdfDocument(PdfReader, PdfWriter)

Opens PDF document in the stamping mode.

public PdfDocument(PdfReader reader, PdfWriter writer)

Parameters

reader PdfReader

PDF reader.

writer PdfWriter

PDF writer.

Remarks

Opens PDF document in the stamping mode.

PdfDocument(PdfReader, PdfWriter, StampingProperties)

Open PDF document in stamping mode.

public PdfDocument(PdfReader reader, PdfWriter writer, StampingProperties properties)

Parameters

reader PdfReader

PDF reader.

writer PdfWriter

PDF writer.

properties StampingProperties

properties of the stamping process

PdfDocument(PdfWriter)

Open PDF document in writing mode.

public PdfDocument(PdfWriter writer)

Parameters

writer PdfWriter

PDF writer

Remarks

Open PDF document in writing mode. Document has no pages when initialized.

PdfDocument(PdfWriter, DocumentProperties)

Open PDF document in writing mode.

public PdfDocument(PdfWriter writer, DocumentProperties properties)

Parameters

writer PdfWriter

PDF writer

properties DocumentProperties

document properties

Remarks

Open PDF document in writing mode. Document has no pages when initialized.

Fields

catalog

Document catalog.

protected PdfCatalog catalog

Field Value

PdfCatalog

closeReader

protected bool closeReader

Field Value

bool

closeWriter

protected bool closeWriter

Field Value

bool

closed

protected bool closed

Field Value

bool

eventDispatcher

protected EventDispatcher eventDispatcher

Field Value

EventDispatcher

fingerPrint

protected FingerPrint fingerPrint

Field Value

FingerPrint

flushUnusedObjects

flag determines whether to write unused objects to result document

protected bool flushUnusedObjects

Field Value

bool

info

Document info.

protected PdfDocumentInfo info

Field Value

PdfDocumentInfo

isClosing

protected bool isClosing

Field Value

bool

pdfVersion

Document version.

protected PdfVersion pdfVersion

Field Value

PdfVersion

properties

protected readonly StampingProperties properties

Field Value

StampingProperties

reader

PdfReader associated with the document.

protected PdfReader reader

Field Value

PdfReader

Remarks

PdfReader associated with the document. Not null if document is opened either in reading or stamping mode.

serializeOptions

protected SerializeOptions serializeOptions

Field Value

SerializeOptions

structParentIndex

protected int structParentIndex

Field Value

int

structTreeRoot

protected PdfStructTreeRoot structTreeRoot

Field Value

PdfStructTreeRoot

tagStructureContext

protected TagStructureContext tagStructureContext

Field Value

TagStructureContext

trailer

Document trailed.

protected PdfDictionary trailer

Field Value

PdfDictionary

writer

PdfWriter associated with the document.

protected PdfWriter writer

Field Value

PdfWriter

Remarks

PdfWriter associated with the document. Not null if document opened either in writing or stamping mode.

xmpMetadata

XMP Metadata for the document.

protected byte[] xmpMetadata

Field Value

byte[]

Methods

AddAssociatedFile(string, PdfFileSpec)

Adds file associated with PDF document as a whole and identifies the relationship between them.

public virtual void AddAssociatedFile(string description, PdfFileSpec fs)

Parameters

description string

the file description

fs PdfFileSpec

file specification dictionary of associated file

Remarks

Adds file associated with PDF document as a whole and identifies the relationship between them.

Associated files may be used in Pdf/A-3 and Pdf 2.0 documents. The method is very similar to AddFileAttachment(string, PdfFileSpec). However, besides adding file description to Names tree, it adds file to array value of the AF key in the document catalog.

For associated files their associated file specification dictionaries shall include the AFRelationship key
See Also

AddCustomMetadataExtensions(XMPMeta)

Adds custom XMP metadata extension.

protected virtual void AddCustomMetadataExtensions(XMPMeta xmpMeta)

Parameters

xmpMeta XMPMeta

XMPMeta to add custom metadata to.

Remarks

Adds custom XMP metadata extension. Useful for PDF/UA, ZUGFeRD, etc.

AddEventHandler(string, IEventHandler)

public virtual void AddEventHandler(string type, IEventHandler handler)

Parameters

type string
handler IEventHandler

AddFileAttachment(string, PdfFileSpec)

Adds file attachment at document level.

public virtual void AddFileAttachment(string key, PdfFileSpec fs)

Parameters

key string

name of the destination.

fs PdfFileSpec

PdfFileSpec object.

AddFont(PdfFont)

Adds a PdfFont instance to this document so that this font is flushed automatically on document close.

public virtual PdfFont AddFont(PdfFont font)

Parameters

font PdfFont

a PdfFont instance to add

Returns

PdfFont

the same PdfFont instance.

Remarks

Adds a PdfFont instance to this document so that this font is flushed automatically on document close. As a side effect, the underlying font dictionary is made indirect if it wasn't the case yet

AddNamedDestination(string, PdfObject)

This methods adds new name in the Dests NameTree.

public virtual void AddNamedDestination(string key, PdfObject value)

Parameters

key string

Name of the destination.

value PdfObject

An object destination refers to. Must be an array or a dictionary with key /D and array. See ISO 32000-1 12.3.2.3 for more info.

Remarks

This methods adds new name in the Dests NameTree. It throws an exception, if the name already exists.

AddNamedDestination(PdfString, PdfObject)

This methods adds new name in the Dests NameTree.

public virtual void AddNamedDestination(PdfString key, PdfObject value)

Parameters

key PdfString

Name of the destination.

value PdfObject

An object destination refers to. Must be an array or a dictionary with key /D and array. See ISO 32000-1 12.3.2.3 for more info.

Remarks

This methods adds new name in the Dests NameTree. It throws an exception, if the name already exists.

AddNewPage()

Creates and adds new page to the end of document.

public virtual PdfPage AddNewPage()

Returns

PdfPage

added page

AddNewPage(int)

Creates and inserts new page to the document.

public virtual PdfPage AddNewPage(int index)

Parameters

index int

position to addPage page to

Returns

PdfPage

inserted page

AddNewPage(int, PageSize)

Creates and inserts new page to the document.

public virtual PdfPage AddNewPage(int index, PageSize pageSize)

Parameters

index int

position to addPage page to

pageSize PageSize

page size of the new page

Returns

PdfPage

inserted page

AddNewPage(PageSize)

Creates and adds new page with the specified page size.

public virtual PdfPage AddNewPage(PageSize pageSize)

Parameters

pageSize PageSize

page size of the new page

Returns

PdfPage

added page

AddOutputIntent(PdfOutputIntent)

Adds PdfOutputIntent that shall specify the colour characteristics of output devices on which the document might be rendered.

public virtual void AddOutputIntent(PdfOutputIntent outputIntent)

Parameters

outputIntent PdfOutputIntent

PdfOutputIntent to add.

See Also

AddPage(int, PdfPage)

Inserts page to the document.

public virtual PdfPage AddPage(int index, PdfPage page)

Parameters

index int

position to addPage page to

page PdfPage

page to addPage

Returns

PdfPage

inserted page

AddPage(PdfPage)

Adds page to the end of document.

public virtual PdfPage AddPage(PdfPage page)

Parameters

page PdfPage

page to add.

Returns

PdfPage

added page.

CheckAndAddPage(int, PdfPage)

Checks page before adding and add.

protected virtual void CheckAndAddPage(int index, PdfPage page)

Parameters

index int

one-base index of the page.

page PdfPage

PdfPage to add.

CheckAndAddPage(PdfPage)

Checks page before adding.

protected virtual void CheckAndAddPage(PdfPage page)

Parameters

page PdfPage

PdfPage to add.

CheckClosingStatus()

checks whether a method is invoked at the closed document

protected virtual void CheckClosingStatus()

CheckIsoConformance()

Checks whether PDF document conforms to a specific standard.

protected virtual void CheckIsoConformance()

CheckIsoConformance(object, IsoKey)

Checks whether PDF document conforms a specific standard.

public virtual void CheckIsoConformance(object obj, IsoKey key)

Parameters

obj object

An object to conform.

key IsoKey

type of object to conform.

CheckIsoConformance(object, IsoKey, PdfResources, PdfStream)

Checks whether PDF document conforms a specific standard.

public virtual void CheckIsoConformance(object obj, IsoKey key, PdfResources resources, PdfStream contentStream)

Parameters

obj object

an object to conform.

key IsoKey

type of object to conform.

resources PdfResources

PdfResources associated with an object to check.

contentStream PdfStream

current content stream

CheckIsoConformance(object, IsoKey, PdfResources, PdfStream, object)

Checks whether PDF document conforms a specific standard.

public virtual void CheckIsoConformance(object obj, IsoKey key, PdfResources resources, PdfStream contentStream, object extra)

Parameters

obj object

an object to conform.

key IsoKey

type of object to conform.

resources PdfResources

PdfResources associated with an object to check.

contentStream PdfStream

current content stream.

extra object

extra data required for the check.

CheckShowTextIsoConformance(CanvasGraphicsState, PdfResources)

Checks whether PDF document conforms a specific standard.

public virtual void CheckShowTextIsoConformance(CanvasGraphicsState gState, PdfResources resources)

Parameters

gState CanvasGraphicsState

a CanvasGraphicsState object to conform.

resources PdfResources

PdfResources associated with an object to check.

Remarks

Checks whether PDF document conforms a specific standard. Shall be overridden.

Close()

Close PDF document.

public virtual void Close()

CopyPagesTo(IList<int>, PdfDocument)

Copies a range of pages from current document to toDocument appending copied pages to the end.

public virtual IList<PdfPage> CopyPagesTo(IList<int> pagesToCopy, PdfDocument toDocument)

Parameters

pagesToCopy IList<int>

list of pages to be copied.

toDocument PdfDocument

a document to copy pages to.

Returns

IList<PdfPage>

list of copied pages

Remarks

Copies a range of pages from current document to toDocument appending copied pages to the end. Use this method if you want to copy pages across tagged documents. This will keep resultant PDF structure consistent.

If outlines destination names are the same in different documents, all such outlines will lead to a single location in the resultant document. In this case iText will log a warning. This can be avoided by renaming destinations names in the source document.

CopyPagesTo(IList<int>, PdfDocument, int)

Copies a range of pages from current document to toDocument.

public virtual IList<PdfPage> CopyPagesTo(IList<int> pagesToCopy, PdfDocument toDocument, int insertBeforePage)

Parameters

pagesToCopy IList<int>

list of pages to be copied.

toDocument PdfDocument

a document to copy pages to.

insertBeforePage int

a position where to insert copied pages.

Returns

IList<PdfPage>

list of new copied pages

Remarks

Copies a range of pages from current document to toDocument. Use this method if you want to copy pages across tagged documents. This will keep resultant PDF structure consistent.

If outlines destination names are the same in different documents, all such outlines will lead to a single location in the resultant document. In this case iText will log a warning. This can be avoided by renaming destinations names in the source document.

CopyPagesTo(IList<int>, PdfDocument, int, IPdfPageExtraCopier)

Copies a range of pages from current document to toDocument.

public virtual IList<PdfPage> CopyPagesTo(IList<int> pagesToCopy, PdfDocument toDocument, int insertBeforePage, IPdfPageExtraCopier copier)

Parameters

pagesToCopy IList<int>

list of pages to be copied.

toDocument PdfDocument

a document to copy pages to.

insertBeforePage int

a position where to insert copied pages.

copier IPdfPageExtraCopier

a copier which bears a special copy logic. May be null. It is recommended to use the same instance of IPdfPageExtraCopier for the same output document.

Returns

IList<PdfPage>

list of new copied pages

Remarks

Copies a range of pages from current document to toDocument. Use this method if you want to copy pages across tagged documents. This will keep resultant PDF structure consistent.

If outlines destination names are the same in different documents, all such outlines will lead to a single location in the resultant document. In this case iText will log a warning. This can be avoided by renaming destinations names in the source document.

CopyPagesTo(IList<int>, PdfDocument, IPdfPageExtraCopier)

Copies a range of pages from current document to toDocument appending copied pages to the end.

public virtual IList<PdfPage> CopyPagesTo(IList<int> pagesToCopy, PdfDocument toDocument, IPdfPageExtraCopier copier)

Parameters

pagesToCopy IList<int>

list of pages to be copied.

toDocument PdfDocument

a document to copy pages to.

copier IPdfPageExtraCopier

a copier which bears a special copy logic. May be null. It is recommended to use the same instance of IPdfPageExtraCopier for the same output document.

Returns

IList<PdfPage>

list of copied pages

Remarks

Copies a range of pages from current document to toDocument appending copied pages to the end. Use this method if you want to copy pages across tagged documents. This will keep resultant PDF structure consistent.

If outlines destination names are the same in different documents, all such outlines will lead to a single location in the resultant document. In this case iText will log a warning. This can be avoided by renaming destinations names in the source document.

CopyPagesTo(int, int, PdfDocument)

Copies a range of pages from current document to toDocument appending copied pages to the end.

public virtual IList<PdfPage> CopyPagesTo(int pageFrom, int pageTo, PdfDocument toDocument)

Parameters

pageFrom int

1-based start of the range of pages to be copied.

pageTo int

1-based end (inclusive) of the range of pages to be copied. This page is included in list of copied pages.

toDocument PdfDocument

a document to copy pages to.

Returns

IList<PdfPage>

list of new copied pages

Remarks

Copies a range of pages from current document to toDocument appending copied pages to the end. This range is inclusive, both page and pageTo are included in list of copied pages. Use this method if you want to copy pages across tagged documents. This will keep resultant PDF structure consistent.

If outlines destination names are the same in different documents, all such outlines will lead to a single location in the resultant document. In this case iText will log a warning. This can be avoided by renaming destinations names in the source document.

CopyPagesTo(int, int, PdfDocument, int)

Copies a range of pages from current document to toDocument.

public virtual IList<PdfPage> CopyPagesTo(int pageFrom, int pageTo, PdfDocument toDocument, int insertBeforePage)

Parameters

pageFrom int

start of the range of pages to be copied.

pageTo int

end of the range of pages to be copied.

toDocument PdfDocument

a document to copy pages to.

insertBeforePage int

a position where to insert copied pages.

Returns

IList<PdfPage>

list of copied pages

Remarks

Copies a range of pages from current document to toDocument. Use this method if you want to copy pages across tagged documents. This will keep resultant PDF structure consistent.

If outlines destination names are the same in different documents, all such outlines will lead to a single location in the resultant document. In this case iText will log a warning. This can be avoided by renaming destinations names in the source document.

CopyPagesTo(int, int, PdfDocument, int, IPdfPageExtraCopier)

Copies a range of pages from current document to toDocument.

public virtual IList<PdfPage> CopyPagesTo(int pageFrom, int pageTo, PdfDocument toDocument, int insertBeforePage, IPdfPageExtraCopier copier)

Parameters

pageFrom int

1-based start of the range of pages to be copied.

pageTo int

1-based end (inclusive) of the range of pages to be copied. This page is included in list of copied pages.

toDocument PdfDocument

a document to copy pages to.

insertBeforePage int

a position where to insert copied pages.

copier IPdfPageExtraCopier

a copier which bears a special copy logic. May be null. It is recommended to use the same instance of IPdfPageExtraCopier for the same output document.

Returns

IList<PdfPage>

list of new copied pages

Remarks

Copies a range of pages from current document to toDocument . This range is inclusive, both page and pageTo are included in list of copied pages. Use this method if you want to copy pages across tagged documents. This will keep resultant PDF structure consistent.

If outlines destination names are the same in different documents, all such outlines will lead to a single location in the resultant document. In this case iText will log a warning. This can be avoided by renaming destinations names in the source document.

CopyPagesTo(int, int, PdfDocument, IPdfPageExtraCopier)

Copies a range of pages from current document to toDocument appending copied pages to the end.

public virtual IList<PdfPage> CopyPagesTo(int pageFrom, int pageTo, PdfDocument toDocument, IPdfPageExtraCopier copier)

Parameters

pageFrom int

1-based start of the range of pages to be copied.

pageTo int

1-based end (inclusive) of the range of pages to be copied. This page is included in list of copied pages.

toDocument PdfDocument

a document to copy pages to.

copier IPdfPageExtraCopier

a copier which bears a special copy logic. May be null. It is recommended to use the same instance of IPdfPageExtraCopier for the same output document.

Returns

IList<PdfPage>

list of new copied pages.

Remarks

Copies a range of pages from current document to toDocument appending copied pages to the end. This range is inclusive, both page and pageTo are included in list of copied pages. Use this method if you want to copy pages across tagged documents. This will keep resultant PDF structure consistent.

If outlines destination names are the same in different documents, all such outlines will lead to a single location in the resultant document. In this case iText will log a warning. This can be avoided by renaming destinations names in the source document.

CreateNextIndirectReference()

Creates next available indirect reference.

public virtual PdfIndirectReference CreateNextIndirectReference()

Returns

PdfIndirectReference

created indirect reference.

DispatchEvent(Event)

public virtual void DispatchEvent(Event @event)

Parameters

event Event

DispatchEvent(Event, bool)

public virtual void DispatchEvent(Event @event, bool delayed)

Parameters

event Event
delayed bool

FindFont(string, string)

Find PdfFont from loaded fonts with corresponding fontProgram and encoding or CMAP.

public virtual PdfFont FindFont(string fontProgram, string encoding)

Parameters

fontProgram string

a font name or path to a font program

encoding string

an encoding or CMAP

Returns

PdfFont

the font instance, or null if font wasn't found

FlushCopiedObjects(PdfDocument)

Flush all copied objects and remove them from copied cache.

public virtual void FlushCopiedObjects(PdfDocument sourceDoc)

Parameters

sourceDoc PdfDocument

source document

Remarks

Flush all copied objects and remove them from copied cache.

Note, if you will copy objects from the same document, duplicated objects will be created. That's why usually this method is meant to be used when all copying from source document is finished. For other cases one can also consider other flushing mechanisms, e.g. pages-based flushing.

FlushFonts()

Flushes all newly added or loaded fonts.

protected virtual void FlushFonts()

FlushInfoDictionary(bool)

Flush info dictionary if needed.

protected virtual void FlushInfoDictionary(bool appendMode)

Parameters

appendMode bool

true if the document is edited in append mode.

FlushObject(PdfObject, bool)

Flush an 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.

GetAssociatedFiles()

Returns files associated with PDF document.

public virtual PdfArray GetAssociatedFiles()

Returns

PdfArray

associated files array.

GetCatalog()

Gets PDF catalog.

public virtual PdfCatalog GetCatalog()

Returns

PdfCatalog

PDF catalog.

GetConformanceLevel()

public virtual IConformanceLevel GetConformanceLevel()

Returns

IConformanceLevel

the IConformanceLevel will be null if the document does not have a conformance level specified

GetDefaultFont()

Gets default font for the document: Helvetica, WinAnsi.

public virtual PdfFont GetDefaultFont()

Returns

PdfFont

instance of PdfFont or null on error.

Remarks

Gets default font for the document: Helvetica, WinAnsi. One instance per document.

GetDefaultPageSize()

Gets default page size.

public virtual PageSize GetDefaultPageSize()

Returns

PageSize

default page size

Remarks

Gets default page size. New pages by default are created with this size.

GetDiContainer()

Gets the container containing all available dependencies.

public virtual DIContainer GetDiContainer()

Returns

DIContainer

the container containing all available dependencies.

GetDocumentFonts()

List all newly added or loaded fonts

protected virtual ICollection<PdfFont> GetDocumentFonts()

Returns

ICollection<PdfFont>

List of PdfFont.

GetDocumentId()

Obtains numeric document id.

public virtual long GetDocumentId()

Returns

long

document id

GetDocumentIdWrapper()

Obtains document id as a iText.Commons.Actions.Sequence.SequenceId.

public virtual SequenceId GetDocumentIdWrapper()

Returns

SequenceId

document id

GetDocumentInfo()

Gets document information dictionary.

public virtual PdfDocumentInfo GetDocumentInfo()

Returns

PdfDocumentInfo

document information dictionary.

Remarks

Gets document information dictionary. info is lazy initialized. It will be initialized during the first call of this method.

GetEncryptedPayloadDocument()

Gets the encrypted payload of this document, or returns null if this document isn't an unencrypted wrapper document.

public virtual PdfEncryptedPayloadDocument GetEncryptedPayloadDocument()

Returns

PdfEncryptedPayloadDocument

encrypted payload of this document.

GetFingerPrint()

Returns the object containing the registered products.

public virtual FingerPrint GetFingerPrint()

Returns

FingerPrint

fingerprint object

GetFirstPage()

Get the first page of the document.

public virtual PdfPage GetFirstPage()

Returns

PdfPage

first page of the document.

GetFont(PdfDictionary)

Create a new instance of PdfFont or load already created one.

public virtual PdfFont GetFont(PdfDictionary dictionary)

Parameters

dictionary PdfDictionary

PdfDictionary that presents PdfFont.

Returns

PdfFont

instance of PdfFont

Note, PdfFont which created with CreateFont(PdfDictionary) won't be cached until it will be added to PdfCanvas or PdfResources.

GetLastPage()

Gets the last page of the document.

public virtual PdfPage GetLastPage()

Returns

PdfPage

last page.

GetMemoryLimitsAwareHandler()

Gets current memory limits handler

public virtual MemoryLimitsAwareHandler GetMemoryLimitsAwareHandler()

Returns

MemoryLimitsAwareHandler

MemoryLimitsAwareHandler instance

GetModifiedDocumentId()

Gets modified document id

public virtual PdfString GetModifiedDocumentId()

Returns

PdfString

modified document id

Remarks

Gets modified document id

In order to set modifiedDocumentId SetModifiedDocumentId(PdfString) should be used

GetNextStructParentIndex()

Gets next parent index of tagged document.

public virtual int GetNextStructParentIndex()

Returns

int

-1 if document is not tagged, or >= 0 if tagged.

See Also

GetNumberOfPages()

Gets number of pages of the document.

public virtual int GetNumberOfPages()

Returns

int

number of pages.

GetNumberOfPdfObjects()

Get number of indirect objects in the document.

public virtual int GetNumberOfPdfObjects()

Returns

int

number of indirect objects.

GetOriginalDocumentId()

Gets original document id

public virtual PdfString GetOriginalDocumentId()

Returns

PdfString

original dccument id

Remarks

Gets original document id

In order to set originalDocumentId SetInitialDocumentId(PdfString) should be used

GetOutlines(bool)

This method returns a complete outline tree of the whole document.

public virtual PdfOutline GetOutlines(bool updateOutlines)

Parameters

updateOutlines bool

if the flag is true , the method reads the whole document and creates outline tree. If the flag is false , the method gets cached outline tree (if it was cached via calling getOutlines method before).

Returns

PdfOutline

fully initialize PdfOutline object.

GetPage(int)

Gets the page by page number.

public virtual PdfPage GetPage(int pageNum)

Parameters

pageNum int

page number.

Returns

PdfPage

page by page number.

GetPage(PdfDictionary)

Gets the PdfPage instance by PdfDictionary.

public virtual PdfPage GetPage(PdfDictionary pageDictionary)

Parameters

pageDictionary PdfDictionary

PdfDictionary that present page.

Returns

PdfPage

page by PdfDictionary.

GetPageFactory()

Returns the factory for creating page instances.

protected virtual IPdfPageFactory GetPageFactory()

Returns

IPdfPageFactory

implementation of IPdfPageFactory for current document

GetPageLabels()

This method retrieves the page labels from a document as an array of String objects.

public virtual string[] GetPageLabels()

Returns

string[]

string list of page labels if they were found, or null otherwise

GetPageNumber(PdfDictionary)

Gets page number by PdfDictionary.

public virtual int GetPageNumber(PdfDictionary pageDictionary)

Parameters

pageDictionary PdfDictionary

PdfDictionary that present page.

Returns

int

page number by PdfDictionary.

GetPageNumber(PdfPage)

Gets page number by page.

public virtual int GetPageNumber(PdfPage page)

Parameters

page PdfPage

the page.

Returns

int

page number.

GetPdfObject(int)

Gets PdfObject by object number.

public virtual PdfObject GetPdfObject(int objNum)

Parameters

objNum int

object number.

Returns

PdfObject

PdfObject or null , if object not found.

GetPdfVersion()

Gets PDF version.

public virtual PdfVersion GetPdfVersion()

Returns

PdfVersion

PDF version.

GetReader()

Gets PdfReader associated with the document.

public virtual PdfReader GetReader()

Returns

PdfReader

PdfReader associated with the document.

GetSerializeOptions()

Gets a persistent XMP metadata serialization options.

public virtual SerializeOptions GetSerializeOptions()

Returns

SerializeOptions

serialize options

GetStructTreeRoot()

Gets PdfStructTreeRoot of tagged document.

public virtual PdfStructTreeRoot GetStructTreeRoot()

Returns

PdfStructTreeRoot

PdfStructTreeRoot in case document is tagged, otherwise it returns null.

See Also

GetTagStructureContext()

Gets document TagStructureContext.

public virtual TagStructureContext GetTagStructureContext()

Returns

TagStructureContext

document TagStructureContext.

Remarks

Gets document TagStructureContext. The document must be tagged, otherwise an exception will be thrown.

GetTrailer()

Gets document trailer.

public virtual PdfDictionary GetTrailer()

Returns

PdfDictionary

document trailer.

GetWriter()

Gets PdfWriter associated with the document.

public virtual PdfWriter GetWriter()

Returns

PdfWriter

PdfWriter associated with the document.

GetXmpMetadata()

Gets XMPMetadata.

public virtual byte[] GetXmpMetadata()

Returns

byte[]

the XMPMetadata

GetXmpMetadata(bool)

Gets XMPMetadata or create a new one.

public virtual byte[] GetXmpMetadata(bool createNew)

Parameters

createNew bool

if true, create a new empty XMPMetadata if it did not present.

Returns

byte[]

existed or newly created XMPMetadata byte array.

HasEventHandler(string)

public virtual bool HasEventHandler(string type)

Parameters

type string

Returns

bool

HasOutlines()

Indicates if the document has any outlines

public virtual bool HasOutlines()

Returns

bool

true , if there are outlines and false otherwise.

InitTagStructureContext()

Initialize TagStructureContext.

protected virtual void InitTagStructureContext()

InitializeOutlines()

This method initializes an outline tree of the document and sets outline mode to true.

public virtual void InitializeOutlines()

IsAppendMode()

Returns true if the document is opened in append mode, and false otherwise.

public virtual bool IsAppendMode()

Returns

bool

true if the document is opened in append mode, and false otherwise.

IsCloseReader()

Checks, whether Close() method will close associated PdfReader.

public virtual bool IsCloseReader()

Returns

bool

true, Close() method is going to close associated PdfReader, otherwise false.

IsCloseWriter()

Checks, whether Close() method will close associated PdfWriter.

public virtual bool IsCloseWriter()

Returns

bool

true, Close() method is going to close associated PdfWriter, otherwise false.

IsClosed()

Gets close status of the document.

public virtual bool IsClosed()

Returns

bool

true, if the document has already been closed, otherwise false.

IsFlushUnusedObjects()

Checks, whether Close() will flush unused objects, e.g. unreachable from PDF Catalog.

public virtual bool IsFlushUnusedObjects()

Returns

bool

false, if Close() shall not flush unused objects, otherwise true.

Remarks

Checks, whether Close() will flush unused objects, e.g. unreachable from PDF Catalog. By default - false.

IsTagged()

Gets tagged status of the document.

public virtual bool IsTagged()

Returns

bool

true, if the document has tag structure, otherwise false.

ListIndirectReferences()

Gets static copy of cross reference table.

public virtual IList<PdfIndirectReference> ListIndirectReferences()

Returns

IList<PdfIndirectReference>

a static copy of cross reference table

MarkObjectAsMustBeFlushed(PdfObject)

Mark an object with MUST_BE_FLUSHED.

protected virtual void MarkObjectAsMustBeFlushed(PdfObject pdfObject)

Parameters

pdfObject PdfObject

an object to mark.

MarkStreamAsEmbeddedFile(PdfStream)

Marks PdfStream object as embedded file stream.

public virtual void MarkStreamAsEmbeddedFile(PdfStream stream)

Parameters

stream PdfStream

to be marked as embedded file stream

Remarks

Marks PdfStream object as embedded file stream. Note that this method is for internal usage. To add an embedded file to the PDF document please use specialized API for file attachments. (e.g. AddFileAttachment(string, PdfFileSpec) , AddAnnotation(PdfAnnotation) )

MovePage(int, int)

Moves page to new place in same document with all it tag structure

public virtual void MovePage(int pageNumber, int insertBefore)

Parameters

pageNumber int

number of Page that will be moved

insertBefore int

indicates before which page new one will be inserted to

MovePage(PdfPage, int)

Moves page to new place in same document with all it tag structure

public virtual bool MovePage(PdfPage page, int insertBefore)

Parameters

page PdfPage

page to be moved in document if present

insertBefore int

indicates before which page new one will be inserted to

Returns

bool

true if this document contained the specified page

Open(PdfVersion)

Initializes document.

protected virtual void Open(PdfVersion newPdfVersion)

Parameters

newPdfVersion PdfVersion

new pdf version of the resultant file if stamper is used and the version needs to be changed, or null otherwise

RegisterProduct(ProductData)

Registers a product for debugging purposes.

public virtual bool RegisterProduct(ProductData productData)

Parameters

productData ProductData

product to be registered.

Returns

bool

true if the product hadn't been registered before.

RemoveAllHandlers()

Remove all event handlers.

public virtual void RemoveAllHandlers()

RemoveEventHandler(string, IEventHandler)

public virtual void RemoveEventHandler(string type, IEventHandler handler)

Parameters

type string
handler IEventHandler

RemovePage(int)

Removes page from the document by page number.

public virtual void RemovePage(int pageNum)

Parameters

pageNum int

the one-based index of the PdfPage to be removed

RemovePage(PdfPage)

Removes the first occurrence of the specified page from this document, if it is present.

public virtual bool RemovePage(PdfPage page)

Parameters

page PdfPage

page to be removed from this document, if present

Returns

bool

true if this document contained the specified page

Remarks

Removes the first occurrence of the specified page from this document, if it is present. Returns true if this document contained the specified element (or equivalently, if this document changed as a result of the call).

SetCloseReader(bool)

Sets, whether Close() method shall close associated PdfReader.

public virtual void SetCloseReader(bool closeReader)

Parameters

closeReader bool

true, Close() method shall close associated PdfReader, otherwise false.

SetCloseWriter(bool)

Sets, whether Close() method shall close associated PdfWriter.

public virtual void SetCloseWriter(bool closeWriter)

Parameters

closeWriter bool

true, Close() method shall close associated PdfWriter, otherwise false.

SetDefaultPageSize(PageSize)

Sets default page size.

public virtual void SetDefaultPageSize(PageSize pageSize)

Parameters

pageSize PageSize

page size to be set as default

Remarks

Sets default page size. New pages by default will be created with this size.

SetEncryptedPayload(PdfFileSpec)

Sets an encrypted payload, making this document an unencrypted wrapper document.

public virtual void SetEncryptedPayload(PdfFileSpec fs)

Parameters

fs PdfFileSpec

encrypted payload file spec. PdfEncryptedPayloadFileSpecFactory can produce one.

Remarks

Sets an encrypted payload, making this document an unencrypted wrapper document. The file spec shall include the AFRelationship key with a value of EncryptedPayload, and shall include an encrypted payload dictionary.

SetFlushUnusedObjects(bool)

Sets, whether Close() shall flush unused objects, e.g. unreachable from PDF Catalog.

public virtual void SetFlushUnusedObjects(bool flushUnusedObjects)

Parameters

flushUnusedObjects bool

false, if Close() shall not flush unused objects, otherwise true.

SetSerializeOptions(SerializeOptions)

Sets a persistent XMP metadata serialization options.

public virtual void SetSerializeOptions(SerializeOptions serializeOptions)

Parameters

serializeOptions SerializeOptions

serialize options

SetTagged()

Specifies that document shall contain tag structure.

public virtual PdfDocument SetTagged()

Returns

PdfDocument

this PdfDocument instance

Remarks

Specifies that document shall contain tag structure. See ISO 32000-1, section 14.8 "Tagged PDF"

SetUserProperties(bool)

Sets the flag indicating the presence of structure elements that contain user properties attributes.

public virtual void SetUserProperties(bool userProperties)

Parameters

userProperties bool

the user properties flag

SetXmpMetadata(byte[])

Use this method to set the XMP Metadata.

protected virtual void SetXmpMetadata(byte[] xmpMetadata)

Parameters

xmpMetadata byte[]

The xmpMetadata to set.

SetXmpMetadata(XMPMeta)

Sets the XMP Metadata.

public virtual void SetXmpMetadata(XMPMeta xmpMeta)

Parameters

xmpMeta XMPMeta

the xmpMetadata to set

SetXmpMetadata(XMPMeta, SerializeOptions)

Sets the XMP Metadata.

public virtual void SetXmpMetadata(XMPMeta xmpMeta, SerializeOptions serializeOptions)

Parameters

xmpMeta XMPMeta

the xmpMetadata to set

serializeOptions SerializeOptions

serialization options

StoreDestinationToReaddress(PdfDestination, Action<PdfDestination>, Action<PdfDestination>)

Save destinations in a temporary storage for further copying.

protected virtual void StoreDestinationToReaddress(PdfDestination destination, Action<PdfDestination> onPageAvailable, Action<PdfDestination> onPageNotAvailable)

Parameters

destination PdfDestination

the PdfDestination to be updated itself.

onPageAvailable Action<PdfDestination>

a destination consumer that will handle the copying when the destination still resolves, it gets the new destination as input

onPageNotAvailable Action<PdfDestination>

a destination consumer that will handle the copying when the destination is not available, it gets the original destination as input

TryInitTagStructure(PdfDictionary)

Initializes the new instance of document's structure tree root PdfStructTreeRoot.

protected virtual void TryInitTagStructure(PdfDictionary str)

Parameters

str PdfDictionary

dictionary to create structure tree root

Remarks

Initializes the new instance of document's structure tree root PdfStructTreeRoot. See ISO 32000-1, section 14.7.2 Structure Hierarchy.

UpdateDefaultXmpMetadata()

Update XMP metadata values from PdfDocumentInfo.

protected virtual XMPMeta UpdateDefaultXmpMetadata()

Returns

XMPMeta

the XMPMetadata

UpdateXmpMetadata()

Updates XMP metadata.

protected virtual void UpdateXmpMetadata()

Remarks

Updates XMP metadata. Shall be overridden.