pdfnative 1.0.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,6 +10,8 @@
10
10
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
11
11
  [![npm provenance](https://img.shields.io/badge/provenance-signed-blueviolet)](https://docs.npmjs.com/generating-provenance-statements)
12
12
  [![website](https://img.shields.io/badge/pdfnative.dev-0066FF?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0id2hpdGUiPjxyZWN0IHg9IjMiIHk9IjIiIHdpZHRoPSIxNCIgaGVpZ2h0PSIxOCIgcng9IjIiIGZpbGw9Im5vbmUiIHN0cm9rZT0id2hpdGUiIHN0cm9rZS13aWR0aD0iMS41Ii8+PHBhdGggZD0iTTcgN2g2TTcgMTFoOE03IDE1aDQiIHN0cm9rZT0id2hpdGUiIHN0cm9rZS13aWR0aD0iMS41IiBzdHJva2UtbGluZWNhcD0icm91bmQiLz48L3N2Zz4=)](https://pdfnative.dev)
13
+ [![pdfnative-mcp](https://img.shields.io/npm/v/pdfnative-mcp?label=pdfnative-mcp&color=6366f1)](https://www.npmjs.com/package/pdfnative-mcp)
14
+ [![pdfnative-cli](https://img.shields.io/npm/v/pdfnative-cli?label=pdfnative-cli&color=0e7490)](https://www.npmjs.com/package/pdfnative-cli)
13
15
 
14
16
  Pure native PDF generation library — zero vendor dependencies. ISO 32000-1 (PDF 1.7) compliant.
15
17
 
@@ -44,6 +46,8 @@ Pure native PDF generation library — zero vendor dependencies. ISO 32000-1 (PD
44
46
  - **NPM provenance** — signed builds via GitHub Actions OIDC
45
47
  - **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
46
48
  - **No telemetry, no network calls** — verifiable in source. The library never opens a socket, fetches remote fonts, or phones home
49
+ - **AI client integration** — use pdfnative from Claude Desktop, Cursor, Continue, and Zed via [`pdfnative-mcp`](https://github.com/Nizoka/pdfnative-mcp)
50
+ - **Command-line interface** — render, sign, and inspect PDFs from the shell with [`pdfnative-cli`](https://github.com/Nizoka/pdfnative-cli) — zero-config, scriptable, ideal for CI/CD pipelines
47
51
 
48
52
  ## Installation
49
53
 
@@ -177,6 +181,11 @@ registerFonts({
177
181
  hy: () => import('pdfnative/fonts/noto-armenian-data.js'),
178
182
  bn: () => import('pdfnative/fonts/noto-bengali-data.js'),
179
183
  ta: () => import('pdfnative/fonts/noto-tamil-data.js'),
184
+ // v1.1.0+ — optional Latin fallback for PDF/A documents with curly quotes,
185
+ // em-dash, ellipsis, etc. (activates automatically when needed):
186
+ latin: () => import('pdfnative/fonts/noto-sans-data.js'),
187
+ // v1.1.0+ — optional monochrome emoji:
188
+ emoji: () => import('pdfnative/fonts/noto-emoji-data.js'),
180
189
  });
181
190
 
182
191
  const thaiFont = await loadFontData('th');
@@ -208,6 +217,8 @@ const pdf = buildPDFBytes({
208
217
  | Armenian | `hy` | Noto Sans Armenian | Armenian alphabet |
209
218
  | Bengali | `bn` | Noto Sans Bengali | GSUB conjuncts + GPOS marks |
210
219
  | Tamil | `ta` | Noto Sans Tamil | GSUB ligatures + split vowels |
220
+ | Latin (PDF/A) | `latin` | Noto Sans VF | WinAnsi-extended Latin (curly quotes, em-dash, ellipsis…) |
221
+ | Emoji | `emoji` | Noto Emoji | Monochrome emoji (BMP/SMP, Fitzpatrick, ZWJ, VS-15/16) |
211
222
 
212
223
  ## Multi-Font (Mixed Scripts)
213
224
 
@@ -365,7 +376,7 @@ Generate sample PDFs for all supported languages to visually verify output:
365
376
  npm run test:generate
366
377
  ```
367
378
 
368
- This creates **140+ PDF files** in `test-output/` (git-ignored), organized in twenty-three categories.
379
+ This creates **150+ PDF files** in `test-output/` (git-ignored), organized in twenty-five categories (including `emoji/` and `pdfa-latin/` added in v1.1.0).
369
380
  See [scripts/README.md](scripts/README.md) for the modular generator architecture.
370
381
 
371
382
  ### Financial Statements (per language)
@@ -804,6 +815,77 @@ const pdf = buildPDFBytes(params, { compress: true });
804
815
  | `PAGE_SIZES` | Preset page dimensions (A4, Letter, Legal, A3, Tabloid) |
805
816
  | `resolveTemplate(tpl, page, pages, title, date)` | Resolve header/footer template placeholders |
806
817
 
818
+ ## Ecosystem
819
+
820
+ pdfnative ships as a library, but two official companion packages cover the most common non-library use cases. Both live in separate repositories and depend on `pdfnative` only through the public API.
821
+
822
+ ### pdfnative-cli — command-line interface
823
+
824
+ [`pdfnative-cli`](https://github.com/Nizoka/pdfnative-cli) v0.2.0 is the **official CLI**. It exposes four commands — `render`, `sign`, `inspect`, **`verify`** — covering the full `pdfnative` v1.0.5 surface for use in shell scripts, Makefiles, GitHub Actions, and Docker images. Zero extra runtime dependencies, npm-provenance-signed.
825
+
826
+ **Highlights (v0.2.0):** hybrid `flags + --layout file.json` model, encryption (AES-128/256), watermarks (text + image), header/footer page templates with `{page}/{pages}/{date}/{title}`, PDF/A-3 attachments (Factur-X / ZUGFeRD pattern), multilingual fonts via `--lang`, table-variant rendering, signing metadata + intermediate cert chains, `inspect --verbose/--pages/--check`, and a brand-new `verify` command for byte-range integrity and certificate-chain validation. **100 % backward-compatible** with v0.1.0.
827
+
828
+ ```bash
829
+ # render with full layout coverage (encryption + watermark + PDF/A-2b)
830
+ npx pdfnative-cli render --input doc.json --output report.pdf \
831
+ --tagged pdfa2b --compress \
832
+ --watermark-text "DRAFT" --watermark-opacity 0.15
833
+
834
+ # sign with metadata and intermediate cert chain
835
+ npx pdfnative-cli sign --input report.pdf --output signed.pdf \
836
+ --reason "Approved" --name "Finance Team" \
837
+ --signing-time 2026-04-28T10:00:00Z \
838
+ --cert-chain intermediate.pem
839
+
840
+ # verify embedded signatures (byte-range + chain + trust)
841
+ npx pdfnative-cli verify --input signed.pdf --strict --trust ca-root.pem
842
+
843
+ # inspect with CI assertions (exit 1 on failure)
844
+ npx pdfnative-cli inspect --input signed.pdf \
845
+ --check pdfa --check signed --format json
846
+ ```
847
+
848
+ See the [CLI Guide](https://pdfnative.dev/guides/cli.html) for the full v0.2.0 reference, security model, recipes, and the `--conformance` → `--tagged` migration path. Try the [interactive CLI playground](https://pdfnative.dev/playgrounds/cli.html) to build commands without leaving the browser.
849
+
850
+ ### pdfnative-mcp — Model Context Protocol server
851
+
852
+ [`pdfnative-mcp`](https://github.com/Nizoka/pdfnative-mcp) 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 documents, and render international text — all without writing code.
853
+
854
+ ```bash
855
+ npx -y pdfnative-mcp
856
+ ```
857
+
858
+ ### Available tools
859
+
860
+ | Tool | Purpose |
861
+ |------|---------|
862
+ | `generate_basic_pdf` | Multi-page documents from structured blocks (headings, paragraphs, lists) |
863
+ | `add_table` | Tabular reports from column headers and data rows |
864
+ | `add_barcode` | QR Code, Code 128, EAN-13, Data Matrix, PDF417 |
865
+ | `add_international_text` | 16 non-Latin scripts with BiDi & OpenType shaping |
866
+ | `add_form` | Interactive AcroForm PDFs (text, checkbox, radio, dropdown) |
867
+ | `embed_image` | Embed a JPEG or PNG image (base64) |
868
+ | `prepare_signature_placeholder` | PDF with a `/Sig` field ready to be signed |
869
+ | `sign_pdf` | CMS/PKCS#7 digital signatures (RSA-SHA256 / ECDSA-SHA256) |
870
+
871
+ ### Claude Desktop configuration
872
+
873
+ ```json
874
+ {
875
+ "mcpServers": {
876
+ "pdfnative": {
877
+ "command": "npx",
878
+ "args": ["-y", "pdfnative-mcp"],
879
+ "env": {
880
+ "PDFNATIVE_MPC_OUTPUT_DIR": "/Users/you/Documents/mcp-pdfs"
881
+ }
882
+ }
883
+ }
884
+ }
885
+ ```
886
+
887
+ See the [MCP Integration Guide](https://pdfnative.dev/guides/mcp.html) and the [pdfnative-mcp repository](https://github.com/Nizoka/pdfnative-mcp) for configuration on Cursor, Continue, Zed, and more.
888
+
807
889
  ## Architecture
808
890
 
809
891
  ```
@@ -867,7 +949,7 @@ src/
867
949
  fonts/ # Pre-built font data modules (16 scripts)
868
950
  tools/ # CLI: build-font-data.cjs (TTF → JS module)
869
951
  scripts/ # Modular sample PDF generation (23 generators, 140+ PDFs)
870
- tests/ # 1588+ tests (40 files: unit + integration + fuzz + parser)
952
+ tests/ # 1726+ tests (48 files: unit + integration + fuzz + parser)
871
953
  bench/ # Performance benchmarks (vitest bench)
872
954
  ```
873
955
 
@@ -881,7 +963,7 @@ npm install
881
963
  npm run build # tsup → dist/ (ESM + CJS + .d.ts)
882
964
  npm run test # vitest run (1588+ tests)
883
965
  npm run test:coverage # vitest with v8 coverage (95%+)
884
- npm run test:generate # Generate 140+ sample PDFs → test-output/
966
+ npm run test:generate # Generate 150+ sample PDFs → test-output/
885
967
  npm run lint # ESLint 9 + typescript-eslint strict
886
968
  npm run typecheck # tsc --noEmit (src/)
887
969
  npm run typecheck:tests # tsc --project tsconfig.test.json
@@ -946,17 +1028,26 @@ When `tagged` is set, the output includes:
946
1028
 
947
1029
  The `tagged` option is backward-compatible — omitting it or setting `false` produces the same output as before.
948
1030
 
949
- > **PDF/A status (v1.0.4).** As of v1.0.4 every PDF emits a trailer
950
- > `/ID` and the `/Info CreationDate` is byte-equivalent to the
951
- > `xmp:CreateDate` (with timezone offset) closing two veraPDF
952
- > reference-validator findings. **Latin font embedding** is **not yet
953
- > implemented**: standard 14 Helvetica is still emitted as an
954
- > unembedded reference, which veraPDF flags under ISO 19005-1 §6.3.4.
955
- > Treat the `pdfaid:part` claim in XMP as aspirational until **v1.0.5**
956
- > lands. See [docs/guides/pdfa.html](docs/guides/pdfa.html) and the
957
- > tracking issue [release-notes/draft-issue-v1.0.5-latin-embedding.md](release-notes/draft-issue-v1.0.5-latin-embedding.md).
958
- > Run `npm run validate:pdfa` locally (with veraPDF installed) to
959
- > verify against the reference validator.
1031
+ > **PDF/A status (v1.1.0).** Every PDF/A-claiming sample now passes
1032
+ > the **veraPDF** reference validator (1b / 2b / 2u / 3b) when the
1033
+ > Latin font module is registered. Trailer `/ID` and
1034
+ > `/Info CreationDate` are byte-equivalent to `xmp:CreateDate`
1035
+ > (with timezone offset). `<dc:title>`, `<dc:description>`,
1036
+ > `<pdf:Keywords>` mirror `/Info /Title`, `/Subject`, `/Keywords`
1037
+ > byte-for-byte (ISO 19005-1 §6.7.3 t1 / t4 / t5). Object 3 / Object 4
1038
+ > are emitted as Type0 redirector dicts pointing to the embedded
1039
+ > CIDFontType2 chain — no more unembedded `Helvetica` references
1040
+ > (ISO 19005-1 §6.3.4 / ISO 19005-2 §6.2.11.4.1). To produce strict
1041
+ > PDF/A:
1042
+ >
1043
+ > ```ts
1044
+ > import { registerFont } from 'pdfnative';
1045
+ > registerFont('latin', () => import('pdfnative/fonts/noto-sans-data.js'));
1046
+ > ```
1047
+ >
1048
+ > Run `npm run validate:pdfa` locally (with veraPDF installed, see
1049
+ > [docs/guides/pdfa.html](docs/guides/pdfa.html)) to verify against
1050
+ > the reference validator. CI runs veraPDF as a blocking check.
960
1051
 
961
1052
  ### PDF Encryption — Implemented ✅
962
1053