On line guide/help

You are on page 22 of the online help. Navigate sequentially through the guide pages or search for a topic of interest to you.

Index Prev. Next

Barcode

Print a barcode

Prints a barcode with optional border.


Parameters

Elements / attributes of the <barcode> element:

Coordinate parameters (required) that define the print area of the barcode:
<x1>: Starting X coordinate
<y1>: Starting Y coordinate
<x2>: Ending X coordinate
<y2>: Ending Y coordinate

The above parameters can alternatively be indicated in this way (one of the two methods is mandatory):
<x> Initial X coordinate (top/left corner)
<y> Initial Y coordinate (top/left corner)
<width> Width of the drawing area, calculated from the initial X coordinate
<height> Height of the drawing area, calculated from the initial Y coordinate

Other parameters:
<type> (string) Barcode type. Possible values: C39 (default), C93, C128, EAN8, EAN13, CODE11, PHARMA, .. (full list of the supported types in the TCPDF documentation). 2D barcodes (version 1.0.12 or later): QRCODE (or QRCODE,L / QRCODE,M / QRCODE,Q / QRCODE,H with the error correction level: low 7%, medium 15%, quartile 25%, high 30%), DATAMATRIX, PDF417
<value> (string, numeric, required) Barcode value, in the format required by the barcode type. Placeholders are supported, eg. {ord.orderNumber}
<align> Barcode alignment in the print area: L left, C center (default), R right
<border> Border around the barcode: 1 show (default), 0 hide
<color> Color of the bars / modules, RGB hex format (default 000000, black). Version 1.0.12 or later
<backcolor> Background color, RGB hex format (default FFFFFF, white). Version 1.0.12 or later
QR codes and DataMatrix are square: the barcode is the largest square in the print area, aligned with the align attribute and centered vertically. The value of a 2D barcode is not printed below it.
The barcode value is also printed below the bars. Each barcode element uses only its own settings: the settings that are not set are not inherited from the previous barcode (version 1.0.11 or later).

Extra optional parameters:
<printif> Optional expression: the element is printed only if the expression is true, eg. {doc.type}=1. See the Conditional printing page.

Example

Two barcodes: the first one prints a data field, the second one a constant value.

Barcode examples

QR code

A QR code with the link to verify a certificate (the value contains a data placeholder) and a DataMatrix with a constant value. Version 1.0.12 or later.
The higher the error correction level, the more the code can be damaged or covered (eg. by a logo) and still be read, but the modules are smaller: for long values use the level L or M.

QR code and DataMatrix