PdfRasterizer

class PdfRasterizer(density: Density, layoutDirection: LayoutDirection, textMeasurer: TextMeasurer)

Imperative page → ImageBitmap pipeline. This is the raster engine behind PdfView; it is public so apps with custom viewers (own pagers, thumbnail grids, PNG export jobs) don't have to re-implement the CTM/flip/hairline math themselves.

Obtain one inside composition with rememberPdfRasterizer, or construct it directly off-composition when you already hold a TextMeasurer.

rasterize runs synchronously on the calling thread; rasterizeOffMain moves the work to kitepdfRasterDispatcher (a background pool on JVM/Android/Apple, Main on JS/Wasm) so a complex page never janks scrolling or pinch. PdfView uses that path.

Constructors

Link copied to clipboard
constructor(density: Density, layoutDirection: LayoutDirection, textMeasurer: TextMeasurer)

Functions

Link copied to clipboard
fun rasterize(page: KitePage, widthPx: Int, heightPx: Int, background: Color = Color.White, hairlineWidthPx: Float = 1.0f, theme: ReaderTheme? = null): ImageBitmap

Renders page into a fresh widthPx×heightPx bitmap.

Link copied to clipboard
suspend fun rasterizeOffMain(page: KitePage, widthPx: Int, heightPx: Int, background: Color = Color.White, hairlineWidthPx: Float = 1.0f, theme: ReaderTheme? = null): ImageBitmap

rasterize, off the main thread where the platform allows. One page runs to completion once started (the synchronous renderer has no cancellation points; the operation budget bounds the worst case), so cancellation takes effect between pages.