Comparison
HTML to PDF in Java without PDFBox
Apache PDFBox is a library for reading, writing, and manipulating PDF files at a low level. It does not render HTML. Building an invoice or report with PDFBox means calculating the pixel position of every text string, line, and image manually. Any layout change requires updating coordinate values throughout the code. PDFPipe accepts HTML and CSS templates and renders them with a browser engine, so you design documents the same way you design web pages.
What PDFBox is for versus what you probably need
| PDFPipe | PDFBox | |
|---|---|---|
| Input | HTML + CSS template | Programmatic drawing API |
| Layout model | CSS layout engine | Manual x/y coordinates |
| Iteration speed | Edit HTML, reload | Recompile, recalculate positions |
| Table support | CSS tables | Draw every cell border manually |
| Images | Any URL in HTML | Embed via PDImageXObject |
| Fonts | Web fonts from URL | Embed TTF/OTF files |
| Use case fit | Documents from templates | PDF manipulation, form fill, merge, sign |
PDFBox is the wrong tool for HTML rendering
PDFBox is an excellent library for what it does: reading PDF metadata, extracting text, filling form fields, merging files, and adding digital signatures. It is not designed to render HTML to PDF and has no HTML parser. Teams that try to use it for invoice or report generation end up writing and maintaining their own layout engine, including text wrapping, page breaks, and table pagination. This is significant work that a browser engine does automatically.
Migration
// Before: PDFBox — manual coordinate layout for every element
PDDocument doc = new PDDocument();
PDPage page = new PDPage(PDRectangle.A4);
doc.addPage(page);
PDPageContentStream cs = new PDPageContentStream(doc, page);
cs.setFont(PDType1Font.HELVETICA_BOLD, 18);
cs.beginText();
cs.newLineAtOffset(50, 750); // pixel coordinates
cs.showText("Invoice #" + invoice.getId());
cs.endText();
// ... repeat for every field, line item, total ...
cs.close();
ByteArrayOutputStream out = new ByteArrayOutputStream();
doc.save(out);// After: PDFPipe — write HTML, get a PDF
String html = templateEngine.process("invoice", ctx);
byte[] pdf = restTemplate.postForObject(
"https://api.pdfpipe.xyz/v1/pdf",
new HttpEntity<>(
Map.of("html", html, "options", Map.of("format", "A4")),
bearerHeaders(apiKey)
),
byte[].class
);When to keep PDFBox
Keep PDFBox when you need to manipulate existing PDF files: merging documents, extracting text for indexing, filling AcroForm fields, or adding digital signatures. For generating new PDFs from HTML templates, a render API removes the coordinate-math entirely.
Full Spring Boot and Java examples on the Java guide.
See pricing →