AndroidPdfBitmapRenderer

Headless rendering on Android. Produces an ARGB_8888 Bitmap sized by PdfPage.rasterGeometry (rotation, crop box and /UserUnit all included), at scale device pixels per point. No Compose dependency.

Typical uses:

  • Custom View onDraw(Canvas) overrides that paint the bitmap onto the screen.

  • Generating cached page thumbnails on disk.

  • Pre-rendering pages off the main thread (call from a coroutine on Dispatchers.Default).

Functions

Link copied to clipboard
fun renderToBitmap(page: PdfPage, scale: Double = 1.0, background: Int = Color.WHITE): Bitmap

Render with the default allocation ceiling.

fun renderToBitmap(page: PdfPage, scale: Double = 1.0, background: Int = Color.WHITE, maxPixels: Long): Bitmap

Render with an explicit allocation ceiling.