Click or drag to resize

PDFDoc Class

PDFDoc is a high-level class describing a single PDF (Portable Document Format) document. Most applications using PDFNet will use this class to open existing PDF documents, or to create new PDF documents from scratch. The class offers a number of entry points into the document. For example,
  • To access pages use pdfdoc.getPageIterator() or pdfdoc.PageFind(page_num).
  • To access form fields use pdfdoc.GetFieldIterator() or pdfdoc.FieldFind(name).
  • To access document's meta-data use pdfdoc.GetDocInfo().
  • To access the outline tree use pdfdoc.GetFirstBookmark().
  • To access low-level Document Catalog use pdfdoc.GetRoot().
The class also offers utility methods to slit and merge PDF pages, to create new pages, to flatten forms, to change security settings, etc.
Stamps an image to the given destination document at the set of page numbers.
Stamps a PDF page to the given destination document at the set of page numbers.
Stamps text to the given destination document at the set of page numbers.
Deletes PDFTron stamps from document at given page numbers.
Returns true if the given set of pages has at least one stamp.
Optimize the given document using the optimizers settings
Optimize the given document using the optimizers settings
Inheritance Hierarchy
SystemObject
  pdftron.PDFPDFDoc

Namespace:  pdftron.PDF
Assembly:  pdftron (in pdftron.dll) Version: 255.255.255.255
Syntax
public sealed class PDFDoc : IClosable

Return Value

Type: 
true, if successful

The PDFDoc type exposes the following members.

Constructors
  NameDescription
Public methodPDFDoc
Creates a new empty PDF document.
Public methodPDFDoc(Byte)
Creates a new PDF document from an array of bytes.
Public methodPDFDoc(String)
Creates a new PDF document from the specified full path of the file.
Public methodPDFDoc(IStorageFile)
Creates a new PDF document from an IStorageFile instance.
Public methodPDFDoc(IBuffer)
Creates a new PDF document from a buffer.
Public methodPDFDoc(IInputStream)
Creates a new PDF document from an IInputStream instance.
Public methodPDFDoc(IRandomAccessStream)
Creates a new PDF document from an IRandomAccessStream instance.
Public methodPDFDoc(IFilter)
Creates a new PDF document from an existing IFilter instance.
Public methodPDFDoc(SDFDoc)
Creates a new PDF document from an existing SDFDoc instance.
Public methodPDFDoc(IInputStream, String)
Creates a new PDF document from an IInputStream instance.
Public methodPDFDoc(IRandomAccessStream, String)
Creates a new PDF document from an IRandomAccessStream instance.
Top
Methods
  NameDescription
