@@ -8,6 +8,7 @@ the shared three-cluster codeword patterns, and the two symbol layouts.
88
99``` js
1010import { MicroPdf417Core , Pdf417Core } from ' ../libs/PDF417core.js'
11+ import { Pdf417SvgRenderer } from ' ../libs/PDF417Svg.js'
1112
1213const 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
2427Both constructors accept a JavaScript string, ` Uint8Array ` , another typed-array
2528view, ` ArrayBuffer ` , or an array of byte values. Strings are converted to UTF-8.
2629Pass 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
104136table from the installed ZXing development package. The generated table is
0 commit comments