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.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Interactive form (AcroForm) catalog metadata. null when the catalog has no /AcroForm entry — the document carries no interactive form fields.

Link copied to clipboard

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.

Link copied to clipboard

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.

Link copied to clipboard
Link copied to clipboard

The document catalog (/Root in the trailer).

Link copied to clipboard

Document-level JavaScript scripts from /Names /JavaScript. Map keys are the script names; values are the JS source. Empty when none.

Link copied to clipboard

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.

Link copied to clipboard

Document /Info dictionary (title, author, dates, …). Returns an empty info object if the trailer has no /Info or it doesn't resolve.

Link copied to clipboard

True if open (or openEncrypted) found a working password for an encrypted doc.

Link copied to clipboard

True if the document is encrypted.

Link copied to clipboard

Document language tag (BCP 47), e.g. "en-US", "fr-CA". null when /Lang is absent.

Link copied to clipboard

Tagged-PDF accessibility metadata. null when the document has no /MarkInfo dict — i.e. it is not tagged.

Link copied to clipboard

Optional Content / layers metadata (read-only). null when the catalog has no /OCProperties.

Link copied to clipboard

Document outline (bookmarks). Top-level entries from the catalog /Outlines /First chain; empty list if the document has no outline.

Link copied to clipboard
Link copied to clipboard

Initial page-layout hint (/PageLayout). PageLayout.SinglePage when absent.

Link copied to clipboard

Initial UI panel hint (/PageMode). PageMode.UseNone when absent.

Link copied to clipboard

All pages in document order (lazily built from the catalog's /Pages tree).

Link copied to clipboard

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.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Viewer-preferences hints (/ViewerPreferences). Returns PdfViewerPreferences.DEFAULT when the catalog doesn't carry the dict.

Link copied to clipboard

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.

Link copied to clipboard

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).

Link copied to clipboard

Functions

Link copied to clipboard

Open an incremental-update editor over this document. Edits are saved by appending to the original bytes (see PdfEditor); this document instance itself is never mutated.

Link copied to clipboard
fun formField(fullyQualifiedName: String): PdfFormField?

Look up a form field by its fully-qualified name; null if not present.

Link copied to clipboard
open override fun resolve(ref: PdfReference): PdfObject?
Link copied to clipboard

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.