This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pdfnative) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
pdfnative
Pure native PDF generation library — zero vendor dependencies. ISO 32000-1 (PDF 1.7) compliant.
Ecosystem
pdfnative ships as four coordinated packages — pick whichever entry point fits your workflow:
Write PDFs as declarative JSX — <Document>, <Table>, <Barcode>… compiled on-device to pdfnative blocks by a custom React reconciler. Render hooks (usePdf), client components (PDFViewer), and a token-frugal DocSpec for AI agents.
Arabic positional shaping — GSUB isolated/initial/medial/final forms + lam-alef ligatures
BiDi text layout — Unicode Bidirectional Algorithm (UAX #9) with glyph mirroring, isolates (LRI/RLI/FSI/PDI), and explicit embeddings (LRE/RLE/LRO/RLO/PDF) including character-level X4–X5 overrides (v1.3.0)
USE-lite shaping — classifyUseCategory / classifyClusters drive joiner classification across the Devanagari, Bengali, and Tamil shapers, fixing nukta+virama, half-form, eyelash-ra, and ya-phalaa edge cases (v1.3.0)
Colour emoji (COLRv1) — opt-in Noto Color Emoji subset; solid + linear + radial gradient layers rendered as native PDF Form XObjects; monochrome fallback when not registered (v1.3.0). Variation selectors, ZWJ/ZWNJ, and skin-tone modifiers no longer leave tofu, and glyph /BBox is computed from contour bounds so emoji are never clipped (v1.3.0). Advanced compositing (v1.4.0): COLRv1 sweep (conic) gradients render as native flat-shaded wedges, and PaintComposite separable blend modes (Multiply, Screen, Overlay, Darken, Lighten, …) map to PDF /BM ExtGState; structural Porter-Duff modes fall back to monochrome. Guide →
Multi-font fallback — automatic cross-script font switching with continuation bias
TTF subsetting — only used glyphs embedded (dramatic file size reduction)
Tagged PDF / PDF/A — structure tree, /ActualText, XMP metadata, sRGB OutputIntent (PDF/A-1b, 2b, 2u, 3b with embedded file attachments)
PDF Encryption — AES-128 (V4/R4) and AES-256 (V5/R6), owner + user passwords, granular permissions
Free-form document builder — headings, paragraphs, lists (incl. nested / hierarchical bullet & numbered lists, v1.4.0), tables, images, barcodes, SVG paths, form fields, spacers, page breaks, table of contents. Configurable block limit via layout.maxBlocks (default 100 000) for very large reports (v1.3.0)
Smart tables — multi-page slicing with repeated headers, auto-wrap on column overflow, zebra striping, captions, and smart auto-fit columns (v1.2.0), plus per-cell borders (cellBorders) and vertical alignment (cellVAlign / ColumnDef.vAlign, v1.4.0). Guide →
Barcode & QR code generation — Code 128, EAN-13, QR Code, Data Matrix, PDF417 — pure PDF path operators (no images)
SVG rendering — path, rect, circle, ellipse, line, polyline, polygon as native PDF operators, plus <text> elements rendered as upright PDF text with x/y positioning and text-anchor (start/middle/end) support (v1.5.0)
AcroForm fields — text, multiline, checkbox, radio, dropdown, listbox with appearance streams (ISO 32000-1 §12.7)
Digital signatures — CMS/PKCS#7 detached signatures with RSA + ECDSA, SHA-256/384/512, X.509 parsing (ISO 32000-1 §12.8). One-call placeholder injection via addSignaturePlaceholder() (v1.2.0). Pluggable native crypto provider (setCryptoProvider() / PdfSignOptions.provider, v1.4.0) for constant-time, hardware-backed signing (node:crypto / Web Crypto / HSM)
Streaming output — AsyncGenerator-based progressive PDF emission with configurable chunk size, object-boundary page-by-page streaming, and true constant-memory streaming (buildDocumentPDFStreamTrue(), v1.3.0) where the full PDF binary never materialises. One-call streamToFile() drains any stream to disk with back-pressure and AbortSignal support (v1.4.0). Guide →
Document outline & page labels — nested bookmarks (/Outlines tree, with bold/italic/colour, collapsible nodes via open: false, explicit or outline: 'auto' from headings) and logical page numbering (/PageLabels: decimal, roman, alpha, prefixes, custom start) (v1.4.0). Guide →
PDF parser & modifier — read existing PDFs (tokenizer, xref, object parser, FlateDecode inflate) + incremental modification. Read-only PDF/UA structural checker validatePdfUA() (ISO 14289-1: MarkInfo, StructTree, ParentTree, Lang, per-page MCID uniqueness) (v1.3.0). Page-tree manipulation (v1.4.0): mergePdfs(), splitPdf(), extractPages() rebuild a clean object graph (inherited attributes resolved, annotations/signatures optionally dropped, deterministic trailer /ID, bounded-depth copy, 256 MiB output cap via maxOutputSize). Round-trip readers (v1.5.0): getPageLabels() parses /PageLabels back into a typed PageLabelRange[]; getAnnotations() / getPageRef() read page annotations, and PdfModifier.addAnnotation() injects new ones incrementally. Guide →
Markup annotations — typed annotation model (text, highlight, underline, strikeout, squiggly, square, circle, line, freetext) via buildAnnotation() / buildAnnotationBody(), plus PdfReader.getAnnotations() and PdfModifier.addAnnotation() for round-trip read/write (v1.5.0). Guide →
Layout debug & inspection — opt-in layout: { debug: true } overlays margin / content / cell boxes for visual layout debugging; inspectDocumentLayout() returns a programmatic per-page block-geometry report. Byte-identical when debug is off (v1.5.0). Guide →
Math & technical symbols — bundleable math font under lang 'math'; mathematical operators, Greek, arrows, and technical symbols route automatically via script detection (v1.5.0)
Font-data tooling — pdfnative/tools exposes compileFontData() / parseFontData() to build and introspect font-data modules programmatically (v1.5.0)
Image embedding — JPEG (DCTDecode) and PNG (FlateDecode) with auto-scaling and alignment
Hyperlinks — PDF link annotations (/URI) with URL validation, blue underlined text, tagged /Link
Header/footer templates — configurable PageTemplate with left/center/right zones and {page}/{pages}/{date}/{title} placeholders
Watermarks — text and image overlays with configurable opacity, rotation, and position (background/foreground)
Table of contents — auto-generated TOC with internal /GoTo links, dot leaders, and page numbers
Web Worker support — off-main-thread generation for large datasets
Tree-shakeable — ESM + CJS dual build with TypeScript declarations
95%+ test coverage — 2218+ tests across 93 files, fuzz suite, dual-mode visual-regression suite, performance benchmarks
NPM provenance — signed builds via GitHub Actions OIDC
On-device generation — runs in Node, browsers, Workers, Deno, Bun. No SaaS round-trip; documents never leave the calling process unless your application explicitly sends them
No telemetry, no network calls — verifiable in source. The library never opens a socket, fetches remote fonts, or phones home
AI client integration — use pdfnative from Claude Desktop, Cursor, Continue, and Zed via pdfnative-mcp — 17 production tools (generate, tables, barcodes, forms, sign, verify, validate, attachments, extraction, inspect, plus page-tree merge_pdfs / split_pdf / extract_pages)
Command-line interface — render, sign, verify, inspect, and batch-render PDFs from the shell with pdfnative-cli — zero-config, scriptable, agent-native (--json/E_*/--dry-run), ideal for CI/CD pipelines
React renderer — author PDFs as declarative JSX with pdfnative-react: <Document>/<Table>/<Barcode> components, usePdf/PDFViewer client hooks, on-device rendering with no DOM or headless browser
Installation
npminstall pdfnative
Requirements: Node.js >= 22 | Modern browsers | Deno | Bun
Documentation
🌐 Website:pdfnative.dev — landing page, live in-browser demo with 10 examples, comparisons, benchmarks.
pdfnative was designed for teams that need ISO-compliant, production-grade PDF generation with zero supply-chain risk. Here is how it compares to other popular JavaScript PDF libraries:
Feature
pdfnative
jsPDF
pdfkit
pdf-lib
pdfmake
Runtime dependencies
0
3
6
4
3
TypeScript declarations
Built-in
Built-in
@types/*
Built-in
@types/*
PDF/A (ISO 19005)
1b, 2b, 2u, 3b
—
—
—
—
Tagged PDF / PDF/UA
✅
—
✅
—
—
Encryption
AES-128/256
✅
✅
—
✅
Complex text shaping (GSUB/GPOS)
✅ Thai, Arabic, Devanagari, Bengali, Tamil
—
Via fontkit
Via @pdf-lib/fontkit
Via pdfkit
BiDi (RTL) layout
✅
—
—
—
—
Modify existing PDFs
✅ (incremental)
—
—
✅
—
Forms (AcroForms)
✅
✅
✅
✅
—
Digital signatures
✅ (RSA + ECDSA)
—
—
—
—
Barcode / QR code (native)
✅ 5 formats
—
—
—
QR
SVG path rendering
✅
✅
✅
✅
✅
Streaming output
✅
—
✅
—
✅
PDF parser
✅
—
—
✅
—
Tree-shakeable (ESM)
✅
—
—
✅
—
NPM provenance (SLSA)
✅
—
—
—
✅
Data sources: npm registry metadata and official README/documentation for each library as of April 2026. Dependency counts reflect direct dependencies listed in each package's package.json. "—" means the feature is not supported or not documented. Feature claims about third-party libraries are based on their public documentation and may not reflect the latest version — please verify against current releases. Sample PDFs validate with veraPDF (PDF/A) and Adobe Acrobat.
When to choose another library: You need advanced vector graphics (complex gradients, arbitrary transforms), rich interactive form scripting (JavaScript actions), or mature ecosystem integrations with existing toolchains.
When to choose pdfnative: You need zero-dependency PDF generation with ISO archival compliance (PDF/A), accessibility (tagged PDF), AES encryption, digital signatures, multi-script Unicode support — particularly Arabic/Hebrew BiDi and Thai GSUB/GPOS shaping — form fields, barcode generation, SVG rendering, or the ability to parse and incrementally modify existing PDFs.
import{ createPDF }from'pdfnative';const pdf =awaitcreatePDF(params,{
workerUrl:newURL('pdfnative/worker',import.meta.url),
threshold:500,// use Worker above 500 rows
timeout:30000,// Worker timeout in ms (default: 60000)onProgress:(percent)=>console.log(`${percent}%`),});
For lower-level control, use generatePDFInWorker directly with WorkerGenerationOptions:
All inputs are validated and normalized before interpolation into PDF content streams, preventing operator injection.
Font Sizes
Customize font sizes for each zone (title, info bar, table header, table cells, footer):
const pdf =buildPDFBytes(params,{
fontSizes:{
title:20,// Title text (default: 16)
info:10,// Info bar items (default: 9)
th:9,// Table header cells (default: 8)
td:8,// Table body cells (default: 7.5)
ft:8,// Footer text (default: 7)},});
Zone
Key
Default
Description
Title
title
16
PDF title text
Info bar
info
9
Key-value pairs below title
Table header
th
8
Column header row
Table cells
td
7.5
Data row cells
Footer
ft
7
Page footer text
All values are in PDF points (1pt = 1/72 inch). Partial overrides are supported — unspecified keys use defaults.
The tool extracts cmap, widths, metrics, GSUB, GPOS, and embeds the raw TTF as base64.
Full colour-emoji coverage (pdfnative-build-emoji-font)
The bundled colour-emoji module (pdfnative/fonts/noto-color-emoji-data.js)
ships a lean curated subset to keep the package small. When you need glyphs
beyond that subset — up to the full ~3,600-glyph Noto Color Emoji set — a
second bundled binary generates a custom data module on demand, so even
pdfnative-only users get full coverage without the package ever carrying the
~32 MB source font:
# Download the pinned Noto Color Emoji (SHA-256 verified) and emit every glyph
npx pdfnative-build-emoji-font --download--all--out my-color-emoji-data.js
# …or build from a local TTF, selecting only the glyphs you need
npx pdfnative-build-emoji-font --ttf NotoColorEmoji-Regular.ttf \--codepoints"1F600,1F680,2764"--out my-color-emoji-data.js
Select glyphs with --all, --preset, --codepoints, or --ranges, then
register the generated module under lang 'emoji'. See the
Colour-emoji CLI guide.
Visual PDF Inspection
Generate sample PDFs for all supported languages to visually verify output:
npm run test:generate
This creates ~210 PDF files in test-output/ (git-ignored), organized in twenty-nine categories (including emoji/ and pdfa-latin/ added in v1.1.0, and math/, svg/, debug/, annotations/, tools/ added in v1.5.0).
See scripts/README.md for the modular generator architecture.
Return a programmatic per-page block-geometry LayoutInspection (v1.5.0)
Enable the visual overlay via layout: { debug: true } or a granular LayoutDebugOptions (showMargins / showContentBounds / showCells). Byte-identical when debug is off.
Font-Data Tools (pdfnative/tools)
Function
Description
compileFontData(buffer, opts?)
Compile a TTF/OTF Uint8Array into a font-data module source string (v1.5.0)
parseFontData(buffer, opts?)
Parse a TTF/OTF Uint8Array into a FontDataObject (metrics, cmap, widths, glyph coverage) (v1.5.0)
AcroForm Fields
Function
Description
buildFormWidget(field, objNum, pageRef)
Build form field widget annotation + appearance stream
buildAcroFormDict(fieldRefs)
Build /AcroForm dictionary for catalog
buildRadioGroupParent(group)
Build radio button group parent object
buildAppearanceStreamDict(width, height)
Build appearance stream dictionary
defaultFieldHeight(type)
Default height by field type
Digital Signatures
Function
Description
buildSigDict(options)
Build /Sig dictionary with ByteRange/Contents placeholders
signPdfBytes(pdf, options)
Sign a PDF with CMS/PKCS#7 detached signature
estimateContentsSize(options)
Estimate hex-encoded /Contents size for pre-allocation
setCryptoProvider(provider)
Install (or clear with null) a global native signature provider (v1.4.0)
getCryptoProvider()
Return the current global CryptoProvider, or null (v1.4.0)
pdfnative ships as a library, but three official companion packages cover the most common non-library use cases — a CLI, an MCP server, and a React renderer. All live in separate repositories and depend on pdfnative only through the public API, so the core library stays zero-dependency.
pdfnative-cli — command-line interface
pdfnative-cli v1.1.0 is the official CLI, built on pdfnative v1.3.0. It exposes six commands — render, sign, inspect, verify, batch, and schema (plus completion) — for use in shell scripts, Makefiles, GitHub Actions, and Docker images. Zero extra runtime dependencies, npm-provenance-signed, with a CycloneDX SBOM attached to every release.
New in v1.1.0:22 Unicode scripts + COLRv1 colour emoji through the --font/--lang shortcuts, true constant-memory streaming (--stream-true), a --max-blocks cap for very large documents, and a PDF/UA (ISO 14289-1) structural validator (inspect --pdfua / --check pdfua). It also adds an agent-native contract — a global --json status/error envelope, stable E_* error codes, a --dry-run validation mode, the new schema command (Draft 2020-12), and token-economy output projection (--summary / --fields + compact JSON) that cuts agent output ~90 %. 100 % backward-compatible.
See the CLI Guide for the full v1.1.0 reference, agent contract, security model, and recipes. Try the interactive CLI playground to build commands without leaving the browser.
pdfnative-mcp — Model Context Protocol server
pdfnative-mcp v1.3.0 is a Model Context Protocol server that bridges pdfnative to any MCP-compatible AI client. Once configured, your AI assistant can generate PDFs, embed barcodes, create forms, sign and verify documents, validate PDF/UA structure, embed and extract attachments, extract text, render international text, merge, split and extract pages, and inspect existing PDFs — all without writing code.
v1.0.0: first stable MCP release with 12 tools, verify_pdf, add_attachment (Factur-X / ZUGFeRD PDF/A-3), extract_text, smart-table options, auto-placeholder signing, and _meta.apiVersion.
v1.1.0: adds validate_pdf, six additional scripts (Telugu, Sinhala, Tibetan, Khmer, Myanmar, Ethiopic), and COLRv1 colour-emoji support via the pdfnative 1.3.0 engine.
v1.2.0: adds extract_attachments, watermark options on document tools, Unicode normalize (NFC/NFD/NFKC/NFKD), token-frugal read modes (verbosity/fields), and returns base64 PDF bytes once via a resource block.
v1.3.0: adds the page-tree trio merge_pdfs / split_pdf / extract_pages (17 tools total), enriched authoring options (outline, pageLabels, nested lists, viewerPreferences, cellBorders, cellVAlign), a constant-time node:crypto signing provider, and DNS-rebinding protection on the HTTP transport — all via the pdfnative 1.4.0 engine.
npx -y pdfnative-mcp
Available tools
Tool
Purpose
generate_basic_pdf
Multi-page documents from structured blocks (headings, paragraphs, lists)
pdfnative-react v0.2.0 turns declarative JSX into real, on-device PDFs powered by the zero-dependency pdfnative engine — no DOM, no headless browser, no SaaS round-trips. A custom React reconciler compiles your component tree synchronously into the pdfnative block model. Requires React 19 and Node.js ≥ 20 (React is a peer dependency; pdfnative itself stays zero-dependency).
import{ Document, Heading, Text, Table, renderToBytes }from'pdfnative-react';const bytes =renderToBytes(<Documenttitle="Invoice #1024"footerText="Acme Inc"><Headinglevel={1}>Invoice #1024</Heading><Text>Thank you for your business.</Text><Tableheaders={['Item','Qty','Total']}rows={[{ cells:['Pro plan','1','$49.00'], type:'default', pointed:false}]}zebra/></Document>,);// → Uint8Array, a valid PDF
Every component (Document, Page, Heading, Paragraph/Text, List/Item, Table/Row/Cell, Image, Link, Spacer, PageBreak, TableOfContents, Barcode, Svg, FormField) maps 1:1 onto a pdfnative block. Render with renderToBytes / renderToBlob / renderToStream / renderToFile, preview live with the usePdf hook and PDFViewer / PDFDownloadLink / BlobProvider client components, or let AI agents author documents with the token-frugal DocSpec (terse JSON tuples that compile to the same PDF, validated by a versioned JSON Schema).