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.

Rasterization runs synchronously on the calling thread. Text measurement is not thread-safe on every platform, so call it from the main thread; PdfView does so post-frame to keep the cost out of the composition pass.

Constructors

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

Functions

Link copied to clipboard
fun rasterize(page: <Error class: unknown class>, widthPx: Int, heightPx: Int, background: Color = Color.White, hairlineWidthPx: Float = 1.0f): ImageBitmap

Renders page into a fresh widthPx×heightPx bitmap.