-
- All Implemented Interfaces:
-
java.io.Closeable,java.lang.AutoCloseable
public final class PdfDocument implements Closeable
Represents an opened PDF document.
Use PdfiumCore.openDocument to create instances. Always call close when done to release native resources.
-
-
Field Summary
Fields Modifier and Type Field Description private final IntegerpageCountprivate final Stringtitleprivate final Stringauthorprivate final Stringsubjectprivate final Stringkeywordsprivate final Stringcreatorprivate final Stringproducerprivate final StringcreationDateprivate final StringmodificationDateprivate final IntegerattachmentCountprivate final IntegersignatureCountprivate final BooleanisSigned
-
Method Summary
Modifier and Type Method Description final IntegergetPageCount()final StringgetTitle()final StringgetAuthor()final StringgetSubject()final StringgetKeywords()final StringgetCreator()final StringgetProducer()final StringgetCreationDate()final StringgetModificationDate()final IntegergetAttachmentCount()final IntegergetSignatureCount()final BooleangetIsSigned()final StringgetMetaText(String tag)Get metadata text by tag name. final BooleanisClosed()Check if the document has been closed. Unitclose()Close the document and release native resources. final PdfPageopenPage(Integer index)Open a page at the specified index. final List<Pair<Double, Double>>getAllPageSizes()Get all page sizes in a single batch operation. final Pair<Double, Double>getPageSize(Integer index)Get page size without keeping the page open. final StringgetPageLabel(Integer pageIndex)Get page label (actual page number as displayed in PDF) Returns empty string if no label is defined for the page final List<PdfBookmark>getTableOfContents()Get the Table of Contents (Bookmarks) of the document. final BooleansaveAs(String path)Save the document to a file. final PdfPageaddNewPage(Integer index, Double width, Double height)Add a new blank page to the document. final BooleanimportPages(PdfDocument sourceDoc, String pageRange, Integer insertIndex)Import pages from another document into this document. final PdfAttachmentgetAttachment(Integer index)Get attachment at specified index. final List<PdfAttachment>getAllAttachments()Get all attachments in the document. final PdfSignaturegetSignature(Integer index)Get signature at specified index. final List<PdfSignature>getAllSignatures()Get all signatures in the document. StringtoString()-
-
Method Detail
-
getPageCount
final Integer getPageCount()
-
getSubject
final String getSubject()
-
getKeywords
final String getKeywords()
-
getCreator
final String getCreator()
-
getProducer
final String getProducer()
-
getCreationDate
final String getCreationDate()
-
getModificationDate
final String getModificationDate()
-
getAttachmentCount
final Integer getAttachmentCount()
-
getSignatureCount
final Integer getSignatureCount()
-
getIsSigned
final Boolean getIsSigned()
-
getMetaText
final String getMetaText(String tag)
Get metadata text by tag name.
Supported tags: Title, Author, Subject, Keywords, Creator, Producer, CreationDate, ModDate
-
openPage
final PdfPage openPage(Integer index)
Open a page at the specified index. Use this to access page content, dimensions, and render it.
-
getAllPageSizes
final List<Pair<Double, Double>> getAllPageSizes()
Get all page sizes in a single batch operation. Uses FPDF_GetPageSizeByIndex which is much faster than opening each page.
-
getPageSize
final Pair<Double, Double> getPageSize(Integer index)
Get page size without keeping the page open. Useful when only dimensions are needed.
-
getPageLabel
final String getPageLabel(Integer pageIndex)
Get page label (actual page number as displayed in PDF) Returns empty string if no label is defined for the page
- Parameters:
pageIndex- 0-based page index
-
getTableOfContents
final List<PdfBookmark> getTableOfContents()
Get the Table of Contents (Bookmarks) of the document.
-
saveAs
final Boolean saveAs(String path)
Save the document to a file.
- Parameters:
path- File path to save the PDF to
-
addNewPage
final PdfPage addNewPage(Integer index, Double width, Double height)
Add a new blank page to the document.
- Parameters:
index- Insertion index (0-based)width- Page width in pointsheight- Page height in points
-
importPages
final Boolean importPages(PdfDocument sourceDoc, String pageRange, Integer insertIndex)
Import pages from another document into this document.
- Parameters:
sourceDoc- Source document to import frompageRange- Range of pages to import (e.g.insertIndex- Index to insert pages at, default is end of document.
-
getAttachment
final PdfAttachment getAttachment(Integer index)
Get attachment at specified index.
-
getAllAttachments
final List<PdfAttachment> getAllAttachments()
Get all attachments in the document.
-
getSignature
final PdfSignature getSignature(Integer index)
Get signature at specified index.
-
getAllSignatures
final List<PdfSignature> getAllSignatures()
Get all signatures in the document.
-
-
-
-