Version 1.0.6-beta

PDF Generator for Android

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.

API 24+ Min SDK
Kotlin Language
Apache 2.0 License
MainActivity.kt
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)

✨ Powerful Features

Everything you need to generate professional PDF documents on Android

📝

Rich Text Support

Titles, headings, paragraphs with custom fonts, colors, sizes, and alignment options.

📊

Tables

Full-featured tables with headers, cell styling, and automatic page splitting.

📱

QR Codes

Generate QR codes for URLs, contacts, WiFi, email, phone, SMS, vCard, and location.

🖼️

Images

Add images with flexible sizing, aspect ratio control, and alignment options.

☑️

Checkboxes

Perfect for forms, checklists, surveys, and interactive documents.

📋

Lists

Bullet lists and numbered lists with automatic continuation across pages.

📦

Box Elements

Info, warning, error, and success boxes for highlighted content sections.

🔖

Headers & Footers

Customizable headers and footers with automatic page numbering.

💧

Watermarks

Text watermarks with custom rotation, color, and transparency settings.

📐

Multiple Page Sizes

A3, A4, A5, A6, Letter, Legal, or define your own custom page sizes.

Auto Pagination

Content automatically flows across multiple pages with intelligent splitting.

🧩

Kotlin DSL

Clean, intuitive Kotlin DSL syntax for building PDFs programmatically.

📦 Quick Installation

Add PDF Generator to your project in seconds

build.gradle.kts
dependencies {
    implementation("io.github.alims-repo:pdf-generator:1.0.6-beta")
}
build.gradle
dependencies {
    implementation 'io.github.alims-repo:pdf-generator:1.0.6-beta'
}

🚀 Quick Example

Generate your first PDF in minutes

Create a PDF with DSL
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
}

📤 Flexible Output Options

Save your PDF wherever you need it

📁 To File

pdf { ... }.saveToFile(file)

📂 To Path

pdf { ... }.saveToPath(dir, "doc.pdf")

📊 To ByteArray

pdf { ... }.toByteArray()

🌊 To OutputStream

pdf { ... }.toOutputStream(stream)

Ready to Generate PDFs?

Start building beautiful PDF documents with PDF Generator today.