@ironsoftware/ironpdf
Version:
IronPDF for Node
1,011 lines • 46.1 kB
TypeScript
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import { Buffer } from "buffer";
import { BarcodeStampOptions, BarcodeType, ChangeTrackingModes, ChromePdfRenderOptions, DigitalSignature, VerifiedSignature, HtmlAffix, HtmlFilePath, HtmlStampOptions, HtmlString, HttpLoginCredentials, ImageBuffer, ImageFilePath, ImageStampOptions, ImageToPdfOptions, ImageType, LinearizationMode, PageInfo, PageRotation, PdfInput, PdfPageSelection, PdfPaperSize, PdfPassword, PdfPermission, RenderedElementLocation, SaveOptions, TextAffix, TextStampOptions } from "./types";
import { LinkAnnotation } from "./annotation";
import { Bookmark } from "./bookmark";
import { Readable } from "stream";
import { PdfAVersions, PdfUAVersions } from "../internal/grpc_layer/pdfium/pdfa";
import { NaturalLanguages } from "./naturalLanguages";
/**
* Represents a PDF document. Allows: loading, editing, manipulating, merging, signing printing and saving PDFs.
*
* @remark Make sure that you call {@link PdfDocument.close} or {@link cleanUp} to free the memory, when you stop using the PdfDocument object.
*/
export declare class PdfDocument {
/**
* Open or Create a PdfDocument from a {@link PdfInput}
* @param pdfInput {@link PdfInput}
* @param options including {@link PdfPassword} {@link ChromePdfRenderOptions} {@link HttpLoginCredentials} mainHtmlFile
*/
static open(pdfInput: PdfInput, options?: {
/**
* required for open a protected PDF file
* @default undefined
*/
password?: PdfPassword | undefined;
/**
* Apply renderOptions if PdfInput is a {@link HtmlString} or {@link HtmlFilePath} or {@link ZipFilePath} or {@link Url}}
* @default undefined
*/
renderOptions?: ChromePdfRenderOptions | undefined;
/**
* Apply httpLoginCredentials if PdfInput is a {@link HtmlString} or {@link HtmlFilePath} or {@link ZipFilePath} or {@link Url}}
* @default undefined
*/
httpLoginCredentials?: HttpLoginCredentials | undefined;
/**
* Apply mainHtmlFile if PdfInput is {@link ZipFilePath}
* @default index.html
*/
mainHtmlFile?: string | undefined;
/**
* Optionally track changes to the document (for use with incremental saves)
* @default {@link ChangeTrackingModes.AutoChangeTracking}
*/
trackChanges?: ChangeTrackingModes | undefined;
} | undefined): Promise<PdfDocument>;
/**
* Open a PdfDocument from .pdf file
* @param pdfFilePath A path to .pdf file
* @param Optionally track changes to the document (for use with incremental saves)
*/
static fromFile(pdfFilePath: string, trackChanges?: ChangeTrackingModes | undefined): Promise<PdfDocument>;
/**
* Create a PdfDocument from an Url
* @param url A website Url
* @param options including {@link ChromePdfRenderOptions}
*/
static fromUrl(url: URL | string, options?: {
/**
* Apply renderOptions if PdfInput is a {@link HtmlString} or {@link HtmlFilePath} or {@link ZipFilePath} or {@link Url}}
* @default undefined
*/
renderOptions?: ChromePdfRenderOptions | undefined;
} | undefined): Promise<PdfDocument>;
/**
* Creates a PDF file from a local Zip file, and returns it as a {@link PdfDocument}.
* IronPDF is a W3C standards compliant HTML rendering based on Google's Chromium browser.
* If your output PDF does not look as expected:
*
* - Validate your HTML file using https://validator.w3.org/ & CSS https://jigsaw.w3.org/css-validator/
*
* - To debug HTML, view the file in Chrome web browser's print preview which will work almost exactly as IronPDF.
*
* - Read our detailed documentation on pixel perfect HTML to PDF: https://ironpdf.com/tutorials/pixel-perfect-html-to-pdf/
*
* @param zipFilePath Path to a Zip to be rendered as a PDF.
* @param options including {@link ChromePdfRenderOptions} and `mainHtmlFile` a main .html file default: `index.html`
*/
static fromZip(zipFilePath: string, options?: {
/**
* Apply renderOptions if PdfInput is a {@link HtmlString} or {@link HtmlFilePath} or {@link ZipFilePath} or {@link Url}}
* @default undefined
*/
renderOptions?: ChromePdfRenderOptions | undefined;
/**
* a main .html file default: `index.html`
*/
mainHtmlFile?: string | undefined;
} | undefined): Promise<PdfDocument>;
/**
* Creates a PDF file from a Html string, and returns it as an {@link PdfDocument} object which can be edited and saved to disk or served on a website.
*
* ------------------------------------------------
*
* **Usage:**
* ```ts
* const pdf = await fromHtml(htmlStringOrHtmlFilePath, renderOptions);
* ```
*
* ------------------------------------------------
*
* @param htmlStringOrHtmlFilePath The Html to be rendered as a PDF.
* @param options including {@link ChromePdfRenderOptions}
* @returns A `PdfDocument` generated from the provided HTML file.
*
* ---
* ### Important Notes:
*
* 🐳 **Docker Limitation:**
* This method **does not work** for **HTML file path** when the application runs inside a Docker environment
* due to rendering engine restrictions.
* In such cases, use `fromZip()` instead.
*
* 📄 **Input:** Requires access to a local HTML file on disk if htmlFilePath is passing.
*
* ---
* ### Related Methods:
* 📌 `fromZip()` — Recommended alternative for rendering from HTML file when running inside Docker.
*/
static fromHtml(htmlStringOrHtmlFilePath: string, options?: {
/**
* Apply renderOptions if PdfInput is a {@link HtmlString} or {@link HtmlFilePath} or {@link ZipFilePath} or {@link Url}}
* @default undefined
*/
renderOptions?: ChromePdfRenderOptions | undefined;
} | undefined): Promise<PdfDocument>;
/**
* Converts multiple image files to a PDF document. Each image creates 1 page which matches the image
* dimensions. The default PaperSize is A4. You can set it via ImageToPdfConverter.PaperSize.
* Note: Imaging.ImageBehavior.CropPage will set PaperSize equal to ImageSize.
* @param images The image file path name(s) or {@link ImageBuffer} object(s)
* @param options including {@link ImageToPdfOptions}
*/
static fromImage(images: ImageFilePath | ImageFilePath[] | ImageBuffer | ImageBuffer[], options?: {
/**
* Apply renderOptions if PdfInput is a {@link HtmlString} or {@link HtmlFilePath} or {@link ZipFilePath} or {@link Url}}
* @default undefined
*/
imageToPdfOptions?: ImageToPdfOptions | undefined;
}): Promise<PdfDocument>;
/**
* Static method that joins (concatenates) multiple PDF documents together into one compiled PDF document.
* If the PDF contains form fields the form field in the resulting PDF's name will be appended with '_{index}' e.g. 'Name' will be 'Name_0'
* @param pdfs array of PDF
*/
static mergePdf(pdfs: PdfInput[]): Promise<PdfDocument>;
/**
* Saves the PdfDocument to a file.
* @param filePath Target file path
* @param saveOptions see {@link SaveOptions}
*/
saveAs(filePath: string, saveOptions?: SaveOptions | undefined): Promise<void>;
/**
* Saves the PdfDocument to a binary (Buffer)
* @param saveOptions see {@link SaveOptions}
*/
saveAsBuffer(saveOptions?: SaveOptions | undefined): Promise<Buffer>;
/**
* Compress existing PDF images using JPG encoding and the specified settings.
* @deprecated Use {@link compressAndSaveAs}, {@link compressPdfToBytes}, or {@link compressPdfToStream} instead for better compression results.
* @param imageQuality Quality (1 - 100) to use during compression
* @param scaleToVisibleSize Scale down the image resolution according to its visible size in the PDF document
*/
compressSize(imageQuality: number, scaleToVisibleSize?: boolean): Promise<void>;
/**
* Remove document struct tree information which describes the logical layout of the document.
* Removing the "structure tree" can significantly reduce the disk space used by the document.
* Removing the "structure tree" of a complicated document can negatively impact text selection.
*/
compressStructTree(): Promise<void>;
/**
* Compress the PDF and return the result as a Buffer (byte array).
* Uses QPdf compression which can significantly reduce file size.
* @param imageQuality Optional JPEG quality (1-100) for image compression. If omitted, default compression is applied.
* @returns A Promise resolving to a Buffer containing the compressed PDF bytes.
*/
compressPdfToBytes(imageQuality?: number): Promise<Buffer>;
/**
* Compress the PDF and return the result as a Readable stream.
* Uses QPdf compression which can significantly reduce file size.
* Useful for piping directly to file streams or HTTP responses without buffering the entire PDF in memory.
* @param imageQuality Optional JPEG quality (1-100) for image compression. If omitted, default compression is applied.
* @returns A Promise resolving to a Readable stream of the compressed PDF bytes.
*/
compressPdfToStream(imageQuality?: number): Promise<Readable>;
/**
* Compress the PDF and save the result directly to a file.
* Uses QPdf compression which can significantly reduce file size.
* @param filePath The output file path to save the compressed PDF.
* @param imageQuality Optional JPEG quality (1-100) for image compression. If omitted, default compression is applied.
*/
compressAndSaveAs(filePath: string, imageQuality?: number): Promise<void>;
/**
* Linearize the current PDF document and return the result as a {@link Buffer} (byte array).
* Produces a web-optimized PDF that can be viewed incrementally in a browser.
*
* @param mode Linearization strategy. Defaults to {@link LinearizationMode.Automatic}.
* @returns A Promise resolving to a Buffer containing the linearized PDF bytes.
*/
linearizePdfToBytes(mode?: LinearizationMode): Promise<Buffer>;
/**
* Linearize the current PDF document and return the result as a {@link Readable} stream.
* Useful for piping directly to file streams or HTTP responses without buffering the
* entire PDF in memory.
*
* <b>Note:</b> Stream output is only supported with {@link LinearizationMode.InMemory}
* (or {@link LinearizationMode.Automatic} when memory mode is selected). For
* {@link LinearizationMode.FileBased} use {@link linearizePdfToBytes} or
* {@link saveAsLinearized}.
*
* @returns A Promise resolving to a Readable stream of the linearized PDF bytes.
*/
linearizePdfToStream(): Promise<Readable>;
/**
* Linearize the current PDF document and save the result to the given output file path.
*
* @param outputFilePath The file path to save the linearized PDF.
* @param mode Linearization strategy. Defaults to {@link LinearizationMode.Automatic}.
*/
saveAsLinearized(outputFilePath: string, mode?: LinearizationMode): Promise<void>;
/**
* Check whether the PDF file at the given path is linearized ("Fast Web View").
*
* @param pdfFilePath Path to a PDF file on disk.
* @param password Optional password for encrypted PDFs.
* @returns A Promise resolving to true if the file is linearized, false otherwise.
*/
static isLinearized(pdfFilePath: string, password?: string): Promise<boolean>;
/**
* Linearize the given PDF bytes and return the linearized bytes.
* Static helper for linearizing PDFs without creating a PdfDocument instance.
*
* @param pdfBytes Buffer containing the PDF data.
* @param password Optional password to decrypt the PDF if encrypted.
* @param mode Linearization strategy. Defaults to {@link LinearizationMode.Automatic}.
*/
static linearizePdfBytesToBytes(pdfBytes: Buffer, password?: string, mode?: LinearizationMode): Promise<Buffer>;
/**
* Linearize the given PDF bytes and save the result to the given output file path.
* Static helper for linearizing PDFs without creating a PdfDocument instance.
*
* @param pdfBytes Buffer containing the PDF data.
* @param outputFilePath The file path to save the linearized PDF.
* @param password Optional password to decrypt the PDF if encrypted.
* @param mode Linearization strategy. Defaults to {@link LinearizationMode.Automatic}.
*/
static saveAsLinearizedFromBytes(pdfBytes: Buffer, outputFilePath: string, password?: string, mode?: LinearizationMode): Promise<void>;
/**
* Retrieves the rendered page locations of HTML elements that were tracked during rendering.
*
* To use this feature, set {@link ChromePdfRenderOptions.elementQuerySelectors} with CSS
* selectors before rendering. After rendering, call this method to retrieve the page index
* and coordinates of each matched element.
*
* Results are cached on first call and reused on subsequent calls. If you modify the
* document's annotations after rendering, call {@link resetElementLocationCache} to force
* the cache to be rebuilt on next access.
*
* Mirrors {@code IronPdf.PdfDocument.GetElementLocations()} on the C# side.
*
* @returns A list of {@link RenderedElementLocation} objects, one per matched element,
* sorted in document order. Returns an empty list if no element query selectors were
* configured or no elements matched.
*/
getElementLocations(): Promise<RenderedElementLocation[]>;
/**
* Clears the cached result of {@link getElementLocations}, forcing a fresh scan of the
* document's annotations on the next call. Call this if you've modified the document's
* annotations or structure after rendering.
*/
resetElementLocationCache(): void;
/**
* Retrieves all outline bookmarks (table-of-contents entries) in this PDF document.
*
* <p>Bookmarks are returned as a flat list with parent linkage via
* {@link Bookmark.parentItemId}. Roots have an empty {@code parentItemId}.
* Use {@link Bookmark.hierarchy} for depth information.</p>
*
* <p>Auto-bookmarks generated from HTML headings (via
* {@link ChromePdfRenderOptions.autoBookmarksFromHeadings}) are included.</p>
*
* <p>Mirrors {@code IronPdf.PdfDocument.Bookmarks} on the C# side.</p>
*
* @returns A list of {@link Bookmark} objects, sorted in document order.
* Returns an empty list if the document has no bookmarks.
*/
getBookmarks(): Promise<Bookmark[]>;
/**
* Adds a clickable internal hyperlink annotation that navigates to another page within
* the same PDF document. Useful for building custom tables of contents, cross-references,
* and in-document navigation.
*
* The target page and display options are configured via the {@link LinkAnnotation}
* fields ({@code destinationPageIndex}, {@code destinationType}, etc.).
*
* Mirrors {@code IronPdf.Annotations.LinkAnnotation} on the C# side.
*
* @example
* ```ts
* await pdf.addLinkAnnotation({
* pageIndex: 0,
* destinationPageIndex: 3,
* x: 72, y: 700,
* width: 300, height: 18,
* contents: "Chapter 1",
* });
* ```
*/
addLinkAnnotation(link: LinkAnnotation): Promise<void>;
/**
* Retrieves the number of annotations contained on the specified page.
*
* @param pageIndex Zero-based page index. The first page has a page index of 0.
*/
getAnnotationCount(pageIndex: number): Promise<number>;
/**
* Gets information of all pages in the PdfDocument
*/
getPagesInfo(): Promise<PageInfo[]>;
/**
* Gets the number of pages in the PdfDocument.
*/
getPageCount(): Promise<number>;
/**
* Set the page orientation.
* @param pageRotation see {@link PageRotation}
* @param options including {@link PdfPageSelection}
*/
setRotation(pageRotation: PageRotation, options?: {
/**
* @default "all"
*/
pdfPageSelection?: PdfPageSelection | undefined;
} | undefined): Promise<void>;
/**
* Resize a page to the specified dimensions
* @param newSize {@link PdfPaperSize}
* @param options including {@link PdfPageSelection}
*/
resize(newSize: PdfPaperSize, options?: {
/**
* @default "all"
*/
pdfPageSelection?: PdfPageSelection | undefined;
} | undefined): Promise<void>;
/**
* Adds another PDF to the beginning of the current PdfDocument
* If AnotherPdfFile contains form fields, those fields will be appended with '_' in the resulting PDF. e.g. 'Name' will be 'Name_'
* @param fromPdfDocument PdfDocument to prepend
*/
prependAnotherPdf(fromPdfDocument: PdfDocument): Promise<void>;
/**
* Appends another PDF to the end of the current <see cref="PdfDocument"/>
* If AnotherPdfFile contains form fields, those fields will be appended with '_' in the resulting PDF. e.g. 'Name' will be 'Name_'
* @param fromPdfDocument PdfDocument to Append
*/
appendAnotherPdf(fromPdfDocument: PdfDocument): Promise<void>;
/**
* Inserts another PDF into the current PdfDocument, starting at a given Page Index.
* If AnotherPdfFile contains form fields, those fields will be appended with '_' in the resulting PDF. e.g. 'Name' will be 'Name_'
* @param fromPdfDocument Another PdfDocument
* @param insertAtPageIndex Index at which to insert the new content. Note: Page 1 has index 0...
*/
insertPagesFromAnotherPdf(fromPdfDocument: PdfDocument, insertAtPageIndex: number): Promise<void>;
/**
* Removes a range of pages from the PDF
* @param pages pages to remove
*/
removePage(pages: PdfPageSelection): Promise<void>;
/**
* Creates a new PDF by copying a range of pages from this {@link PdfDocument}.
* @param pages pages to copy (default "all")
*/
duplicate(pages?: PdfPageSelection): Promise<PdfDocument>;
/**
* Finds all embedded Images from within a specified pages in the PDF and returns them as Buffer
* @param options including {@link PdfPageSelection}
*/
extractRawImages(options?: {
/**
* @default "all"
*/
fromPages?: PdfPageSelection;
} | undefined): Promise<Buffer[]>;
/**
* Renders the PDF and exports image Files in convenient formats. 1 image file is created for each
* page.
*
* @param options including {@link PdfPageSelection} {@link ImageType}
*
* @return array of images as Buffer[]
*/
rasterizeToImageBuffers(options?: {
/**
* @default "all"
*/
fromPages?: PdfPageSelection | undefined;
/**
* @default {@link ImageType.PNG}
*/
imageType?: ImageType | undefined;
} | undefined): Promise<Buffer[]>;
/**
* Renders the PDF and exports image Files in convenient formats. 1 image file is created for each
* page. Running number will append output file path.
*
* @param filePath output file path.
* @param options including {@link PdfPageSelection} {@link ImageType}
*
* @return array of images file name as string[]
*/
rasterizeToImageFiles(filePath: string, options?: {
/**
* @default "all"
*/
fromPages?: PdfPageSelection | undefined;
/**
* @default {@link ImageType.PNG}
*/
type?: ImageType | undefined;
} | undefined): Promise<string[]>;
/**
* Replace the specified old text with new text on a given page
* @param oldText Old text to remove
* @param newText New text to add
* @param onPages Page index to search for old text to replace (default "all")
*/
replaceText(oldText: string, newText: string, onPages?: PdfPageSelection | undefined): Promise<void>;
extractText(onPages?: PdfPageSelection | undefined): Promise<string>;
/**
* Convert the current document into the specified PDF-A standard format
* @param pdfaVersion The PDF/A version to convert to (default: PdfA3b)
* @param customICC (Optional) Custom color profile file path
*/
convertToPdfA(pdfaVersion?: PdfAVersions, customICC?: string | undefined): Promise<void>;
/**
* Render HTML to PDF and convert to PDF/UA format with screen reader support.
* Produces a proper semantic structure tree (Sect → H1, P, etc.) for accessibility.
* @param html The HTML string to render
* @param naturalLanguages Document language for screen readers (default: English)
* @param options Optional render options
*/
static fromHtmlAsPdfUA(html: string, naturalLanguages?: NaturalLanguages, options?: {
renderOptions?: ChromePdfRenderOptions | undefined;
} | undefined): Promise<PdfDocument>;
/**
* Convert the current document into the specified PDF/UA standard format
*/
convertToPdfUA(naturalLanguages: NaturalLanguages, pdfUaVersion?: PdfUAVersions): Promise<void>;
/**
* Gets a Map<string, string> of metadata properties
*/
getMetadata(): Promise<Map<string, string>>;
/**
* Add or Update a single metadata property
* @param key
* @param value
*/
addOrUpdateMetadata(key: string, value: string): Promise<void>;
/**
* Remove a single metadata property
* @param key
*/
removeMetadata(key: string): Promise<void>;
/**
* Sets a whole metadata properties Map<string, string> (override all the metadata property)
* @param newMetadataDictionary new metadata properties Map<string, string>
*/
overrideMetadata(newMetadataDictionary: Map<string, string>): Promise<void>;
/**
* Sign PDF with digital signature certificate.
* Note that the PDF will not be fully signed until Saved
* using {@link saveAs} or {@link saveAsBuffer}
*
* Multiple certificates may be used.
* @param signature see {@link DigitalSignature}
*/
signDigitalSignature(signature: DigitalSignature): Promise<void>;
/**
* Check if PdfDocument was signed or not
*/
isSigned(): Promise<boolean>;
/**
* Count the number signature that signed to this PdfDocument
*/
signatureCount(): Promise<number>;
/**
* Get all verified digital signatures from this PdfDocument.
* Returns details including signature name, signer contact, reason, location, date, and validity.
* @returns A Promise resolving to an array of {@link VerifiedSignature} objects.
*/
getVerifiedSignatures(): Promise<VerifiedSignature[]>;
/**
* Apply page header on top of an existing Pdf.
* @param header {@link TextAffix}
* @param toPages {@link PdfPageSelection}
*/
addTextHeader(header: TextAffix, toPages?: PdfPageSelection | undefined): Promise<void>;
/**
* Apply page footer on top of an existing Pdf.
* @param footer {@link TextAffix}
* @param toPages {@link PdfPageSelection}
*/
addTextFooter(footer: TextAffix, toPages?: PdfPageSelection | undefined): Promise<void>;
/**
* Apply HTML header on top of an existing Pdf.
* @param header {@link HtmlAffix}
* @param toPages {@link PdfPageSelection}
*/
addHtmlHeader(header: HtmlAffix, toPages?: PdfPageSelection | undefined): Promise<void>;
/**
* Apply HTML footer on top of an existing Pdf.
* @param footer {@link HtmlAffix}
* @param toPages {@link PdfPageSelection}
*/
addHtmlFooter(footer: HtmlAffix, toPages?: PdfPageSelection | undefined): Promise<void>;
/**
* Edits the PDF by applying the HTML's rendered to only selected page(s).
* @param htmlStringOrHtmlFilePath
* @param options including {@link HtmlStampOptions} {@link PdfPageSelection}
*/
stampHtml(htmlStringOrHtmlFilePath: HtmlFilePath | HtmlString, options?: {
htmlStampOptions?: HtmlStampOptions | undefined;
toPages?: PdfPageSelection | undefined;
} | undefined): Promise<void>;
/**
* Edits the PDF by applying the image to only selected page(s).
* @param image image file path or image buffer
* @param options including {@link ImageStampOptions} {@link PdfPageSelection}
*/
stampImage(image: ImageFilePath | ImageBuffer, options?: {
imageStampOptions?: ImageStampOptions | undefined;
toPages?: PdfPageSelection | undefined;
} | undefined): Promise<void>;
/**
* Edits the PDF by applying the text to only selected page(s).
* @param text text to stamp
* @param options including {@link TextStampOptions} {@link PdfPageSelection}
*/
stampText(text: string, options?: {
textStampOptions?: TextStampOptions | undefined;
toPages?: PdfPageSelection | undefined;
} | undefined): Promise<void>;
/**
* Edits the PDF by applying the barcode to only selected page(s).
* @param barcodeValue barcode
* @param options including {@link BarcodeType} {@link BarcodeStampOptions} {@link PdfPageSelection}
*/
stampBarcode(barcodeValue: string, options?: {
barcodeEncoding: BarcodeType;
barcodeStampOptions?: BarcodeStampOptions | undefined;
toPages?: PdfPageSelection | undefined;
} | undefined): Promise<void>;
/**
* Adds a background to each page of this PDF. The background is copied from a first page in the
* backgroundPdf document.
*
* @param fromPdf background PDF document
* @param sourcePageIndex Index (zero-based page number) of the page to copy from the Background/Foreground PDF. Default is 0.
* @param applyToPages PageSelection to which the background/foreground will be added. Default is "all"
*/
addBackgroundFromAnotherPdf(fromPdf: PdfDocument, sourcePageIndex?: number, applyToPages?: PdfPageSelection | undefined): Promise<void>;
/**
* Adds a foreground to each page of this PDF. The background is copied from a first page in the
* backgroundPdf document.
*
* @param fromPdf foreground PDF document
* @param sourcePageIndex Index (zero-based page number) of the page to copy from the Background/Foreground PDF. Default is 0.
* @param applyToPages PageSelection to which the background/foreground will be added. Default is "all"
*/
addForegroundFromAnotherPdf(fromPdf: PdfDocument, sourcePageIndex?: number, applyToPages?: PdfPageSelection | undefined): Promise<void>;
/**
* Removes all user and owner password security for a PDF document. Also disables content
* encryption.
* If content is encrypted at 128 bit, copy and paste of content, annotations and form editing may be disabled.
*/
removePasswordsAndEncryption(): Promise<void>;
/**
* Sets the user password and enables 128Bit encryption of PDF content.
* A user password is a password that each user must enter to open or print the PDF document.
*/
setUserPassword(userPassword: string): Promise<void>;
/**
* Sets the owner password and enables 128Bit encryption of PDF content. An owner password is one used to
* enable and disable all other security settings. <para>OwnerPassword must be set to a non-empty string
* value for {@link PdfPermission.AllowAccessibilityExtractContent} , {@link PdfPermission.AllowAnnotations} ,
* {@link PdfPermission.AllowFillForms}, {@link PdfPermission.AllowPrint}, {@link PdfPermission.AllowModify} to be
* restricted.
*/
setOwnerPassword(ownerPassword: string): Promise<void>;
/**
* Sets the permissions of this PdfDocument
* @param permissions see {@link PdfPermission}
*/
setPermission(permissions: PdfPermission): Promise<void>;
/**
* Gets the current permissions of this PdfDocument
* @return {@link PdfPermission}
*/
getPermission(): Promise<PdfPermission>;
/**
* Makes this PDF document read only such that: Content is encrypted at 128 bit. Copy and paste of
* content is disallowed. Annotations and form editing are disabled.
* @param ownerPassword The owner password for the PDF. A string for owner password is required to enable PDF encryption and
* all document security options.
*/
makePdfDocumentReadOnly(ownerPassword: string): Promise<void>;
/**
* Dispose this PdfDocument object (clean up the resource)
* This is necessary to free the memory used by PdfDocument. See {@link cleanUp}
* Once this method was called this PdfDocument object no longer usable.
*/
close(): Promise<void>;
/**
* Internal PDF document ID
* @private
*/
private pdfDocumentId?;
/**
* @private
*/
private readonly promiseDocumentId?;
/**
* @private
*/
private pdfPassword?;
/**
* Create a PdfDocument object from a {@link PdfInput}
* For more specific way to create/open PdfDocument see {@link fromUrl} {@link fromZip} {@link fromHtml} {@link fromImage} {@link open}
*
* @param pdfInput see {@link PdfInput} (required) (pdfInput is {@link PdfFilePath} or {@link Buffer})
* @param password a password to open the PDF required if PDF file was private.
* @param trackChanges Optionally track changes to the document (for use with incremental saves)
*/
constructor(pdfInput?: PdfInput | undefined, password?: PdfPassword | undefined, trackChanges?: ChangeTrackingModes | undefined);
/**
* Dispose this PdfDocument object (clean up the resource)
* This is necessary to free the memory used by PdfDocument. See {@link cleanUp}
* Once this method was called this PdfDocument object no longer usable.
*/
private internal_close;
/**
* @private
*/
private internal_getId;
/**
* Open or Create a PdfDocument from a {@link PdfInput}
* @param pdfInput {@link PdfInput}
* @param options including {@link PdfPassword} {@link ChromePdfRenderOptions} {@link HttpLoginCredentials} mainHtmlFile
*/
private static internal_open;
/**
* Open a PdfDocument from .pdf file
* @param pdfFilePath A path to .pdf file
* @param Optionally track changes to the document (for use with incremental saves)
*/
private static internal_fromFile;
/**
* Create a PdfDocument from an Url
* @param url A website Url
* @param options including {@link ChromePdfRenderOptions}
*/
private static internal_fromUrl;
/**
* Creates a PDF file from a local Zip file, and returns it as a {@link PdfDocument}.
* IronPDF is a W3C standards compliant HTML rendering based on Google's Chromium browser.
* If your output PDF does not look as expected:
*
* - Validate your HTML file using https://validator.w3.org/ & CSS https://jigsaw.w3.org/css-validator/
*
* - To debug HTML, view the file in Chrome web browser's print preview which will work almost exactly as IronPDF.
*
* - Read our detailed documentation on pixel perfect HTML to PDF: https://ironpdf.com/tutorials/pixel-perfect-html-to-pdf/
*
* @param zipFilePath Path to a Zip to be rendered as a PDF.
* @param options including {@link ChromePdfRenderOptions} and `mainHtmlFile` a main .html file default: `index.html`
*/
private static internal_fromZip;
/**
* Creates a PDF file from a Html string, and returns it as an {@link PdfDocument} object which can be edited and saved to disk or served on a website.
* @param htmlStringOrHtmlFilePath The Html to be rendered as a PDF.
* @param options including {@link ChromePdfRenderOptions}
*/
private static internal_fromHtml;
/**
* Converts multiple image files to a PDF document. Each image creates 1 page which matches the image
* dimensions. The default PaperSize is A4. You can set it via ImageToPdfConverter.PaperSize.
* Note: Imaging.ImageBehavior.CropPage will set PaperSize equal to ImageSize.
* @param images The image file path name(s) or {@link ImageBuffer} object(s)
* @param options including {@link ImageToPdfOptions}
*/
private static internal_fromImage;
/**
* Static method that joins (concatenates) multiple PDF documents together into one compiled PDF document.
* If the PDF contains form fields the form field in the resulting PDF's name will be appended with '_{index}' e.g. 'Name' will be 'Name_0'
* @param pdfs array of PDF
*/
private static internal_mergePdf;
/**
* Saves the PdfDocument to a file.
* @param filePath Target file path
* @param saveOptions see {@link SaveOptions}
*/
private internal_saveAs;
/**
* Saves the PdfDocument to a binary (Buffer)
* @param saveOptions see {@link SaveOptions}
*/
private internal_saveAsBuffer;
/**
* Compress existing PDF images using JPG encoding and the specified settings
* @param imageQuality Quality (1 - 100) to use during compression
* @param scaleToVisibleSize Scale down the image resolution according to its visible size in the PDF document
*/
private internal_compressSize;
/**
* Remove document struct tree information which describes the logical layout of the document.
* Removing the "structure tree" can significantly reduce the disk space used by the document.
* Removing the "structure tree" of a complicated document can negatively impact text selection.
*/
private internal_compressStructTree;
/**
* Compress the PDF and return the result as a Buffer (byte array).
* Uses QPdf compression which can significantly reduce file size.
* @param imageQuality Optional JPEG quality (1-100) for image compression. If omitted, default compression is applied.
*/
private internal_compressPdfToBytes;
/**
* Compress the PDF and return the result as a Readable stream.
* Uses QPdf compression which can significantly reduce file size.
* Useful for piping directly to file streams or HTTP responses without buffering the entire PDF in memory.
* @param imageQuality Optional JPEG quality (1-100) for image compression. If omitted, default compression is applied.
*/
private internal_compressPdfToStream;
/**
* Compress the PDF and save the result directly to a file.
* Uses QPdf compression which can significantly reduce file size.
* @param filePath The output file path to save the compressed PDF.
* @param imageQuality Optional JPEG quality (1-100) for image compression. If omitted, default compression is applied.
*/
private internal_compressAndSaveAs;
/**
* Linearize the current PDF document and return the result as a Buffer.
*/
private internal_linearizePdfToBytes;
/**
* Linearize the current PDF document and return the result as a Readable stream.
* Always uses the in-memory streaming RPC.
*/
private internal_linearizePdfToStream;
/**
* Linearize the current PDF document and save the result to the given output file path.
*/
private internal_saveAsLinearized;
/**
* Prefix used by the engine-side element query JavaScript extension when injecting anchor
* markers. Must match {@code IronPdf.TableOfContents.ElementQueryJavascriptExtension.ELEMENT_QUERY_PREFIX}
* on the C# side.
*/
private static readonly ELEMENT_QUERY_PREFIX;
/**
* Cache for {@link getElementLocations}. Built lazily on first call.
*
* The underlying element-query anchor annotations are written during rendering and are
* not expected to be mutated afterwards, so a simple populate-once cache is appropriate.
* Callers who modify the document's annotations after rendering should call
* {@link resetElementLocationCache} to force a rebuild.
*/
private cachedElementLocations;
private internal_getElementLocations;
private internal_addLinkAnnotation;
private internal_getAnnotationCount;
private internal_getBookmarks;
/**
* Gets information of all pages in the PdfDocument
*/
private internal_getPagesInfo;
/**
* Gets the number of pages in the PdfDocument.
*/
private internal_getPageCount;
/**
* Set the page orientation.
* @param pageRotation see {@link PageRotation}
* @param options including {@link PdfPageSelection}
*/
private internal_setRotation;
/**
* Resize a page to the specified dimensions
* @param newSize {@link PdfPaperSize}
* @param options including {@link PdfPageSelection}
*/
private internal_resize;
/**
* Adds another PDF to the beginning of the current PdfDocument
* If AnotherPdfFile contains form fields, those fields will be appended with '_' in the resulting PDF. e.g. 'Name' will be 'Name_'
* @param fromPdfDocument PdfDocument to prepend
*/
private internal_prependAnotherPdf;
/**
* Appends another PDF to the end of the current <see cref="PdfDocument"/>
* If AnotherPdfFile contains form fields, those fields will be appended with '_' in the resulting PDF. e.g. 'Name' will be 'Name_'
* @param fromPdfDocument PdfDocument to Append
*/
private internal_appendAnotherPdf;
/**
* Inserts another PDF into the current PdfDocument, starting at a given Page Index.
* If AnotherPdfFile contains form fields, those fields will be appended with '_' in the resulting PDF. e.g. 'Name' will be 'Name_'
* @param fromPdfDocument Another PdfDocument
* @param insertAtPageIndex Index at which to insert the new content. Note: Page 1 has index 0...
*/
private internal_insertPagesFromAnotherPdf;
/**
* Removes a range of pages from the PDF
* @param pages pages to remove
*/
private internal_removePage;
/**
* Creates a new PDF by copying a range of pages from this {@link PdfDocument}.
* @param pages pages to copy (default "all")
*/
private internal_duplicate;
/**
* Finds all embedded Images from within a specified pages in the PDF and returns them as Buffer
* @param options including {@link PdfPageSelection}
*/
private internal_extractRawImages;
/**
* Renders the PDF and exports image Files in convenient formats. 1 image file is created for each
* page.
*
* @param options including {@link PdfPageSelection} {@link ImageType}
*
* @return array of images as Buffer[]
*/
private internal_rasterizeToImageBuffers;
/**
* Renders the PDF and exports image Files in convenient formats. 1 image file is created for each
* page. Running number will append output file path.
*
* @param filePath output file path.
* @param options including {@link PdfPageSelection} {@link ImageType}
*
* @return array of images file name as string[]
*/
private internal_rasterizeToImageFiles;
/**
* Replace the specified old text with new text on a given page
* @param oldText Old text to remove
* @param newText New text to add
* @param onPages Page index to search for old text to replace (default "all")
*/
private internal_replaceText;
private internal_extractText;
/**
* Convert the current document into the specified PDF-A standard format
* @param pdfaVersion The PDF/A version to convert to
* @param customICC (Optional) Custom color profile file path
*/
private internal_convertToPdfA;
/**
* Convert the current document into the specified PDF/UA standard format
*/
private internal_convertToPdfUA;
/**
* Gets a Map<string, string> of metadata properties
*/
private internal_getMetadata;
/**
* Add or Update a single metadata property
* @param key
* @param value
*/
private internal_addOrUpdateMetadata;
/**
* Remove a single metadata property
* @param key
*/
private internal_removeMetadata;
/**
* Sets a whole metadata properties Map<string, string> (override all the metadata property)
* @param newMetadataDictionary new metadata properties Map<string, string>
*/
private internal_overrideMetadata;
/**
* Sign PDF with digital signature certificate.
* Note that the PDF will not be fully signed until Saved
* using {@link saveAs} or {@link saveAsBuffer}
*
* Multiple certificates may be used.
* @param signature see {@link DigitalSignature}
*/
private internal_signDigitalSignature;
/**
* Check if PdfDocument was signed or not
*/
private internal_isSigned;
/**
* Count the number signature that signed to this PdfDocument
*/
private internal_signatureCount;
/**
* Get all verified digital signatures from this PdfDocument.
*/
private internal_getVerifiedSignatures;
/**
* Apply page header on top of an existing Pdf.
* @param header {@link TextAffix}
* @param toPages {@link PdfPageSelection}
*/
private internal_addTextHeader;
/**
* Apply page footer on top of an existing Pdf.
* @param footer {@link TextAffix}
* @param toPages {@link PdfPageSelection}
*/
private internal_addTextFooter;
/**
* Apply HTML header on top of an existing Pdf.
* @param header {@link HtmlAffix}
* @param toPages {@link PdfPageSelection}
*/
private internal_addHtmlHeader;
/**
* Apply HTML footer on top of an existing Pdf.
* @param footer {@link HtmlAffix}
* @param toPages {@link PdfPageSelection}
*/
private internal_addHtmlFooter;
/**
* Edits the PDF by applying the HTML's rendered to only selected page(s).
* @param htmlStringOrHtmlFilePath
* @param options including {@link HtmlStampOptions} {@link PdfPageSelection}
*/
private internal_stampHtml;
/**
* Edits the PDF by applying the image to only selected page(s).
* @param image image file path or image buffer
* @param options including {@link ImageStampOptions} {@link PdfPageSelection}
*/
private internal_stampImage;
/**
* Edits the PDF by applying the text to only selected page(s).
* @param text text to stamp
* @param options including {@link TextStampOptions} {@link PdfPageSelection}
*/
private internal_stampText;
/**
* Edits the PDF by applying the barcode to only selected page(s).
* @param barcodeValue barcode
* @param options including {@link BarcodeType} {@link BarcodeStampOptions} {@link PdfPageSelection}
*/
private internal_stampBarcode;
/**
* Adds a background to each page of this PDF. The background is copied from a first page in the
* backgroundPdf document.
*
* @param fromPdf background PDF document
* @param sourcePageIndex Index (zero-based page number) of the page to copy from the Background/Foreground PDF. Default is 0.
* @param applyToPages PageSelection to which the background/foreground will be added. Default is "all"
*/
private internal_addBackgroundFromAnotherPdf;
/**
* Adds a foreground to each page of this PDF. The background is copied from a first page in the
* backgroundPdf document.
*
* @param fromPdf foreground PDF document
* @param sourcePageIndex Index (zero-based page number) of the page to copy from the Background/Foreground PDF. Default is 0.
* @param applyToPages PageSelection to which the background/foreground will be added. Default is "all"
*/
private internal_addForegroundFromAnotherPdf;
/**
* Removes all user and owner password security for a PDF document. Also disables content
* encryption.
* If content is encrypted at 128 bit, copy and paste of content, annotations and form editing may be disabled.
*/
private internal_removePasswordsAndEncryption;
/**
* Sets the user password and enables 128Bit encryption of PDF content.
* A user password is a password that each user must enter to open or print the PDF document.
*/
private internal_setUserPassword;
/**
* Sets the owner password and enables 128Bit encryption of PDF content. An owner password is one used to
* enable and disable all other security settings. <para>OwnerPassword must be set to a non-empty string
* value for {@link PdfPermission.AllowAccessibilityExtractContent} , {@link PdfPermission.AllowAnnotations} ,
* {@link PdfPermission.AllowFillForms}, {@link PdfPermission.AllowPrint}, {@link PdfPermission.AllowModify} to be
* restricted.
*/
private internal_setOwnerPassword;
/**
* Sets the permissions of this PdfDocument
* @param permissions see {@link PdfPermission}
*/
private internal_setPermission;
/**
* Gets the current permissions of this PdfDocument
* @return {@link PdfPermission}
*/
private internal_getPermission;
/**
* Makes this PDF document read only such that: Content is encrypted at 128 bit. Copy and paste of
* content is disallowed. Annotations and form editing are disabled.
* @param ownerPassword The owner password for the PDF. A string for owner password is required to enable PDF encryption and
* all document security options.
*/
private internal_makePdfDocumentReadOnly;
}
//# sourceMappingURL=pdfDocument.d.ts.map