pdfnative 1.0.4 → 1.0.5
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 +64 -0
- package/dist/index.cjs +5 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -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
|
|
|
@@ -804,6 +808,66 @@ const pdf = buildPDFBytes(params, { compress: true });
|
|
|
804
808
|
| `PAGE_SIZES` | Preset page dimensions (A4, Letter, Legal, A3, Tabloid) |
|
|
805
809
|
| `resolveTemplate(tpl, page, pages, title, date)` | Resolve header/footer template placeholders |
|
|
806
810
|
|
|
811
|
+
## Ecosystem
|
|
812
|
+
|
|
813
|
+
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.
|
|
814
|
+
|
|
815
|
+
### pdfnative-cli — command-line interface
|
|
816
|
+
|
|
817
|
+
[`pdfnative-cli`](https://github.com/Nizoka/pdfnative-cli) is the **official CLI**. It exposes three commands — `render`, `sign`, `inspect` — for use in shell scripts, Makefiles, GitHub Actions, and Docker images. Zero extra runtime dependencies, npm-provenance-signed.
|
|
818
|
+
|
|
819
|
+
```bash
|
|
820
|
+
# render a JSON document spec to PDF
|
|
821
|
+
npx pdfnative-cli render document.json --output report.pdf
|
|
822
|
+
|
|
823
|
+
# sign an existing PDF (RSA or ECDSA, CMS/PKCS#7)
|
|
824
|
+
npx pdfnative-cli sign report.pdf --cert cert.pem --key key.pem --output signed.pdf
|
|
825
|
+
|
|
826
|
+
# inspect a PDF (page count, metadata, fonts, signatures)
|
|
827
|
+
npx pdfnative-cli inspect signed.pdf
|
|
828
|
+
```
|
|
829
|
+
|
|
830
|
+
See the [CLI Guide](https://pdfnative.dev/guides/cli.html) for full reference, security model, and pipeline examples.
|
|
831
|
+
|
|
832
|
+
### pdfnative-mcp — Model Context Protocol server
|
|
833
|
+
|
|
834
|
+
[`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.
|
|
835
|
+
|
|
836
|
+
```bash
|
|
837
|
+
npx -y pdfnative-mcp
|
|
838
|
+
```
|
|
839
|
+
|
|
840
|
+
### Available tools
|
|
841
|
+
|
|
842
|
+
| Tool | Purpose |
|
|
843
|
+
|------|---------|
|
|
844
|
+
| `generate_basic_pdf` | Multi-page documents from structured blocks (headings, paragraphs, lists) |
|
|
845
|
+
| `add_table` | Tabular reports from column headers and data rows |
|
|
846
|
+
| `add_barcode` | QR Code, Code 128, EAN-13, Data Matrix, PDF417 |
|
|
847
|
+
| `add_international_text` | 16 non-Latin scripts with BiDi & OpenType shaping |
|
|
848
|
+
| `add_form` | Interactive AcroForm PDFs (text, checkbox, radio, dropdown) |
|
|
849
|
+
| `embed_image` | Embed a JPEG or PNG image (base64) |
|
|
850
|
+
| `prepare_signature_placeholder` | PDF with a `/Sig` field ready to be signed |
|
|
851
|
+
| `sign_pdf` | CMS/PKCS#7 digital signatures (RSA-SHA256 / ECDSA-SHA256) |
|
|
852
|
+
|
|
853
|
+
### Claude Desktop configuration
|
|
854
|
+
|
|
855
|
+
```json
|
|
856
|
+
{
|
|
857
|
+
"mcpServers": {
|
|
858
|
+
"pdfnative": {
|
|
859
|
+
"command": "npx",
|
|
860
|
+
"args": ["-y", "pdfnative-mcp"],
|
|
861
|
+
"env": {
|
|
862
|
+
"PDFNATIVE_MPC_OUTPUT_DIR": "/Users/you/Documents/mcp-pdfs"
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
```
|
|
868
|
+
|
|
869
|
+
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.
|
|
870
|
+
|
|
807
871
|
## Architecture
|
|
808
872
|
|
|
809
873
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -5501,6 +5501,7 @@ var DEFAULT_TEXT_COLOR = "0.75 0.75 0.75";
|
|
|
5501
5501
|
var DEFAULT_TEXT_OPACITY = 0.15;
|
|
5502
5502
|
var DEFAULT_TEXT_ANGLE = -45;
|
|
5503
5503
|
var DEFAULT_IMAGE_OPACITY = 0.1;
|
|
5504
|
+
var DEFAULT_CAP_HEIGHT_RATIO = 0.718;
|
|
5504
5505
|
function validateWatermark(watermark, pdfaLevel) {
|
|
5505
5506
|
if (pdfaLevel === "pdfa1b") {
|
|
5506
5507
|
const textOpacity = watermark.text?.opacity ?? DEFAULT_TEXT_OPACITY;
|
|
@@ -5555,10 +5556,12 @@ function _buildTextWatermarkOps(wm, pgW, pgH, enc, gsName) {
|
|
|
5555
5556
|
const cy = pgH / 2;
|
|
5556
5557
|
const textWidth = enc.tw(wm.text, sz);
|
|
5557
5558
|
const offsetX = -textWidth / 2;
|
|
5558
|
-
const
|
|
5559
|
+
const fd = enc.fontData;
|
|
5560
|
+
const capHeightRatio = fd ? fd.metrics.capHeight / fd.metrics.unitsPerEm : DEFAULT_CAP_HEIGHT_RATIO;
|
|
5561
|
+
const offsetY = -sz * capHeightRatio / 2;
|
|
5559
5562
|
const tx = cx + offsetX * cos - offsetY * sin;
|
|
5560
5563
|
const ty = cy + offsetX * sin + offsetY * cos;
|
|
5561
|
-
const escapedText =
|
|
5564
|
+
const escapedText = enc.ps(wm.text);
|
|
5562
5565
|
const ops = [
|
|
5563
5566
|
"q",
|
|
5564
5567
|
`${gsName} gs`,
|