22 Supported PDF Libraries Across 8 Programming Runtimes
Compare the 22 PDF libraries CodePDF exports to: React-PDF, pdf-lib, jsPDF, PDFKit, Puppeteer, ReportLab, WeasyPrint, Dompdf, QuestPDF, PDFBox and more.
All 22 engines supported: @react-pdf/renderer, pdf-lib, jsPDF, PDFKit Node, pdfmake, ReportLab, fpdf2, WeasyPrint, xhtml2pdf, Dompdf, TCPDF, FPDF PHP, printpdf, lopdf, pdf-writer, gofpdf, Prawn, QuestPDF, Apache PDFBox, Puppeteer, Playwright, HTML5 Paged Media.
Node.js PDF Libraries (8)
@react-pdf/renderer (v4.3.0)
Compiles layouts to @react-pdf/renderer TSX components powered by a custom React reconciler and Meta’s Yoga Flexbox engine (no browser or DOM). Produces the #2 smallest multi-page PDF overall (126.8 KB across 18 pages in 1.06s; 12 ms single-page) and is best run on Node.js servers (including Next.js Route Handlers via renderToBuffer()) or client-only React SPAs.
@react-pdf/renderer uses Yoga Flexbox primitives (<Document>, <Page>, <View>, <Text>, <Image>) styled with StyleSheet.create() rather than HTML DOM tags. CodePDF compiles visual layouts, repeating arrays, headers/footers, and data tables into idiomatic Flexbox TSX components with Font.register() support.
Install: npm install @react-pdf/renderer@^4.3.0
Custom fonts: Register TTF, OTF, or WOFF font sources globally with Font.register() before rendering <Document />.
Benchmark (26-component flow test): 1.06 s, 237.3 MB peak RAM, 126.8 KB PDF.
Explore React-PDF & Templates | Official React-PDF Docs
pdf-lib (v1.17.1)
Pure TypeScript PDF object & vector builder with zero native binaries — runs in browsers, Node.js, Deno, Bun, and Cloudflare Workers, and can also open, edit, merge, or fill AcroForms in existing PDFs (5.3 ms single-page; 334 ms & 203.8 KB on our 20-page stress test).
pdf-lib operates on raw PDF primitives (PDFDocument, page.drawText, page.drawRectangle, page.drawLine, and PDFCheckBox / PDFTextField AcroForms) using a bottom-left Cartesian origin. CodePDF's WASM layout compiler flips top-left canvas coordinates, wraps multiline text, draws vector tables, and wires interactive form widgets automatically.
Install: npm install pdf-lib@^1.17.1 @pdf-lib/fontkit
Custom fonts: Generated standalone code defaults to Standard 14 fonts (Helvetica/Times/Courier); attach @pdf-lib/fontkit to your PDFDocument instance before embedding custom TTF or OTF font bytes.
Benchmark (26-component flow test): 334 ms, 209.7 MB peak RAM, 203.8 KB PDF.
Explore pdf-lib & Templates | Official pdf-lib Docs
jsPDF (v2.5.2)
Imperative vector drawing library for browsers and Node.js with zero framework or Chromium dependencies. Fastest JS/TS PDF engine in our 22-page stress test (120 ms pure PDF generation, 3.5 ms single-page, 98.3 MB RAM, 157.4 KB PDF) with crisp selectable vector text.
jsPDF builds documents via imperative canvas-style calls (doc.text, doc.roundedRect, doc.line, doc.addImage). CodePDF pre-calculates exact PDF point coordinates and emits dynamic array loop helpers so tables and repeating blocks expand cleanly across pages.
Install: npm install jspdf@^2.5.2
Custom fonts: Base64-encode TrueType (.ttf) fonts and mount them in jsPDF's VFS via addFileToVFS() + addFont().
Benchmark (26-component flow test): 120 ms, 98.3 MB peak RAM, 157.4 KB PDF.
Explore jsPDF & Templates | Official jsPDF Docs
pdfmake (v0.2.12)
Declarative JSON docDefinition engine that compiles to PDFKit streams with automatic multi-page table pagination (189 ms & 165.5 KB across 27 pages; 4.4 ms single-page). Works in Node.js (PdfPrinter) and browsers (vfs_fonts.js).
pdfmake consumes a declarative JSON tree (docDefinition with content, styles, columns, stack, and table bodies). CodePDF translates visual components, typography, and dynamic array bindings directly into structured pdfmake definitions.
Install: npm install pdfmake@^0.2.12
Custom fonts: Pass a font dictionary mapping normal, bold, italics, and bolditalics weights to TTF paths into PdfPrinter.
Benchmark (26-component flow test): 189 ms, 183.7 MB peak RAM, 165.5 KB PDF.
Explore pdfmake & Templates | Official pdfmake Docs
PDFKit (Node.js) (v0.15.2)
Pure Node.js streaming vector writer — the same low-level engine powering @react-pdf/renderer and pdfmake underneath. Generates single-page invoices in 2.8 ms (2.6 KB) and 22 stress-test pages in 140 ms (125.5 MB RAM, 162.6 KB PDF).
PDFKit streams vector graphics, standard/embedded fonts, and positioned text directly to a Node.js WritableStream or HTTP response without any DOM or Chromium overhead.
Install: npm install pdfkit@^0.15.2 @types/pdfkit
Custom fonts: Register TTF, OTF, or WOFF aliases via doc.registerFont(name, path) or pass paths directly to doc.font().
Benchmark (26-component flow test): 140 ms, 125.5 MB peak RAM, 162.6 KB PDF.
Explore PDFKit & Templates | Official PDFKit Docs
Puppeteer (v24.8.0)
Drives Headless Chrome to print HTML5 + @page CSS via page.pdf(). Delivers full browser CSS fidelity at the cost of a ~300–400 MB browser binary, higher RAM (263.2 MB), and larger PDFs (841.2 KB & 1.35s warm render across 19 pages, plus cold browser startup if unpooled).
Puppeteer launches headless Chrome, injects dynamic data into a self-contained HTML + CSS document with @page print rules, waits for fonts/assets, and prints via page.pdf().
Install: npm install puppeteer@^24.8.0
Custom fonts: Declare @font-face rules in the HTML template and await document.fonts.ready before calling page.pdf().
Benchmark (26-component flow test): 1.35 s, 263.2 MB peak RAM, 841.2 KB PDF.
Explore Puppeteer & Templates | Official Puppeteer Docs
Playwright (v1.53.0)
Automates Headless Chromium via Playwright for modern HTML5/CSS3 print-to-PDF. Outperformed Puppeteer on pure PDF generation speed (883 ms vs. 1.35s), memory (203.8 vs. 263.2 MB), and file size (452.2 vs. 841.2 KB) across our 19-page stress test.
Playwright renders self-contained HTML5 + @page CSS in headless Chromium and exports A4/Letter PDFs with full web font, SVG, and CSS Flexbox support.
Install: npm install playwright@^1.53.0
Custom fonts: Include CSS @font-face rules and wait for document.fonts.ready before invoking Chromium page.pdf().
Benchmark (26-component flow test): 883 ms, 203.8 MB peak RAM, 452.2 KB PDF.
Explore Playwright & Templates | Official Playwright Docs
HTML5 & CSS Paged Media (vHTML5)
Exports renderer-agnostic HTML5 + @page print CSS with Mustache/Handlebars {{variable}} placeholders. Output size and speed depend on your print engine — warm headless Chromium renders 19 pages in 818 ms (453.6 KB; 581 ms single-page), while html2pdf.js rasterizes pages into images.
Emits zero-dependency HTML5 markup with scoped CSS rules, @page size/margin declarations, print-color-adjust: exact, and clean {{var}} bindings compatible with any template engine.
Install: npm install html2pdf.js # or: npm install puppeteer
Custom fonts: Declare @font-face rules with HTTPS URLs, local paths, or Google Fonts stylesheets in <head>.
Benchmark (26-component flow test): 818 ms, 196.3 MB peak RAM, 453.6 KB PDF.
Explore HTML / CSS & Templates | Official HTML / CSS Docs
Python PDF Libraries (4)
ReportLab (Python) (v4.4.1)
C-accelerated Python canvas engine installed via pure pip wheels (no Cairo/Pango OS binaries). Fastest & lowest-RAM Python PDF library in pure PDF generation: 1.5 ms single-page and 170 ms across 22 stress-test pages (46.4 MB RAM, 0.29s CPU, permissive BSD-3-Clause).
CodePDF compiles your visual layout into a standalone Python 3 ReportLab script using reportlab.pdfgen.canvas and vector drawing helpers, automatically flipping Y-coordinates and expanding dynamic list/table rows.
Install: pip install reportlab==4.4.1
Custom fonts: Register TrueType (.ttf) fonts with pdfmetrics.registerFont() and map bold/italic families via registerFontFamily().
Benchmark (26-component flow test): 170 ms, 46.4 MB peak RAM, 179.5 KB PDF.
Explore ReportLab & Templates | Official ReportLab Docs
WeasyPrint (Python) (v63.1)
Renders HTML5 + @page CSS Paged Media in Python using native Pango, HarfBuzz, and Cairo instead of headless Chrome. Generates single-page invoices in 144 ms (37.5 KB) and our dense 18-page 26-component custom-TTF/AcroForm stress test in 4.34s (1,059.8 KB).
Generates a self-contained Python 3 module that formats dynamic HTML + @page CSS and renders print-grade PDFs via weasyprint.HTML(string=...).write_pdf().
Install: pip install weasyprint==63.1
Custom fonts: Load custom TTF, OTF, or WOFF2 fonts cleanly via CSS @font-face in WeasyPrint.
Benchmark (26-component flow test): 4.34 s, 188.2 MB peak RAM, 1059.8 KB PDF.
Explore WeasyPrint & Templates | Official WeasyPrint Docs
fpdf2 (Python) (v2.8.3)
100% pure-Python top-left coordinate writer with zero C or OS binaries — zips cleanly into AWS Lambda and runs on Pyodide. Produced the smallest Python PDF in our 22-page stress test (135.0 KB in 389 ms; 2.0 KB in 3.5 ms single-page; LGPL-3.0).
Maps CodePDF's top-left point coordinates directly onto fpdf2's FPDF(unit='pt') API (set_xy, multi_cell, rect, line, image) with runtime dynamic flow-block offsets.
Install: pip install fpdf2==2.8.3
Custom fonts: Call pdf.add_font() with any Unicode .ttf/.otf file before invoking pdf.set_font().
Benchmark (26-component flow test): 389 ms, 81.8 MB peak RAM, 135 KB PDF.
Explore fpdf2 & Templates | Official fpdf2 Docs
xhtml2pdf (Python) (v0.2.16)
Pure-Python HTML-to-PDF converter built on top of ReportLab — pip-only with no Cairo/Pango binaries. Renders single-page HTML in 61 ms and 23 stress-test pages in 2.06s (139.0 KB PDF), subject to CSS 2.1 layout limits.
Emits xhtml2pdf-compatible HTML/CSS rendered via pisa.CreatePDF() on top of ReportLab — pip-installable anywhere Python runs.
Install: pip install xhtml2pdf==0.2.16
Custom fonts: Generated code falls back to Standard 14 fonts unless CSS @font-face rules point to local TrueType (.ttf) files on disk (inline base64 font URIs and WOFF2 are not supported by pisa).
Benchmark (26-component flow test): 2.06 s, 159.6 MB peak RAM, 139 KB PDF.
Explore xhtml2pdf & Templates | Official xhtml2pdf Docs
PHP PDF Libraries (3)
Dompdf (PHP / Laravel) (v3.1.0)
Pure-PHP HTML-to-PDF engine for Laravel, Symfony, and WordPress with zero Node.js or Chromium sidecars. Emits compact PDFs (2.2 KB in 17 ms single-page; 140.7 KB across 22 stress-test pages in 1.03s), though CSS Flexbox/Grid support remains partial.
Emits a standalone PHP 8 script configuring Dompdf\Options (isRemoteEnabled, defaultFont) and rendering Dompdf-safe positioned/tabular HTML + CSS into a crisp PDF.
Install: composer require dompdf/dompdf:^3.1.0
Custom fonts: Generated code falls back to Standard 14 fonts for inline base64 font data; load local .ttf files via CSS @font-face inside Dompdf's configured chroot and writable fontCache directories.
Benchmark (26-component flow test): 1.03 s, 103.2 MB peak RAM, 140.7 KB PDF.
Explore Dompdf & Templates | Official Dompdf Docs
TCPDF (PHP) (v6.7.7)
Pure-PHP coordinate writer with native UTF-8 Unicode and built-in barcodes. Generates single-page PDFs in 2.7 ms and 22 stress-test pages in 176 ms (41.0 MB RAM, 195.9 KB PDF).
Compiles visual layouts directly into TCPDF canvas calls (SetXY, MultiCell, Rect, Line, Image) in PDF points with automatic header/footer suppression and dynamic table pagination.
Install: composer require tecnickcom/tcpdf:^6.7.7
Custom fonts: Convert .ttf/.otf binaries using TCPDF_FONTS::addTTFfont() once and apply with $pdf->SetFont().
Benchmark (26-component flow test): 176 ms, 41 MB peak RAM, 195.9 KB PDF.
Explore TCPDF & Templates | Official TCPDF Docs
FPDF (PHP) (v1.86)
Single-class PHP coordinate writer with zero external dependencies and the fastest pure PDF generation of any interpreted language (0.4 ms single-page; 37 ms & 28.8 MB RAM for 22 stress-test pages). Tradeoff: ISO-8859-1 only (no native UTF-8).
Compiles CodePDF's top-left point layout directly onto FPDF('P', 'pt', 'A4') calls (SetXY, MultiCell, Rect, Line) with dynamic flow-block offsets.
Install: composer require setasign/fpdf:^1.86
Custom fonts: Generated code falls back to Standard 14 fonts; pre-compile .php and .z font definition files with FPDF's MakeFont utility, then register via $pdf->AddFont() (or switch to TCPDF).
Benchmark (26-component flow test): 37 ms, 28.8 MB peak RAM, 140.1 KB PDF.
Explore FPDF PHP & Templates | Official FPDF PHP Docs
Rust PDF Libraries (3)
printpdf (Rust) (v0.12.5)
Pure-Rust typed Op-vector PDF builder (0.12 API) with zero C++ dependencies. Generates 1-page PDFs in 0.3 ms and 22 stress-test pages in 44 ms (0.08s CPU, 37.7 MB RAM, 154.2 KB PDF); requires explicit Cargo feature flags per image format.
Emits a standalone Rust main.rs assembling typed printpdf::Op vectors (SetTextCursor, WriteTextBuiltinFont, DrawPolygon, DrawLine) in Pt/Mm coordinates.
Install: cargo add printpdf@0.12.5 --features "images png jpeg"
Custom fonts: Generated code defaults to BuiltinFont Standard 14 fonts; parse .ttf/.otf font bytes via ParsedFont::from_bytes() and register the resulting FontId on PdfDocument.
Benchmark (26-component flow test): 44 ms, 37.7 MB peak RAM, 154.2 KB PDF.
Explore printpdf & Templates | Official printpdf Docs
pdf-writer (Rust) (v0.12)
The low-level typed Rust PDF serializer crate built for Typst — zero layout engine, #1 lowest RAM (5.9 MB), and #2 fastest pure PDF generation across all 22 libraries (0.2 ms single-page; 16 ms & 0.04s CPU for 22 stress-test pages).
Emits strongly-typed Rust code using pdf_writer::Pdf, Ref, Content, and Standard-14 font dictionaries to serialize spec-compliant PDFs directly to bytes.
Install: cargo add pdf-writer@0.12
Custom fonts: Generated code defaults to Type1 WinAnsi Standard 14 fonts; manually emit Type0Font, CidFont, FontDescriptor, and FontFile2 stream objects using pdf-writer's typed writers for custom typefaces.
Benchmark (26-component flow test): 16 ms, 5.9 MB peak RAM, 157.2 KB PDF.
Explore pdf-writer & Templates | Official pdf-writer Docs
lopdf (Rust) (v0.44)
Low-level Rust PDF object-model and stream-operator builder that both generates compact PDFs in 33 ms across 22 pages (0.3 ms / 1.7 KB single-page; 132.6 KB stress PDF, 9.9 MB RAM) and loads/merges/stamps existing PDFs.
Generates a Rust program constructing lopdf::Document, Dictionary, Stream, and Operation primitives (`BT`, `Tf`, `Td`, `Tj`, `re`, `f`) directly.
Install: cargo add lopdf@0.44
Custom fonts: Generated code defaults to Type1 Standard 14 fonts (/F1–/F12); manually embed a Type0/CIDFontTrueType FontDescriptor + FontFile2 stream and register its ref in page /Resources/Font for custom typefaces.
Benchmark (26-component flow test): 33 ms, 9.9 MB peak RAM, 132.6 KB PDF.
Explore lopdf & Templates | Official lopdf Docs