///
///
///
import { Buffer } from "buffer";
import { BarcodeStampOptions, BarcodeType, ChangeTrackingModes, ChromePdfRenderOptions, DigitalSignature, VerifiedSignature, HtmlAffix, HtmlFilePath, HtmlStampOptions, HtmlString, HttpLoginCredentials, ImageBuffer, ImageFilePath, ImageStampOptions, ImageToPdfOptions, ImageType, PageInfo, PageRotation, PdfInput, PdfPageSelection, PdfPaperSize, PdfPassword, PdfPermission, SaveOptions, TextAffix, TextStampOptions } from "./types";
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;
/**
* 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;
/**
* 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;
/**
* 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;
/**
* 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;
/**
* 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;
/**
* 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;
/**
* Saves the PdfDocument to a file.
* @param filePath Target file path
* @param saveOptions see {@link SaveOptions}
*/
saveAs(filePath: string, saveOptions?: SaveOptions | undefined): Promise;
/**
* Saves the PdfDocument to a binary (Buffer)
* @param saveOptions see {@link SaveOptions}
*/
saveAsBuffer(saveOptions?: SaveOptions | undefined): Promise;
/**
* 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;
/**
* 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;
/**
* 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;
/**
* 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;
/**
* 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;
/**
* Gets information of all pages in the PdfDocument
*/
getPagesInfo(): Promise;
/**
* Gets the number of pages in the PdfDocument.
*/
getPageCount(): Promise;
/**
* 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;
/**
* 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;
/**
* 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;
/**
* Appends another PDF to the end of the current
* 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;
/**
* 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;
/**
* Removes a range of pages from the PDF
* @param pages pages to remove
*/
removePage(pages: PdfPageSelection): Promise;
/**
* 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;
/**
* 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;
/**
* 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;
/**
* 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;
/**
* 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;
extractText(onPages?: PdfPageSelection | undefined): Promise;
/**
* 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;
/**
* Convert the current document into the specified PDF/UA standard format
*/
convertToPdfUA(naturalLanguages: NaturalLanguages, pdfUaVersion?: PdfUAVersions): Promise;
/**
* Gets a Map of metadata properties
*/
getMetadata(): Promise