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 = KiteMatrix.IDENTITY)Properties
The indirect references of this page's annotations, in the order /Annots lists them. A caller that has an annotation's reference, such as a form field's widget, uses this to find which page holds it, without building every annotation.
Annotations attached to this page (links, highlights, etc.). Parsed from the page's /Annots array; empty when the page has none.
Extent of meaningful content (excluding margins, crop marks). Defaults to cropBox.
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.
The action the page's /AA /C entry names, run when the page closes (ISO 32000-1 §12.6.3, Table 195). Null when the page defines 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").
Page box in PDF user-space units (1/72 inch). left, bottom, right, top.
The action the page's /AA /O entry names, run when the page opens (ISO 32000-1 §12.6.3, Table 195). Null when the page defines none.
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.
Intended dimensions of the finished page after trimming. Defaults to cropBox.
mediaBox width, in points. This is the sheet, NOT what a viewer shows: it ignores /CropBox and /Rotate. For the on-screen size use displayWidth (or rotatedWidth, the same value).
Functions
Extract page text using the naive Tj/TJ/' / " operator scan.
The form field whose widget covers the point, in page space, or null when none does.
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.
rasterGeometry with the library's default allocation ceiling.
The PdfRasterGeometry for rendering this page at scale device pixels per PDF user-space unit (so scale = dpi / 72.0). maxPixels prevents an untrusted page size, /UserUnit, or accidental scale from requesting an allocation large enough to terminate the host process.
Draws only the annotations annotations accepts, with none of the page's own content.
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.
renderTo, drawing only the annotations annotations accepts. { false } renders the page content alone: for printing or exporting without markup, a clean thumbnail, or an editor that redraws its annotation layer on its own.