NO_SUCH_PAGE, PAGE_EXISTS| Constructor and Description |
|---|
PdfDocument(byte[] pdfData)
Opens an existing PDF document for editing.
|
PdfDocument(byte[] pdfData,
String password)
Opens an existing PDF document for editing.
|
PdfDocument(byte[] pdfData,
String password,
String ownerPassword)
Opens an existing PDF document for editing.
|
PdfDocument(Path pdfFilePath)
Opens an existing PDF document for editing.
|
PdfDocument(Path pdfFilePath,
String password)
Opens an existing PDF document for editing.
|
PdfDocument(Path pdfFilePath,
String password,
String ownerPassword)
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 |
compressImages(int quality)
Reduces the PDF's file size by compressing existing images using JPEG encoding and the specified quality setting.
|
void |
compressImages(int quality,
boolean scaleToVisibleSize)
Reduces the PDF's file size by compressing existing images using JPEG encoding and the specified quality settings.
|
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(Iterable<Integer> PageIndexes)
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,
String password)
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 |
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()
Returns the binary data for the full PDF file.
|
BookmarkManager |
getBookmark()
Gets the BookmarkManager for this PDF document.
|
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. |
SecurityManager |
getSecurity() |
SignatureManager |
getSignature() |
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 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 |
renderHtmlAsPdf(String html,
ChromePdfRenderOptions renderOptions,
ChromeHttpLoginCredentials loginCredentials,
String baseUrl)
Creates a PDF file from a Html string, and returns it as a
PdfDocument. |
static PdfDocument |
renderHtmlAsPdf(String html,
String baseUrl)
Creates a PDF file from a Html string, and returns it as a
PdfDocument. |
static PdfDocument |
renderHtmlAsPdf(String html,
String baseUrl,
ChromeHttpLoginCredentials loginCredentials)
Creates a PDF file from a Html string, and returns it as a
PdfDocument. |
static PdfDocument |
renderHtmlAsPdf(String html,
String baseUrl,
ChromePdfRenderOptions renderOptions)
Creates a PDF file from a Html string, and returns it as a
PdfDocument. |
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 |
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. |
void |
replaceTextOnPage(int pageIndex,
String oldText,
String newText)
Replace the specified old text with new text on a given page.
|
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.
|
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.
|
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, 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(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(Path pdfFilePath) throws IOException
pdfFilePath - The PDF file path.IOExceptionpublic 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)
pdfData - The PDF file data as byte array.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, 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) throws IOException
pdfFilePath - The PDF file path.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(Iterable<Integer> PageIndexes)
PageIndexes - An IEnumerable of page indexes to copy into the new PDF.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 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.IOExceptionpublic final void drawImage(byte[] imageBytes,
DrawImageOptions option)
imageBytes - image byte arraypublic final List<BufferedImage> toBufferedImages() throws IOException
IOExceptionpublic final List<BufferedImage> toBufferedImages(ToImageOptions options) throws IOException
options - The ToImageOptionsIOExceptionpublic final List<BufferedImage> toBufferedImages(PageSelection pageSelection) throws IOException
pageSelection - Selected page indexes. Default is all pages.IOExceptionpublic final List<BufferedImage> toBufferedImages(ToImageOptions options, PageSelection pageSelection) throws IOException
options - The ToImageOptionspageSelection - Selected page indexes. Default is all pages.IOExceptionpublic 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_*.pngIOExceptionpublic 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 ToImageOptionsIOExceptionpublic 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.IOExceptionpublic 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.IOExceptionpublic 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"IOExceptionpublic 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 ToImageOptionsIOExceptionpublic 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.IOExceptionpublic 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.IOExceptionpublic 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_*.jpgIOExceptionpublic 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 ToImageOptionsIOExceptionpublic 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.IOExceptionpublic 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.IOExceptionpublic final void compressImages(int quality)
quality - Quality (1 - 100) to use during compressionpublic final void compressImages(int quality,
boolean scaleToVisibleSize)
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 List<BufferedImage> extractAllImages() throws IOException
BufferedImage images.BufferedImage objects.IOExceptionpublic final List<byte[]> extractAllRawImages() throws IOException
IOExceptionpublic final List<BufferedImage> extractAllImagesFromPages(PageSelection pageSelection) throws IOException
pageSelection - The selected page index(es). Default is all pages.BufferedImage objects.IOExceptionpublic final List<byte[]> extractAllRawImagesFromPages(PageSelection pageSelection) throws IOException
pageSelection - The selected page index(es). Default is all pages.IOExceptionpublic final PdfDocument saveAs(Path filePath) throws IOException
filePath - File PathIOExceptionpublic final PdfDocument saveAs(String filePath) throws IOException
filePath - File path stringIOExceptionpublic final byte[] getBinaryData()
public 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.
PrinterExceptionpublic 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.
PrinterExceptionpublic 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 replaceTextOnPage(int pageIndex,
String oldText,
String newText)
pageIndex - Page index to search for old text to replaceoldText - Old text to removenewText - New text to addpublic static PdfDocument renderHtmlFileAsPdf(String htmlFilePath) throws IOException
PdfDocument.htmlFilePath - Path to a Html to be rendered as a PDF.PdfDocumentIOExceptionpublic 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 credentialsPdfDocumentIOExceptionpublic static PdfDocument renderHtmlAsPdf(String html, ChromePdfRenderOptions renderOptions, ChromeHttpLoginCredentials loginCredentials, String baseUrl)
PdfDocument.html - The Html to be rendered as a PDF.renderOptions - Rendering optionsloginCredentials - Http login credentialsbaseUrl - Optional. Setting the BaseURL property gives the relative file path or
URL context for hyperlinks, images, CSS and JavaScript files.PdfDocumentpublic static PdfDocument renderHtmlFileAsPdf(String htmlFilePath, ChromeHttpLoginCredentials loginCredentials) throws IOException
PdfDocument.htmlFilePath - Path to a Html to be rendered as a PDF.loginCredentials - Http login credentialsPdfDocumentIOExceptionpublic static PdfDocument renderHtmlFileAsPdf(String htmlFilePath, ChromePdfRenderOptions renderOptions) throws IOException
PdfDocument.htmlFilePath - Path to a Html to be rendered as a PDF.renderOptions - Rendering optionsPdfDocumentIOExceptionpublic 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, String baseUrl, ChromeHttpLoginCredentials loginCredentials)
PdfDocument.html - The Html to be rendered as a PDF.loginCredentials - Http login credentialsbaseUrl - Optional. Setting the BaseURL property gives the relative file path or
URL context for hyperlinks, images, CSS and JavaScript files.PdfDocumentpublic static PdfDocument renderHtmlAsPdf(String html, String baseUrl, ChromePdfRenderOptions renderOptions)
PdfDocument.html - The Html to be rendered as a PDF.renderOptions - Rendering optionsbaseUrl - Optional. Setting the BaseURL property gives the relative file path or URL
context for hyperlinks, images, CSS and JavaScript files.PdfDocumentpublic 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 renderHtmlAsPdf(String html, String baseUrl)
PdfDocument.html - The 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.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 optionsPdfDocumentCopyright © 2022. All rights reserved.