Creates a new PDF document instance.
ObjectManager that controls the object lifetime
Optionaloptions: PdfDocumentOptionsCreation options for new documents (optional)
Creates a new PDF document instance.
Optionaloptions: PdfDocumentOptionsCreation options for new documents (optional)
Gets or sets the compression level. Default value is CompressionLevel#Fastest.
Gets or sets the compression level. Default value is CompressionLevel#Fastest.
Gets or sets a ActionJavaScript to be performed after printing the document.
Gets or sets a ActionJavaScript to be performed after printing the document.
Gets or sets a ActionJavaScript to be performed after saving the document.
Gets or sets a ActionJavaScript to be performed after saving the document.
Gets or sets the DocumentInfo object that contains information about this document (author, title, etc).
Gets or sets the DocumentInfo object that contains information about this document (author, title, etc).
Gets the dictionary of document level file attachments.
Gets or sets the FontCollection object used when the PdfDocument needs to find a Font (e.g. if it is not embedded in the PDF).
Gets or sets the FontCollection object used when the PdfDocument needs to find a Font (e.g. if it is not embedded in the PDF).
Gets or sets the font embedding mode. The default is FontEmbedMode.EmbedSubset. Note that this property does not affect the 14 standard PDF fonts, their embedding is determined by the PdfDocument#standardFontEmbedMode property. Also note that if the PdfDocument is saved as PDF/A, and the value of this property is FontEmbedMode.NotEmbed, the fonts are embedded anyway using the FontEmbedMode.EmbedSubset mode.
Gets or sets the font embedding mode. The default is FontEmbedMode.EmbedSubset. Note that this property does not affect the 14 standard PDF fonts, their embedding is determined by the PdfDocument#standardFontEmbedMode property. Also note that if the PdfDocument is saved as PDF/A, and the value of this property is FontEmbedMode.NotEmbed, the fonts are embedded anyway using the FontEmbedMode.EmbedSubset mode.
Gets the collection of font handlers associated with the current document.
Gets the reference to the object.
Gets the collection of PdfImageHandler objects associated with the current document.
Gets or sets the ImageOptions object that contains options controlling how images are processed in the current document.
Gets or sets the ImageOptions object that contains options controlling how images are processed in the current document.
Gets a value indicating if the PDF document was created from scratch.
Gets the document-level java scripts as a dictionary where key is a custom user defined name and value is a ActionJavaScript object containing a JavaScript associated with a name.
Gets a value indicating whether the PDF was linearized ("fast web view").
Gets or sets the metadata associated with this document.
Gets or sets the metadata associated with this document.
Gets the dictionary of named destinations defined in the current document.
Gets the owner ObjectManager instance.
Gets or sets a DocAction to be displayed or performed when the document is opened.
Gets the collection of the current document outlines.
Gets a PdfPageCollection with document pages.
import JSZip from 'jszip';
const doc = PdfDocument.load(await Util.loadPdfAsArray("document.pdf"));
const coll = doc.pages;
const pageCount = coll.count;
const zip = new JSZip();
for (let num = 1; num <= pageCount; num++) {
const page = coll.getAt(num - 1);
const svgBytes: Uint8Array = page.saveAsSvg({ zoom: 2 });
zip.file(`page${num}.svg`, svgBytes, { binary: true });
}
const zipBytes = await zip.generateAsync({ type: "uint8array" });
Util.saveFile("sample.zip", zipBytes, 'application/zip');
Gets or sets the format used to represent fonts in the current document. The default is PdfFontFormat.Type0AutoOneByteEncoding. Note that this property does not affect the 14 standard PDF fonts, those are always encoded as Type1.
Gets or sets the format used to represent fonts in the current document. The default is PdfFontFormat.Type0AutoOneByteEncoding. Note that this property does not affect the 14 standard PDF fonts, those are always encoded as Type1.
Gets the PDF Version of the document.
Gets or sets the type of algorithm that is used for PDF content recognition when building page text maps.
This property affects the behavior of methods such as getText, findText and other APIs that rely on text maps.
Gets or sets the type of algorithm that is used for PDF content recognition when building page text maps.
This property affects the behavior of methods such as getText, findText and other APIs that rely on text maps.
Gets or sets the font embedding mode for the 14 standard PDF fonts. The default is FontEmbedMode.NotEmbed. Note that if the PdfDocument is saved as PDF/A, and the value of this property is FontEmbedMode.NotEmbed, the standard fonts are embedded anyway using the FontEmbedMode.EmbedSubset mode.
Gets or sets the font embedding mode for the 14 standard PDF fonts. The default is FontEmbedMode.NotEmbed. Note that if the PdfDocument is saved as PDF/A, and the value of this property is FontEmbedMode.NotEmbed, the standard fonts are embedded anyway using the FontEmbedMode.EmbedSubset mode.
Gets or sets a ActionJavaScript to be performed before closing the document.
Gets or sets a ActionJavaScript to be performed before closing the document.
Gets or sets a ActionJavaScript to be performed before printing the document.
Gets or sets a ActionJavaScript to be performed before printing the document.
Gets or sets a ActionJavaScript to be performed before saving the document.
Gets or sets a ActionJavaScript to be performed before saving the document.
StaticloadLoads an existing PDF document from binary data using specified decryption options.
Object manager that controls the lifetime of the PdfDocument.
Binary data containing the PDF document
Optionaldecryption: PdfDecryptionOptionsOptional decryption options for password-protected documents
A new instance of PdfDocument representing the loaded document
Loads an existing PDF document from binary data using specified decryption options.
Binary data containing the PDF document
Optionaldecryption: PdfDecryptionOptionsOptional decryption options for password-protected documents
A new instance of PdfDocument representing the loaded document
Loads an existing PDF document from binary data using specified password.
Object manager that controls the lifetime of the PdfDocument.
Binary data containing the PDF document
Optionalpassword: stringThe optional password used to decrypt a document
A new instance of PdfDocument representing the loaded document
Loads an existing PDF document from binary data using specified password.
Binary data containing the PDF document
Optionalpassword: stringThe optional password used to decrypt a document
A new instance of PdfDocument representing the loaded document
Loads an existing PDF document from binary data.
Object manager that controls the lifetime of the PdfDocument.
Binary data containing the PDF document
A new instance of PdfDocument representing the loaded document
Loads an existing PDF document from binary data.
Binary data containing the PDF document
A new instance of PdfDocument representing the loaded document
Adds the binary data as an embedded file to the PDF document.
The FileSpecProperties object defining properties of embedded file.
const doc = new PdfDocument();
const pngFile = await Util.loadImageAsArray("cars.png");
doc.addEmbeddedFile("cars.png", {
fileName: "cars.png",
desc: "My car from the dream.",
stream: {
data: pngFile,
mimeType: "image/png",
creationDate: new Date('2019/12/01'),
modificationDate: new Date('2020/04/19')
}
});
const jpgFile = await Util.loadImageAsArray("tudor.jpg");
doc.addEmbeddedFile("tudor.jpg", {
fileName: "tudor.jpg",
desc: "The house to buy.",
stream: {
data: jpgFile,
mimeType: "image/jpeg",
creationDate: new Date('2022/12/01'),
modificationDate: new Date('2023/04/19')
}
});
Util.saveFile("embeddedFiles.pdf", doc.savePdf(), 'application/pdf');
Clears the document, removing all content and resetting all properties and settings to their initial default values.
Deletes a specified text from all pages of the current document.
Note that the results may be affected by the current value of the RecognitionAlgorithm property.
The text to search for.
The text delete mode.
OptionalsearchRange: OutputRangeThe search scope.
Exports the document's form data to a stream in FDF format.
Optionaloptions: ExportFormDataOptionsThe export options.
Searches for all occurrences of a text in a range of the document's pages.
Note that the results may be affected by the current value of the RecognitionAlgorithm property.
The text searching parameters.
OptionalsearchRange: OutputRangeThe search scope.
Detaches the object from the ObjectManager and deallocates its memory, if possible.
Extracts and returns all text from the current document.
Imports the document's form data from a stream in FDF format.
The data in FDF format.
Merges all or some pages from a specified PdfDocument into the current document.
The source document which is to be merged into the current document.
Optionaloptions: MergeDocumentOptions | nullThe options controlling what and how to merge.
Adds a new PdfPage to the document and returns its drawing context.
Optionaloptions: PdfPageContextOptionsThe options for adding a new page and creating a PdfContext object.
A PdfContext object for the new page.
Rebinds the object from the current ObjectManager to the specified one.
The new ObjectManager for the object.
Applies all RedactAnnotations to the current document.
Optionaloptions: RedactOptionsSpecifies the additional redact options.
Applies a list of specified RedactAnnotations to the current document.
The array of RedactAnnotation objects to apply.
Optionaloptions: RedactOptionsSpecifies the additional redact options.
Replaces a specified text on all pages of the current document.
Note that the results may be affected by the current value of the recognitionAlgorithm property.
The text to search for.
The replacement text.
OptionalsearchRange: OutputRangeThe search scope.
Optionalfont: Font | nullThe font to use on 'newText', if null the current font will be used.
OptionalfontSize: number | nullThe font size to use on 'newText', if null the current font size will be used.
Saves the original (unmodified) PdfDocument to a byte array.
A byte array with original PDF document data.
Saves the current PdfDocument to a byte array.
Optionaloptions: SavePdfOptionsThe options for saving a PDF document.
A byte array with PDF document data.
Represents a PDF document that can be created from scratch or loaded from existing data. Provides methods for creating, loading, and manipulating PDF documents.
Example
Example
Example