Developers
There are three ways to produce a PDF from code, and the choice matters more than the library.
| Approach | How it works | Best for | Watch out for | Examples |
|---|---|---|---|---|
| Drawing API | You position text, lines and images in points on each page. | Labels, certificates, forms, anything with a fixed layout; small dependencies; full control of the output file. | You write the layout code: line wrapping, pagination, tables. | pdf-lib, PDFKit, fpdf2, FPDF, PDFsharp, PDFBox, go-pdf/fpdf, SynPDF |
| Layout engine | You describe a document (paragraphs, tables, columns) and the library paginates it. | Reports, invoices, data-heavy documents with predictable structure. | Each engine has its own layout model to learn; HTML and CSS skills do not transfer. | ReportLab Platypus, QuestPDF, iText layout, pdfmake, Maroto |
| HTML renderer | You produce HTML and CSS; a browser engine or a CSS paged-media engine renders it to PDF. | Documents that already exist as web templates; rich typography; teams fluent in CSS. | A browser process to run and secure; print CSS has its own rules; output files are larger and less structured. | Headless Chromium (Puppeteer, Playwright), WeasyPrint, Prince, mPDF, Dompdf, OpenHTMLtoPDF |
A rule that holds across languages: if the document has a fixed layout and fewer than a few dozen elements, a drawing API is the smallest and most reliable choice. If it is a multi-page report with tables, a layout engine saves weeks. If it is a web page that must also exist as a PDF, render the HTML and spend the saved time on the print stylesheet. The HTML-to-PDF guide covers that pipeline in depth, independent of language.
Every language guide below uses the same shape: a comparison table with the exact licence of each library, two or three complete examples that were run before publication, and the traps specific to that ecosystem, fonts above all.
- HTML to PDF
The rendering pipeline, engine choice, print CSS, headers and footers, fonts, security and scaling, with a verified Chromium example.
- JavaScript
pdf-lib, PDFKit, jsPDF, pdfmake and react-pdf compared, with executed Node examples and the traps around fonts, Unicode and buffers.
- Python
ReportLab, fpdf2, WeasyPrint, pypdf and Playwright compared, with examples checked against the current documentation and the traps around fonts and system libraries.
- PHP
FPDF, TCPDF, mPDF, Dompdf and headless Chrome compared by approach, CSS support and licence, with examples checked against the documentation.
- C# and .NET
QuestPDF, PDFsharp and MigraDoc, iText 9, PdfPig and headless Chromium compared, with examples and the traps that break Linux deployments.
- Java
Apache PDFBox, OpenPDF, iText 9, OpenHTMLtoPDF, Playwright, JasperReports and Apache FOP compared, with examples and the font traps.
- Go
go-pdf/fpdf, Maroto v2, pdfcpu, gopdf, UniPDF and headless Chromium with chromedp compared, with examples and Go-specific traps.
- Delphi and Free Pascal
SynPDF, fcl-pdf, llPDFLib, libHaru, report-engine exports and commercial SDKs for Object Pascal, with examples and licences.
- llPDFLib historyReference
What the llionsoft products were, their version timeline from 2002 to 2017, and where the open-source code lives now.