← All updates

Real Code 39 + Code 128 barcodes via barcode()

New barcode() builder generates scannable Code 39 and Code 128 barcodes as native PDF vector graphics — no font, no rasterisation, dynamic values via {{template}} placeholders.

dslbuilderbarcodesshipping-label

Templates can now render real, scannable barcodes. The new barcode() DSL builder produces Code 39 or Code 128 symbologies as native PDF vector graphics — no font to embed, no image to fetch, no rasterisation.

barcode("{{trackingNumber}}", {
  format: "code128", // "code128" (default) or "code39"
  width: 240,
  height: 56,
  "show-text": true,
  alt: "Tracking {{trackingNumber}}",
});

The value field accepts {{template}} placeholders and resolves at render time, so the same template renders a different barcode for every payload. Code 128 (default) is the dense general-purpose choice and accepts ASCII 32–127. Code 39 is the older alphanumeric format that's still common in legacy logistics workflows.

Module width is derived from the requested image width and the encoded length so the bars always fill the box minus the standard quiet zones. Pick a width that yields ≥ 0.5pt per module for reliable consumer-scanner reads.

The two shipping label templates in the library (Compact 4×6 and Standard A5) have been migrated to use real barcodes.

Skill: see pdf-template-author.md §Barcodes.