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 KiteCanvas (see :kitepdf-compose-viewer 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

The region to display: cropBox clamped to mediaBox bounds (their intersection). Falls back to mediaBox when the intersection is empty or degenerate (zero/negative width or height).

Link copied to clipboard
open override val displayHeight: Double
Link copied to clipboard
open override val displayWidth: Double
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

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

Height of displayBox after applying rotationNormalized (dimensions swap at 90/270).

Link copied to clipboard

Width of displayBox after applying rotationNormalized (dimensions swap at 90/270).

Link copied to clipboard
Link copied to clipboard

rotation normalised into {0, 90, 180, 270}: reduced modulo 360 into [0, 360) then snapped to the nearest right angle (defensive: in practice the value is already a multiple of 90).

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
open override fun displayToDeviceBase(): Matrix
Link copied to clipboard

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

Link copied to clipboard

The unscaled user-space -> device base transform, with the device origin at the top-left and y growing downward. The resulting device box is [0, rotatedWidth] x [0, rotatedHeight]. Compose additional scaling on top of this to fit a target surface.

Link copied to clipboard
open override fun renderTo(canvas: KiteCanvas, deviceCtm: Matrix)

Render this page into a KiteCanvas (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.

Link copied to clipboard
fun PdfPage.search(needle: String, ignoreCase: Boolean = true): List<PdfSearchHit>

Find needle on this page. Matches may cross line boundaries inside a block (a break reads as one space, or joins directly after a hyphenated line with the hyphen dropped); they never cross block boundaries.

Link copied to clipboard
open override fun textContent(): KiteStructuredText