Public methodAddFileAttachment
Public methodAddHighlights
AddHighlights is used to highlight text in a document using 'Adobe's Highlight File Format' (Technical Note #5172). The method will parse the Character offset data and modify the current document by adding new highlight annotations.
Public methodAddRootBookmark
Public methodAddSignatureHandler
Adds a signature handler to the signature manager.
Public methodAddStdSignatureHandler(Byte, String)
Adds a standard (built-in) signature handler to the signature manager. This method will use cryptographic algorithm based on Adobe.PPKLite/adbe.pkcs7.detached filter to sign a PDF.
Public methodAddStdSignatureHandler(String, String)
Adds a standard (built-in) signature handler to the signature manager. This method will use cryptographic algorithm based on Adobe.PPKLite/adbe.pkcs7.detached filter to sign a PDF.
Public methodAppendTextDiff(Page, Page)
Imports two external pages and highlights the differences between them. This function adds two new pages to the current document. The two input pages are typically coming from two different PDF files. Note: Each contiguous block of change is considered a single difference. A deletion immediately followed by an insertion is considered a single edit.
Public methodAppendTextDiff(PDFDoc, PDFDoc)
Imports two external PDFs and highlights the differences between them. This function appends alternating pages from the two input documents into the current document. Note: Each contiguous block of change is considered a single difference. A deletion immediately followed by an insertion is considered a single edit.
Public methodAppendTextDiff(PDFDoc, PDFDoc, TextDiffOptions)
Imports two external PDFs and highlights the differences between them. This function appends alternating pages from the two input documents into the current document. Note: Each contiguous block of change is considered a single difference. A deletion immediately followed by an insertion is considered a single edit.
Public methodAppendVisualDiff
Generates a PDF diff of the given pages by overlaying and blending them on top of each other, then appends that diff as a new page in this document.
Public methodClose
Public methodCreateDigitalSignatureField
Creates an unsigned digital signature form field inside the document with an automatically-generated unique name.
Public methodCreateDigitalSignatureField(String)
Creates an unsigned digital signature form field inside the document.
Public methodCreateIndirectArray
Creates the indirect Array.
Public methodCreateIndirectBool
Creates the indirect bool.
Public methodCreateIndirectDict
Creates the indirect dict.
Public methodCreateIndirectName
The following list of methods is used to create SDF/Cos indirect objects. Unlike direct objects, indirect objects can be referenced by more than one object (i.e. indirect objects they can be shared).
Public methodCreateIndirectNull
Creates the indirect null.
Public methodCreateIndirectNumber
Creates the indirect number.
Public methodCreateIndirectStream(Byte)
Creates the indirect stream.
Public methodCreateIndirectStream(FilterReader)
Creates the indirect stream.
Public methodCreateIndirectStream(Byte, IFilter)
Creates the indirect stream.
Public methodCreateIndirectStream(FilterReader, IFilter)
Creates the indirect stream.
Public methodCreateIndirectString(Byte)
Creates the indirect string.
Public methodCreateIndirectString(String)
Creates the indirect string.
Public methodDestroy
Closes PDFDoc and release resources
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodFDFExtract
Fdf extract.
Public methodFDFExtract(IVectorIAnnot)
Public methodFDFExtract(PDFDocExtractFlag)
Extract selected annotations to FDF.
Public methodFDFMerge
Import form data from FDF file to PDF interactive form.
Public methodFDFUpdate
Replace existing form and annotation data with those imported from the FDF file. It will make annotations in the FDF match those in the PDF. Since this method avoids updating annotations unnecessarily it works well with incremental save and can sometimes preserve annotation appearances, but it requires that the annotations intended to be in the final document be in the provided FDF file. Note: Some PDF viewers (like Chrome) cannot display annotations that don't already have an appearance, so it is often desirable to call PDFDoc.RefreshAnnotAppearances after this method to ensure these annotations can still be displayed in those applications. Note: This method is not suitable for realtime collaboration.
Public methodFieldCreate(String, FieldType)
Create a new interactive form Field.
Public methodFieldCreate(String, FieldType, Obj)
Field create.
Public methodFieldCreate(String, FieldType, String)
Field create.
Public methodFieldCreate(String, FieldType, Obj, Obj)
Field create.
Public methodFieldCreate(String, FieldType, String, String)
Field create.
Public methodFlattenAnnotations
Flatten all annotations in the document.
Public methodFlattenAnnotations(Boolean)
Flatten all annotations in the document.
Public methodGenerateThumbnails
Generates thumbnail images for all the pages in this PDF document.
Public methodGetAcroForm
Gets the acro form.
Public methodGetDigitalSignatureFieldIterator
Retrieves an iterator that iterates over digital signature fields.
Public methodGetDigitalSignaturePermissions
Retrieves the most restrictive document permissions locking level from all of the signed digital signatures in the document.
Public methodGetDocInfo
Gets the doc info.
Public methodCode exampleGetField
field_name - a string representing the fully qualified name of the field (e.g. "employee.name.first").
Public methodCode exampleGetFieldIterator
An interactive form (sometimes referred to as an AcroForm) is a collection of fields for gathering information interactively from the user. A PDF document may contain any number of fields appearing on any combination of pages, all of which make up a single, global interactive form spanning the entire document. The following methods are used to access and manipulate Interactive form fields (sometimes referred to as AcroForms).
Public methodGetFileName
Gets the file name.
Public methodGetFirstBookmark
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetOCGConfig
Gets the OCG configuration.
Public methodGetOCGs
Gets the oC gs.
Public methodGetOpenAction
Public methodCode exampleGetPage
Gets the page.
Public methodGetPageCount
Gets the page count.
Public methodCode exampleGetPageIterator
Gets the page iterator.
Public methodGetPageIterator(Int32)
Gets the page iterator.
Public methodGetPageLabel
Gets the page label.
Public methodGetPages
Gets the pages.
Public methodGetRoot
Gets the root.
Public methodGetSDFDoc
Gets the SDFDoc.
Public methodGetSecurityHandler
Gets the security handler.
Public methodGetSignatureHandler
Gets the associated signature handler instance from the signature manager by looking it up with the provided id.
Public methodGetTrailer
Gets the trailer.
Public methodGetTriggerAction
Get the Action associated with the selected PDFDoc Trigger event
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetUndoManager
Public methodGetViewPrefs
Gets the view prefs.
Public methodHasOC
Gets the structure tree.
Public methodHasRepairedXRef
Checks whether or not the underlying file has an XRef table that had to be repaired when the file was opened.If the document had an invalid XRef table when opened, PDFNet will have repaired the XRef table for its working representation of the document.
Public methodHasSignatures
Indicates whether this documents contains any digital signatures.
Public methodStatic memberHighlightTextDiff
Highlights the differences between the external PDFs. The highlights are added directly to the inputs. This function directly adds the highlights to the two input documents. Note: Each contiguous block of change is considered a single difference. A deletion immediately followed by an insertion is considered a single edit.
Public methodImportPages(IVectorPage)
Public methodImportPages(IVectorPage, Boolean)
Public methodInitSecurityHandler
Initializes document's SecurityHandler. This version of InitSecurityHandler() works with Standard and Custom PDF security and can be used in situations where the password is obtained dynamically via user feedback. See EncTest sample for example code. This function should be called immediately after an encrypted document is opened. The function does not have any side effects on documents that are not encrypted. If the security handler was successfully initialized it can be later obtained using GetSecurityHandler() method.
Public methodInitSecurityHandler(Int32)
Inits the security handler.
Public methodInitStdSecurityHandler(Byte)
Initializes document's SecurityHandler using the supplied password. This version of InitSecurityHandler() assumes that document uses Standard security and that a password is specified directly. This function should be called immediately after an encrypted document is opened. The function does not have any side effects on documents that are not encrypted. If the security handler was successfully initialized, it can be later obtained using GetSecurityHandler() method.
Public methodInitStdSecurityHandler(String)
Initializes document's SecurityHandler using the supplied password. This version of InitSecurityHandler() assumes that document uses Standard security and that a password is specified directly. This function should be called immediately after an encrypted document is opened. The function does not have any side effects on documents that are not encrypted. If the security handler was successfully initialized, it can be later obtained using GetSecurityHandler() method.
Public methodInsertPages(Int32, PDFDoc, PageSet, PDFDocInsertFlag)
Inserts a range of pages from specified PDFDoc using PageSet
Public methodInsertPages(Int32, PDFDoc, Int32, Int32, PDFDocInsertFlag)
Public methodIsEncrypted
Checks if is encrypted.
Public methodIsLinearized
Call this function to determine whether the document is represented in linearized (fast web view) format.
Public methodIsLocked
Checks if is locked.
Public methodIsModified
Call this function to determine whether the document has been modified since it was last saved.
Public methodIsTagged
Checks if is tagged.
Public methodLock
Locks the document to prevent competing threads from accessiong the document at the same time. Threads attempting to access the document will wait in suspended state until the thread that owns the lock calls doc.Unlock().
Public methodLockRead
Locks the document to prevent competing write threads (using Lock()) from accessing the document at the same time. Other reader threads however, will be allowed to access the document. Threads attempting to obtain write access to the document will wait in suspended state until the thread that owns the lock calls doc.UnlockRead().
Public methodMergeXFDF(String, MergeXFDFOptions)
Merge existing form and annotation data with those imported from the XFDF file. It will replace annotations from pdfdocument with matching annotations from XFDF. In order for the annotations to be considered matching, "name" of the xfdf annotation needs to match "NM" of that in pdf. XFDF annotations that don't have a match in the pdf document will be added. For regular xfdf files, no deletions will be made This method also supports command form of xfdf, for those files, deletions will be performed for annotations in "delete" section Since this method avoids updating annotations unnecessarily it works well with incremental save. Note: This method is suitable for realtime collaboration.
Public methodMergeXFDF(IFilter, MergeXFDFOptions)
Merge existing form and annotation data with those imported from the XFDF file. It will replace annotations from pdfdocument with matching annotations from XFDF. In order for the annotations to be considered matching, "name" of the xfdf annotation needs to match "NM" of that in pdf. XFDF annotations that don't have a match in the pdf document will be added. For regular xfdf files, no deletions will be made This method also supports command form of xfdf, for those files, deletions will be performed for annotations in "delete" section Since this method avoids updating annotations unnecessarily it works well with incremental save. Note: This method is suitable for realtime collaboration.
Public methodMovePages(Int32, PDFDoc, PageSet, PDFDocInsertFlag)
Moves a range of pages from specified PDFDoc. Pages are deleted from source document after move.
Public methodMovePages(Int32, PDFDoc, Int32, Int32, PDFDocInsertFlag)
Moves a range of pages from specified PDFDoc. Pages are deleted from source document after move.
Public methodPageCreate
Create a new, empty page in the document. You can use PageWriter to fill the page with new content. Finally the page should be inserted at specific place within document page sequence using PageInsert/PagePushFront/PagePushBack methods.
Public methodPageCreate(Rect)
Page create.
Public methodPageInsert
Insert/Import a single page at a specific location in the page sequence.
Public methodPagePushBack
Adds a page to the end of a documents's page sequence.
Public methodPagePushFront
Adds a page to the beginning of a documents's page sequence.
Public methodPageRemove
Page remove.
Public methodRefreshAnnotAppearances
Generates the appearance stream for annotations in the document using the default RefreshOptions. A common use case is to generate appearances only for missing annotations, which can be accomplished using the default options.
Public methodRefreshAnnotAppearances(RefreshOptions)
Generates the appearance stream for annotations in the document using the specified options. A common use case is to generate appearances only for missing annotations, which can be accomplished using the default options.
Public methodRefreshFieldAppearances
Regenerates the appearance stream for every widget annotation in the document Call this method if you modified field's value and would like to update field's appearances.
Public methodRemovePageLabel
Removes the page label that is attached to the specified page, effectively merging the specified range with the previous page label sequence.
Public methodRemoveSecurity
Removes all security for the document.
Public methodRemoveSignatureHandler
Removes a signature handler from the signature manager.
Public methodSaveAsync
Saves all changes incrementally to the document and writes them to the original source. Incremental saving is very fast, as it only appends data to the end of the file (and so is independent of the file size) This is suitable for quick save operations that you don't want to interrupt the user of the app.
Public methodSaveAsync(SDFDocSaveOptions)
Saves all changes incrementally document and writes them to the original source. Note that this might be slow, unless you are using the e_incremental flag only. Preferably shouldn't be used while the user is viewing the document. Saving with the e_incremental flag only will only append data, making the save fast no matter the original file size.
Public methodSaveAsync(String, SDFDocSaveOptions)
Saves all changes to the document and writes them to a file pointed by the given path.
Public methodSaveAsync(IStorageFile, SDFDocSaveOptions)
Saves all changes to the document and writes them to an IRandomAccessStream instance without using the saved document as the new source. Note, this will assume that randomAccessStream is pointing to a different location that the PDFDoc currently is. If this is not the case, the behavior is undefined and may corrupt the underlying document.
Public methodSaveAsync(IOutputStream, SDFDocSaveOptions)
Saves all changes to the document and writes them to an IOutputStream instance.
Public methodSaveAsync(IRandomAccessStream, SDFDocSaveOptions)
Saves all changes to the document and writes them to an IRandomAccessStream instance. Note, this save method will always create a copy of the document first, as it can no establish whether randomAccessStream is referring to the same location as the document, and so will make a copy for safety. If you know the location is different, then use SaveToNewLocationAsync.
Public methodSaveAsync(IFilter, SDFDocSaveOptions)
Saves all changes to the document and writes them to file specified by the IStorageFile instance without using the saved document as the new source. Note, this will assume that randomAccessStream is pointing to a different location that the PDFDoc currently is. If this is not the case, the behavior is undefined and may corrupt the underlying document.
Public methodSaveAsync(IRandomAccessStream, SDFDocSaveOptions, String)
Saves all changes to the document and writes them to an IRandomAccessStream instance. Note, this save method will always create a copy of the document first, as it can no establish whether randomAccessStream is referring to the same location as the document, and so will make a copy for safety. If you know the location is different, then use SaveToNewLocationAsync.
Public methodSaveCustomSignature(Byte, DigitalSignatureField, IFilter)
Saves a custom signature Contents to a document which has been prepared to receive it. No changes should be made to document in meantime.
Public methodSaveCustomSignature(Byte, DigitalSignatureField, String)
Saves all changes to the document and writes them to an output IFilter sink without using the saved document as the new source.
Public methodSaveToBufferAsync
Saves all changes to the document and writes them to a buffer.
Public methodSaveToNewLocationAsync(IStorageFile, SDFDocSaveOptions)
Saves all changes to the document and writes them to an IRandomAccessStream instance. Note, this will assume that storageFile is pointing to a different location that the PDFDoc currently is. If this is not the case, the behavior is undefined and may corrupt the underlying document.
Public methodSaveToNewLocationAsync(IRandomAccessStream, SDFDocSaveOptions, String)
Saves all changes to the document and writes them to an IRandomAccessStream instance. Note, this will assume that randomAccessStream is pointing to a different location that the PDFDoc currently is. If this is not the case, the behavior is undefined and may corrupt the underlying document.
Public methodSetOpenAction
Public methodSetPageLabel
Attaches a label to a page. This establishes the numbering scheme for that page and all following it, until another page label is encountered. This label allows PDF producers to define a page numbering system other than the default.
Public methodSetSecurityHandler
The function sets a new SecurityHandler as the current security handler.
Public methodTimedLock
Try locking the document, waiting no longer than specified number of milliseconds.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodTryLock
Try locking the document in non-blocking manner.
Public methodUnlock
Removes the lock from the document.
Public methodUnlockRead
Removes the read lock from the document.
Public methodVerifySignedDigitalSignatures
Attempts to verify all signed cryptographic digital signatures in the document, ignoring unsigned signatures.
Top
See Also