
Render @Composable UI into multi‑page vector PDFs with automatic and item‑based pagination, custom page formats/orientation, and consistent layout styling for pixel‑accurate document exports.
A Compose Multiplatform library for exporting UI content to vector PDFs across Android, iOS, and JVM/desktop.
@Composable to a multi‑page PDF (vector output).A4, Letter, Custom, etc.) and orientation.kotlin {
sourceSets {
commonMain.dependencies {
implementation("de.charlex.compose:multiplatform-pdf-export:<version>")
}
}
}Use the version shown in the Maven Central badge above.
val pdfBytes = renderComposeToPdf(
context = PdfContext(),
format = PdfFormat.A4,
orientation = PdfOrientation.Portrait
) {
Column {
Text("Hello PDF")
// ... long content
}
}val pdfBytes = renderComposeToPdf(
context = PdfContext(),
format = PdfFormat.A4,
orientation = PdfOrientation.Portrait
) {
item { Header() }
items(data) { row -> RowItem(row) }
item { Footer() }
}// Android
val pdfBytes = renderComposeToPdf(
context = PdfContext(activity),
content = { /* ... */ }
)
// iOS / JVM
val pdfBytes = renderComposeToPdf(
context = PdfContext(),
content = { /* ... */ }
)android.graphics.pdf.PdfDocument.PDF output uses the Compose rendering stack. If you need identical typography across platforms, consider providing explicit fonts in your Compose theme (instead of relying on system defaults).
See sample/ for Android, iOS and JVM examples.
MIT — see LICENSE.
A Compose Multiplatform library for exporting UI content to vector PDFs across Android, iOS, and JVM/desktop.
@Composable to a multi‑page PDF (vector output).A4, Letter, Custom, etc.) and orientation.kotlin {
sourceSets {
commonMain.dependencies {
implementation("de.charlex.compose:multiplatform-pdf-export:<version>")
}
}
}Use the version shown in the Maven Central badge above.
val pdfBytes = renderComposeToPdf(
context = PdfContext(),
format = PdfFormat.A4,
orientation = PdfOrientation.Portrait
) {
Column {
Text("Hello PDF")
// ... long content
}
}val pdfBytes = renderComposeToPdf(
context = PdfContext(),
format = PdfFormat.A4,
orientation = PdfOrientation.Portrait
) {
item { Header() }
items(data) { row -> RowItem(row) }
item { Footer() }
}// Android
val pdfBytes = renderComposeToPdf(
context = PdfContext(activity),
content = { /* ... */ }
)
// iOS / JVM
val pdfBytes = renderComposeToPdf(
context = PdfContext(),
content = { /* ... */ }
)android.graphics.pdf.PdfDocument.PDF output uses the Compose rendering stack. If you need identical typography across platforms, consider providing explicit fonts in your Compose theme (instead of relying on system defaults).
See sample/ for Android, iOS and JVM examples.
MIT — see LICENSE.