Actually, there is a very hacky way to do this. https://github.com/zach-klippenstein/compose-richtext/blob/main/printing/src/main/java/com/zachklipp/richtext/ui/printing/ComposePdfRenderer.kt#L74
I also used a very similar approach in the past for taking screenshots of composables but the hack I linked is more foreseeable. Moreover, I think this is something you were actually looking for the way you explained in here.