Usage Guide

compose2pdf lets you render any @Composable content to PDF. The core pattern is simple:

// Returns ByteArray
val pdfBytes: ByteArray = renderToPdf {
    // Your Compose content here
}

// Or stream directly to an OutputStream
renderToPdf(outputStream) {
    // Your Compose content here
}

Everything you write inside the lambda is standard Compose – Column, Row, Box, Text, Canvas, Image, and all the modifiers you already know.


Topics

Topic What you’ll learn
Single Page Render a single-page PDF with all configuration options
Multi-page Create multi-page documents with headers, footers, and page numbers
Auto-pagination Automatic page splitting for flowing content
Page Configuration Page sizes (A4, Letter, A3), margins, landscape, custom dimensions
Text and Fonts Text styling, font weights, decorations, custom fonts
Layout Column, Row, Box, weights, alignment, tables
Shapes and Drawing Backgrounds, borders, clips, Canvas drawing, rounded corners
Images Embedding bitmap images, clipping, sizing
Links Clickable URL annotations in PDF output
Vector vs Raster Choosing between vector and raster rendering modes

Table of contents