KiteCanvas
High-level drawing target. Implement this to add a new render backend; use PdfPage.renderTo to drive an existing one.
The PageRenderer walks the content stream, maintains the graphics-state stack, accumulates paths, and finally calls one of these device methods with a complete, ready-to-paint primitive. Backends therefore don't need to track the CTM, the current path, or text positioning. They receive only the final geometry plus the transform to apply.
Concrete implementations shipped:
ComposeCanvas(:kitepdf-compose-viewer): paints into a ComposeDrawScope.SkiaCanvas(:kitepdf-skia-renderer): paints into a SkiaCanvas.AwtCanvas/AndroidNativeCanvas/CoreGraphicsCanvas/Canvas2dCanvas(:kitepdf-native-renderer): host-platform raster backends.
Inheritors
Properties
True when this canvas needs resolved glyph outlines (TextGlyph.outline), i.e. it actually paints (a render backend). Extraction canvases that only read text + advances override this to false, letting the driver skip the cost of resolving glyph outlines. Such a canvas gets every text run through drawGlyphs, also a run that paints nothing, such as invisible OCR text.
Functions
Apply a soft mask to the content rendered inside render (ISO 32000-1 §11.6.5). The default implementation just calls render. Backends without offscreen compositing fall back to painting through the mask.
Set up for a page render. The renderer calls this once before any draw call, with the page dimensions (in PDF user units, 1pt = 1/72 inch) and the desired device CTM (e.g. flip Y and scale to fit a target rectangle).
Open a transparency group (ISO 32000-1 §11.4). Subsequent paints accumulate into an offscreen layer; endTransparencyGroup composites the layer back onto the parent with blendMode + alpha.
Paint one text run, already laid out into glyphs by the document handler. Format-neutral: no PDF (or other) font object crosses the seam, so every handler (PDF, EPUB, and others) drives text the same way.
The outline of text in the host face this canvas draws a font without embedded outlines in, chosen from fontSpec as drawGlyphs chooses it. The outline is in glyph space: 1000 units per em, y up, and the pen at the origin on the baseline. A document handler strokes and clips such text with it, since a missing font program does not excuse the stroke (ISO 32000-1, 9.3.6).
Renders the complex shading types, so every backend supports them identically with no code of its own: