What this thread does
For invoice tables, start with npm install pdfmake (README install line; latest release 0.3.15, checked 2026-11-24). Check embedded fonts and runtime constraints before using the example below; use the comparison table if your task is streamed drawing, existing-PDF editing or static HTML conversion.
What changed
- pdfmake release, 2026-10-25 (checked 2026-10-28), fixes consumed-stream and write-after-buffer failures. Its migration guide changes server invocation and replaces callbacks with promises.
- React-pdf renderer release, 2026-08-27 (checked 2026-10-28), adds
conformancefor PDF/A output; embedded fonts are still required for validation. - PDFKit release, 2026-08-30 (checked 2026-10-28), fixes standard-font packaging failures and
unsupported number: NaNwith unwrapped decorated text.
How to migrate or start
1. Pick a row below; measure bundle size, cold start and memory. 2. Each snippet is an independent Node entry point. Install one option; keep its pin in a lockfile.
pdfmake — invoice tables. Server API, standard fonts. Install npm install pdfmake (README install line; add @0.3.14 to pin the release checked 2026-11-15). This Latin-only example needs embedded fonts for Unicode/PDF/A.
// invoice.cjs
const pdfmake = require('pdfmake');
pdfmake.addFonts({ Helvetica: { normal: 'Helvetica' } });
pdfmake.createPdf({
defaultStyle: { font: 'Helvetica' },
content: [{ table: { headerRows: 1, body: [
['Item', 'Total'], ['Service', '100']
] } }]
}).write('invoice.pdf').catch(console.error);
PDFKit — streamed layout. Install npm install pdfkit@0.20.2 (checked 2026-10-28). From setup and tables.
// invoice.cjs
const { PDFDocument } = require('pdfkit');
const { createWriteStream } = require('node:fs');
const doc = new PDFDocument();
const output = createWriteStream('invoice.pdf');
output.on('error', console.error);
doc.on('error', console.error);
doc.pipe(output);
doc.table({ data: [['Item', 'Total'], ['Service', '100']] });
doc.end();
pdf-lib — forms, merging and stamping. Install npm install pdf-lib@1.17.1 (checked 2026-10-28). Official examples.
// invoice.mjs
import { PDFDocument } from 'pdf-lib';
import { writeFile } from 'node:fs/promises';
const pdf = await PDFDocument.create();
pdf.addPage().drawText('Invoice');
await writeFile('invoice.pdf', await pdf.save());
React-pdf — document components. Install npm install react @react-pdf/renderer@4.9.0 (checked 2026-10-28). Adapted Node example, using createElement without JSX.
// invoice.mjs
import { createElement as h } from 'react';
import { Document, Page, Text, renderToFile } from '@react-pdf/renderer';
await renderToFile(h(Document, null,
h(Page, null, h(Text, null, 'Invoice'))), 'invoice.pdf');
jsPDF — simple exports. Install npm install jspdf@4.2.1 (checked 2026-10-28). Official Node example:
// invoice.mjs
import { jsPDF } from 'jspdf';
const pdf = new jsPDF();
pdf.text('Invoice', 10, 10);
pdf.save('invoice.pdf');
Typst — native typesetting CLI. Install with brew install typst on macOS, or ship an official binary. Put = Invoice in invoice.typ. PDF CLI supports typst compile invoice.typ invoice.pdf and --pdf-standard ua-1 when accessibility is a requirement.
WeasyPrint — static HTML/CSS. Follow OS dependency installation, then pip install weasyprint==70.0 in a Python virtual environment (checked 2026-10-28). Create invoice.html containing <h1>Invoice</h1> and run weasyprint invoice.html invoice.pdf. Package Python and Pango too.
Node adapter using execFile, without a shell:
import { execFile } from 'node:child_process';
import { promisify } from 'node:util';
const run = promisify(execFile);
await run('typst', ['compile', 'invoice.typ', 'invoice.pdf']);
// Alternative: await run('weasyprint', ['invoice.html', 'invoice.pdf']);
3. Upgrading pdfmake? Await promises, regenerate browser VFS and review pageBreakBefore(currentNode, nodeContainer).
Versions, licences and when to pick — checked 2026-10-28
Hosting/font costs and hosted prices are unverified.
| Option / official status | Pick for | Not for |
|---|---|---|
| pdf-lib 1.17.1, MIT — README above | PDF forms, merge, stamping | Automatic invoice pagination or HTML/CSS |
| PDFKit 0.20.2, MIT — metadata | Streams, custom layout, native tables | Browser CSS compatibility |
| pdfmake 0.3.14 (November 2026), MIT — metadata | Declarative invoice tables | Reusing an HTML page unchanged |
| @react-pdf/renderer 4.9.0, MIT — metadata | React document components | Rendering existing React DOM components |
| jsPDF 4.2.1, MIT — metadata | Small programmatic exports | Assuming its DOM-oriented HTML helper works in bare Node |
| Typst 0.15.1, Apache-2.0 — release | Typesetting and PDF standard targets | HTML input or runtimes without subprocesses |
| WeasyPrint 70.0, BSD — official docs | Print HTML/CSS | Executing page JavaScript or browser-identical layout |
What breaks
Diagnostic: Error: WinAnsi cannot encode "Ω" (0x03a9)
Install @pdf-lib/fontkit, call pdf.registerFontkit(fontkit), and await pdf.embedFont(fontBytes) with a font covering your text. Test shaping for Arabic, Indic scripts, CJK and emoji as needed. React-pdf also needs registered fonts.
What to test
Test long invoices, headers, oversized rows, totals and text extraction. Check actual serverless filesystem, stream and subprocess support; edge isolates differ. Ship fonts and use writable temporary paths. For PDF/A, follow pdfmake's options or renderer conformance docs. For accessibility, PDFKit requires logical structure and marked content; validate output and reading order rather than trusting a flag.
Evidence and pitfalls
- Raneto4ka asked about HTML conversion in pdf-lib #358; maintainer Hopding replied, “pdf-lib does not support converting HTML to PDF.”
- monolithed reports page gaps and ellipsized long cells in PDFKit #1613. Not a current regression test.
- Measure bundle size including fonts/images. PDF/A and accessible PDF/UA are different targets.
A prompt to give your agent
Your training data predates these releases. Read the linked official release, migration and API pages; do not guess APIs. Check our runtime, invoice fixture, scripts and compliance target. Choose one option, explain exclusions, generate a multi-page sample and report font, pagination, bundle-size and compliance tests. Do not substitute a headless browser.
Limits
No installs, rendering, compliance tests or benchmarks. Two issues are not comparative trials.
Started from a post by @Raneto4ka, packaged by the editor. Original post