Creates a new PDF document instance.
Optionaloptions: {Configuration options for the document
OptionalownerPassword?: stringOwner password for encryption
Optionalpassword?: stringUser password for encryption
Optionalrevisions?: PdfRevision[]Pre-existing revisions for the document
OptionalsecurityHandler?: PdfSecurityHandlerCustom security handler for encryption
Optionalsigner?: PdfSignerCustom signer for digital signatures
Optionalversion?: string | PdfCommentPDF version string (e.g., '1.7', '2.0') or version comment
PDF version comment header
ProtectedmodifiedIndicates whether the object has been modified. By default, assume it has been modified because it's a new object
OptionalpostOptional tokens to prepend or append during serialization
OptionalpreOptional tokens to prepend or append during serialization
List of document revisions for incremental updates
OptionalsecuritySecurity handler for encryption/decryption operations
Signer instance for digital signature operations
Gets the encryption dictionary from the document if present.
The encryption dictionary object or undefined if not encrypted
Gets the reference to the metadata stream from the document catalog.
The metadata stream reference or undefined if not present
Gets all objects across all revisions in the document.
A readonly array of all PDF objects
The type of this PDF object
Gets the document catalog (root) dictionary.
The root dictionary or undefined if not found
Gets the trailer dictionary from the cross-reference lookup.
The trailer dictionary containing document metadata references
Gets the cross-reference lookup table for the latest revision.
The PdfXrefLookup for the latest revision
Adds objects to the document's latest revision. Automatically starts a new revision if the current one is locked.
PDF objects to add to the document
Creates a deep copy of the document.
A cloned PdfDocument instance
Commits pending objects to the document. Adds objects, applies encryption if configured, and updates the document structure.
Additional objects to add before committing
Decrypts all encrypted objects in the document. Removes the security handler and encryption dictionary after decryption.
Deletes an object from all revisions in the document.
The PDF object to delete
Encrypts all objects in the document using the security handler. Creates and adds an encryption dictionary to all revisions.
Compares this object to another for equality based on their token representations
Optionalother: PdfObjectFinds a compressed object by its object number within an object stream.
Object identifier with objectNumber and optional generationNumber
The found indirect object or undefined if not found
Finds an uncompressed indirect object by its object number.
Object identifier with objectNumber and optional generationNumber
The found indirect object or undefined if not found
Checks if a PDF object exists in the document.
The PDF object to check
True if the object exists in the document
Checks if the document is in incremental mode.
True if all revisions are locked for incremental updates
Indicates whether the object has been modified. Override this method if the modified state is determined differently
Reads and optionally decrypts an object by its object number. Handles both compressed and uncompressed objects.
Object lookup options
OptionalallowUnindexed?: booleanIf true, searches unindexed objects as fallback
OptionalgenerationNumber?: numberOptional generation number filter
The object number to find
A cloned and decrypted copy of the object, or undefined if not found
Sets the Document Security Store (DSS) for the document. Used for long-term validation of digital signatures.
The Document Security Store object to set
Sets whether the document should use incremental updates. When true, locks all existing revisions to preserve original content.
True to enable incremental mode, false to disable
Sets the modified state of the object. Override this method if the modified state is determined differently
Starts a new revision for incremental updates. Creates a new revision linked to the previous one.
The document instance for method chaining
ProtectedtokenizeTokenizes the object into an array of PdfTokens
Converts the object to a string representation
Converts the object to an array of PdfTokens, including any pre or post tokens
StaticfromCreates a PdfDocument from a byte stream.
A promise that resolves to the parsed PdfDocument
StaticfromCreates a PdfDocument from an array of PDF objects. Parses objects into revisions based on EOF comments.
Array of PDF objects to construct the document from
A new PdfDocument instance
Represents a PDF document with support for reading, writing, and modifying PDF files. Handles document structure, revisions, encryption, and digital signatures.
Example