pdf

fun pdf(factory: PdfDriverFactory = defaultPdfDriverFactory(), block: DocumentScope.() -> Unit): PdfDocument

Top-level entry point of the PdfKmp DSL. Builds a PDF document and returns it ready for PdfDocument.save or PdfDocument.toByteArray.

Example:

val document = pdf {
metadata { title = "Invoice" }
page {
padding = Padding.all(40.dp)
text("Hello, world!") {
fontSize = 18.sp
bold = true
}
}
}
document.save("/tmp/hello.pdf")

Parameters

factory

backend used to encode the document; defaults to the platform's defaultPdfDriverFactory. Override for tests or to use an alternative PDF backend.

block

DSL configuration applied to a fresh DocumentScope.