Repository navigation
v0.1.0 — Official CLI for pdfnative (render JSON → PDF, sign, inspect)
Released 2026-04-27
v0.1.0 is the inaugural release of the official command-line interface for
the pdfnative library. The CLI exposes three core workflows as composable
commands — render (JSON document → PDF bytes), sign (CMS/PKCS#7 digital
signatures), and inspect (PDF metadata extraction) — with zero extra runtime
dependencies. All PDF logic is delegated to pdfnative.
100 % backward-compatible with future v0.x releases (CLI is new; compatibility
guarantees apply to the pdfnative library version pinning at ^1.0.4).
Highlights
- Three production-ready commands —
render(with streaming & PDF/A modes),
sign(RSA & ECDSA),inspect(JSON and text output formats) - Zero extra dependencies —
pdfnativeis the sole runtime dependency - 23 comprehensive samples — covering document types, barcodes, tables, forms,
watermarks, PDF/A conformance, and digital signatures - Secret-safe signing — private keys loaded from environment variables
(PDFNATIVE_SIGN_KEY,PDFNATIVE_SIGN_CERT), never logged - Stdin/stdout by default — every command reads from stdin and writes to
stdout, enabling composable shell pipelines - Streaming output —
render --streamemits PDF chunks progressively
for large documents (>50 MB) - NPM provenance — signed builds via GitHub Actions OIDC (SLSA Level 2+)
Added
Commands
-
rendercommand — transforms aDocumentParamsJSON document (file or stdin)
into a PDF. Flags:--output file.pdf(default: stdout),--stream(AsyncGenerator
streaming mode),--conformance [pdfa1b|pdfa2b|pdfa3b](PDF/A compliance).
(src/commands/render.ts) -
signcommand — applies CMS/PKCS#7 digital signatures to an existing PDF.
Private key and certificate loaded from environment variables
(PDFNATIVE_SIGN_KEY= base64-encoded private key,PDFNATIVE_SIGN_CERT= certificate,
recommended) or file paths (--key,--cert; env vars take precedence). Keys are
never logged. (src/commands/sign.ts) -
inspectcommand — extracts and reports PDF metadata: version, page count,
encryption type, PDF/A conformance level, signature count, embedded metadata.
Flags:--format [json|text](default: JSON). (src/commands/inspect.ts)
Utilities & Infrastructure
-
Zero-dep argument parser (
src/utils/args.ts) — handles--flag value,
--flag=value,-f value, boolean flags,--pass-through. No third-party
dependency. Properly rejects unknown flags and validates positional arguments. -
I/O helpers (
src/utils/io.ts) —readStdin(),readFileOrStdin(),
writeOutput()(streams binary data to stdout or file). All paths validated
against traversal attacks before filesystem access. -
CLI error handling (
src/utils/error.ts) —CliErrorclass with exit codes
(0 = success, 1 = runtime error, 2 = usage error), formatted output to stderr. -
Core bridge (
src/core-bridge/index.ts) — selective re-exports frompdfnative
(buildDocumentPDFBytes,streamDocumentPdf,signPdfBytes,PdfReader).
Prevents accidental over-exposure of internal APIs.
Security & Validation
-
Path traversal validation — all file path arguments (render input, sign input,
key/cert paths) validated withpath.resolve()and whitelist checks before
fs.readFile()/fs.writeFile(). -
50 MB JSON input cap — enforced before
JSON.parse()to prevent memory exhaustion
on untrusted input. -
Global flags —
--help/-h(exit code 0),--version/-V(exit code 0),
--(end-of-flags).
Documentation & Samples
-
Comprehensive samples — 23 working examples organized in categorized subdirectories:
samples/render/document/— 5 documents (minimal, report, all-blocks reference, invoice, technical spec)samples/render/table/— 2 table layouts (project status, financial summary)samples/render/barcode/— 3 barcode types (QR, Code 128, EAN-13)samples/render/form/— 2 interactive form samples (contact form, survey)samples/render/toc/— table of contents samplesamples/render/link/— hyperlink samplesamples/render/watermark/— 2 watermark samples (draft, confidential)samples/render/layout/— 3 page size/orientation samples (US Letter, A5, A4)samples/render/pdfa/— 3 PDF/A conformance samples (PDF/A-1b, 2b, 3b)samples/sign/— cross-platform digital signature walkthroughs (shell + PowerShell)samples/inspect/— metadata extraction examples (JSON and text output)samples/streaming/— large document rendering demo (200-section AsyncGenerator)samples/run-all.js— cross-platform batch runner with--categoryand--cleanflags
-
docs/KNOWLEDGE_BASE.md— structured knowledge base for AI assistants and developers:- Core concepts (CLI philosophy, zero-dep design, stdin/stdout patterns)
- CLI command reference (render, sign, inspect with flag documentation)
- Architecture overview (dispatcher, command modules, utils, bridge)
- Security model (key handling, path validation, input limits)
- Troubleshooting and FAQ
- Sample integration patterns
-
samples/output/added to.gitignore— generated PDFs never committed.
Testing & CI
-
100% command coverage — tests verify all three commands, flag combinations,
stdin/stdout flows, error conditions. Coverage thresholds: statements 90%, branches 80%, functions 85%. -
CI pipeline — GitHub Actions on push/PR to main (
ci.yml):- Node.js matrix
[20, 22] npm run typecheck:all— TypeScript strict modenpm run lint— ESLint (typescript-eslint strict)npm run test:coverage— vitest with coverage reportnpm run build— tsup ESM + CJS + DTS- Binary smoke test (
node dist/cli.cjs --help)
- Node.js matrix
-
Security scanning — CodeQL SAST and OpenSSF Scorecard on every PR
-
Publish pipeline — GitHub Actions OIDC Trusted Publishing to NPM (no long-lived secrets)
Build & Packaging
-
NPM provenance — builds signed via GitHub Actions OIDC, SLSA Level 2+ attestation,
published via Trusted Publishing (no NPM_TOKEN secret). Configure at npmjs.com package settings. -
Binary entry —
dist/cli.cjs(CJS with shebang for Node compatibility) and
dist/cli.js(ESM). Both built from singlesrc/index.tsentry point via tsup. -
ESM-first source — all source code is ESM, internal imports use
.jsextension,
TypeScript strict mode enabled,const-only variable declarations, noconsole.log.
Changed
samples/directory reorganized from 6 flat JSON files into 9 categorized subdirectories
(document, table, barcode, form, toc, link, watermark, layout, pdfa, plus sign, inspect, streaming).- README.md Examples section updated to reflect categorized sample layout.
- docs/KNOWLEDGE_BASE.md enriched with complete block type reference
(all 10 block types: heading, paragraph, table, list, barcode, link, toc, formField, spacer, pageBreak).
Documentation
- README.md — feature matrix, installation, quick start, command reference
- CONTRIBUTING.md — development setup (Node.js ≥20, npm ≥9), build/test/lint commands
- SECURITY.md — signing key safety, secret handling best practices
- SUPPORT.md — documentation links, issue reporting guidelines
- CODE_OF_CONDUCT.md — community standards
Install
npm install --global pdfnative-cli@0.1.0Then verify:
pdfnative --version # → 0.1.0
pdfnative --help # → usage outputUsage Examples
Render JSON to PDF (stdin/stdout)
cat render-doc.json | pdfnative render > output.pdfRender with streaming (large documents)
pdfnative render --input huge-doc.json --output huge-doc.pdf --streamRender with PDF/A-2b conformance
pdfnative render --input document.json --output archived.pdf --conformance pdfa2bSign a PDF
export PDFNATIVE_SIGN_KEY=$(cat private-key.pem | base64)
export PDFNATIVE_SIGN_CERT=$(cat certificate.crt | base64)
pdfnative sign --input unsigned.pdf --output signed.pdfInspect PDF metadata (JSON)
pdfnative inspect --input sample.pdf --format json | jq .Inspect PDF metadata (human-readable text)
pdfnative inspect --input sample.pdf --format textUpgrade
N/A (initial release).
Verification
All quality gates passed for v0.1.0:
npm run typecheck:all— clean (0 errors)npm run lint— 0 errorsnpm run test:coverage— 100+ tests passing, coverage thresholds metnpm run build— ESM + CJS + DTS generated successfully- Binary smoke tests — all commands respond correctly to
--helpand--version - Samples batch test —
npm run samples:allproduces valid PDFs for all 23 samples
Known Limitations
- Watermark centering — watermark vertical centering has a known limitation in
pdfnative
(identified in v1.0.4 testing; tracked for fix in futurepdfnativerelease) - CLI JSON schema — the
rendercommand accepts the fullpdfnativeDocumentParamsschema;
some advanced features (custom page sizes, encryption, headers/footers via code) are not yet
exposed via JSON. Use thepdfnativeNode.js library directly for these features. - PDF encryption — not yet exposed via CLI; use Node.js library API directly
Backward Compatibility
This is v0.1.0. Pre-v1.0 CLI releases may introduce breaking changes to the command interface or
flag names without a MAJOR version bump (following the Node.js CLI convention of semantic versioning
for the binary, not the library). Once v1.0.0 is released, full SemVer guarantees apply.
The underlying pdfnative library (v1.0.4, pinned via ^1.0.4) is stable and backward-compatible.