image

fun image(bytes: ByteArray, width: Dp, height: Dp, contentScale: ContentScale = ContentScale.Fit, allowDownScale: Boolean = true, altText: String? = null)

Appends an image node with explicit dimensions.

Parameters

bytes

encoded bytes of the source image. PNG and JPEG are supported on every platform; WebP and HEIF are decoded by the platform when available (Android 10+ for HEIF, iOS 11+ for both).

width

rendered width on the page.

height

rendered height on the page.

contentScale

how to fit the intrinsic pixels into the destination rectangle. Defaults to ContentScale.Fit which preserves aspect ratio with letterboxing.

allowDownScale

when true (default), the platform backend subsamples the source bitmap to roughly match the rendered size at 200 DPI before drawing — keeping heap and PDF size in check for image-heavy documents. Pass false for one-off assets that must keep every source pixel.


fun image(bytes: ByteArray, width: Dp, contentScale: ContentScale = ContentScale.Fit, allowDownScale: Boolean = true, altText: String? = null)

Appends an image whose width is given and whose height is derived from the intrinsic aspect ratio (sniffed from the PNG/JPEG header).

Falls back to the supplied width as the height if the format header is not recognized — pass an explicit height in that case.

Parameters

allowDownScale

see the explicit-dimensions overload above.


fun image(bytes: ByteArray, contentScale: ContentScale = ContentScale.Fit, allowDownScale: Boolean = true, altText: String? = null)

Appends an image rendered at its intrinsic pixel dimensions, mapped 1px → 1pt. Useful when the source asset is already sized for print.

Parameters

allowDownScale

see the explicit-dimensions overload above.