AwtPdfRasterizer

Headless raster output using AWT + ImageIO: no Skia, no Compose, no native binaries beyond what the JDK already ships. Perfect for:

  • CI / server-side PDF → PNG / JPEG conversion

  • Embedded thumbnails inside JavaFX / Swing apps

  • "I just need a BufferedImage" use cases

Functions

Link copied to clipboard
fun encodeToJpeg(page: PdfPage, scale: Double = 1.0, background: Color = Color.WHITE): ByteArray

Returns JPEG bytes. Quality is JDK default; tweak with custom ImageWriter when needed.

fun encodeToJpeg(page: PdfPage, scale: Double = 1.0, background: Color = Color.WHITE, maxPixels: Long): ByteArray

Returns JPEG bytes with an explicit allocation ceiling.

Link copied to clipboard
fun encodeToPng(page: PdfPage, scale: Double = 1.0, background: Color = Color.WHITE): ByteArray

Returns PNG bytes ready to write to disk / a network response.

fun encodeToPng(page: PdfPage, scale: Double = 1.0, background: Color = Color.WHITE, maxPixels: Long): ByteArray

Returns PNG bytes with an explicit allocation ceiling.

Link copied to clipboard
fun renderToImage(page: PdfPage, scale: Double = 1.0, background: Color = Color.WHITE): BufferedImage

Render with the default allocation ceiling.

fun renderToImage(page: PdfPage, scale: Double = 1.0, background: Color = Color.WHITE, maxPixels: Long): BufferedImage

Render with an explicit allocation ceiling.