# PDF417

> Pdf417 from @salmonui/charts/barcode/pdf417: Text, Numeric and Byte compaction, error correction levels 0 to 8, columns, rows, Compact PDF417 and the row height ratio.

Canonical: https://salmonui.dev/docs/data-visualization/pdf417

```tsx
import { Pdf417 } from '@salmonui/charts/barcode/pdf417';
import '@salmonui/charts/barcode/styles.css';

<Pdf417 value="PDF417 Symbology Standard" errorCorrection={1} columns={2} />;
```

`Pdf417` lives in `@salmonui/charts/barcode/pdf417`: it shares the SVG output, color, size,
quiet zone, label, invalid-value and `BarcodeApi` export options of `Barcode`
and uses the barcode stylesheet. It is a subpath of its own so a page that
only needs 1D codes or QR codes never downloads its encoder (and this one
never downloads theirs). The encoder follows
ISO/IEC 15438 and reproduces the standard's published example symbols module
for module.

- `compaction: 'auto' | 'text' | 'numeric' | 'byte'`: `'auto'` (default) uses
  the ISO selection: 13 or more digits go to Numeric Compaction, runs of 5 or
  more text characters to Text Compaction (with its upper, lower, mixed and
  punctuation sub-modes), everything else to Byte Compaction. A forced mode
  that cannot encode the value (letters in `'numeric'`, bytes outside printable
  ASCII, tab, CR and LF in `'text'`) renders the invalid state. The value is
  ISO 8859-1 text.
- `errorCorrection: 'auto' | 0 … 8`: level `n` adds `2^(n + 1)` Reed-Solomon
  codewords over GF(929). `'auto'` is the ISO recommended minimum for the data
  length (level 2 up to 40 data codewords, 3 up to 160, 4 up to 320, else 5).
- `columns` (1 to 30) and `rows` (3 to 90): either, both or neither; by default
  the column count gives a symbol about twice as wide as it is high. A value
  that does not fit renders the invalid state (928 codewords at most).
- `compact`: Compact PDF417 (truncated): no right row indicator, and the stop
  pattern becomes a one-module bar.
- `rowHeightRatio`: row height in modules (default 3, the ISO minimum);
  `height` scales the rows instead.
- `moduleSize` defaults to 2 px; the quiet zone is 2 modules. No
  human-readable text is drawn unless `text` is set.

Like `Barcode`, the symbol is one `<svg role="img">` named by `label`
(default the value), renders its final markup on the server and draws only
as SVG (see
[Barcode](https://salmonui.dev/docs/data-visualization/barcode#svg-only)).
`ref` gives a `BarcodeApi` for `toSVGString`, `toBlob`, `toDataURL` and
`export`. All props and types are in the
[API reference](https://salmonui.dev/docs/reference/charts/barcode-pdf417).

### Live demo: PDF417 layouts

Live demo: https://salmonui.dev/demos/data-visualization/pdf417-basic

PDF417 with automatic columns and error correction, a fixed two-column level 1 symbol and Compact PDF417 with taller rows.

`Demo.tsx`:

```tsx
'use client';

import { Pdf417 } from '@salmonui/charts/barcode/pdf417';

const cell = { display: 'grid', gap: 4, justifyItems: 'start' } as const;

// PDF417 with automatic and fixed layouts, and Compact PDF417.
export default function Pdf417BasicDemo() {
  return (
    <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(280px, 1fr))', gap: 24 }}>
      <div style={cell}>
        <span>Automatic columns and error correction</span>
        <Pdf417 value="Salmon UI PDF417 symbol" />
      </div>
      <div style={cell}>
        <span>2 columns, level 1</span>
        <Pdf417 value="PDF417 Symbology Standard" errorCorrection={1} columns={2} />
      </div>
      <div style={cell}>
        <span>Compact PDF417, taller rows</span>
        <Pdf417 value="Compact" compact rowHeightRatio={4} />
      </div>
    </div>
  );
}
```
