toBytes

suspend fun <Error class: unknown class>.toBytes(): ByteArray

Reads the bytes of a Compose Multiplatform DrawableResource from the platform's default resource environment.

Use this from a suspend context (a coroutine, a LaunchedEffect, or a Swift Task { }), then hand the result to the PdfKmp DSL — for example image(bytes = Res.drawable.photo.toBytes(), width = 200.dp). Suitable for raster formats accepted by image(...) (PNG, JPEG, and any format the running platform decodes), and also for the raw XML / SVG payload consumed by toVectorImage.

Receiver

the typed Res.drawable.* reference produced by the Compose Multiplatform resources plugin.

Return

the file's raw bytes exactly as packaged inside the consumer project's composeResources/ tree.