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
Annotations attached to this page (links, highlights, etc.). Parsed from the page's /Annots array; empty when the page has none.
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").
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.
Height of displayBox after applying rotationNormalized (dimensions swap at 90/270).
Width of displayBox after applying rotationNormalized (dimensions swap at 90/270).
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).
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.
Functions
Extract page text using the naive Tj/TJ/' / " operator scan.
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.
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.