Generate barcodes
This recipe puts EAN-13, Code 128, and QR codes into a PDF with the <barcode> element. The codes are generated as vector graphics directly in the PDF, so they stay crisp at any print resolution. Since raw HTML is allowed inside Markdown, the element works in both Markdown and HTML documents.
Full example: glu/markdown/barcodes
The whole document
---
title: Barcode Examples
lang: en
---
# Barcodes in glu
## EAN-13
<barcode type="ean13" value="4006381333931" width="4cm" height="2cm"/>
## Code 128
<barcode type="code128" value="ABC-12345" width="5cm" height="1.5cm"/>
## QR Code
<barcode type="qr" value="https://boxesandglue.dev" width="3cm"/>
QR code with high error correction:
<barcode type="qr" value="https://boxesandglue.dev" width="3cm" eclevel="H"/>Run it
glu barcodes.mdAttributes
| Attribute | Purpose |
|---|---|
type |
ean13, code128, or qr |
value |
The encoded content (digits for EAN-13, any text for Code 128 and QR) |
width, height |
Rendered size; QR codes are square, so width alone suffices |
eclevel |
QR error correction level (L, M, Q, H); higher levels survive more damage |
Dynamic values work the usual way: an inline expression such as value="{= order_number =}" fills the barcode from Lua data, which is how the ZUGFeRD invoice pattern would add a scannable payment code.
Related
- Barcodes in the HTML mode reference for all attributes
- Inline expressions for data-driven barcode values