ApplePdfRasterizer

Headless rendering on Apple platforms (iOS, macOS, tvOS) — produces a PNG-encoded NSData sized to the page in pt × scale. Pure CoreGraphics + ImageIO, no UIKit/AppKit, no Compose dependency.

Typical uses:

  • Pre-rendering thumbnails on disk (writeToFile:atomically:)

  • Generating sharing previews / extension thumbnails

  • CI snapshots of PDF rendering

For drawing into a UIView's drawRect: (or an NSView) directly, instantiate CoreGraphicsCanvas over the current CGContext instead — the rasterizer is for off-screen output.

Functions

Link copied to clipboard
fun renderToPngData(page: <Error class: unknown class>, scale: Double = 1.0, backgroundR: Double = 1.0, backgroundG: Double = 1.0, backgroundB: Double = 1.0, backgroundA: Double = 1.0): <Error class: unknown class>?

Render a page into a PNG-encoded NSData. Returns null if the underlying CGBitmapContext or PNG encoder can't be created (very rare; would indicate a system-level resource failure).