Skip to content

Commit 3bdf98f

Browse files
committed
docs: add pdf417 svg renderer usage
1 parent 173c9d2 commit 3bdf98f

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ On `main`, the studio focuses on QR Code. Additional 2D barcode families live in
1313
* `feat/maxi-code`
1414

1515
The reusable native PDF417 foundation on `feat/pdf417-core` provides all 34
16-
MicroPDF417 variants plus a standard PDF417 core. See
16+
MicroPDF417 variants, a standard PDF417 core, and a shared SVG renderer. See
1717
[`docs/pdf417-core.md`](docs/pdf417-core.md) for its low-level API, validation
1818
rules, reference coverage, and the planned ZPL `^BF`/`^B7` integration path.
1919

docs/pdf417-core.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ the shared three-cluster codeword patterns, and the two symbol layouts.
88

99
```js
1010
import { MicroPdf417Core, Pdf417Core } from '../libs/PDF417core.js'
11+
import { Pdf417SvgRenderer } from '../libs/PDF417Svg.js'
1112

1213
const micro = new MicroPdf417Core('MICRO PDF417 1234567890123', {
1314
variant: '2x11',
@@ -19,12 +20,42 @@ const standard = new Pdf417Core('STANDARD PDF417', {
1920
errorCorrectionLevel: 2,
2021
truncated: false,
2122
}).generate()
23+
24+
const svg = new Pdf417SvgRenderer(standard).render()
2225
```
2326

2427
Both constructors accept a JavaScript string, `Uint8Array`, another typed-array
2528
view, `ArrayBuffer`, or an array of byte values. Strings are converted to UTF-8.
2629
Pass bytes when the caller must control the byte encoding exactly.
2730

31+
### SVG renderer
32+
33+
`Pdf417SvgRenderer` accepts the result of either `Pdf417Core` or
34+
`MicroPdf417Core`. The aliases `PDF417SvgRenderer`, `MicroPdf417SvgRenderer`,
35+
and `MicroPDF417SvgRenderer` refer to the same renderer.
36+
37+
The renderer produces barcode-faithful SVG paths with no rounded or decorative
38+
modules. Adjacent dark modules in a row are merged into horizontal runs and the
39+
SVG uses `shape-rendering="crispEdges"`. Standard PDF417 defaults to a row-height
40+
ratio of 3, while MicroPDF417 defaults to 2. Standalone output includes a
41+
two-module quiet zone by default.
42+
43+
```js
44+
const svg = new Pdf417SvgRenderer(micro, {
45+
moduleSize: 2,
46+
rowHeight: 2,
47+
margin: 2,
48+
foreground: '#000000',
49+
background: '#ffffff', // use null for transparency
50+
width: 400,
51+
height: 120,
52+
}).render()
53+
```
54+
55+
`buildPdf417Path(modules, options)` is exported for renderers that need to place
56+
the barcode inside a larger SVG without nesting documents. `margin: 0` is useful
57+
when another symbology owns the surrounding quiet zone.
58+
2859
### MicroPDF417 options
2960

3061
| Option | Default | Meaning |
@@ -99,6 +130,7 @@ lookup for deterministic tests and future barcode adapters.
99130
| `libs/PDF417ErrorCorrection.js` | Generator-polynomial construction and Reed-Solomon ECC modulo 929. |
100131
| `libs/PDF417Patterns.js` | Shared 3 × 929 standard codeword patterns. |
101132
| `libs/PDF417core.js` | Size selection and separate PDF417/MicroPDF417 row layouts. |
133+
| `libs/PDF417Svg.js` | Shared barcode-faithful SVG renderer and reusable path builder. |
102134

103135
`scripts/generate-pdf417-patterns.mjs` deterministically regenerates the pattern
104136
table from the installed ZXing development package. The generated table is

0 commit comments

Comments
 (0)