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"). A /Contents that is null or of a type no content can have is an empty page, which still draws its annotations (#583).
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 kid inlined directly in /Kids. The writer needs this to target the page object for edits. A blank page that stands for a kid that is no dictionary keeps the kid's reference, so it can be removed, though it names no page dictionary (#585).
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
The page's text as one string, in the order of its content stream. Text inside form XObjects counts, and /ActualText replaces the text it marks. Use structuredText for positions and reading order.
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.
This page's content in the order a screen reader says it (#208). A tagged page follows its structure tree: one item per paragraph, heading, list item, table cell, caption or figure, with the role its structure type gives, and artifacts such as running heads left out. A page without tagged content gives its text blocks in layout order.
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 that stops between operators once cancellation reads true (#188).
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.
renderTo with the form being filled: a widget whose field has a value in formState is drawn from that value, and a field the state hides is not drawn. Pass null to render the file as it arrived.
renderTo with the form state, the annotation filter and a cancellation that stops the render between operators once it reads true. The page returns with the canvas closed and what it painted so far (#188).
The form widget under a point in page space, with its field, or null when none is there.