For the complete documentation index, see llms.txt. This page is also available as Markdown.

Barcode generation

With barcode generation, you can create over 100 types of 1D and 2D barcodes and receive them as base64-encoded PNG images. The utility class provides static functions only, meaning you do not need to create an instance before calling them. The code class name is Barcode.

generateBarcode

Creates a barcode image from the specified type, text, and options.

Parameters

See the options reference for a full list of available configuration keys.

Input
Key
Description
Type

type

The barcode type, for example qrcode, code128, ean13, or pdf417. See the full list of supported types.

string

text

The text or data to encode into the barcode.

string

options

scale

Sets both the x-axis and y-axis scaling factors. Must be an integer greater than 0.

integer

scaleX

The x-axis scaling factor. Must be an integer greater than 0. Default 2.

integer

scaleY

The y-axis scaling factor. Must be an integer greater than 0. Defaults to the value of scaleX.

integer

width

Bar width in millimeters.

integer

height

Bar height in millimeters.

integer

includeText

Shows the human-readable text below the barcode. Default false.

boolean

textAlign

Alignment of the human-readable text: left, center, right, or justify. Default center.

string

rotate

Rotates the image: N (normal), R (right 90 degrees), L (left 90 degrees), or I (180 degrees). Default N.

string

binaryText

By default the text string is encoded as UTF-8 binary bytes. If the text is already 8-bit encoded, set this to true to disable that behavior. Default false.

boolean

padding

Space generated around the barcode.

integer

barColor

Bar color as an RGB, RRGGBB, or CCMMYYKK hex value, for example 0F7180.

string

textColor

Text color as an RGB, RRGGBB, or CCMMYYKK hex value.

string

backgroundColor

Background color as an RGB, RRGGBB, or CCMMYYKK hex value.

string

borderColor

Border color as an RGB, RRGGBB, or CCMMYYKK hex value.

string

Output

Returns a base64-encoded string representing the generated PNG image (for example, iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACt...). Throws an error if the type or text is invalid.

Examples

Simple QR code

Generates a standard QR code for a URL.

Styled Code 128 barcode

Creates a code128 barcode, scales it, includes the human-readable text, and applies custom colors.

Rotated EAN-13 barcode

Generates an ean13 barcode (which requires a 12-digit input) and rotates it 90 degrees to the right.

Last updated

Was this helpful?