Barcode at
A QR code, a Code 128 or an EAN-13 at a fixed place on the page, in a layer. It is the barcode of the layout, placed by x and y.
Attributes
Section titled “Attributes”| Attribute | Type | Default | Description |
|---|---|---|---|
type |
string | — | Required. qr, code128 or ean13 |
data |
string | — | Required. Payload string to encode |
x |
signed pt | — | X of the left edge of the barcode’s box (or offset from anchor) |
y |
signed pt | — | Y of the top edge of the barcode’s box (or offset from anchor) |
anchor |
string | — | Reference point: when set, x and y are offsets, and the box’s matching point is placed there |
width |
pt | — | Width. At least one of width and height is required |
height |
pt | — | Height of the whole barcode, with the digits of hrt inside it |
ec |
string | M |
QR error correction: L M Q H |
hrt |
boolean | false |
Show human-readable text below Code 128 and EAN-13 |
color |
color | #000000 |
Barcode foreground color |
background |
color | — | Background color |
data-value |
string | — | Dot-path: the data the barcode encodes comes from the bound value |
data-if |
string | — | Draw only when the value at the path is truthy |
data-if-not |
string | — | Draw only when the value at the path is falsy |
Either anchor or both x and y must be provided.
One size or both
Section titled “One size or both”A barcode needs width or height, and the other follows the barcode’s proportions. It is never stretched.
- A QR code is square, so one size is the side.
- An EAN-13 has the proportions of the standard symbol.
- A Code 128 is as wide as its bars, whose number depends on the data.
- With both sizes, they are a maximum: the barcode takes the largest size that fits in them, and its box becomes that size, so
anchorplaces the barcode itself. A QR code takes the smaller of the two.
With hrt, height is the whole barcode: the digits take the bottom 12pt of it, and the bars the rest.
QR code in the corner
Section titled “QR code in the corner”<layer page="first"> <barcode-at type="qr" data="https://lpdf.io" anchor="bottom-right" x="-36pt" y="-36pt" width="72pt"/></layer>L.layer({ page: 'first' }, [ L.barcodeAt({ type: 'qr', data: 'https://lpdf.io', anchor: 'bottom-right', x: '-36pt', y: '-36pt', width: '72pt' }),])L.layer(LayerAttr(page='first'), [ L.barcode_at(BarcodeAtAttr(type='qr', data='https://lpdf.io', anchor='bottom-right', x='-36pt', y='-36pt', width='72pt'))])L::layer(new LayerAttr(page: 'first'), [ L::barcodeAt(new BarcodeAtAttr(type: 'qr', data: 'https://lpdf.io', anchor: 'bottom-right', x: '-36pt', y: '-36pt', width: '72pt')),])L.Layer(new() { Page = "first" }, [ L.BarcodeAt(new() { Type = "qr", Data = "https://lpdf.io", Anchor = "bottom-right", X = "-36pt", Y = "-36pt", Width = "72pt" }),])Code 128 with human-readable text
Section titled “Code 128 with human-readable text”<layer page="each"> <barcode-at type="code128" data="INV-2026-001" x="48pt" y="48pt" width="160pt" height="48pt" hrt="true"/></layer>L.layer({ page: 'each' }, [ L.barcodeAt({ type: 'code128', data: 'INV-2026-001', x: '48pt', y: '48pt', width: '160pt', height: '48pt', hrt: 'true' }),])L.layer(LayerAttr(page='each'), [ L.barcode_at(BarcodeAtAttr(type='code128', data='INV-2026-001', x='48pt', y='48pt', width='160pt', height='48pt', hrt='true'))])L::layer(new LayerAttr(page: 'each'), [ L::barcodeAt(new BarcodeAtAttr(type: 'code128', data: 'INV-2026-001', x: '48pt', y: '48pt', width: '160pt', height: '48pt', hrt: 'true')),])L.Layer(new() { Page = "each" }, [ L.BarcodeAt(new() { Type = "code128", Data = "INV-2026-001", X = "48pt", Y = "48pt", Width = "160pt", Height = "48pt", Hrt = "true" }),])Data from the document’s data
Section titled “Data from the document’s data”<layer> <barcode-at type="qr" data="https://lpdf.io/pending" data-value="invoice.url" x="48pt" y="48pt" width="80pt"/></layer>