Class PdfDocument
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
PdfReaderPDF reader.
PdfDocument(PdfReader, DocumentProperties)
Open PDF document in reading mode.
public PdfDocument(PdfReader reader, DocumentProperties properties)
Parameters
reader
PdfReaderPDF reader.
properties
DocumentPropertiesdocument properties
PdfDocument(PdfReader, PdfWriter)
Opens PDF document in the stamping mode.
public PdfDocument(PdfReader reader, PdfWriter writer)
Parameters
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
PdfReaderPDF reader.
writer
PdfWriterPDF writer.
properties
StampingPropertiesproperties of the stamping process
PdfDocument(PdfWriter)
Open PDF document in writing mode.
public PdfDocument(PdfWriter writer)
Parameters
writer
PdfWriterPDF 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
PdfWriterPDF writer
properties
DocumentPropertiesdocument properties
Remarks
Open PDF document in writing mode. Document has no pages when initialized.
Fields
catalog
Document catalog.
protected PdfCatalog catalog
Field Value
closeReader
protected bool closeReader
Field Value
closeWriter
protected bool closeWriter
Field Value
closed
protected bool closed
Field Value
eventDispatcher
protected EventDispatcher eventDispatcher
Field Value
fingerPrint
protected FingerPrint fingerPrint
Field Value
flushUnusedObjects
flag determines whether to write unused objects to result document
protected bool flushUnusedObjects
Field Value
info
Document info.
protected PdfDocumentInfo info
Field Value
isClosing
protected bool isClosing
Field Value
pdfVersion
Document version.
protected PdfVersion pdfVersion
Field Value
properties
protected readonly StampingProperties properties
Field Value
reader
PdfReader associated with the document.
protected PdfReader reader
Field Value
Remarks
PdfReader associated with the document. Not null if document is opened either in reading or stamping mode.
serializeOptions
protected SerializeOptions serializeOptions
Field Value
structParentIndex
protected int structParentIndex
Field Value
structTreeRoot
protected PdfStructTreeRoot structTreeRoot
Field Value
tagStructureContext
protected TagStructureContext tagStructureContext
Field Value
trailer
Document trailed.
protected PdfDictionary trailer
Field Value
writer
PdfWriter associated with the document.
protected PdfWriter writer
Field Value
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
stringthe file description
fs
PdfFileSpecfile 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
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
stringhandler
IEventHandler
AddFileAttachment(string, PdfFileSpec)
Adds file attachment at document level.
public virtual void AddFileAttachment(string key, PdfFileSpec fs)
Parameters
key
stringname of the destination.
fs
PdfFileSpecPdfFileSpec 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
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
stringName of the destination.
value
PdfObjectAn 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
PdfStringName of the destination.
value
PdfObjectAn 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
intposition 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
Returns
- PdfPage
inserted page
AddNewPage(PageSize)
Creates and adds new page with the specified page size.
public virtual PdfPage AddNewPage(PageSize pageSize)
Parameters
pageSize
PageSizepage 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
PdfOutputIntentPdfOutputIntent to add.
- See Also
AddPage(int, PdfPage)
Inserts page to the document.
public virtual PdfPage AddPage(int index, PdfPage page)
Parameters
Returns
- PdfPage
inserted page
AddPage(PdfPage)
Adds page to the end of document.
public virtual PdfPage AddPage(PdfPage page)
Parameters
page
PdfPagepage to add.
Returns
- PdfPage
added page.
CheckAndAddPage(int, PdfPage)
Checks page before adding and add.
protected virtual void CheckAndAddPage(int index, PdfPage page)
Parameters
CheckAndAddPage(PdfPage)
Checks page before adding.
protected virtual void CheckAndAddPage(PdfPage page)
Parameters
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
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
objectan object to conform.
key
IsoKeytype of object to conform.
resources
PdfResourcesPdfResources associated with an object to check.
contentStream
PdfStreamcurrent 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
objectan object to conform.
key
IsoKeytype of object to conform.
resources
PdfResourcesPdfResources associated with an object to check.
contentStream
PdfStreamcurrent content stream.
extra
objectextra 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
CanvasGraphicsStatea CanvasGraphicsState object to conform.
resources
PdfResourcesPdfResources 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
PdfDocumenta document to copy pages to.
Returns
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.
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
PdfDocumenta document to copy pages to.
insertBeforePage
inta position where to insert copied pages.
Returns
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.
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
PdfDocumenta document to copy pages to.
insertBeforePage
inta position where to insert copied pages.
copier
IPdfPageExtraCopiera 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
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.
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
PdfDocumenta document to copy pages to.
copier
IPdfPageExtraCopiera 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
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.
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
int1-based start of the range of pages to be copied.
pageTo
int1-based end (inclusive) of the range of pages to be copied. This page is included in list of copied pages.
toDocument
PdfDocumenta document to copy pages to.
Returns
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.
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
intstart of the range of pages to be copied.
pageTo
intend of the range of pages to be copied.
toDocument
PdfDocumenta document to copy pages to.
insertBeforePage
inta position where to insert copied pages.
Returns
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.
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
int1-based start of the range of pages to be copied.
pageTo
int1-based end (inclusive) of the range of pages to be copied. This page is included in list of copied pages.
toDocument
PdfDocumenta document to copy pages to.
insertBeforePage
inta position where to insert copied pages.
copier
IPdfPageExtraCopiera 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
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.
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
int1-based start of the range of pages to be copied.
pageTo
int1-based end (inclusive) of the range of pages to be copied. This page is included in list of copied pages.
toDocument
PdfDocumenta document to copy pages to.
copier
IPdfPageExtraCopiera 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
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.
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
FindFont(string, string)
Find PdfFont from loaded fonts with corresponding fontProgram and encoding or CMAP.
public virtual PdfFont FindFont(string fontProgram, string encoding)
Parameters
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
PdfDocumentsource 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
booltrue
if the document is edited in append mode.
FlushObject(PdfObject, bool)
Flush an object.
protected virtual void FlushObject(PdfObject pdfObject, bool canBeInObjStm)
Parameters
pdfObject
PdfObjectobject to flush.
canBeInObjStm
boolindicates 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()
Get the IConformanceLevel
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
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
PdfDictionaryPdfDictionary 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 usedGetNextStructParentIndex()
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 usedGetOutlines(bool)
This method returns a complete outline tree of the whole document.
public virtual PdfOutline GetOutlines(bool updateOutlines)
Parameters
updateOutlines
boolif 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
intpage number.
Returns
- PdfPage
page by page number.
GetPage(PdfDictionary)
Gets the PdfPage instance by PdfDictionary.
public virtual PdfPage GetPage(PdfDictionary pageDictionary)
Parameters
pageDictionary
PdfDictionaryPdfDictionary 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
GetPageNumber(PdfDictionary)
Gets page number by PdfDictionary.
public virtual int GetPageNumber(PdfDictionary pageDictionary)
Parameters
pageDictionary
PdfDictionaryPdfDictionary that present page.
Returns
- int
page number by PdfDictionary.
GetPageNumber(PdfPage)
Gets page number by page.
public virtual int GetPageNumber(PdfPage page)
Parameters
page
PdfPagethe page.
Returns
- int
page number.
GetPdfObject(int)
Gets PdfObject by object number.
public virtual PdfObject GetPdfObject(int objNum)
Parameters
objNum
intobject number.
Returns
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
boolif 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
HasOutlines()
Indicates if the document has any outlines
public virtual bool HasOutlines()
Returns
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()
public virtual bool IsAppendMode()
Returns
IsCloseReader()
Checks, whether Close() method will close associated PdfReader.
public virtual bool IsCloseReader()
Returns
IsCloseWriter()
Checks, whether Close() method will close associated PdfWriter.
public virtual bool IsCloseWriter()
Returns
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
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
PdfObjectan object to mark.
MarkStreamAsEmbeddedFile(PdfStream)
Marks PdfStream object as embedded file stream.
public virtual void MarkStreamAsEmbeddedFile(PdfStream stream)
Parameters
stream
PdfStreamto 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
intnumber of Page that will be moved
insertBefore
intindicates 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
PdfPagepage to be moved in document if present
insertBefore
intindicates 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
PdfVersionnew 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
ProductDataproduct 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
stringhandler
IEventHandler
RemovePage(int)
Removes page from the document by page number.
public virtual void RemovePage(int pageNum)
Parameters
pageNum
intthe 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
PdfPagepage 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
SetCloseWriter(bool)
Sets, whether Close() method shall close associated PdfWriter.
public virtual void SetCloseWriter(bool closeWriter)
Parameters
SetDefaultPageSize(PageSize)
Sets default page size.
public virtual void SetDefaultPageSize(PageSize pageSize)
Parameters
pageSize
PageSizepage 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
PdfFileSpecencrypted 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
SetSerializeOptions(SerializeOptions)
Sets a persistent XMP metadata serialization options.
public virtual void SetSerializeOptions(SerializeOptions serializeOptions)
Parameters
serializeOptions
SerializeOptionsserialize 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
boolthe 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
XMPMetathe xmpMetadata to set
SetXmpMetadata(XMPMeta, SerializeOptions)
Sets the XMP Metadata.
public virtual void SetXmpMetadata(XMPMeta xmpMeta, SerializeOptions serializeOptions)
Parameters
xmpMeta
XMPMetathe xmpMetadata to set
serializeOptions
SerializeOptionsserialization 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
PdfDestinationthe 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
PdfDictionarydictionary 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.