Choosing your surface
Write application code → the library. Drive a shell, Makefile or CI job →
pdfnative-cli. Give a conversational AI assistant tool access →pdfnative-mcp. Author documents inside a React 19 app →pdfnative-react. All four surfaces sit on the same zero-dependency engine and produce the same ISO 32000-1 / PDF/A-conformant bytes, so the choice is about who is calling, not about what comes out — and you can switch later without re-authoring your documents.
The decision, in prose#
You are writing application code — a Node.js, Deno, Bun or browser
service, a worker, a script with logic around the PDF. Use the library
(npm install pdfnative). It is the full surface: synchronous builders, the
parser, signatures with long-term validation, streaming, Web Worker support.
Everything the other three surfaces do, they do by calling this package.
You are driving a shell, a CI pipeline, a container, or a build tool in
another language. Use the CLI (pdfnative-cli, binary pdfnative) —
21 commands over stdin/stdout pipelines, with an agent-native automation
contract: a --json envelope, stable E_* error codes, --dry-run, and
compact --summary / --fields output projection. No JavaScript required.
You are (or you are building) a conversational assistant with tool
access — Claude Desktop, Cursor, Continue, Zed, or any Model Context
Protocol client. Use the MCP server (pdfnative-mcp, npx -y pdfnative-mcp) — 28 tools with strict JSON Schemas, read-back tools for
self-verification, and no outbound network access except the
operator-configured TSA/OCSP/CRL endpoints.
Your host application is React 19. Use the React renderer
(pdfnative-react) — declarative JSX compiled on-device to pdfnative blocks
by a custom reconciler (no DOM, no headless browser), with live-preview hooks
and the token-frugal DocSpec for agent authoring. React 19 is a peer
dependency of this package only; the engine stays zero-dependency.
Capability × surface#
The same facts in machine-readable form live in
docs/data/surfaces.json; tool, command and export
names are verified against
docs/assets/ecosystem.json and the engine's
export surface by the documentation CI. Version annotations name the release
of that surface's own package which introduced the capability; an em-dash
means the surface does not offer it.
| Capability | Library (pdfnative) |
CLI (pdfnative-cli) |
MCP (pdfnative-mcp) |
React (pdfnative-react) |
|---|---|---|---|---|
| Generate documents | buildDocumentPDFBytes / buildPDFBytes |
render |
generate_basic_pdf (+ the dedicated document tools) |
renderToBytes and friends, <Document> tree |
| Smart tables | table block |
render (table block, or --variant table) |
add_table |
<Table> |
| Native vector charts | chart block (v1.6.0; per-value ChartSeries.colors on the four bar kinds and optional label since v1.9.0) |
render (chart block) (v1.3.0; series[].colors and optional label since v1.6.0) |
add_chart (v1.5.0; series[].colors and optional label since v1.8.0) |
<Chart> (v1.1.0; charts v2 — nine kinds, secondary axis, log/time scales, data labels — since v1.2.0; ChartSeries.colors + L_CHART_SERIES_COLORS since v1.4.0) |
| Digital signatures (PAdES CMS) | addSignaturePlaceholder (v1.2.0) + signPdfBytes |
sign |
sign_pdf (+ prepare_signature_placeholder) |
— |
| LTV ladder (B-T → B-LTA) | signPdfBytesWithTimestamp, addValidationInfo, addDocumentTimestamp (v1.7.0) |
sign --timestamp, ltv, doc-timestamp (v1.4.0; ltv embed --cert/--ocsp/--crl --match all|chain since v1.6.0) |
add_ltv, timestamp_pdf (v1.6.0; mode: 'offline' + match since v1.8.0) |
— |
| Encrypt / decrypt | build-time encryption layout option; existing PDFs via the page-tree encrypt option and openPdf with a password |
encrypt / decrypt (v1.3.0) |
encrypt_pdf / decrypt_pdf (v1.5.0) |
build-time only, via the layout render option |
| Fill / flatten forms | readFormFields, fillForm, flattenForm (v1.6.0) |
fill (v1.3.0) |
read_form_fields, fill_form (v1.5.0) |
— |
| Extract text | extractText (v1.6.0; onStreamError: 'limit' | 'throw' | 'skip' and logical-order right-to-left runs since v1.9.0) |
extract-text (v1.3.0; --on-stream-error limit|throw|skip since v1.6.0) |
extract_text (onStreamError since v1.8.0) |
— |
| Merge / split / extract pages | mergePdfs, splitPdf, extractPages (v1.4.0) |
merge / split / extract (v1.2.0) |
merge_pdfs / split_pdf / extract_pages (v1.3.0) |
— |
| Markup annotations | buildAnnotation + PdfModifier.addAnnotation (v1.5.0; { type: 'link' } since v1.9.0) |
annotate (v1.2.0; link type since v1.5.0, its body built by the engine since v1.6.0) |
annotate_pdf (v1.4.0; link type since v1.8.0 — colours stay hex / RGB / CMYK, no spot form) |
— |
| Inspect layout (pagination dry run) | inspectDocumentLayout (v1.5.0) |
render --inspect-layout (v1.2.0) |
inspect_layout (v1.6.0) |
inspectDocument |
| Validate PDF/UA | validatePdfUA (v1.3.0) |
inspect --pdfua (v1.1.0) |
validate_pdf (v1.1.0) |
— (lintDocument checks the authoring model before rendering, not the emitted PDF) |
| Update metadata (signature-safe) | PdfModifier.updateMetadata (v1.7.0) |
metadata (v1.4.0) |
update_metadata (v1.6.0) |
— |
| Compare two PDFs (text + structure) | — (compose openPdf / extractText / the readers) |
compare (v1.4.0) |
— | — |
| Runtime font registration | registerFont / registerFonts (v1.5.0, any loader — incl. fonts you compile with compileFontData) |
render --font (the 36 bundled font modules) (v1.1.0) / --font-file <path> for a font you ship (v1.5.0) |
font: '<slug>' on generate_basic_pdf / add_international_text / inspect_layout, faces registered at boot from PDFNATIVE_MCP_FONT_DIR (operator-level; the lang enum stays fixed) (v1.8.0) |
registerFont / registerFonts (re-exported) |
| Typography (paragraph breaking, justification, hyphenation, kerning, OpenType features) | layout.typography (TypographyOptions) + setHyphenationProvider / bindUnits / bindShortWords / applyPunctuationSpacing (v1.8.0; every option opt-in and byte-identical when absent) |
render --split-paragraphs / --keep-headings-with-next / --kerning / --font-features, or the full layout.typography object in the document JSON / a --layout file (v1.5.0) |
typography object on the nine document tools and inspect_layout; paragraph align: 'justify' / keepWithNext / splittable, heading keepWithNext (v1.7.0) |
<Document typography> · <Paragraph align="justify" keepWithNext splittable> · <Heading keepWithNext> (v1.3.0) |
| CMYK content colours | [c, m, y, k] tuples (percent) or 'c m y k' strings on any colour field; parseColor / resolveColor / fillOp / strokeOp (v1.8.0) |
render ("c m y k" or [c, m, y, k] colour fields in the document JSON) (v1.5.0) |
'0 0.6 1 0' or [0, 60, 100, 0] on every colour input (v1.7.0) |
Color accepts a CMYK tuple or string on every colour prop; L_CMYK_INTENT_MISMATCH (layout.colors is accepted but never read by the block-flow renderer; outline[].color stays a process colour) (v1.3.0) |
| CMYK / Gray OutputIntent with RGB content kept conforming | layout.outputIntent with a CMYK or Gray ICC profile (v1.8.0; RGB content routed through a calibrated /DefaultRGB; no press profile shipped) |
render --output-intent-icc <file.icc> --output-intent-id <s> (v1.5.0) |
outputIntent accepts CMYK and Gray profiles on the document tools (v1.7.0) |
<Document outputIntent> (also a DocSpec field) (v1.3.0) |
| Spot colours (Separation and DeviceN) | layout.print.spotColours; { spot, tint? } and { inks } on any colour field and in ChartSeries.colors (v1.9.0) |
render — print.spotColours + { spot, tint? } / { inks } in the document JSON only (no flag, no CLI-side validator; the engine's Spot colour … / Ink mix … refusals → E_INPUT) (v1.6.0) |
print.spotColours on the nine document tools; { spot, tint? } / { inks } at 46 colour sites — not on annotate_pdf, nor on outline entries (schema-admitted, engine-refused) (v1.8.0) |
<Document print={{ spotColours }}>; PdfSpotColor / PdfInkMix in Color; L_SPOT_UNDECLARED, L_SPOT_INK_MIX; outline colours stay process (v1.4.0) |
| JPEG 2000 images | image block or embedImage with a .jp2 / .j2k codestream, /JPXDecode pass-through; parseJPX (v1.9.0) |
render — image block src / dataBase64 / data with a .jp2 / .j2k file (magic bytes sniffed; PDFA1_JPX_IMAGE / PDFA_JPX_IMAGE fail under --strict) (v1.6.0) |
embed_image, image blocks and watermark.image with mimeType: 'image/jp2' (v1.8.0) |
<Image data> with a .jp2 / .j2k codestream; L_PDFA_JPX_IMAGE (v1.4.0) |
| Right-to-left paragraphs (UAX #9) | layout.direction: 'auto', ParagraphBlock.direction; resolveBidiLevels (v1.9.0) |
render --direction auto|ltr|rtl (no default — omitted means unset) and --actual-text false (v1.6.0) |
direction + actualText on the nine document tools and inspect_layout; paragraph-level direction in generate_basic_pdf (v1.8.0) |
<Document direction> (sugar over layout.direction) · <Paragraph direction>; TextDirection re-exported, 19th DocSpec field (v1.4.0) |
| PDF/X-4 conformance claim | layout: { pdfx: 'pdfx4', outputIntent, metadata.trapped } (v1.8.0; exclusive with encryption; since v1.9.0 combinable with tagged: 'pdfa2b' | 'pdfa2u' into one file that claims both) |
render --pdfx pdfx4 --output-intent-icc <file.icc> --trapped true|false|unknown (coherence errors → E_INPUT, PDFX_* diagnostics fail under --strict) (v1.5.0; with --tagged pdfa2b|pdfa2u since v1.6.0) |
pdfx: 'pdfx4' on six document tools (needs a prtr outputIntent and embedFonts: true; exclusive with encrypt only — combines with pdfA: 'pdfa2b' | 'pdfa2u' since v1.8.0) (v1.7.0) |
<Document pdfx="pdfx4" outputIntent metadata={{ trapped }}> with eight L_PDFX_* lint rules (L_PDFX_TAGGED_CONFLICT fires only for pdfa1b / pdfa3b since v1.4.0) (v1.3.0) |
| Validate PDF/X-4 | validatePdfX (v1.8.0; structural ISO 15930-7 prerequisites, not a certified preflight) |
inspect --pdfx / --check pdfx (v1.5.0) |
validate_pdf with standard: 'pdf-x-4' (two caveats[]: not a certified preflight; blend spaces, optional content and rendering-dependent checks not covered — colour inside XObjects, images and tint transforms checked since v1.8.0); inspect_pdf reports pdfX (v1.7.0) |
— (import validatePdfX from the pdfnative peer and run it on the rendered bytes) |
| Printer's marks: registration colour and colour control bars | layout.print.marks (true, or { colourBars: true | { tints, size } }) (v1.8.0; bars off by default and byte-neutral when off) |
render (print.marks incl. colourBars in the document JSON or a --layout file) (v1.5.0) |
print.marks: true (v1.6.0) or { colourBars: true | { tints, size } } (v1.7.0) |
<Document print={{ marks: { colourBars: true } }}> (ColourBarOptions, L_PRINT_COLOUR_BARS) (v1.3.0; boolean marks since v1.2.0) |
| Reproducible bytes | layout.creationDate, or setDefaultCreationDate(date) once per process; getDefaultCreationDate (v1.8.0; dates are written in UTC, so no TZ pin is needed) |
global --creation-date <iso8601> (SOURCE_DATE_EPOCH fallback), echoed in the --json envelope (v1.5.0) |
creationDate on all nine document tools (v1.6.0); server-wide PDFNATIVE_MCP_CREATION_DATE → SOURCE_DATE_EPOCH → clock (v1.7.0) |
<Document creationDate> (also a DocSpec field); setDefaultCreationDate / getDefaultCreationDate re-exported; no environment variable is read (v1.3.0) |
| Dual claim: PDF/A-2b | 2u and PDF/X-4 in one file | layout: { tagged: 'pdfa2b' | 'pdfa2u', pdfx: 'pdfx4', outputIntent, metadata.trapped } (PDF/A-1 and PDF/A-3 refused; encryption exclusive) (v1.9.0) |
render --tagged pdfa2b|pdfa2u --pdfx pdfx4 … (pdfa1b / pdfa3b → E_INPUT, encryption → exit 2); assert with inspect --check pdfa,pdfx (v1.6.0) |
pdfA: 'pdfa2b' | 'pdfa2u' + pdfx: 'pdfx4' on the six PDF/X tools; validate_pdf + inspect_pdf check: ['pdfa', 'pdfx'] (v1.8.0) |
<Document tagged="pdfa2b" pdfx="pdfx4" …> (also DocSpec fields) (v1.4.0) |
| LTV from material you already hold (offline B-LT) | composeLtvData + embedValidationInfo (ocspResponseMatchesCertificate); match: 'all' | 'chain' (v1.9.0) |
ltv embed --cert <pem|der> --ocsp <der> --crl <der> --match all|chain (exclusive with --data; no network) (v1.6.0) |
add_ltv mode: 'offline' with certificatesDerBase64 / ocspResponsesDerBase64 / crlsDerBase64 + match (v1.8.0) |
— (import composeLtvData / embedValidationInfo from the pdfnative peer) |
| Per-value bar colours and optional series labels | ChartSeries.colors (one colour per value on the four bar kinds); label optional (v1.9.0) |
series[].colors and optional label in chart blocks (v1.6.0) |
add_chart series[].colors (length must equal values, else CHART_ERROR), label optional (v1.8.0) |
<Chart series={[{ values, colors }]}>; L_CHART_SERIES_COLORS (v1.4.0) |
| Stream-error policy on text extraction | extractText onStreamError: 'limit' | 'throw' | 'skip' (limit default: a stream past the decompression cap throws PdfStreamLimitError) (v1.9.0) |
extract-text / compare --on-stream-error limit|throw|skip (default limit → E_INPUT naming the remedies) (v1.6.0) |
extract_text onStreamError (default limit → PDF_PARSE_FAILED with the remedy) (v1.8.0) |
— (the renderer reads no PDF; import extractText from the pdfnative peer) |
| AI-governance contract (policy, protocol, draft check) | — (repository files: .github/ai-governance.json, .github/AGENT_RULES.md, npm run verify:issue) |
govern rules | policy | verify-issue <draft> (E_POLICY on a non-compliant draft) (v1.2.0) |
draft_governance_issue + the governance_contract / draft_issue_workflow prompts (v1.4.0); resources pdfnative://governance/policy and pdfnative://governance/rules, always listed (v1.8.0) |
aiGovernancePolicy / agentRulesText / validateIssueDraft (v1.1.0) |
Honest notes#
- LTV transport differs by surface on purpose. The engine opens no socket:
in the library, the RFC 3161 / OCSP / CRL transport is injected by your
code (
setTimestampProvider/setRevocationProvider). On MCP, the transport is operator-configured through environment variables (PDFNATIVE_MCP_TSA_URL,PDFNATIVE_MCP_REVOCATION, an allow-list) — never from tool arguments. On the CLI (since v1.4.0, which completes the write-side ladder), every network touch is an explicit per-invocation opt-in —sign --timestamp <url>,ltv --online,doc-timestamp --url— behind an SSRF guard, andltv collect/ltv embedsplit the ladder across an air gap: evidence is gathered as replayable JSON on a connected machine and embedded fully offline. - The engine ships no cryptographic signature verifier.
listSignaturesis an inventory; full verification (digest, CMS, chain, trust, timestamps, revocation) lives inpdfnative-cli verifyand the MCPverify_pdftool. - Operator knobs are MCP-only and never tool arguments. The font sandbox
(
PDFNATIVE_MCP_FONT_DIR— faces parsed at boot and named by slug through thefontinput of three tools), the public result URLs (PDFNATIVE_MCP_OUTPUT_BASE_URL, never requested by the server) and the LTV transport are set by whoever runs the server; no tool call can point the server at a path, a host or a URL. The CLI's counterpart is explicit per invocation (--font-file,--timestamp <url>); the library and the React renderer read no environment variable at all. - Spot colours need a declaration, and two places refuse them. Every
{ spot }/{ inks }value names an ink declared inprint.spotColoursfirst (the React linter says so before rendering:L_SPOT_UNDECLARED,L_SPOT_INK_MIX);annotate_pdfcolours stay hex / RGB / CMYK, and an outline bookmark's colour (/C) is a process colour on every surface. No surface converts RGB to CMYK — the alternate plate values are authored. - The dual claim is PDF/A-2b | 2u + PDF/X-4, nothing else. One file can
carry both identifications on all four surfaces;
pdfa1bandpdfa3bnext topdfxare refused by the engine (CLIE_INPUT, MCP refuses the pair, ReactL_PDFX_TAGGED_CONFLICT), and encryption stays exclusive with the PDF/X claim (CLI exit 2, MCPencryptrefused). - React is still an authoring surface. It generates documents — charts,
barcodes, SVG, form widgets, build-time encryption via the
layoutrender option and, since v1.4.0, right-to-left paragraphs, spot colours, the dual claim and JPEG 2000 images — but does not operate on existing PDFs: no fill, extract, merge, signing, offline LTV or stream-error policy. When a React app needs those, call the library directly: it is already installed as the renderer's peer dependency. - The MCP tool names, CLI commands and library exports in the table are the complete story for these capabilities, not a sample — where a cell is an em-dash, the surface genuinely lacks the capability today rather than hiding it under another name.
You can switch later#
All four surfaces call the same engine, so the artefacts are interchangeable:
a PDF rendered by the React reconciler can be signed by the CLI, inspected by
an MCP tool, and have its text extracted by the library. Document inputs
travel too — the CLI's render consumes the same DocumentParams JSON the
library takes, the MCP generate_basic_pdf blocks mirror the engine's block
kinds, and pdfnative-react compiles JSX (or a DocSpec) into that same
model. Starting on the "wrong" surface costs a call-site migration, not a
document rewrite.
Further reading#
- Onboarding — the 90-second install-and-first-call for each surface.
- Ecosystem use cases — five production architectures that compose these surfaces, four with diagrams, plus per-surface cases for the CLI, the MCP server and the React renderer.
- Self-verifying generation — the generate → inspect → assert → correct loop on every surface.
- Architecture — how the four packages relate.
- CLI guide · MCP guide · React guide — the complete per-surface references.
- Agent brief — the same decision tree in paste-into-context form for AI agents.