For complex layouts, dynamic content length, or content that doesn't fit a fixed-template model, generating the entire PDF programmatically from a data source is more flexible:
pdf-lib (JavaScript/Node.js) — Draw text, images, shapes, and set positions programmatically. Excellent for client-side browser generation (as in
this editor) and Node.js server-side generation. For mail merge, iterate over records and generate one PDF per record (or all pages in one PDF using separate page additions).
ReportLab (Python) — A mature Python library for programmatic PDF generation. The Platypus framework provides flow-based layout similar to HTML/CSS. Excellent for data-driven reports, certificates, and any document where content length varies by record.
iText/PDFBox (Java) — Enterprise-grade programmatic PDF generation with comprehensive font support, table layout, and Unicode handling. iText is the standard choice for Java-based enterprise document generation pipelines.
Puppeteer/wkhtmltopdf (HTML-to-PDF) — Generate personalised HTML using a template engine (Handlebars, Jinja2, Mustache) and convert to PDF. Puppeteer uses Chromium's rendering engine, producing high-quality output with excellent CSS support. This approach is fastest for developers comfortable with web technologies and is particularly good for complex layouts that would be tedious to reproduce with a drawing API.
Tradeoffs: AcroForm population is simplest for fixed templates. Programmatic generation is most flexible. HTML-to-PDF conversion provides the best developer experience for complex layouts but produces larger files and limited PDF/A compliance.