A lightweight, powerful Kotlin DSL library for generating multi-page PDF documents on Android. Create professional PDFs with text, tables, images, QR codes, and more — all with automatic pagination.
pdf {
pageSize(PageSize.A4)
margins(PageMargins.NORMAL)
title("My Document")
text("Hello, PDF Generator!")
spacer(16f)
table {
header("Name", "Age", "City")
row("John", "28", "New York")
row("Jane", "32", "London")
}
qrCode("https://example.com")
}.saveToFile(outputFile)
Everything you need to generate professional PDF documents on Android
Titles, headings, paragraphs with custom fonts, colors, sizes, and alignment options.
Full-featured tables with headers, cell styling, and automatic page splitting.
Generate QR codes for URLs, contacts, WiFi, email, phone, SMS, vCard, and location.
Add images with flexible sizing, aspect ratio control, and alignment options.
Perfect for forms, checklists, surveys, and interactive documents.
Bullet lists and numbered lists with automatic continuation across pages.
Info, warning, error, and success boxes for highlighted content sections.
Customizable headers and footers with automatic page numbering.
Text watermarks with custom rotation, color, and transparency settings.
A3, A4, A5, A6, Letter, Legal, or define your own custom page sizes.
Content automatically flows across multiple pages with intelligent splitting.
Clean, intuitive Kotlin DSL syntax for building PDFs programmatically.
Add PDF Generator to your project in seconds
dependencies {
implementation("io.github.alims-repo:pdf-generator:1.0.6-beta")
}
dependencies {
implementation 'io.github.alims-repo:pdf-generator:1.0.6-beta'
}
Generate your first PDF in minutes
import io.github.alimsrepo.pdf.generator.pdf
import io.github.alimsrepo.pdf.generator.saveToFile
// Create a PDF file
val pdfFile = File(context.cacheDir, "invoice.pdf")
pdf {
// Page Configuration
pageSize(PageSize.A4)
orientation(PageOrientation.PORTRAIT)
margins(PageMargins.NORMAL)
// Header & Footer
header(center = "INVOICE", showPageNumber = true)
footer(center = "Company Name • contact@company.com")
// Watermark
textWatermark("PAID", rotation = -45f)
// Content
title("Invoice #INV-2024-001")
spacer(20f)
text("Bill To:", size = 14f, typeface = Typeface.DEFAULT_BOLD)
text("John Doe")
text("123 Main Street")
text("New York, NY 10001")
spacer(20f)
divider()
spacer(20f)
// Invoice Items Table
table {
header("Item", "Qty", "Price", "Total")
row("Product A", "2", "$50.00", "$100.00")
row("Product B", "1", "$75.00", "$75.00")
row("Product C", "3", "$25.00", "$75.00")
}
spacer(20f)
text("Total: $250.00", size = 18f, align = TextAlign.RIGHT)
spacer(30f)
// QR Code for payment
text("Scan to Pay:", align = TextAlign.CENTER)
qrCode("https://pay.example.com/inv-2024-001", size = 150f)
}.saveToFile(pdfFile)
// Share or open the PDF
pdfFile.let { file ->
// Use FileProvider to share
}
Save your PDF wherever you need it
pdf { ... }.saveToFile(file)
pdf { ... }.saveToPath(dir, "doc.pdf")
pdf { ... }.toByteArray()
pdf { ... }.toOutputStream(stream)
Start building beautiful PDF documents with PDF Generator today.