PdfPage

class PdfPage

A single PDF page. Obtained from PdfDocument.pages; not constructed directly.

val page = doc.pages[0]
println("${page.width} x ${page.height} pt, rotation ${page.rotation}°")
println(page.extractText())
for (link in page.annotations) { /* … */}

// Paint into any backend implementing PdfCanvas (see :kitepdf-compose etc.):
page.renderTo(canvas, deviceCtm = Matrix.IDENTITY)

Properties

Link copied to clipboard

Annotations attached to this page (links, highlights, etc.). Parsed from the page's /Annots array; empty when the page has none.

Link copied to clipboard

Extent of meaningful content (excluding margins, crop marks). Defaults to cropBox.

Link copied to clipboard

Region the page is to be clipped to for production-style output (printing with bleed). Defaults to cropBox when /BleedBox is absent. ISO 32000-1 §14.11.2.

Link copied to clipboard

Decoded content-stream bytes (FlateDecode etc. applied). May be empty. If /Contents is an array, the chunks are concatenated with a separating newline (per ISO 32000-1 §7.8.2: "The effect is as if all of the streams in the array were concatenated").

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val index: Int

Zero-based position in the document's flat page list.

Link copied to clipboard

Display label from /PageLabels (e.g. "iii", "A-1", "12"). Falls back to the one-based index as a string when the document doesn't define its own labels.

Link copied to clipboard

Page box in PDF user-space units (1/72 inch). left, bottom, right, top.

Link copied to clipboard
val reference: PdfReference? = null

The page's own indirect reference (its entry in the parent's /Kids). null only for the unusual case of a page dict inlined directly in /Kids. The writer needs this to target the page object for edits.

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

Structured text — spans clustered into lines, lines clustered into blocks. Use this when you need geometry (selection rectangles, search highlights) alongside the text. For a plain string, prefer extractText.

Link copied to clipboard

Intended dimensions of the finished page after trimming. Defaults to cropBox.

Link copied to clipboard

Multiplier for user-space units on this page (PDF 1.6+, §14.8.1). Default 1.0 — each unit is 1/72 inch. A /UserUnit of 2.0 means each unit is 2/72 inch, doubling the effective page size for the same coordinate stream. Useful for very large pages (architectural drawings, posters).

Link copied to clipboard

Functions

Link copied to clipboard

Extract page text using the naive Tj/TJ/' / " operator scan.

Link copied to clipboard
fun renderTo(canvas: PdfCanvas, deviceCtm: Matrix = Matrix.IDENTITY)

Render this page into a PdfCanvas (typically the Compose binding's ComposeCanvas). deviceCtm is applied on top of user-space — pass an identity matrix for a 1pt = 1pt rendering, or a scaled / Y-flipped matrix to fit a UI surface.