Create a PdfDocument object from a PdfInput For more specific way to create/open PdfDocment see fromUrl fromZip fromHtml fromImage open
Optional
pdfInput: PdfInputsee PdfInput (required)
Optional
password: PdfPassworda password to open the PDF required if PDF file was protected (pdfInput is PdfFilePath or Buffer)
Private
Optional
pdfInternal PDF document ID
Private
Optional
pdfPrivate
Optional
Readonly
promiseAdds a background to each page of this PDF. The background is copied from a first page in the backgroundPdf document.
background PDF document
Index (zero-based page number) of the page to copy from the Background/Foreground PDF. Default is 0.
Optional
applyToPages: PdfPageSelectionPageSelection to which the background/foreground will be added. Default is "all"
Adds a foreground to each page of this PDF. The background is copied from a first page in the backgroundPdf document.
foreground PDF document
Index (zero-based page number) of the page to copy from the Background/Foreground PDF. Default is 0.
Optional
applyToPages: PdfPageSelectionPageSelection to which the background/foreground will be added. Default is "all"
Apply HTML footer on top of an existing Pdf.
Optional
toPages: PdfPageSelectionApply HTML header on top of an existing Pdf.
Optional
toPages: PdfPageSelectionApply page footer on top of an existing Pdf.
Optional
toPages: PdfPageSelectionApply page header on top of an existing Pdf.
Optional
toPages: PdfPageSelectionAppends another PDF to the end of the current
PdfDocument to Append
Dispose this PdfDocument object (clean up the resource) This is necessary to free the memory used by PdfDocument. See cleanUp Once this method was called this PdfDocument object no longer usable.
Compress existing PDF images using JPG encoding and the specified settings
Quality (1 - 100) to use during compression
Scale down the image resolution according to its visible size in the PDF document
Creates a new PDF by copying a range of pages from this PdfDocument.
pages to copy (default "all")
Finds all embedded Images from within a specified pages in the PDF and returns them as Buffer
Optional
options: { including PdfPageSelection
"all"
Optional
onPages: PdfPageSelectionPrivate
getGets the current permissions of this PdfDocument
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'
Another PdfDocument
Index at which to insert the new content. Note: Page 1 has index 0...
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.
The owner password for the PDF. A string for owner password is required to enable PDF encryption and all document security options.
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'
PdfDocument to prepend
Renders the PDF and exports image Files in convenient formats. 1 image file is created for each page.
Optional
options: { including PdfPageSelection ImageType
"all"
Optional
image{@link ImageType.PNG}
array of images as 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.
output file path.
Optional
options: { including PdfPageSelection ImageType
Optional
from"all"
Optional
type?: ImageType{@link ImageType.PNG}
array of images file name as string[]
Removes a range of pages from the PDF
pages to remove
Replace the specified old text with new text on a given page
Old text to remove
New text to add
Optional
onPages: PdfPageSelectionPage index to search for old text to replace (default "all")
Resize a page to the specified dimensions
Optional
options: { including PdfPageSelection
Optional
Pdf"all"
Saves the PdfDocument to a file.
Target file path
Optional
saveOptions: SaveOptionssee SaveOptions
Saves the PdfDocument to a binary (Buffer)
Optional
saveOptions: SaveOptionssee SaveOptions
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.
Sets the permissions of this PdfDocument
see PdfPermission
Set the page orientation.
see PageRotation
Optional
options: { including PdfPageSelection
Optional
pdf"all"
Sign PDF with digital signature certificate. Note that the PDF will not be fully signed until Saved using saveAs or saveAsBuffer
Multiple certificates may be used.
see DigitalSignature
Edits the PDF by applying the barcode to only selected page(s).
barcode
Optional
options: { including BarcodeType HtmlStampOptions PdfPageSelection
Optional
options?: BarcodeStampOptionsOptional
toEdits the PDF by applying the HTML's rendered to only selected page(s).
Optional
options: { including HtmlStampOptions PdfPageSelection
Optional
htmlOptional
toEdits the PDF by applying the image to only selected page(s).
image file path or image buffer
Optional
options: { including HtmlStampOptions PdfPageSelection
Optional
imageOptional
toEdits the PDF by applying the text to only selected page(s).
text to stamp
Optional
options: { including HtmlStampOptions PdfPageSelection
Optional
imageOptional
toStatic
fromOpen a PdfDocument from .pdf file
A path to .pdf file
Static
fromCreates a PDF file from a Html string, and returns it as an PdfDocument object which can be edited and saved to disk or served on a website.
The Html to be rendered as a PDF.
Optional
options: { including ChromePdfRenderOptions
Optional
renderApply renderOptions if PdfInput is a HtmlString or HtmlFilePath or ZipFilePath or Url}
undefined
Static
fromConverts 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.
The image file path name(s) or ImageBuffer object(s)
Optional
options: { including ImageToPdfOptions
Optional
imageApply renderOptions if PdfInput is a HtmlString or HtmlFilePath or ZipFilePath or Url}
undefined
Static
fromCreate a PdfDocument from an Url
A website Url
Optional
options: { including ChromePdfRenderOptions
Optional
renderApply renderOptions if PdfInput is a HtmlString or HtmlFilePath or ZipFilePath or Url}
undefined
Static
fromCreates a PDF file from a local Zip file, and returns it as a 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/
Path to a Zip to be rendered as a PDF.
Optional
options: { including ChromePdfRenderOptions and mainHtmlFile
a main .html file default: index.html
Optional
maina main .html file default: index.html
Optional
renderApply renderOptions if PdfInput is a HtmlString or HtmlFilePath or ZipFilePath or Url}
undefined
Static
mergeStatic 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'
array of PDF
Static
openOpen or Create a PdfDocument from a PdfInput
Optional
options: { including PdfPassword ChromePdfRenderOptions HttpLoginCredentials mainHtmlFile
Optional
httpApply httpLoginCredentials if PdfInput is a HtmlString or HtmlFilePath or ZipFilePath or Url}
undefined
Optional
mainApply mainHtmlFile if PdfInput is ZipFilePath
index.html
Optional
password?: PdfPasswordrequired for open a protected PDF file
undefined
Optional
renderApply renderOptions if PdfInput is a HtmlString or HtmlFilePath or ZipFilePath or Url}
undefined
Generated using TypeDoc
Represents a PDF document. Allows: loading, editing, manipulating, merging, signing printing and saving PDFs.
Remark
Make sure that you call close or cleanUp to free the memory, when you stop using the PdfDocument object.