Repository navigation
Home
Build reports in Java, one element at a time.
Unbox PDF is a small Java library for creating PDFs with a fluent API on top of Apache PDFBox. Combine paragraphs, rows, columns, tables, and custom graphics to build reports, invoices, and other structured documents.
It is designed for application code that already knows what it wants to print. Layout is expressed in Java; HTML rendering and a template engine are outside its scope.
Start with your first PDF · Browse the source · Read the changelog
| Principle | What it means when writing a report |
|---|---|
| Work from top to bottom | Call document.render(...) in reading order. Unbox places the next element below the previous one. |
| Compose small elements | Use paragraphs for text, rows and columns for groups, and tables for repeated records. |
| Keep spacing explicit | Margins separate elements; padding separates content from its edges. Measurements use PDF points, with helpers for physical units. |
| Let the element handle page breaks | Ordinary elements move as a whole; tables break between rows and can repeat their headers. |
| Keep drawing accessible | Use decorators for visual treatments and Canvas or PDFBox for custom graphics. |
| Own the document lifecycle | Create, render, finish, save, and close. Use a separate Document for each PDF. |
| Guide | What you will build or learn |
|---|---|
| Getting started | Add the Maven dependency and save your first PDF. |
| Page layout and units | Set page orientation, margins, padding, and deliberate page breaks. |
| Text layout | Wrap and align paragraphs, mix text styles, and handle overflow. |
| Fonts and encoding | Choose fonts, embed your own TrueType files, and reject missing glyphs. |
| Rows and columns | Arrange content side by side, stack it, and stretch panels. |
| Tables | Define columns, style cells and dividers, and repeat table headers. |
| Headers, footers, and page numbers | Add repeated page content and “Page x of y.” |
| Styling and custom drawing | Add backgrounds, rounded borders, and simple drawn graphics. |
| Designing reports for Unbox | For designers: what is cheap, what is expensive, and what a handover should specify. |
These guides target Unbox PDF 0.10.1, Java 17 or newer, and PDFBox 2.x. They start with complete examples and then explain the choices behind them.
Unbox writes content as you render it. It does not perform a later document-wide layout pass. Large paragraphs, containers, and individual table rows are not automatically split across pages; keep them small enough to fit. Most fluent configuration methods mutate their element, so create fresh elements for independent layouts.
For deeper details, see the repository's library principles and executable samples.
Unbox PDF wiki · Source · Examples target Unbox PDF 0.10.1 and Java 17+.
Unbox PDF
Start here
Build your content
Finish your report
Design
Project