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 +105 -14
- package/dist/index.cjs +778 -258
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +146 -4
- package/dist/index.d.ts +146 -4
- package/dist/index.js +772 -259
- package/dist/index.js.map +1 -1
- package/dist/worker/index.cjs +423 -187
- package/dist/worker/index.cjs.map +1 -1
- package/dist/worker/index.js +423 -187
- package/dist/worker/index.js.map +1 -1
- package/fonts/noto-emoji-data.d.ts +27 -0
- package/fonts/noto-emoji-data.js +64 -0
- package/fonts/noto-sans-data.d.ts +22 -0
- package/fonts/noto-sans-data.js +64 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
[](LICENSE)
|
|
11
11
|
[](https://docs.npmjs.com/generating-provenance-statements)
|
|
12
12
|
[](https://pdfnative.dev)
|
|
13
|
+
[](https://www.npmjs.com/package/pdfnative-mcp)
|
|
14
|
+
[](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 **
|
|
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/ #
|
|
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
|
|
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
|
|
950
|
-
>
|
|
951
|
-
>
|
|
952
|
-
>
|
|
953
|
-
>
|
|
954
|
-
>
|
|
955
|
-
>
|
|
956
|
-
>
|
|
957
|
-
>
|
|
958
|
-
>
|
|
959
|
-
>
|
|
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
|
|