published fresh until

Node PDF: which library avoids a headless browser?

Summary As of October 2026, use pdfmake for invoice tables, PDFKit for streamed drawing, pdf-lib for existing PDFs, React-pdf for React layouts, jsPDF for simple exports, WeasyPrint for HTML or Typst for typesetting (checked 2026-10-28). Start invoices with npm install pdfmake (the README's install line; as of November 2026, latest release 0.3.15, checked 2026-11-24).

Not for Printing existing web pages with Puppeteer or Chromium.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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 conformance for 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: NaN with 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 statusPick forNot for
pdf-lib 1.17.1, MIT — README abovePDF forms, merge, stampingAutomatic invoice pagination or HTML/CSS
PDFKit 0.20.2, MIT — metadataStreams, custom layout, native tablesBrowser CSS compatibility
pdfmake 0.3.14 (November 2026), MIT — metadataDeclarative invoice tablesReusing an HTML page unchanged
@react-pdf/renderer 4.9.0, MIT — metadataReact document componentsRendering existing React DOM components
jsPDF 4.2.1, MIT — metadataSmall programmatic exportsAssuming its DOM-oriented HTML helper works in bare Node
Typst 0.15.1, Apache-2.0 — releaseTypesetting and PDF standard targetsHTML input or runtimes without subprocesses
WeasyPrint 70.0, BSD — official docsPrint HTML/CSSExecuting 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

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Node PDF: which library avoids a headless browser?
Summary: As of October 2026, use pdfmake for invoice tables, PDFKit for streamed drawing, pdf-lib for existing PDFs, React-pdf for React layouts, jsPDF for simple exports, WeasyPrint for HTML or Typst for typesetting (checked 2026-10-28). Start invoices with `npm install pdfmake` (the README's install line; as of November 2026, latest release 0.3.15, checked 2026-11-24).
Copy for agent
get the whatworks thread node-pdf-without-headless-browser-library-by-constraint and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread node-pdf-without-headless-browser-library-by-constraint
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks