public class PdfDocument extends Object implements Printable, AutoCloseable
NO_SUCH_PAGE, PAGE_EXISTS| Constructor and Description |
|---|
PdfDocument(byte[] pdfData)
Opens an existing PDF document for editing.
|
PdfDocument(byte[] pdfData,
ChangeTrackingModes trackChanges)
Opens an existing PDF document for editing.
|
PdfDocument(byte[] pdfData,
String password)
Opens an existing PDF document for editing.
|
PdfDocument(byte[] pdfData,
String password,
ChangeTrackingModes trackChanges)
Opens an existing PDF document for editing.
|
PdfDocument(byte[] pdfData,
String password,
String ownerPassword)
Opens an existing PDF document for editing.
|
PdfDocument(byte[] pdfData,
String password,
String ownerPassword,
ChangeTrackingModes trackChanges)
Opens an existing PDF document for editing.
|
PdfDocument(Path pdfFilePath)
Opens an existing PDF document for editing.
|
PdfDocument(Path pdfFilePath,
ChangeTrackingModes trackChanges)
Opens an existing PDF document for editing.
|
PdfDocument(Path pdfFilePath,
String password)
Opens an existing PDF document for editing.
|
PdfDocument(Path pdfFilePath,
String password,
ChangeTrackingModes trackChanges)
Opens an existing PDF document for editing.
|
PdfDocument(Path pdfFilePath,
String password,
String ownerPassword)
Opens an existing PDF document for editing.
|
PdfDocument(Path pdfFilePath,
String password,
String ownerPassword,
ChangeTrackingModes trackChanges)
Opens an existing PDF document for editing.
|
| Modifier and Type | Method and Description |
|---|---|
PdfDocument |
addBackgroundPdf(PdfDocument backgroundPdf)
Adds a background to each page of this PDF.
|
PdfDocument |
addBackgroundPdf(PdfDocument backgroundPdf,
int backgroundPdfPageIndex)
Adds a background to each page of this PDF.
|
PdfDocument |
addBackgroundPdf(PdfDocument backgroundPdf,
int backgroundPdfPageIndex,
PageSelection pageSelection)
Adds a background to selected page(s) of this PDF.
|
PdfDocument |
addBackgroundPdf(PdfDocument backgroundPdf,
PageSelection pageSelection)
Adds a background to selected page(s) of this PDF.
|
PdfDocument |
addForegroundPdf(PdfDocument foregroundPdf)
Adds a foreground to each page of this PDF.
|
PdfDocument |
addForegroundPdf(PdfDocument foregroundPdf,
int foregroundPdfPageIndex)
Adds a foreground to each page of this PDF.
|
PdfDocument |
addForegroundPdf(PdfDocument foregroundPdf,
int foregroundPdfPageIndex,
PageSelection pageSelection)
Adds a foreground to selected page(s) of this PDF.
|
PdfDocument |
addForegroundPdf(PdfDocument foregroundPdf,
PageSelection pageSelection)
Adds a foreground to selected page(s) of this PDF.
|
PdfDocument |
addHtmlFooter(HtmlHeaderFooter footer)
Renders HTML page footers onto an existing PDF File
|
PdfDocument |
addHtmlFooter(HtmlHeaderFooter footer,
HeaderFooterOptions headerFooterOptions)
Renders HTML page footer onto an existing PDF File
|
PdfDocument |
addHtmlFooter(HtmlHeaderFooter footer,
HeaderFooterOptions headerFooterOptions,
PageSelection pageSelection)
Renders HTML page footer onto an existing PDF File
|
PdfDocument |
addHtmlFooter(HtmlHeaderFooter footer,
PageSelection pageSelection)
Renders HTML page footers onto an existing PDF File
|
PdfDocument |
addHtmlHeader(HtmlHeaderFooter header)
Renders HTML page headers onto an existing PDF File
|
PdfDocument |
addHtmlHeader(HtmlHeaderFooter header,
HeaderFooterOptions headerFooterOptions)
Renders HTML page headers onto an existing PDF File
|
PdfDocument |
addHtmlHeader(HtmlHeaderFooter header,
HeaderFooterOptions headerFooterOptions,
PageSelection pageSelection)
Renders HTML page headers onto an existing PDF File
|
PdfDocument |
addHtmlHeader(HtmlHeaderFooter header,
PageSelection pageSelection)
Renders HTML page headers onto an existing PDF File
|
PdfDocument |
addTextFooter(TextHeaderFooter footer)
Renders TEXT page footers onto an existing PDF File
|
PdfDocument |
addTextFooter(TextHeaderFooter footer,
HeaderFooterOptions headerFooterOptions)
Renders TEXT page footer onto an existing PDF File
|
PdfDocument |
addTextFooter(TextHeaderFooter footer,
HeaderFooterOptions headerFooterOptions,
PageSelection pageSelection)
Renders TEXT page footer onto an existing PDF File
|
PdfDocument |
addTextFooter(TextHeaderFooter footer,
PageSelection pageSelection)
Renders TEXT page footers onto an existing PDF File
|
PdfDocument |
addTextHeader(TextHeaderFooter header)
Renders TEXT page headers onto an existing PDF File
|
PdfDocument |
addTextHeader(TextHeaderFooter header,
HeaderFooterOptions headerFooterOptions)
Renders TEXT page headers onto an existing PDF File
|
PdfDocument |
addTextHeader(TextHeaderFooter header,
HeaderFooterOptions headerFooterOptions,
PageSelection pageSelection)
Renders TEXT page headers onto an existing PDF File
|
PdfDocument |
addTextHeader(TextHeaderFooter header,
PageSelection pageSelection)
Renders TEXT page headers onto an existing PDF File
|
PdfDocument |
appendPdf(PdfDocument AnotherPdfFile)
Appends another PDF to the end of the current
PdfDocument. |
PdfDocument |
applyStamp(Stamper stamper)
Edits the PDF by applying the
Stamper's rendered to every page. |
PdfDocument |
applyStamp(Stamper stamper,
PageSelection pageSelection)
Edits the PDF by applying the
Stamper's rendered to only selected page(s). |
PdfDocument |
applyWatermark(String html)
Adds Watermark to PDF, Please use
applyStamp(Stamper) for more control. |
PdfDocument |
applyWatermark(String html,
int opacity)
Adds Watermark to PDF, Please use
applyStamp(Stamper) for more control. |
PdfDocument |
applyWatermark(String html,
int opacity,
VerticalAlignment verticalAlignment)
Adds a watermark to this PDF.
|
PdfDocument |
applyWatermark(String html,
int opacity,
VerticalAlignment verticalAlignment,
HorizontalAlignment horizontalAlignment)
Adds a watermark to this PDF.
|
void |
close() |
static void |
compressAndSaveAs(byte[] pdfBytes,
String outputFilePath,
String password,
AdvancedCompressionOptions options)
Apply the advanced compression pipeline to byte[] input and save the
result to a file.
|
static void |
compressAndSaveAs(InputStream pdfStream,
String outputFilePath,
String password,
AdvancedCompressionOptions options)
Apply the advanced compression pipeline to a stream input and save the
result to a file.
|
void |
compressAndSaveAs(String outputFilePath)
Compresses the PDF using QPdf smart compression and saves the result to a file.
|
void |
compressAndSaveAs(String outputFilePath,
AdvancedCompressionOptions options)
Apply the advanced compression pipeline and save the result to a file.
|
void |
compressAndSaveAs(String outputFilePath,
int jpegQuality)
Compresses the PDF using QPdf smart compression and saves the result to a file,
with JPEG quality setting for image recompression.
|
void |
compressImages(int quality)
Deprecated.
Use
compressAndSaveAs(String) or compressPdfToBytes() for QPdf smart compression. |
void |
compressImages(int quality,
boolean scaleToVisibleSize)
Deprecated.
Use
compressAndSaveAs(String) or compressPdfToBytes() for QPdf smart compression. |
byte[] |
compressPdfToBytes()
Compresses the PDF using QPdf smart compression and returns the compressed bytes in memory.
|
byte[] |
compressPdfToBytes(String password)
Compresses the PDF using QPdf smart compression and returns the compressed bytes in memory.
|
InputStream |
compressPdfToStream()
Compresses the PDF using QPdf smart compression and returns the result as an InputStream.
|
InputStream |
compressPdfToStream(String password)
Compresses the PDF using QPdf smart compression and returns the result as an InputStream.
|
void |
compressStructTree(int quality,
boolean scaleToVisibleSize)
Remove document struct tree information which describes the logical layout of the document.
|
PdfDocument |
convertToPdfA()
Convert the current document into the PDF-A (PDF/A-3B ISO 19005-3) standard format
|
PdfDocument |
convertToPdfA(PdfAVersions pdfAVersion)
Convert the current document into the specified PDF-A standard format
|
PdfDocument |
convertToPdfA(PdfAVersions pdfAVersion,
String customICCFilePath)
Convert the current document into the specified PDF-A standard format
|
PdfDocument |
convertToPdfA(String customICCFilePath)
Convert the current document into the PDF-A (PDF/A-3B ISO 19005-3) standard format
|
PdfDocument |
convertToPdfUA(NaturalLanguages naturalLanguages)
Convert the current document into the specified PDF/UA standard format (defaults to PDF/UA-1)
|
PdfDocument |
convertToPdfUA(NaturalLanguages naturalLanguages,
PdfUAVersions pdfUaVersion)
Convert the current document into the specified PDF/UA standard format
|
PdfDocument |
copyPage(int PageIndex)
Creates a new PDF by copying a page from this PdfDocument into a new blank document.
|
PdfDocument |
copyPages(int StartIndex,
int EndIndex)
Creates a new PDF by copying a range of pages from this
PdfDocument into a new blank document. |
PdfDocument |
copyPages(PageSelection pageSelection)
Creates a new PDF by copying a page from this PdfDocument into a new blank document.
|
void |
drawImage(byte[] imageBytes,
DrawImageOptions option)
Draws an image onto the PDF document
|
void |
drawImage(Path imagePath,
DrawImageOptions option)
Draws an image onto the PDF document
|
List<BufferedImage> |
extractAllImages()
Finds all embedded Images from within the PDF and returns them as a list of
BufferedImage images. |
List<BufferedImage> |
extractAllImagesFromPages(PageSelection pageSelection)
Finds all embedded Images from within the PDF and returns as a list of image bytes
|
List<byte[]> |
extractAllRawImages()
Finds all embedded Images from within the PDF and returns as a list of image bytes
|
List<byte[]> |
extractAllRawImagesFromPages(PageSelection pageSelection)
Finds all embedded Images from within the PDF and returns them as raw bytes.
|
String |
extractAllText()
Extracts the written text content from the PDF and returns it as a string.
|
String |
extractTextFromPage(PageSelection pageSelection)
Extracts the text content from one page of the PDF and returns it as a string.
|
static PdfDocument |
fromFile(Path pdfFilePath)
Opens an existing PDF document for editing.
|
static PdfDocument |
fromFile(Path pdfFilePath,
ChangeTrackingModes trackChanges)
Opens an existing PDF document for editing.
|
static PdfDocument |
fromFile(Path pdfFilePath,
String password)
Opens an existing PDF document for editing.
|
static PdfDocument |
fromFile(Path pdfFilePath,
String password,
ChangeTrackingModes trackChanges)
Opens an existing PDF document for editing.
|
static PdfDocument |
fromFile(Path pdfFilePath,
String password,
String ownerPassword)
Opens an existing PDF document for editing.
|
static PdfDocument |
fromFile(Path pdfFilePath,
String password,
String ownerPassword,
ChangeTrackingModes trackChanges)
Opens an existing PDF document for editing.
|
static PdfDocument |
fromImage(List<Path> imagesPath)
Converts a single image file to an identical PDF document of matching dimensions.
|
static PdfDocument |
fromImage(List<Path> imagesPath,
ImageBehavior imageBehavior)
Converts a single image file to an identical PDF document of matching dimensions.
|
static PdfDocument |
fromImage(List<Path> imagesPath,
ImageBehavior imageBehavior,
ChromePdfRenderOptions renderOptions)
Converts a single image file to an identical PDF document of matching dimensions.
|
static PdfDocument |
fromImage(List<Path> imagesPath,
ImageBehavior imageBehavior,
PaperSize paperSize)
Converts a single image file to an identical PDF document of matching dimensions.
|
static PdfDocument |
fromImage(List<Path> imagesPath,
PaperSize paperSize)
Converts a single image file to an identical PDF document of matching dimensions.
|
AnnotationManager |
getAnnotation()
Gets the annotation manager for this PDF document.
|
AttachmentManager |
getAttachment()
Gets the attachment manager for this PDF document.
|
byte[] |
getBinaryData()
Saves the PDF as byte array, including any changes.
|
byte[] |
getBinaryDataIncremental()
Saves the PDF as byte array with changes appended to the end of the file.
|
BookmarkManager |
getBookmark()
Gets the BookmarkManager for this PDF document.
|
List<RenderedElementLocation> |
getElementLocations()
Retrieves the rendered page locations of HTML elements that were tracked during rendering.
|
FormManager |
getForm()
Gets the form manager for this PDF document.
|
MetadataManager |
getMetadata()
Gets the metadata manager for this PDF document.
|
List<PageInfo> |
getPagesInfo()
Gets a list of information about pages in this PDF as a List of
PageInfo. |
Map<Integer,PageInfo> |
getPagesInfo(PageSelection pageSelection)
Gets a Map of information a selection of pages in this PDF as a List of
PageInfo. |
byte[] |
getRevision(int index)
Saves the PDF as byte array at the specified revision number.
|
SecurityManager |
getSecurity()
Gets security.
|
SignatureManager |
getSignature()
Gets signature.
|
PdfDocument |
insertPdf(PdfDocument AnotherPdfFile)
Inserts another PDF into the current PdfDocument, starting at a given Page Index.
|
PdfDocument |
insertPdf(PdfDocument AnotherPdfFile,
int AtIndex)
Inserts another PDF into the current PdfDocument, starting at a given Page Index.
|
static boolean |
isLinearized(Path pdfFilePath)
Check whether the PDF file at the given path is linearized (a.k.a.
|
static boolean |
isLinearized(String pdfFilePath)
Check whether the PDF file at the given path is linearized (a.k.a.
|
static boolean |
isLinearized(String pdfFilePath,
String password)
Check whether the PDF file at the given path is linearized (a.k.a.
|
byte[] |
linearizePdfToBytes()
Linearizes the current PDF document and returns the result as a byte array
using the
LinearizationMode.Automatic strategy. |
static byte[] |
linearizePdfToBytes(byte[] pdfBytes)
Static helper that linearizes the given PDF bytes and returns the linearized bytes
using the
LinearizationMode.Automatic strategy. |
static byte[] |
linearizePdfToBytes(byte[] pdfBytes,
String password)
Static helper that linearizes the given PDF bytes and returns the linearized bytes.
|
static byte[] |
linearizePdfToBytes(byte[] pdfBytes,
String password,
LinearizationMode mode)
Static helper that linearizes the given PDF bytes and returns the linearized bytes.
|
static byte[] |
linearizePdfToBytes(InputStream pdfStream)
Static helper that linearizes a PDF from an
InputStream and returns the linearized bytes. |
static byte[] |
linearizePdfToBytes(InputStream pdfStream,
String password)
Static helper that linearizes a PDF from an
InputStream and returns the linearized bytes. |
static byte[] |
linearizePdfToBytes(InputStream pdfStream,
String password,
LinearizationMode mode)
Static helper that linearizes a PDF from an
InputStream and returns the linearized bytes. |
byte[] |
linearizePdfToBytes(LinearizationMode mode)
Linearizes the current PDF document and returns the result as a byte array.
|
byte[] |
linearizePdfToBytes(String password)
Linearizes the current PDF document and returns the result as a byte array.
|
byte[] |
linearizePdfToBytes(String password,
LinearizationMode mode)
Linearizes the current PDF document and returns the result as a byte array.
|
InputStream |
linearizePdfToStream()
Linearizes the current PDF document and returns the result as an
InputStream. |
InputStream |
linearizePdfToStream(LinearizationMode mode)
Linearizes the current PDF document and returns the result as an
InputStream. |
InputStream |
linearizePdfToStream(String password)
Linearizes the current PDF document and returns the result as an
InputStream. |
InputStream |
linearizePdfToStream(String password,
LinearizationMode mode)
Linearizes the current PDF document and returns the result as an
InputStream. |
static PdfDocument |
merge(List<PdfDocument> Documents)
Static method that joins (concatenates) 2 PDF documents together into one PDF document.
|
static PdfDocument |
merge(PdfDocument A,
PdfDocument B)
Static method that joins (concatenates) 2 PDF documents together into one PDF document.
|
PdfDocument |
prependPdf(PdfDocument AnotherPdfFile)
Adds another PDF to the beginning of the current PdfDocument.
|
void |
print()
Prints this PDF by sending it to the computer's real world printer(s).
|
int |
print(Graphics graphics,
PageFormat pageFormat,
int pageIndex) |
void |
printWithoutDialog()
Prints this PDF by sending it to the computer's real world printer(s).
|
PdfDocument |
removePages(PageSelection pageSelection)
Removes a range of pages from the PDF
|
static PdfDocument |
renderHtmlAsPdf(String html)
Creates a PDF file from a Html string, and returns it as a
PdfDocument. |
static PdfDocument |
renderHtmlAsPdf(String html,
ChromeHttpLoginCredentials loginCredentials)
Creates a PDF file from a Html string, and returns it as a
PdfDocument. |
static PdfDocument |
renderHtmlAsPdf(String html,
ChromePdfRenderOptions renderOptions)
Creates a PDF file from a Html string, and returns it as a
PdfDocument. |
static PdfDocument |
renderHtmlAsPdf(String html,
ChromePdfRenderOptions renderOptions,
ChromeHttpLoginCredentials loginCredentials)
Creates a PDF file from a Html string, and returns it as a
PdfDocument. |
static PdfDocument |
renderHtmlAsPdfUA(String html)
Render HTML to PDF and convert to PDF/UA format with screen reader support.
|
static PdfDocument |
renderHtmlAsPdfUA(String html,
NaturalLanguages naturalLanguages)
Render HTML to PDF and convert to PDF/UA format with screen reader support.
|
static PdfDocument |
renderHtmlAsPdfUA(String html,
NaturalLanguages naturalLanguages,
ChromePdfRenderOptions renderOptions)
Render HTML to PDF and convert to PDF/UA format with screen reader support.
|
static PdfDocument |
renderHtmlFileAsPdf(String htmlFilePath)
Creates a PDF file from a local Html file, and returns it as a
PdfDocument. |
static PdfDocument |
renderHtmlFileAsPdf(String htmlFilePath,
ChromeHttpLoginCredentials loginCredentials)
Creates a PDF file from a local Html file, and returns it as a
PdfDocument. |
static PdfDocument |
renderHtmlFileAsPdf(String htmlFilePath,
ChromePdfRenderOptions renderOptions)
Creates a PDF file from a local HTML file and returns it as a
PdfDocument. |
static PdfDocument |
renderHtmlFileAsPdf(String htmlFilePath,
ChromePdfRenderOptions renderOptions,
ChromeHttpLoginCredentials loginCredentials)
Creates a PDF file from a local Html file, and returns it as a
PdfDocument. |
static PdfDocument |
renderHtmlFileAsPdf(String htmlFilePath,
String baseUrl)
Creates a PDF file from a local Html file, and returns it as a
PdfDocument. |
static PdfDocument |
renderHtmlFileAsPdf(String htmlFilePath,
String baseUrl,
ChromeHttpLoginCredentials loginCredentials)
Creates a PDF file from a local Html file, and returns it as a
PdfDocument. |
static PdfDocument |
renderHtmlFileAsPdf(String htmlFilePath,
String baseUrl,
ChromePdfRenderOptions renderOptions)
Creates a PDF file from a local Html file, and returns it as a
PdfDocument. |
static PdfDocument |
renderHtmlFileAsPdf(String htmlFilePath,
String baseUrl,
ChromePdfRenderOptions renderOptions,
ChromeHttpLoginCredentials loginCredentials)
Creates a PDF file from a local Html file, and returns it as a
PdfDocument. |
static PdfDocument |
renderRtfAsPdf(String rtfString)
Creates a PDF file from RTF string, and returns it as a
PdfDocument. |
static PdfDocument |
renderRtfFileAsPdf(Path rtfFilePath)
Creates a PDF file from RTF file, and returns it as a
PdfDocument. |
static PdfDocument |
renderRtfFileAsPdf(String rtfFilePath)
Creates a PDF file from RTF file, and returns it as a
PdfDocument. |
static PdfDocument |
renderUrlAsPdf(String url)
Creates a PDF file from a URL or local file path and returns it as a
PdfDocument. |
static PdfDocument |
renderUrlAsPdf(String url,
ChromeHttpLoginCredentials loginCredentials)
Creates a PDF file from a URL or local file path and returns it as a
PdfDocument. |
static PdfDocument |
renderUrlAsPdf(String url,
ChromePdfRenderOptions renderOptions)
Creates a PDF file from a URL or local file path and returns it as a
PdfDocument. |
static PdfDocument |
renderUrlAsPdf(String url,
ChromePdfRenderOptions renderOptions,
ChromeHttpLoginCredentials loginCredentials)
Creates a PDF file from a URL or local file path and returns it as a
PdfDocument. |
static PdfDocument |
renderZipAsPdf(Path zipFilePath,
String mainFile)
Creates a PDF file from a local Zip file, and returns it as a
PdfDocument. |
static PdfDocument |
renderZipAsPdf(Path zipFilePath,
String mainFile,
ChromePdfRenderOptions renderOptions)
Creates a PDF file from a local Zip file, and returns it as a
PdfDocument. |
void |
replaceText(PageSelection pageSelection,
String oldText,
String newText)
Replace the specified old text with new text on a given page.
|
void |
replaceText(PageSelection pageSelection,
String oldText,
String newText,
FontTypes customFont,
Float customFontSize)
Replace the specified old text with new text on a given page.
|
void |
resetElementLocationCache()
Clears the cached result of
getElementLocations(), forcing a fresh scan of the
document's annotations on the next call. |
void |
resizePage(double pageWidth,
double pageHeight,
PageSelection pageSelection)
Resize a page to the specified dimensions (in millimeters)
|
void |
rotateAllPages(PageRotation rotation)
Rotates all pages of the PdfDocument by a specified number of degrees.
|
void |
rotatePage(PageRotation pageRotation,
PageSelection pageSelection)
Rotates a selection page of the PdfDocument by a specified number of degrees.
|
PdfDocument |
saveAs(Path filePath)
Saves this PdfDocument to a file.
|
PdfDocument |
saveAs(String filePath)
Saves this PdfDocument to a file.
|
static void |
saveAsLinearized(byte[] pdfBytes,
String outputFilePath)
Static helper that linearizes the given PDF bytes and saves the result to the given output file path.
|
static void |
saveAsLinearized(byte[] pdfBytes,
String outputFilePath,
String password)
Static helper that linearizes the given PDF bytes and saves the result to the given output file path.
|
void |
saveAsLinearized(String outputFilePath)
Linearizes the current PDF document and saves the result to a file path.
|
void |
saveAsLinearized(String outputFilePath,
String password)
Linearizes the current PDF document and saves the result to a file path.
|
PdfDocument |
saveAsPdfA(String filePath)
Save the current document into the PDF-A (PDF/A-3B ISO 19005-3) standard format
|
PdfDocument |
saveAsPdfA(String filePath,
PdfAVersions pdfAVersion)
Save the current document into the specified PDF-A standard format
|
PdfDocument |
saveAsPdfA(String filePath,
PdfAVersions pdfAVersion,
String customICCFilePath)
Save the current document into the specified PDF-A standard format
|
PdfDocument |
saveAsPdfA(String filePath,
String customICCFilePath)
Save the current document into the PDF-A (PDF/A-3B ISO 19005-3) standard format
|
PdfDocument |
saveAsPdfUA(String filePath,
NaturalLanguages naturalLanguages)
Save the current document into the specified PDF/UA standard format.
|
PdfDocument |
saveAsRevision(Path filePath)
Saves this PdfDocument to a file.
|
PdfDocument |
saveAsRevision(String filePath)
Saves this PdfDocument to a file.
|
List<BufferedImage> |
toBufferedImages()
Rasterizes (renders) the PDF into BufferedImage objects.
|
List<BufferedImage> |
toBufferedImages(PageSelection pageSelection)
Rasterizes (renders) the PDF into BufferedImage objects.
|
List<BufferedImage> |
toBufferedImages(ToImageOptions options)
Rasterizes (renders) the PDF into BufferedImage objects.
|
List<BufferedImage> |
toBufferedImages(ToImageOptions options,
PageSelection pageSelection)
Rasterizes (renders) the PDF into BufferedImage objects.
|
List<String> |
toImages(String fileNamePattern,
String imageFileType)
Renders the pages of the PDF as specific image files type and saves them to disk.
|
List<String> |
toImages(String fileNamePattern,
String imageFileType,
PageSelection pageSelection)
Renders the pages of the PDF as specific image files type and saves them to disk.
|
List<String> |
toImages(String fileNamePattern,
String imageFileType,
ToImageOptions options)
Renders the pages of the PDF as specific image files type and saves them to disk.
|
List<String> |
toImages(String fileNamePattern,
String imageFileType,
ToImageOptions options,
PageSelection pageSelection)
Renders the pages of the PDF as specific image files type and saves them to disk.
|
List<String> |
toJpegImages(String fileNamePattern)
Renders the pages of the PDF as JPEG image files and saves them to disk.
|
List<String> |
toJpegImages(String fileNamePattern,
PageSelection pageSelection)
Renders the pages of the PDF as JPEG image files and saves them to disk.
|
List<String> |
toJpegImages(String fileNamePattern,
ToImageOptions options)
Renders the pages of the PDF as JPEG image files and saves them to disk.
|
List<String> |
toJpegImages(String fileNamePattern,
ToImageOptions options,
PageSelection pageSelection)
Renders the pages of the PDF as JPEG image files and saves them to disk.
|
String |
toMultiPageTiff(Path filePath)
Renders the pages of the PDF as TIFF (Tagged Image File Format / Tif) file and saves it to disk.
|
String |
toMultiPageTiff(Path filePath,
PageSelection pageSelection)
Renders the pages of the PDF as TIFF (Tagged Image File Format / Tif) file and saves it to disk.
|
String |
toMultiPageTiff(Path filePath,
ToImageOptions options)
Renders the pages of the PDF as TIFF (Tagged Image File Format / Tif) file and saves it to disk.
|
String |
toMultiPageTiff(Path filePath,
ToImageOptions options,
PageSelection pageSelection)
Renders the pages of the PDF as TIFF (Tagged Image File Format / Tif) file and saves it to disk.
|
List<String> |
toPngImages(String fileNamePattern)
Renders the pages of the PDF as PNG (Portable Network Graphic) files and saves them to disk.
|
List<String> |
toPngImages(String fileNamePattern,
PageSelection pageSelection)
Renders the pages of the PDF as PNG (Portable Network Graphic) files and saves them to disk.
|
List<String> |
toPngImages(String fileNamePattern,
ToImageOptions options)
Renders the pages of the PDF as PNG (Portable Network Graphic) files and saves them to disk.
|
List<String> |
toPngImages(String fileNamePattern,
ToImageOptions options,
PageSelection pageSelection)
Renders the pages of the PDF as PNG (Portable Network Graphic) files and saves them to disk.
|
public PdfDocument(Path pdfFilePath, String password) throws IOException
pdfFilePath - The PDF file path.password - Optional user password if the PDF document is encrypted.IOException - if an I/O error occurs reading from the streampublic PdfDocument(Path pdfFilePath, String password, ChangeTrackingModes trackChanges) throws IOException
pdfFilePath - The PDF file path.password - Optional user password if the PDF document is encrypted.trackChanges - Optionally track changes to the document (for use with incremental saves)IOException - if an I/O error occurs reading from the streampublic PdfDocument(Path pdfFilePath, String password, String ownerPassword) throws IOException
pdfFilePath - The PDF file path.password - Optional user password if the PDF document is encrypted.ownerPassword - Optional password if the PDF document is protected by owner (printing, modifying restrictions etc..)IOException - if an I/O error occurs reading from the streampublic PdfDocument(Path pdfFilePath, String password, String ownerPassword, ChangeTrackingModes trackChanges) throws IOException
pdfFilePath - The PDF file path.password - Optional user password if the PDF document is encrypted.ownerPassword - Optional password if the PDF document is protected by owner (printing, modifying restrictions etc..)trackChanges - Optionally track changes to the document (for use with incremental saves)IOException - if an I/O error occurs reading from the streampublic PdfDocument(byte[] pdfData,
String password,
String ownerPassword)
pdfData - The PDF file data as byte array.password - Optional user password if the PDF document is encrypted.ownerPassword - Optional password if the PDF document is protected by owner (printing, modifying restrictions etc..)public PdfDocument(byte[] pdfData,
String password,
String ownerPassword,
ChangeTrackingModes trackChanges)
pdfData - The PDF file data as byte array.password - Optional user password if the PDF document is encrypted.ownerPassword - Optional password if the PDF document is protected by owner (printing, modifying restrictions etc..)trackChanges - Optionally track changes to the document (for use with incremental saves)public PdfDocument(Path pdfFilePath) throws IOException
pdfFilePath - The PDF file path.IOException - the io exceptionpublic PdfDocument(Path pdfFilePath, ChangeTrackingModes trackChanges) throws IOException
pdfFilePath - The PDF file path.trackChanges - Optionally track changes to the document (for use with incremental saves)IOException - the io exceptionpublic PdfDocument(byte[] pdfData,
String password)
pdfData - The PDF file data as byte array.password - Optional user password if the PDF document is encrypted.public PdfDocument(byte[] pdfData,
String password,
ChangeTrackingModes trackChanges)
pdfData - The PDF file data as byte array.password - Optional user password if the PDF document is encrypted.trackChanges - Optionally track changes to the document (for use with incremental saves)public PdfDocument(byte[] pdfData)
pdfData - The PDF file data as byte array.public PdfDocument(byte[] pdfData,
ChangeTrackingModes trackChanges)
pdfData - The PDF file data as byte array.trackChanges - Optionally track changes to the document (for use with incremental saves)public static PdfDocument fromFile(Path pdfFilePath, String password) throws IOException
pdfFilePath - The PDF file path.password - Optional user password if the PDF document is encrypted.IOException - if an I/O error occurs reading from the streampublic static PdfDocument fromFile(Path pdfFilePath, String password, ChangeTrackingModes trackChanges) throws IOException
pdfFilePath - The PDF file path.password - Optional user password if the PDF document is encrypted.trackChanges - Optionally track changes to the document (for use with incremental saves)IOException - if an I/O error occurs reading from the streampublic static PdfDocument fromFile(Path pdfFilePath, String password, String ownerPassword) throws IOException
pdfFilePath - The PDF file path.password - Optional user password if the PDF document is encrypted.ownerPassword - Optional password if the PDF document is protected by owner (printing, modifying restrictions etc..)IOException - if an I/O error occurs reading from the streampublic static PdfDocument fromFile(Path pdfFilePath, String password, String ownerPassword, ChangeTrackingModes trackChanges) throws IOException
pdfFilePath - The PDF file path.password - Optional user password if the PDF document is encrypted.ownerPassword - Optional password if the PDF document is protected by owner (printing, modifying restrictions etc..)trackChanges - Optionally track changes to the document (for use with incremental saves)IOException - if an I/O error occurs reading from the streampublic static PdfDocument fromFile(Path pdfFilePath) throws IOException
pdfFilePath - The PDF file path.IOException - if an I/O error occurs reading from the streampublic static PdfDocument fromFile(Path pdfFilePath, ChangeTrackingModes trackChanges) throws IOException
pdfFilePath - The PDF file path.trackChanges - Optionally track changes to the document (for use with incremental saves)IOException - if an I/O error occurs reading from the streampublic static PdfDocument fromImage(List<Path> imagesPath)
The default PaperSize is A4.
Note: Imaging.ImageBehavior.CropPage will set PaperSize equal to ImageSize.
imagesPath - A list of file path of the image file.PdfDocument document which can then be edited, saved or served over the web.public static PdfDocument fromImage(List<Path> imagesPath, PaperSize paperSize)
The default PaperSize is A4. You can set it via ImageToPdfConverter.PaperSize.
Note: Imaging.ImageBehavior.CropPage will set PaperSize equal to ImageSize.
imagesPath - A list of file path of the image file.paperSize - A target paper size. Default is A4.PdfDocument document which can then be edited, saved or served over the web.public static PdfDocument fromImage(List<Path> imagesPath, ImageBehavior imageBehavior)
The default PaperSize is A4.
Note: Imaging.ImageBehavior.CropPage will set PaperSize equal to ImageSize.
imagesPath - A list of file path of the image file.imageBehavior - Describes how image should be placed on the PDF pagePdfDocument document which can then be edited, saved or served over the web.public static PdfDocument fromImage(List<Path> imagesPath, ImageBehavior imageBehavior, PaperSize paperSize)
Note: Imaging.ImageBehavior.CropPage will set PaperSize equal to ImageSize.
imagesPath - A list of file path of the image file.imageBehavior - Describes how image should be placed on the PDF page.paperSize - A target paper size. Default is A4.PdfDocument document which can then be edited, saved or served over the web.public static PdfDocument fromImage(List<Path> imagesPath, ImageBehavior imageBehavior, ChromePdfRenderOptions renderOptions)
The default PaperSize is A4. You can set it via ChromePdfRenderOptions.setPaperSize(PaperSize).
Note: Imaging.ImageBehavior.CropPage will set PaperSize equal to ImageSize.
imagesPath - A list of file path of the image file.imageBehavior - Describes how image should be placed on the PDF page.renderOptions - Rendering options.PdfDocument document which can then be edited, saved or served over the web.public BookmarkManager getBookmark()
See: BookmarkManager.
public MetadataManager getMetadata()
See: MetadataManager.
public AnnotationManager getAnnotation()
See: AnnotationManager.
public FormManager getForm()
See: FormManager.
public AttachmentManager getAttachment()
See: AttachmentManager.
public SecurityManager getSecurity()
public SignatureManager getSignature()
public static PdfDocument merge(PdfDocument A, PdfDocument B)
If the second PDF contains form fields, the resulting PDF's form fields will be appended with an origin index number. e.g. 'Name' from the first PDF will become 'Name_0'
A - A PDFB - A Seconds PDFPdfDocumentpublic static PdfDocument merge(List<PdfDocument> Documents)
If the second PDF contains form fields, the resulting PDF's form fields will be appended with an origin index number. e.g. 'Name' from the first PDF will become 'Name_0'
Documents - A List of PdfDocument. To merge existing PDF files you may use the PdfDocument.FromFile static method in conjunction with Merge.PdfDocumentpublic final PdfDocument copyPage(int PageIndex)
PageIndex - Index of the page. Note: Page 1 has index 0...PdfDocumentpublic final PdfDocument copyPages(PageSelection pageSelection)
pageSelection - The selected page index(es). Default is all pages.PdfDocumentpublic final PdfDocument copyPages(int StartIndex, int EndIndex)
PdfDocument into a new blank document.StartIndex - The index of the first PDF page to copy. Note: Page 1 has index 0EndIndex - The index of the last PDF page to copy.PdfDocumentpublic final PdfDocument appendPdf(PdfDocument AnotherPdfFile)
PdfDocument. If AnotherPdfFile contains form fields, those fields will be appended with '_' in the resulting PDF. e.g. 'Name' will become 'Name_'
AnotherPdfFile - PdfDocument to append.PdfDocumentpublic final PdfDocument insertPdf(PdfDocument AnotherPdfFile)
If AnotherPdfFile contains form fields, those fields will be appended with '_' in the resulting PDF. e.g. 'Name' will be 'Name_'
AnotherPdfFile - Another PdfDocument...public final PdfDocument insertPdf(PdfDocument AnotherPdfFile, int AtIndex)
If AnotherPdfFile contains form fields, those fields will be appended with '_' in the resulting PDF. e.g. 'Name' will be 'Name_'
AnotherPdfFile - Another PdfDocument.AtIndex - Index at which to insert the new content. Note: Page 1 has index 0...public final PdfDocument prependPdf(PdfDocument AnotherPdfFile)
If AnotherPdfFile contains form fields, those fields will be appended with '_' in the resulting PDF. e.g. 'Name' will be 'Name_'
AnotherPdfFile - PdfDocument to prepend.public final PdfDocument removePages(PageSelection pageSelection)
pageSelection - The selected page index(es). Default is all pages.public final List<PageInfo> getPagesInfo()
PageInfo.public final Map<Integer,PageInfo> getPagesInfo(PageSelection pageSelection)
PageInfo.pageSelection - Selected page indexes. Default is all pages.public final void rotateAllPages(PageRotation rotation)
rotation - Degrees of rotation. May be 0,90,180 or 270public final void rotatePage(PageRotation pageRotation, PageSelection pageSelection)
pageRotation - Degrees of rotation. May be 0,90,180 or 270pageSelection - Selected page indexes. Default is all pages.public final void resizePage(double pageWidth,
double pageHeight,
PageSelection pageSelection)
pageWidth - Desired page width, in millimeterspageHeight - Desired page height, in millimeterspageSelection - Selected page indexes.public final PdfDocument addBackgroundPdf(PdfDocument backgroundPdf)
backgroundPdf - The background PDF document.public final PdfDocument addBackgroundPdf(PdfDocument backgroundPdf, int backgroundPdfPageIndex)
backgroundPdf - The background PDF document.backgroundPdfPageIndex - Index (zero-based page number) of the page to copy from the Background/Foreground PDF. Default is 0.public final PdfDocument addBackgroundPdf(PdfDocument backgroundPdf, PageSelection pageSelection)
backgroundPdf - The background PDF document.pageSelection - PageSelection to which the background/foreground will be added. Default is PageSelection.AllPages().public final PdfDocument addBackgroundPdf(PdfDocument backgroundPdf, int backgroundPdfPageIndex, PageSelection pageSelection)
backgroundPdf - The background PDF document.backgroundPdfPageIndex - Index (zero-based page number) of the page to copy from the Background/Foreground PDF. Default is 0.pageSelection - PageSelection to which the background/foreground will be added. Default is PageSelection.AllPages().public final PdfDocument addForegroundPdf(PdfDocument foregroundPdf)
foregroundPdf - The foreground PDF document.public final PdfDocument addForegroundPdf(PdfDocument foregroundPdf, int foregroundPdfPageIndex)
foregroundPdf - The foreground PDF document.foregroundPdfPageIndex - Index (zero-based page number) of the page to copy from the Background/Foreground PDF. Default is 0.public final PdfDocument addForegroundPdf(PdfDocument foregroundPdf, PageSelection pageSelection)
foregroundPdf - The foreground PDF document.pageSelection - PageSelection to which the background/foreground will be added. Default is PageSelection.AllPages().public final PdfDocument addForegroundPdf(PdfDocument foregroundPdf, int foregroundPdfPageIndex, PageSelection pageSelection)
foregroundPdf - The foreground PDF document.foregroundPdfPageIndex - Index (zero-based page number) of the page to copy from the Background/Foreground PDF. Default is 0.pageSelection - PageSelection to which the background/foreground will be added. Default is PageSelection.AllPages().public PdfDocument addTextHeader(TextHeaderFooter header)
header - A new instance of IronPdf.TextHeaderFooter that defines the header content and layout.public PdfDocument addTextHeader(TextHeaderFooter header, PageSelection pageSelection)
header - A new instance of IronPdf.TextHeaderFooter that defines the header content and layout.pageSelection - Selected page indexes. Default is all pages.public PdfDocument addTextHeader(TextHeaderFooter header, HeaderFooterOptions headerFooterOptions)
header - A new instance of IronPdf.TextHeaderFooter that defines the header content and layout.headerFooterOptions - HeaderFooterOption.public PdfDocument addTextHeader(TextHeaderFooter header, HeaderFooterOptions headerFooterOptions, PageSelection pageSelection)
header - A new instance of IronPdf.TextHeaderFooter that defines the header content and layout.headerFooterOptions - HeaderFooterOption.pageSelection - Selected page indexes. Default is all pages.public PdfDocument addTextFooter(TextHeaderFooter footer)
footer - A new instance of IronPdf.TextHeaderFooter that defines the footer content and layout.public PdfDocument addTextFooter(TextHeaderFooter footer, PageSelection pageSelection)
footer - A new instance of IronPdf.TextHeaderFooter that defines the footer content and layout.pageSelection - Selected page indexes. Default is all pages.public PdfDocument addTextFooter(TextHeaderFooter footer, HeaderFooterOptions headerFooterOptions)
footer - A new instance of IronPdf.TextHeaderFooter that defines the footer content and layout.headerFooterOptions - HeaderFooterOption.public PdfDocument addTextFooter(TextHeaderFooter footer, HeaderFooterOptions headerFooterOptions, PageSelection pageSelection)
footer - A new instance of IronPdf.TextHeaderFooter that defines the footer content and layout.headerFooterOptions - HeaderFooterOption.pageSelection - Selected page indexes. Default is all pages.public PdfDocument addHtmlHeader(HtmlHeaderFooter header)
header - A new instance of IronPdf.HtmlHeaderFooter that defines the header content and layout.public PdfDocument addHtmlHeader(HtmlHeaderFooter header, PageSelection pageSelection)
header - A new instance of IronPdf.HtmlHeaderFooter that defines the header content and layout.pageSelection - Selected page indexes. Default is all pages.public PdfDocument addHtmlHeader(HtmlHeaderFooter header, HeaderFooterOptions headerFooterOptions)
header - A new instance of IronPdf.HtmlHeaderFooter that defines the header content and layout.headerFooterOptions - HeaderFooterOption.public PdfDocument addHtmlHeader(HtmlHeaderFooter header, HeaderFooterOptions headerFooterOptions, PageSelection pageSelection)
header - A new instance of IronPdf.HtmlHeaderFooter that defines the header content and layout.headerFooterOptions - HeaderFooterOption.pageSelection - Selected page indexes. Default is all pages.public PdfDocument addHtmlFooter(HtmlHeaderFooter footer)
footer - A new instance of IronPdf.HtmlHeaderFooter that defines the footer content and layout.public PdfDocument addHtmlFooter(HtmlHeaderFooter footer, PageSelection pageSelection)
footer - A new instance of IronPdf.HtmlHeaderFooter that defines the footer content and layout.pageSelection - Selected page indexes. Default is all pages.public PdfDocument addHtmlFooter(HtmlHeaderFooter footer, HeaderFooterOptions headerFooterOptions)
footer - A new instance of IronPdf.HtmlHeaderFooter that defines the footer content and layout.headerFooterOptions - HeaderFooterOption.public PdfDocument addHtmlFooter(HtmlHeaderFooter footer, HeaderFooterOptions headerFooterOptions, PageSelection pageSelection)
footer - A new instance of IronPdf.HtmlHeaderFooter that defines the footer content and layout.headerFooterOptions - HeaderFooterOption.pageSelection - Selected page indexes. Default is all pages.public final void drawImage(Path imagePath, DrawImageOptions option) throws IOException
imagePath - The image file path.option - the optionIOException - the io exceptionpublic final void drawImage(byte[] imageBytes,
DrawImageOptions option)
imageBytes - image byte arrayoption - the optionpublic final List<BufferedImage> toBufferedImages() throws IOException
IOException - the io exceptionpublic final List<BufferedImage> toBufferedImages(ToImageOptions options) throws IOException
options - The ToImageOptionsIOException - the io exceptionpublic final List<BufferedImage> toBufferedImages(PageSelection pageSelection) throws IOException
pageSelection - Selected page indexes. Default is all pages.IOException - the io exceptionpublic final List<BufferedImage> toBufferedImages(ToImageOptions options, PageSelection pageSelection) throws IOException
options - The ToImageOptionspageSelection - Selected page indexes. Default is all pages.IOException - the io exceptionpublic final List<String> toPngImages(String fileNamePattern) throws IOException
Specific image dimensions and page numbers may be given as optional parameters.
fileNamePattern should normally contain an asterisk (*) character which will be substituted for the page numbers.
fileNamePattern - A full or partial file path for the output files containing an asterisk. E.g. C:\images\pdf_pages_*.pngIOException - the io exceptionpublic final List<String> toPngImages(String fileNamePattern, ToImageOptions options) throws IOException
Specific image dimensions and page numbers may be given as optional parameters.
fileNamePattern should normally contain an asterisk (*) character which will be substituted for the page numbers.
fileNamePattern - A full or partial file path for the output files containing an asterisk. E.g. C:\images\pdf_pages_*.pngoptions - The ToImageOptionsIOException - the io exceptionpublic final List<String> toPngImages(String fileNamePattern, PageSelection pageSelection) throws IOException
Specific image dimensions and page numbers may be given as optional parameters.
fileNamePattern should normally contain an asterisk (*) character which will be substituted for the page numbers.
fileNamePattern - A full or partial file path for the output files containing an asterisk. E.g. C:\images\pdf_pages_*.pngpageSelection - Selected page indexes. Default is all pages.IOException - the io exceptionpublic final List<String> toPngImages(String fileNamePattern, ToImageOptions options, PageSelection pageSelection) throws IOException
Specific image dimensions and page numbers may be given as optional parameters.
fileNamePattern should normally contain an asterisk (*) character which will be substituted for the page numbers.
fileNamePattern - A full or partial file path for the output files containing an asterisk. E.g. C:\images\pdf_pages_*.pngoptions - The ToImageOptionspageSelection - Selected page indexes. Default is all pages.IOException - the io exceptionpublic List<String> toImages(String fileNamePattern, String imageFileType) throws IOException
Specific image dimensions and page numbers may be given as optional parameters.
fileNamePattern should normally contain an asterisk (*) character which will be substituted for the page numbers.
fileNamePattern - A full or partial file path for the output files containing an asterisk. E.g. C:\images\pdf_page_*.jpgimageFileType - a specific image file type without dot. E.g. "jpg", "png", "bmp", "gif", "tiff"IOException - the io exceptionpublic List<String> toImages(String fileNamePattern, String imageFileType, ToImageOptions options) throws IOException
Specific image dimensions and page numbers may be given as optional parameters.
fileNamePattern should normally contain an asterisk (*) character which will be substituted for the page numbers.
fileNamePattern - A full or partial file path for the output files containing an asterisk. E.g. C:\images\pdf_page_*.jpgimageFileType - a specific image file type without dot. E.g. "jpg", "png", "bmp", "gif", "tiff"options - The ToImageOptionsIOException - the io exceptionpublic List<String> toImages(String fileNamePattern, String imageFileType, PageSelection pageSelection) throws IOException
Specific image dimensions and page numbers may be given as optional parameters.
fileNamePattern should normally contain an asterisk (*) character which will be substituted for the page numbers.
fileNamePattern - A full or partial file path for the output files containing an asterisk. E.g. C:\images\pdf_page_*.jpgimageFileType - a specific image file type without dot. E.g. "jpg", "png", "bmp", "gif", "tiff"pageSelection - Selected page indexes. Default is all pages.IOException - the io exceptionpublic List<String> toImages(String fileNamePattern, String imageFileType, ToImageOptions options, PageSelection pageSelection) throws IOException
Specific image dimensions and page numbers may be given as optional parameters.
fileNamePattern should normally contain an asterisk (*) character which will be substituted for the page numbers.
fileNamePattern - A full or partial file path for the output files containing an asterisk. E.g. C:\images\pdf_page_*.jpgimageFileType - a specific image file type without dot. E.g. "jpg", "png", "bmp", "gif", "tiff"options - The ToImageOptionspageSelection - Selected page indexes. Default is all pages.IOException - the io exceptionpublic final List<String> toJpegImages(String fileNamePattern) throws IOException
Specific image dimensions and page numbers may be given as optional parameters.
fileNamePattern should normally contain an asterisk (*) character which will be substituted for the page numbers.
fileNamePattern - A full or partial file path for the output files containing an asterisk. E.g. C:\images\pdf_page_*.jpgIOException - the io exceptionpublic final List<String> toJpegImages(String fileNamePattern, ToImageOptions options) throws IOException
Specific image dimensions and page numbers may be given as optional parameters.
fileNamePattern should normally contain an asterisk (*) character which will be substituted for the page numbers.
fileNamePattern - A full or partial file path for the output files containing an asterisk. E.g. C:\images\pdf_page_*.jpgoptions - The ToImageOptionsIOException - the io exceptionpublic final List<String> toJpegImages(String fileNamePattern, PageSelection pageSelection) throws IOException
Specific image dimensions and page numbers may be given as optional parameters.
fileNamePattern should normally contain an asterisk (*) character which will be substituted for the page numbers.
fileNamePattern - A full or partial file path for the output files containing an asterisk. E.g. C:\images\pdf_page_*.jpgpageSelection - Selected page indexes. Default is all pages.IOException - the io exceptionpublic final List<String> toJpegImages(String fileNamePattern, ToImageOptions options, PageSelection pageSelection) throws IOException
Specific image dimensions and page numbers may be given as optional parameters.
fileNamePattern should normally contain an asterisk (*) character which will be substituted for the page numbers.
fileNamePattern - A full or partial file path for the output files containing an asterisk. E.g. C:\images\pdf_page_*.jpgoptions - The ToImageOptionspageSelection - Selected page indexes. Default is all pages.IOException - the io exceptionpublic String toMultiPageTiff(Path filePath) throws IOException
filePath - A file path for the output file. E.g. C:\images\pdf_pages.tiffIOException - the io exceptionpublic String toMultiPageTiff(Path filePath, PageSelection pageSelection) throws IOException
filePath - A file path for the output file. E.g. C:\images\pdf_pages.tiffpageSelection - Selected page indexes. Default is all pages.IOException - the io exceptionpublic String toMultiPageTiff(Path filePath, ToImageOptions options) throws IOException
filePath - A file path for the output file. E.g. C:\images\pdf_pages.tiffoptions - The ToImageOptionsIOException - the io exceptionpublic String toMultiPageTiff(Path filePath, ToImageOptions options, PageSelection pageSelection) throws IOException
filePath - A file path for the output file. E.g. C:\images\pdf_pages.tiffoptions - The ToImageOptionspageSelection - Selected page indexes. Default is all pages.IOException - the io exception@Deprecated public final void compressImages(int quality)
compressAndSaveAs(String) or compressPdfToBytes() for QPdf smart compression.quality - Quality (1 - 100) to use during compression@Deprecated public final void compressImages(int quality, boolean scaleToVisibleSize)
compressAndSaveAs(String) or compressPdfToBytes() for QPdf smart compression.quality - Quality (1 - 100) to use during compressionscaleToVisibleSize - Scale down the image resolution according to its visible size in the PDF document; may cause distortion with some image configurations. Default is false.public final void compressStructTree(int quality,
boolean scaleToVisibleSize)
public final byte[] compressPdfToBytes()
compressImages(int), this uses QPdf's full compression pipeline without saving to disk.public final byte[] compressPdfToBytes(String password)
compressImages(int), this uses QPdf's full compression pipeline without saving to disk.password - the PDF password (empty string if none)public final InputStream compressPdfToStream()
compressPdfToBytes().public final InputStream compressPdfToStream(String password)
compressPdfToBytes(String).password - the PDF password (empty string if none)public final void compressAndSaveAs(String outputFilePath)
outputFilePath - the file path to save the compressed PDFpublic final void compressAndSaveAs(String outputFilePath, int jpegQuality)
outputFilePath - the file path to save the compressed PDFjpegQuality - JPEG quality (1-100) for image recompressionpublic final void compressAndSaveAs(String outputFilePath, AdvancedCompressionOptions options)
Combines pdfium-side image DPI downsampling with qpdf-side structural optimization in a single call.
outputFilePath - the file path to save the compressed PDFoptions - advanced compression optionspublic static void compressAndSaveAs(byte[] pdfBytes,
String outputFilePath,
String password,
AdvancedCompressionOptions options)
pdfBytes - the input PDF bytesoutputFilePath - the file path to save the compressed PDFpassword - the PDF password (empty string or null if none)options - advanced compression optionspublic static void compressAndSaveAs(InputStream pdfStream, String outputFilePath, String password, AdvancedCompressionOptions options) throws IOException
IOExceptionpublic static boolean isLinearized(String pdfFilePath) throws IOException
pdfFilePath - the path to the PDF file on diskIOException - if the file cannot be readpublic static boolean isLinearized(String pdfFilePath, String password) throws IOException
pdfFilePath - the path to the PDF file on diskpassword - the PDF password (empty string if none)IOException - if the file cannot be readpublic static boolean isLinearized(Path pdfFilePath) throws IOException
pdfFilePath - the path to the PDF file on diskIOException - if the file cannot be readpublic final byte[] linearizePdfToBytes()
LinearizationMode.Automatic strategy.public final byte[] linearizePdfToBytes(LinearizationMode mode)
mode - the linearization strategy to use; defaults to LinearizationMode.Automatic if nullpublic final byte[] linearizePdfToBytes(String password)
password - the PDF password (empty string if none)public final byte[] linearizePdfToBytes(String password, LinearizationMode mode)
password - the PDF password (empty string if none)mode - the linearization strategy to usepublic final InputStream linearizePdfToStream()
InputStream.
This is the stream equivalent of linearizePdfToBytes().public final InputStream linearizePdfToStream(LinearizationMode mode)
InputStream.mode - the linearization strategy to usepublic final InputStream linearizePdfToStream(String password)
InputStream.password - the PDF password (empty string if none)public final InputStream linearizePdfToStream(String password, LinearizationMode mode)
InputStream.password - the PDF password (empty string if none)mode - the linearization strategy to usepublic final void saveAsLinearized(String outputFilePath) throws IOException
outputFilePath - the file path to save the linearized PDFIOException - if the file cannot be writtenpublic final void saveAsLinearized(String outputFilePath, String password) throws IOException
outputFilePath - the file path to save the linearized PDFpassword - the PDF password (empty string if none)IOException - if the file cannot be writtenpublic static byte[] linearizePdfToBytes(byte[] pdfBytes)
LinearizationMode.Automatic strategy.pdfBytes - the PDF bytes to linearizepublic static byte[] linearizePdfToBytes(byte[] pdfBytes,
String password)
pdfBytes - the PDF bytes to linearizepassword - the PDF password (empty string if none)public static byte[] linearizePdfToBytes(byte[] pdfBytes,
String password,
LinearizationMode mode)
pdfBytes - the PDF bytes to linearizepassword - the PDF password (empty string if none)mode - the linearization strategy to usepublic static byte[] linearizePdfToBytes(InputStream pdfStream) throws IOException
InputStream and returns the linearized bytes.pdfStream - the input PDF streamIOException - if the stream cannot be readpublic static byte[] linearizePdfToBytes(InputStream pdfStream, String password) throws IOException
InputStream and returns the linearized bytes.pdfStream - the input PDF streampassword - the PDF password (empty string if none)IOException - if the stream cannot be readpublic static byte[] linearizePdfToBytes(InputStream pdfStream, String password, LinearizationMode mode) throws IOException
InputStream and returns the linearized bytes.pdfStream - the input PDF streampassword - the PDF password (empty string if none)mode - the linearization strategy to useIOException - if the stream cannot be readpublic static void saveAsLinearized(byte[] pdfBytes,
String outputFilePath)
throws IOException
pdfBytes - the input PDF bytesoutputFilePath - the path to save the linearized PDFIOException - if the file cannot be writtenpublic static void saveAsLinearized(byte[] pdfBytes,
String outputFilePath,
String password)
throws IOException
pdfBytes - the input PDF bytesoutputFilePath - the path to save the linearized PDFpassword - the PDF password (empty string if none)IOException - if the file cannot be writtenpublic final List<RenderedElementLocation> getElementLocations()
To use this feature, set
ChromePdfRenderOptions.setElementQuerySelectors(String[])
with CSS selectors before rendering. After rendering, call this method to retrieve the
page index and coordinates of each matched element.
Mirrors IronPdf.PdfDocument.GetElementLocations() on the C# side.
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.public final void resetElementLocationCache()
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.public final List<BufferedImage> extractAllImages() throws IOException
BufferedImage images.BufferedImage objects.IOException - the io exceptionpublic final List<byte[]> extractAllRawImages() throws IOException
IOException - the io exceptionpublic final List<BufferedImage> extractAllImagesFromPages(PageSelection pageSelection) throws IOException
pageSelection - The selected page index(es). Default is all pages.BufferedImage objects.IOException - the io exceptionpublic final List<byte[]> extractAllRawImagesFromPages(PageSelection pageSelection) throws IOException
pageSelection - The selected page index(es). Default is all pages.IOException - the io exceptionpublic final PdfDocument saveAs(Path filePath) throws IOException
filePath - File PathIOException - the io exceptionpublic final PdfDocument saveAs(String filePath) throws IOException
filePath - File path stringIOException - the io exceptionpublic final PdfDocument saveAsRevision(Path filePath) throws IOException
filePath - File PathIOException - the io exceptionpublic final PdfDocument saveAsRevision(String filePath) throws IOException
filePath - File path stringIOException - the io exceptionpublic final byte[] getBinaryData()
public final byte[] getBinaryDataIncremental()
public final byte[] getRevision(int index)
saveAsRevision(java.nio.file.Path)index - revision indexPdfDocument documentpublic void print()
throws PrinterException
For advanced real-world printing options please implement your own java.awt.print code.
This class PdfDocumentimplements java.awt.print.Printable.
PrinterException - the printer exceptionpublic void printWithoutDialog()
throws PrinterException
For advanced real-world printing options please implement your own java.awt.print code.
This class PdfDocumentimplements java.awt.print.Printable.
PrinterException - the printer exceptionpublic int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException
print in interface PrintablePrinterExceptionpublic final PdfDocument applyWatermark(String html, int opacity, VerticalAlignment verticalAlignment)
Please use applyStamp(Stamper) for more control.
html - The HTML fragment which will be stamped onto your PDF.opacity - Watermark transparent value. 0 is invisible, 100 if fully opaque.verticalAlignment - The vertical alignment of the watermark relative to the page.PdfDocument, allowing for a 'fluent' chained in-line code stylepublic final PdfDocument applyWatermark(String html, int opacity, VerticalAlignment verticalAlignment, HorizontalAlignment horizontalAlignment)
Please use applyStamp(Stamper) for more control.
html - The HTML fragment which will be stamped onto your PDF.opacity - Watermark transparent value. 0 is invisible, 100 if fully opaque.verticalAlignment - The vertical alignment of the watermark relative to the page.horizontalAlignment - The horizontal alignment of the watermark relative to the page.PdfDocument, allowing for a 'fluent' chained in-line code stylepublic final PdfDocument applyWatermark(String html, int opacity)
applyStamp(Stamper) for more control.html - The HTML fragment which will be stamped onto your PDF.opacity - Watermark transparent value. 0 is invisible, 100 if fully opaque.PdfDocument, allowing for a 'fluent' chained in-line code stylepublic final PdfDocument applyWatermark(String html)
applyStamp(Stamper) for more control.html - The HTML fragment which will be stamped onto your PDF.PdfDocument, allowing for a 'fluent' chained in-line code stylepublic final PdfDocument applyStamp(Stamper stamper)
Stamper's rendered to every page.stamper - The Stamper object that has the content to be stamped onto the PDF.PdfDocument, allowing for a 'fluent' chained in-line code stylepublic final PdfDocument applyStamp(Stamper stamper, PageSelection pageSelection)
Stamper's rendered to only selected page(s).stamper - The Stamper object that has the content to be stamped onto the PDF.pageSelection - The selected page index(es). Default is all pages,PdfDocument, allowing for a 'fluent' chained in-line code stylepublic final String extractAllText()
Pages are separated by 4 consecutive line breaks
public final String extractTextFromPage(PageSelection pageSelection)
pageSelection - The selected page index(es). Default is all pages.public final void replaceText(PageSelection pageSelection, String oldText, String newText)
pageSelection - The selected page index(es).oldText - Old text to remove.newText - New text to add.public final void replaceText(PageSelection pageSelection, String oldText, String newText, FontTypes customFont, Float customFontSize)
pageSelection - The selected page index(es).oldText - Old text to remove.newText - New text to add.customFont - The font to use for the new text (nullable).customFontSize - The font size to use for the new text (nullable).public static PdfDocument renderHtmlFileAsPdf(String htmlFilePath) throws IOException
PdfDocument.htmlFilePath - Path to a Html to be rendered as a PDF.PdfDocumentIOException - the io exceptionpublic static PdfDocument renderHtmlFileAsPdf(String htmlFilePath, String baseUrl) throws IOException
PdfDocument.htmlFilePath - Path to a Html to be rendered as a PDF.baseUrl - Optional. Setting the BaseURL property gives the relative file path or URL context for hyperlinks, images, CSS and JavaScript files.PdfDocumentIOException - the io exceptionpublic static PdfDocument renderHtmlFileAsPdf(String htmlFilePath, ChromePdfRenderOptions renderOptions, ChromeHttpLoginCredentials loginCredentials) throws IOException
PdfDocument.htmlFilePath - Path to a Html to be rendered as a PDF.renderOptions - Rendering optionsloginCredentials - Http login credentialsPdfDocumentIOException - the io exceptionpublic static PdfDocument renderHtmlFileAsPdf(String htmlFilePath, String baseUrl, ChromePdfRenderOptions renderOptions, ChromeHttpLoginCredentials loginCredentials) throws IOException
PdfDocument.htmlFilePath - Path to a Html to be rendered as a PDF.baseUrl - Optional. Setting the BaseURL property gives the relative file path or URL context for hyperlinks, images, CSS and JavaScript files.renderOptions - Rendering optionsloginCredentials - Http login credentialsPdfDocumentIOException - the io exceptionpublic static PdfDocument renderHtmlFileAsPdf(String htmlFilePath, ChromeHttpLoginCredentials loginCredentials) throws IOException
PdfDocument.htmlFilePath - Path to a Html to be rendered as a PDF.loginCredentials - Http login credentialsPdfDocumentIOException - the io exceptionpublic static PdfDocument renderHtmlFileAsPdf(String htmlFilePath, String baseUrl, ChromeHttpLoginCredentials loginCredentials) throws IOException
PdfDocument.htmlFilePath - Path to a Html to be rendered as a PDF.baseUrl - Optional. Setting the BaseURL property gives the relative file path or URL context for hyperlinks, images, CSS and JavaScript files.loginCredentials - Http login credentialsPdfDocumentIOException - the io exceptionpublic static PdfDocument renderHtmlFileAsPdf(String htmlFilePath, ChromePdfRenderOptions renderOptions) throws IOException
PdfDocument.
------------------------------------------------
Usage:
PdfDocument pdf = renderHtmlAsPdf(htmlFilePath, renderOptions);
------------------------------------------------
htmlFilePath - The path to the local HTML file to be rendered as a PDF.renderOptions - Rendering options used for PDF generation.PdfDocument generated from the provided HTML file.IOException - If an I/O error occurs while accessing the file or generating the PDF.
Important Notes:
🐳 Docker Limitation:
This method does not work when the application is running inside a Docker environment
due to rendering engine limitations.
In such cases, use renderZipAsPdf() instead.
📄 Input: Requires access to a local HTML file on disk.
Related Methods:
📌 renderZipAsPdf() — Recommended alternative when running inside Docker.
public static PdfDocument renderHtmlFileAsPdf(String htmlFilePath, String baseUrl, ChromePdfRenderOptions renderOptions) throws IOException
PdfDocument.htmlFilePath - Path to a Html to be rendered as a PDF.baseUrl - Optional. Setting the BaseURL property gives the relative file path or URL context for hyperlinks, images, CSS and JavaScript files.renderOptions - Rendering optionsPdfDocumentIOException - the io exceptionpublic static PdfDocument renderUrlAsPdf(String url)
PdfDocument.url - An absolute (fully formed) Uri. Points to the Html document to be rendered as a PDF.PdfDocumentpublic static PdfDocument renderUrlAsPdf(String url, ChromePdfRenderOptions renderOptions, ChromeHttpLoginCredentials loginCredentials)
PdfDocument.url - An absolute (fully formed) Uri. Points to the Html document to be rendered as a PDF.renderOptions - Rendering optionsloginCredentials - Http login credentialsPdfDocumentpublic static PdfDocument renderUrlAsPdf(String url, ChromeHttpLoginCredentials loginCredentials)
PdfDocument.url - An absolute (fully formed) Uri. Points to the Html document to be rendered as a PDF.loginCredentials - Http login credentialsPdfDocumentpublic static PdfDocument renderUrlAsPdf(String url, ChromePdfRenderOptions renderOptions)
PdfDocument.url - An absolute (fully formed) Uri. Points to the Html document to be rendered as a PDF.renderOptions - Rendering optionsPdfDocumentpublic static PdfDocument renderHtmlAsPdf(String html)
PdfDocument.html - The Html to be rendered as a PDF.PdfDocumentpublic static PdfDocument renderHtmlAsPdf(String html, ChromeHttpLoginCredentials loginCredentials)
PdfDocument.html - The Html to be rendered as a PDF.loginCredentials - Http login credentialsPdfDocumentpublic static PdfDocument renderHtmlAsPdf(String html, ChromePdfRenderOptions renderOptions)
PdfDocument.html - The Html to be rendered as a PDF.renderOptions - Rendering optionsPdfDocumentpublic static PdfDocument renderHtmlAsPdf(String html, ChromePdfRenderOptions renderOptions, ChromeHttpLoginCredentials loginCredentials)
PdfDocument.html - The Html to be rendered as a PDF.renderOptions - Rendering optionsloginCredentials - Http login credentialsPdfDocumentpublic static PdfDocument renderRtfAsPdf(String rtfString)
PdfDocument.rtfString - The RTF string to be rendered as a PDF.PdfDocumentpublic static PdfDocument renderRtfFileAsPdf(String rtfFilePath) throws IOException
PdfDocument.rtfFilePath - The RTF file path to be rendered as a PDF.PdfDocumentIOException - the io exceptionpublic static PdfDocument renderRtfFileAsPdf(Path rtfFilePath) throws IOException
PdfDocument.rtfFilePath - The RTF file path to be rendered as a PDF.PdfDocumentIOException - the io exceptionpublic static PdfDocument renderZipAsPdf(Path zipFilePath, String mainFile, ChromePdfRenderOptions renderOptions) throws IOException
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/
zipFilePath - Path to a Zip to be rendered as a PDF.mainFile - Name of the primary HTML file.renderOptions - Rendering optionsPdfDocumentIOException - the io exceptionpublic static PdfDocument renderZipAsPdf(Path zipFilePath, String mainFile) throws IOException
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/
zipFilePath - Path to a Zip to be rendered as a PDF.mainFile - Name of the primary HTML file.PdfDocumentIOException - the io exceptionpublic PdfDocument saveAsPdfA(String filePath) throws IOException
filePath - Target file path stringPdfDocumentIOException - the io exceptionpublic PdfDocument saveAsPdfA(String filePath, String customICCFilePath) throws IOException
filePath - Target file path stringcustomICCFilePath - (Optional) Custom color profile file pathPdfDocumentIOException - the io exceptionpublic PdfDocument saveAsPdfA(String filePath, PdfAVersions pdfAVersion) throws IOException
filePath - Target file path stringpdfAVersion - PDF-A standard versionPdfDocumentIOException - the io exceptionpublic PdfDocument saveAsPdfA(String filePath, PdfAVersions pdfAVersion, String customICCFilePath) throws IOException
filePath - Target file path stringpdfAVersion - PDF-A standard versioncustomICCFilePath - (Optional) Custom color profile file pathPdfDocumentIOException - the io exceptionpublic PdfDocument convertToPdfA() throws IOException
PdfDocumentIOException - the io exceptionpublic PdfDocument convertToPdfA(String customICCFilePath) throws IOException
customICCFilePath - (Optional) Custom color profile file pathPdfDocumentIOException - the io exceptionpublic PdfDocument convertToPdfA(PdfAVersions pdfAVersion) throws IOException
pdfAVersion - PDF-A standard versionPdfDocumentIOException - the io exceptionpublic PdfDocument convertToPdfA(PdfAVersions pdfAVersion, String customICCFilePath) throws IOException
pdfAVersion - PDF-A standard versioncustomICCFilePath - (Optional) Custom color profile file pathPdfDocumentIOException - the io exceptionpublic PdfDocument saveAsPdfUA(String filePath, NaturalLanguages naturalLanguages) throws IOException
naturalLanguages - Natural Languages SpecificationPdfDocumentIOException - the io exceptionpublic PdfDocument convertToPdfUA(NaturalLanguages naturalLanguages) throws IOException
naturalLanguages - Natural Languages SpecificationPdfDocumentIOException - the io exceptionpublic PdfDocument convertToPdfUA(NaturalLanguages naturalLanguages, PdfUAVersions pdfUaVersion) throws IOException
naturalLanguages - Natural Languages SpecificationpdfUaVersion - PDF/UA standard versionPdfDocumentIOException - the io exceptionpublic static PdfDocument renderHtmlAsPdfUA(String html)
html - The HTML string to renderPdfDocument in PDF/UA formatpublic static PdfDocument renderHtmlAsPdfUA(String html, NaturalLanguages naturalLanguages)
html - The HTML string to rendernaturalLanguages - Document language for screen readersPdfDocument in PDF/UA formatpublic static PdfDocument renderHtmlAsPdfUA(String html, NaturalLanguages naturalLanguages, ChromePdfRenderOptions renderOptions)
html - The HTML string to rendernaturalLanguages - Document language for screen readersrenderOptions - Chrome PDF render optionsPdfDocument in PDF/UA formatpublic void close()
close in interface AutoCloseableCopyright © 2022–2026 Iron Software. All rights reserved.