PdfDocument

An open PDF document.

Closing is idempotent and invalidates every PdfPage descriptor created from this document. Stop using the document in UI and page operations before closing it. A closed document must never be reused. If cleanup fails, later calls to close or closeAndAwait rethrow the same failure.

Properties

Link copied to clipboard

Whether the document has been closed.

Link copied to clipboard

Number of pages. Page indexes are zero-based.

Functions

Link copied to clipboard
suspend fun bookmarks(): List<PdfBookmark>

Returns the document outline (bookmark tree).

Link copied to clipboard
open override fun close()

Closes the document and releases its PDFium resources.

Link copied to clipboard
suspend fun closeAndAwait()

Closes this document without blocking the calling thread while waiting for an active PDFium operation to finish.

Link copied to clipboard
operator fun get(pageIndex: Int): PdfPage

Returns a lightweight descriptor for the page at pageIndex.

Link copied to clipboard

Returns structural information: version, permissions, and flags.

Link copied to clipboard
suspend fun metadata(): PdfMetadata

Returns the document information dictionary values.

Link copied to clipboard
suspend fun pageLabel(pageIndex: Int): String?

Returns the page label assigned by the page numbering tree, or null when the page has no label.