[barcode]
Output common 1d type barcode to the document.
Shorthand
It is acceptable to use the abbreviation bc
instead of the full command name barcode
. So the command sequence [bc: type code39; data 1234]
and [barcode: type code39; data 1234]
are equivalent.
Parameters
Several parameters can be provided to determine the type and look of the barcode being output. Of these, the type
and data
parameters are required.
Parameter | Description |
---|---|
type |
Select the barcode type, see full list of supported types below. |
data |
Data to be encoded in the printed barcode. Content may be limited depending on the barcode type. |
height /h |
Height of the barcode to be printed as printer dots, mm (recommended) or % of width. Defaults to 10mm. |
module /m |
Barcode module size as dots or mm. Use 0 to specify minimum. |
wide_module /wm |
Barcode wide bar module size, for barcode types that support it. Use 0 to specify the minimum size allowed relative to the standard module size. Default is 0. |
hri |
No value required, if this parameter is present then HRI (human readable information) will be printed underneath the barcode. |
Supported Barcode Types and Data Limitations
The following barcode symbologies are currently supported by the markup, although some may not be supported by a particular target device or emulation. In case a symbology is not supported by the target device, the [barcode]
command will be ignored. Each symbology has different limitations regarding the type of data that it can represent.
Using data that is not suitable for the requested symbology will cause undefined results.
Use the following table to determine the correct type value and data (e.g. [barcode: type <value>; data <data>]
for the particular barcode type that you need to print.
Symbology | <value> | Wide Module | Data Constraints |
---|---|---|---|
EAN8 | ean8 | ✗ | 7 or 8 numeric characters only, the 8th is a checksum digit and will be calculated by the printer, so does not need to be provided. |
JAN8 | jan8 | ✗ | Japanese subset of EAN8 specification, completely compatible with EAN8 data requirements. |
EAN13 | ean13 | ✗ | 12 or 13 numeric characters only, the 13th is a checksum digit and will be calculated by the printer so does not need to be provided. |
JAN13 | jan13 | ✗ | Japanese subset of EAN13 specification, completely compatible with EAN13 data requirements. |
UPC-E | upc-e | ✗ | 11 or 12 numeric characters only, character 12 is a checksum that will be calculated by the printer and so does not need to be provided. |
UPC-A | upc-a | ✗ | 11 or 12 numeric characters only, character 12 is a checksum that will be calculated by the printer and so does not need to be provided. |
Interleaved 2 of 5 | itf | ✔ | An even number of numerical digits, if an odd number of digits are provided, then a '0' will be added to the beginning of the data. |
Code 39 | code39 | ✔ | Numerical digits ('0' to '9'), upper case characters ('A' to 'Z') and characters ' ', '$', '%', '+', '-', '.', '/' |
Code 93 | code93 | ✗ | Any valid ASCII data |
Code 128 | code128 | ✗ | Any valid ASCII data |
NW-7 | nw7 | ✔ | Numerical digits ('0' to '9'), limited alphabet characters ('A' to 'D', and 'a' to 'd') and characters '$', '+', '-', '.', '/', ':' |
Barcode Sizing
Barcode width are dependent of the Symbology type, module size , data length and in some cases (such as Code 128) which internal character set sequence is used. Some devices also support only a limited set of module sizes and ratios. It is therefore not possible to specify the width of the total symbology, however the following rules will be followed:
- The
module
andwide_module
values will be adjusted to the closest sizes supported by your output device which are also allowed by the symbology being printed. Set a value of 0 for both in order to request the minimum supported width. - Most symbologies will always generate the same size barcode for the same number of data digits. Where a symbology supports multiple internal character encodings (such as Code 128) the width may vary depending on the data content as well as number of digits. Data will be automatically analyzed and packed in the most efficient way supported by your target device.
If your application requires a larger amount of data or data that may vary in length significantly, then it is recommended to use a 2d symbology instead, such as Qr Code of PDF417.
Example
This is a simple markup example, using only the [barcode] and [cut] commands.
Barcode Examples
EAN 8:
[barcode: type ean8; data 1234567]
EAN 13:
[barcode: type ean13; data 500274857162; hri]
Interleaved 2 of 5 (module 3 dot):
[barcode: type itf; data 48129500; height 20mm; hri; module 3]
Code 39:
[barcode: type code39; data ABC123]
Code 39 (module 3, wide module 9):
[barcode: type code39; data ABC123; module 3; wide_module 9]
Code 126:
[barcode: type code128; data Hello World!]
[cut]