Skip to content

Create barcode

Makes a QR code or barcode image from text, for a PDF, an email or a label.

@lainstack/document/create-barcode · Data

Use Create barcode to turn a reference, a link or an ID into a QR code or barcode a scanner can read. The code lands in Image, ready for a Create PDF template, Send email attachments or Write object, and SVG text holds the same code as text.

Good to know:

  • Text can include references, for example {{order.reference}}.
  • Type is one of QR code, Code 128, Data Matrix, EAN-13, GS1-128 and PDF417. QR codes hold any text, including links. Code 128 and GS1-128 hold letters, digits and basic punctuation only.
  • EAN-13 takes 12 digits, or 13 when the last is the right check digit. GS1-128 takes application identifiers in brackets, for example (01)09521234543213(10)ABC123.
  • Format is SVG, sharp at any size, or PNG for email and labels. Size sets the pixels per bar or square; a PDF template sets the printed size itself.
  • Show text prints the text under Code 128, EAN-13 and GS1-128 codes.
  • In Create PDF, pass Image as a named input and write #image(code, width: 60mm). For one code per item, keep each item’s SVG text in the data instead.
  • Text a type cannot hold, or text that is too long for it, stops the step and says why.
Setting Key Type Details
Text (required) text Text Can include references. GS1-128 takes identifiers in brackets: (01)…(10)…
Type (required) type One of QR code, Code 128, Data Matrix, EAN-13, GS1-128, PDF417 Default qrcode.
Format format One of SVG, PNG SVG stays sharp at any size. PNG suits email and labels. Default svg.
Size size One of Small (2 px), Medium (4 px), Large (8 px) Pixels per bar or square. A PDF template sets the printed size itself. Default medium.
Show text showText Yes or no Print the text under the bars. Default true.
Output Path Type
Image file Value
SVG text svg Text

Last updated: