PdfDocument
A loaded PDF document. Construct with open.
val doc = PdfDocument.open(bytes) // unencrypted
val doc = PdfDocument.open(bytes, "secret".encodeToByteArray())
println("${doc.pageCount} pages — PDF ${doc.version}")
println(doc.pages[0].extractText())
// Editing returns a writer; the document itself is immutable.
val editor = doc.edit()
editor.setInfo(title = "Reviewed")
val updated: ByteArray = editor.saveIncremental()Holds the raw byte buffer plus the xref table; pages and indirect objects are resolved lazily and cached.
Properties
Interactive form (AcroForm) catalog metadata. null when the catalog has no /AcroForm entry — the document carries no interactive form fields.
Article threads (/Threads). Each thread is a reading-order sequence of bead rectangles on pages — used by readers to jump between columns in a multi-column layout. Empty list when the catalog has no /Threads.
Embedded file attachments — typically the document author's supplementary files: source artwork, datasets, XML schemas, etc. Empty list when the document has no /EmbeddedFiles name tree.
The document catalog (/Root in the trailer).
Document-level JavaScript scripts from /Names /JavaScript. Map keys are the script names; values are the JS source. Empty when none.
Flattened interactive-form fields (the AcroForm field tree's terminal fields, with inheritable attributes resolved). Empty when the document has no form. Drives form-filling via io.github.yuroyami.kitepdf.writer.PdfEditor.
Document /Info dictionary (title, author, dates, …). Returns an empty info object if the trailer has no /Info or it doesn't resolve.
True if open (or openEncrypted) found a working password for an encrypted doc.
True if the document is encrypted.
Tagged-PDF accessibility metadata. null when the document has no /MarkInfo dict — i.e. it is not tagged.
Optional Content / layers metadata (read-only). null when the catalog has no /OCProperties.
Document outline (bookmarks). Top-level entries from the catalog /Outlines /First chain; empty list if the document has no outline.
Initial page-layout hint (/PageLayout). PageLayout.SinglePage when absent.
Initial UI panel hint (/PageMode). PageMode.UseNone when absent.
Document permissions (ISO 32000-1 §7.6.3.2 Table 22). Always allow-all for unencrypted documents; reflects the /P bit-flags from the security handler otherwise.
Viewer-preferences hints (/ViewerPreferences). Returns PdfViewerPreferences.DEFAULT when the catalog doesn't carry the dict.
Parsed XMP metadata. Extracts the common Dublin Core / Adobe PDF / XMP-basic properties. Falls back to the trailer /Info dict when XMP is absent — call info explicitly if you need both views.
Raw XMP metadata packet as a UTF-8 string, or null if the catalog has no /Metadata stream (or it doesn't resolve to one).
Functions
Look up a form field by its fully-qualified name; null if not present.
Resolve a /Dest (on a Link annotation or outline) or /A /D (a GoTo action's destination) to a typed PdfDestination. Accepts any of: an explicit array, a name pointing into the catalog's name-tree, or a dict containing /D (a wrapped destination). Returns null when the destination can't be resolved.