4. Using the Command Line
This section describes how to encode data using the command line
frontend (CLI) program. The examples given are for the Unix platform,
but the same options are available for Windows - just remember to
include the executable file extension if ".EXE" is not in
your PATHEXT environment variable, i.e.:
For compatibility with Windows the examples use double quotes to delimit data, though on Unix single quotes are generally preferable as they stop the shell from processing any characters such as backslash or dollar. A single quote itself is dealt with by terminating the single-quoted text, backslashing the single quote, and then continuing:
Some examples use backslash (\) to continue commands
onto the next line. For Windows, use caret (^) instead.
Certain options that take values have short names as well as long
ones, namely -b (--barcode), -d
(--data), -i (--input),
-o (--output) and -w
(--whitesp). For these a space should be used to separate
the short name from its value, to avoid ambiguity. For long names a
space or an equals sign may be used. For instance:
The examples use a space separator for short option names, and an equals sign for long option names.
4.1 Inputting Data
The data to encode can be entered at the command line using the
-d or --data option, for example
This will encode the text "This Text". Zint will use the
default symbology, Code 128, and output to the default file
"out.png" in the current directory. Alternatively, if
libpng was not present when Zint was built, the default
output file will be "out.gif".
The data input to the Zint CLI is assumed to be encoded in UTF-8 (Unicode) format (Zint will correctly handle UTF-8 data on Windows). If you are encoding characters beyond the 7-bit ASCII set using a scheme other than UTF-8 then you will need to set the appropriate input options as shown in 4.11 Input Modes below.
Non-printing characters can be entered on the command line using
backslash (\) as an escape character in combination with
the --esc switch. Permissible sequences are shown in the
table below.
| Escape Sequence | ASCII Equivalent | Name | Interpretation |
|---|---|---|---|
\0 | 0x00 | NUL | Null character |
\E | 0x04 | EOT | End of Transmission |
\a | 0x07 | BEL | Bell |
\b | 0x08 | BS | Backspace |
\t | 0x09 | HT | Horizontal Tab |
\n | 0x0A | LF | Line Feed |
\v | 0x0B | VT | Vertical Tab |
\f | 0x0C | FF | Form Feed |
\r | 0x0D | CR | Carriage Return |
\L | 0x10 | DLE | Data Link Escape |
\e | 0x1B | ESC | Escape |
\F | 0x1C | FS | File Separator |
\G | 0x1D | GS | Group Separator |
\R | 0x1E | RS | Record Separator |
\N | 0x1F | US | Unit Separator |
\( | 0x28 | ( | Opening parenthesis (only with
--gs1parens) |
\) | 0x29 | ) | Closing parenthesis (only with
--gs1parens) |
\\ | 0x5C | \ | Backslash |
\dNNN | NNN | Any 8-bit character where NNN is decimal (000-255) | |
\oNNN | 0oNNN | Any 8-bit character where NNN is octal (000-377) | |
\xNN | 0xNN | Any 8-bit character where NN is hexadecimal (00-FF) | |
\uNNNN | Any 16-bit Unicode BMP3 character where NNNN is hexadecimal (0000-FFFF) | ||
\UNNNNNN | Any 21-bit Unicode character where NNNNNN is hexadecimal (000000-10FFFF) |
Extra escape sequences are available for certain symbologies using
the --extraesc option that allows the insertion of special
characters or, in the case of Code 128 only, to manually switch Code
Sets. Extra escapes begin with the sequence backslash caret
(“\^”):
| Extra Escape Sequence | Interpretation | Available for Symbology |
|---|---|---|
\^1 | Insert FNC1 character | Aztec Code, Code 128, Data Matrix |
\^^ | Literal \^ | Aztec Code, Code 128, Data Matrix |
\^A, \^B,
\^C | Select Code Set A, B or C respectively | Code 128 only |
\^@ | Exit manual Code Set selection and resume automatic Code Set selection | Code 128 only |
Currently the only special character recognised is the Function Code
1 character FNC1. If your data contains the sequence
“\^” then it must be escaped using the extra escape
sequence “\^^”, i.e. by doubling the caret.
See 6.1.10.1 Standard Code 128 (ISO 15417) for the details on manually switching Code Sets.
Input data can be read directly from file using the -i
or --input switch as shown below. The input file is assumed
to be UTF-8 formatted unless an alternative mode is selected. This
option replaces the use of the -d switch.
To read from stdin specify a single hyphen "-" as the
input file.
Note that except when batch processing (see 4.12 Batch Processing below), the file (or
stdin) should not end with a newline (LF on Unix,
CR+LF on Windows) unless you want the newline to be encoded
in the symbol.
4.2 Directing Output
Output can be directed to a file other than the default using the
-o or --output switch. For example:
This draws a Code 128 barcode in the file "here.png". If
an Encapsulated PostScript file is needed simply append the filename
with ".eps", and so on for the other supported file
types:
The currently supported output file formats are:
| Extension | File format |
|---|---|
| bmp | Windows Bitmap |
| emf | Enhanced Metafile Format |
| eps | Encapsulated PostScript |
| gif | Graphics Interchange Format |
| pcx | ZSoft Paintbrush image |
| png | Portable Network Graphic |
| svg | Scalable Vector Graphic |
| tif | Tagged Image File Format |
| txt | Text file (see 4.19 Other Options) |
The filename can contain directories and sub-directories also, which will be created if they don’t already exist:
Note that on Windows, filenames are assumed to be UTF-8 encoded.
4.3 Selecting Barcode Type
Selecting which type of barcode you wish to produce (i.e. which
symbology to use) can be done at the command line using the
-b or --barcode switch followed by the
appropriate integer value or name in the following table. For example to
create a Data Matrix symbol you could use:
or
Names are treated case-insensitively by the CLI, and the
BARCODE_ prefix and any underscores are optional.
| Numeric Value | Name4 | Barcode Name |
|---|---|---|
| 1 | BARCODE_CODE11 | Code 11 |
| 2 | BARCODE_C25STANDARD * | Standard Code 2 of 5 |
| 3 | BARCODE_C25INTER | Interleaved 2 of 5 |
| 4 | BARCODE_C25IATA | Code 2 of 5 IATA |
| 6 | BARCODE_C25LOGIC | Code 2 of 5 Data Logic |
| 7 | BARCODE_C25IND | Code 2 of 5 Industrial |
| 8 | BARCODE_CODE39 | Code 3 of 9 (Code 39) |
| 9 | BARCODE_EXCODE39 | Extended Code 3 of 9 (Code 39+) |
| 10 | BARCODE_EAN8 † | EAN-8 (European Article Number) GTIN-8 |
| 11 | BARCODE_EAN_2ADDON † | EAN/UPC 2-digit add-on (standalone) |
| 12 | BARCODE_EAN_5ADDON † | EAN/UPC 5-digit add-on (standalone) |
| 15 | BARCODE_EAN13 † | EAN-13 (European Article Number) GTIN-13 |
| 16 | BARCODE_GS1_128 * | GS1-128 (UCC.EAN-128) |
| 18 | BARCODE_CODABAR | Codabar |
| 20 | BARCODE_CODE128 | Code 128 (automatic Code Set switching) |
| 21 | BARCODE_DPLEIT | Deutsche Post Leitcode |
| 22 | BARCODE_DPIDENT | Deutsche Post Identcode |
| 23 | BARCODE_CODE16K | Code 16K |
| 24 | BARCODE_CODE49 | Code 49 |
| 25 | BARCODE_CODE93 | Code 93 |
| 28 | BARCODE_FLAT | Flattermarken |
| 29 | BARCODE_DBAR_OMN * | GS1 DataBar Omnidirectional (including GS1 DataBar Truncated) |
| 30 | BARCODE_DBAR_LTD * | GS1 DataBar Limited |
| 31 | BARCODE_DBAR_EXP * | GS1 DataBar Expanded |
| 32 | BARCODE_TELEPEN | Telepen Alpha |
| 34 | BARCODE_UPCA | UPC-A |
| 35 | BARCODE_UPCA_CHK | UPC-A with check digit |
| 37 | BARCODE_UPCE | UPC-E |
| 38 | BARCODE_UPCE_CHK | UPC-E with check digit |
| 40 | BARCODE_POSTNET | POSTNET |
| 47 | BARCODE_MSI_PLESSEY | MSI Plessey |
| 49 | BARCODE_FIM | FIM |
| 50 | BARCODE_LOGMARS | LOGMARS |
| 51 | BARCODE_PHARMA | Pharmacode One-Track |
| 52 | BARCODE_PZN | PZN |
| 53 | BARCODE_PHARMA_TWO | Pharmacode Two-Track |
| 54 | BARCODE_CEPNET | Brazilian CEPNet |
| 55 | BARCODE_PDF417 | PDF417 |
| 56 | BARCODE_PDF417COMP * | Compact PDF417 (Truncated PDF417) |
| 57 | BARCODE_MAXICODE | MaxiCode |
| 58 | BARCODE_QRCODE | QR Code |
| 60 | BARCODE_CODE128AB | Code 128 (Suppress Code Set C) |
| 63 | BARCODE_AUSPOST | Australia Post Standard Customer |
| 66 | BARCODE_AUSREPLY | Australia Post Reply Paid |
| 67 | BARCODE_AUSROUTE | Australia Post Routing |
| 68 | BARCODE_AUSDIRECT | Australia Post Redirection |
| 69 | BARCODE_ISBNX | ISBN (EAN-13 with verification stage) |
| 70 | BARCODE_RM4SCC | Royal Mail 4-State Customer Code (RM4SCC) |
| 71 | BARCODE_DATAMATRIX | Data Matrix (ECC 200) |
| 72 | BARCODE_EAN14 | EAN-14 |
| 73 | BARCODE_VIN | Vehicle Identification Number |
| 74 | BARCODE_CODABLOCKF | Codablock F |
| 75 | BARCODE_NVE18 | NVE-18 (SSCC-18) |
| 76 | BARCODE_JAPANPOST | Japanese Postal Code |
| 77 | BARCODE_KOREAPOST | Korea Post |
| 79 | BARCODE_DBAR_STK * | GS1 DataBar Stacked |
| 80 | BARCODE_DBAR_OMNSTK * | GS1 DataBar Stacked Omnidirectional |
| 81 | BARCODE_DBAR_EXPSTK * | GS1 DataBar Expanded Stacked |
| 82 | BARCODE_PLANET | PLANET |
| 84 | BARCODE_MICROPDF417 | MicroPDF417 |
| 85 | BARCODE_USPS_IMAIL * | USPS Intelligent Mail (OneCode) |
| 86 | BARCODE_PLESSEY | UK Plessey |
| 87 | BARCODE_TELEPEN_NUM | Telepen Numeric |
| 89 | BARCODE_ITF14 | ITF-14 |
| 90 | BARCODE_KIX | Dutch Post KIX Code |
| 92 | BARCODE_AZTEC | Aztec Code |
| 93 | BARCODE_DAFT | DAFT Code |
| 96 | BARCODE_DPD | DPD Code |
| 97 | BARCODE_MICROQR | Micro QR Code |
| 98 | BARCODE_HIBC_128 | HIBC Code 128 |
| 99 | BARCODE_HIBC_39 | HIBC Code 39 |
| 102 | BARCODE_HIBC_DM | HIBC Data Matrix |
| 104 | BARCODE_HIBC_QR | HIBC QR Code |
| 106 | BARCODE_HIBC_PDF | HIBC PDF417 |
| 108 | BARCODE_HIBC_MICPDF | HIBC MicroPDF417 |
| 110 | BARCODE_HIBC_BLOCKF | HIBC Codablock F |
| 112 | BARCODE_HIBC_AZTEC | HIBC Aztec Code |
| 115 | BARCODE_DOTCODE | DotCode |
| 116 | BARCODE_HANXIN | Han Xin (Chinese Sensible) Code |
| 119 | BARCODE_MAILMARK_2D | Royal Mail 2D Mailmark (CMDM) (Data Matrix) |
| 121 | BARCODE_MAILMARK_4S | Royal Mail 4-State Mailmark |
| 128 | BARCODE_AZRUNE | Aztec Runes |
| 129 | BARCODE_CODE32 | Code 32 |
| 131 | BARCODE_GS1_128_CC * | GS1 Composite Symbol with GS1-128 linear component |
| 132 | BARCODE_DBAR_OMN_CC * | GS1 Composite Symbol with GS1 DataBar Omnidirectional linear component |
| 133 | BARCODE_DBAR_LTD_CC * | GS1 Composite Symbol with GS1 DataBar Limited linear component |
| 134 | BARCODE_DBAR_EXP_CC * | GS1 Composite Symbol with GS1 DataBar Expanded linear component |
| 135 | BARCODE_UPCA_CC | GS1 Composite Symbol with UPC-A linear component |
| 136 | BARCODE_UPCE_CC | GS1 Composite Symbol with UPC-E linear component |
| 137 | BARCODE_DBAR_STK_CC * | GS1 Composite Symbol with GS1 DataBar Stacked component |
| 138 | BARCODE_DBAR_OMNSTK_CC * | GS1 Composite Symbol with GS1 DataBar Stacked Omnidirectional component |
| 139 | BARCODE_DBAR_EXPSTK_CC * | GS1 Composite Symbol with GS1 DataBar Expanded Stacked component |
| 140 | BARCODE_CHANNEL | Channel Code |
| 141 | BARCODE_CODEONE | Code One |
| 142 | BARCODE_GRIDMATRIX | Grid Matrix |
| 143 | BARCODE_UPNQR | UPNQR (Univerzalnega Plačilnega Naloga QR Code) |
| 144 | BARCODE_ULTRA | Ultracode |
| 145 | BARCODE_RMQR | Rectangular Micro QR Code (rMQR) |
| 146 | BARCODE_BC412 | IBM BC412 (SEMI T1-95) |
| 147 | BARCODE_DXFILMEDGE | DX Film Edge Barcode |
| 148 | BARCODE_EAN8_CC † | GS1 Composite symbol with EAN-8 linear component |
| 149 | BARCODE_EAN13_CC † | GS1 Composite symbol with EAN-13 linear component |
4.4 Adjusting Height
The height of a symbol (except those with a fixed width-to-height
ratio) can be adjusted using the --height switch. For
example:
This specifies a symbol height of 100 times the X-dimension of the symbol.
The default height of most linear barcodes is 50.0X, but this can be
changed for barcodes whose specifications give a standard height by
using the switch --compliantheight. For instance
will produce a barcode of height 45.455X instead of the normal default of 50.0X. The flag also causes Zint to return a warning if a non-compliant height is given:
zint -b LOGMARS -d "This Text" --compliantheight --height=6.2
Warning 247: Height not compliant with standardsAnother switch is --heightperrow, which can be useful
for symbologies that have a variable number of linear rows, namely
Codablock F, Code 16K, Code 49, GS1 DataBar Expanded Stacked,
MicroPDF417 and PDF417, as it changes the treatment of the height value
from overall height to per-row height, allowing you to specify a
consistent height for each linear row without having to know how many
there are. For instance
zint -b PDF417 -d "This Text" --height=4 --heightperrowwill produce a barcode of height 32X, with each of the 8 rows 4X high.
4.5 Adjusting Whitespace
The amount of horizontal whitespace to the left and right of the
generated barcode can be altered using the -w or
--whitesp switch, in integral multiples of the X-dimension.
For example:
This specifies a whitespace width of 10 times the X-dimension of the symbol both to the left and to the right of the barcode.
The amount of vertical whitespace above and below the barcode can be
altered using the --vwhitesp switch, in integral multiples
of the X-dimension. For example for 3 times the X-dimension:
Note that the whitespace at the bottom appears below the text, if any.
Horizontal and vertical whitespace can of course be used together:
A --quietzones option is also available which adds quiet
zones compliant with the symbology’s specification. This is in addition
to any whitespace specified with the --whitesp or
--vwhitesp switches.
Note that Codablock F, Code 16K, Code 49, ITF-14, EAN-13, EAN-8,
EAN/UPC add-ons, ISBN, UPC-A and UPC-E have compliant quiet zones added
by default. This can be disabled with the option
--noquietzones.
4.6 Adding Boundary Bars and Boxes
Zint allows the symbol to be bound with ‘boundary bars’ (also known
as ‘bearer bars’) using the option --bind. These bars help
to prevent misreading of the symbol by corrupting a scan if the scanning
beam strays off the top or bottom of the symbol. Zint can also put a
border right around the symbol and its horizontal whitespace with the
--box option.
The width of the boundary bars or box borders, in integral multiples
of the X-dimension, must be specified using the --border
switch. For example:
zint --border=10 --box -d "This Text" -w 10gives a box with a width 10 times the X-dimension of the symbol. Note
that when specifying a box, horizontal whitespace is usually required in
order to create a quiet zone between the barcode and the sides of the
box. To add a boundary bar to the top only use
--bindtop.
For linear symbols, horizontal boundary bars appear tight against the barcode, inside any vertical whitespace (or text). For matrix symbols, however, where they are decorative rather than functional, boundary bars appear outside any whitespace.
zint -b QRCODE --border=1 --box -d "This Text" --quietzonesCodablock F, Code 16K and Code 49 always have boundary bars, and default to particular horizontal whitespace values. Special considerations apply to ITF-14 and DPD - see 6.1.2.6 ITF-14 and 6.1.10.7 DPD Code for those symbologies.
4.7 Using Colour
The default colours of a symbol are a black symbol on a white
background. Zint allows you to change this. The -r or
--reverse switch allows the default colours to be inverted
so that a white symbol is shown on a black background (known as
“reflectance reversal” or “reversed reflectance”). For example the
command
gives an inverted Code 128 symbol. This is not practical for most symbologies but white-on-black is allowed by the Aztec Code, Data Matrix, DotCode, Han Xin Code, Grid Matrix and QR Code symbology specifications.
For more specific needs the foreground (ink) and background (paper)
colours can be specified using the --fg and
--bg options followed by a number in "RRGGBB"
hexadecimal notation (the same system used in HTML) or in
"C,M,Y,K" decimal percentages format (the latter normally
used with the --cmyk option - see below). For example the
command
alters the symbol to a bright green.
zint -d "This Text" --fg=00FF00Zint also supports RGBA colour information for those output file
formats which support alpha channels (currently only GIF, PCX, PNG, SVG
and TIF, with GIF supporting either a background or foreground alpha but
not both) in a "RRGGBBAA" format. For example:
zint -d "This Text" --fg=00FF0055will produce a semi-transparent green foreground with a standard (white) background. Note that transparency is treated differently by raster and vector (SVG) output formats, as for vector output the background will “shine through” a transparent foreground. For instance
will give different results for PNG and SVG. Experimentation is advised!
In addition the --nobackground option will remove the
background from all output formats except BMP.5
The --cmyk option is specific to output in Encapsulated
PostScript (EPS) and TIF, and selects the CMYK colour space. Custom
colours should then usually be given in the comma-separated
"C,M,Y,K" format, where C, M,
Y and K are expressed as decimal percentage
values from 0 to 100. RGB values may still be used, in which case they
will be converted formulaically to CMYK approximations.
4.8 Rotating the Symbol
The symbol can be rotated through four orientations using the
--rotate option followed by the angle of rotation, valid
values being 0 (the default), 90, 180 and 270.
zint -d "This Text" --rotate=904.9 Adjusting Image Size (X-dimension)
The size of the image can be altered using the --scale
option, which sets the X-dimension. The default scale is 1.0.
The scale is multiplied by 2 (with the exception of MaxiCode) before being applied to the X-dimension. For MaxiCode, it is multiplied by 10 for raster output, by 40 for EMF vector output, and by 2 otherwise (non-EMF vector output).
For non-MaxiCode raster output, the default scale of 1 results in an X-dimension of 2 pixels. For example for non-MaxiCode PNG images a scale of 5 will increase the X-dimension to 10 pixels. For MaxiCode, see 4.9.3 MaxiCode Raster Scaling below.
Scales for non-MaxiCode raster output should be given in increments of 0.5, i.e. 0.5, 1, 1.5, 2, 2.5, 3, 3.5, etc., to avoid the X-dimension varying across the symbol due to interpolation. 0.5 increments are also faster to render.
The minimum scale for non-MaxiCode raster output in non-dotty mode is 0.5, giving a minimum X-dimension of 1 pixel. For MaxiCode, it is 0.2. The minimum scale for raster output in dotty mode is 1 (see 4.15 Working with Dots). For raster output, text will not be printed for scales less than 1.
The minimum scale for vector output is 0.1, giving a minimum X-dimension of 0.2 (or for MaxiCode EMF output, 4). The maximum scale for both raster and vector is 200.
To summarize the more intricate details:
| MaxiCode? | Output | Multiplier | Min. Scale (non-dotty) | Min. Scale (dotty) |
|---|---|---|---|---|
| No | Raster | 2 | 0.5 | 1 |
| No | Vector | 2 | 0.1 | 0.1 |
| Yes | Raster | 10 | 0.2 | N/A |
| Yes | Vector (non-EMF) | 2 | 0.1 | N/A |
| Yes | EMF | 40 | 0.1 | N/A |
4.9.1 Scaling by X-dimension and Resolution
An alternative way to specify the scale, which takes the above
details into account, is to specify measurable units using the
--scalexdimdp option, which has the format
--scalexdimdp[=X[,R]]
where X is the X-dimension (in mm by default) and
R is the resolution (in dpmm, dots per mm, by default).
R is optional, and defaults to 12 dpmm, and X
is optional or may be zero, in which case it uses a symbology-specific
default. The units may be given in inches for X by
appending "in", and in dpi (dots per inch) for
R by appending "dpi". For example
Explicit metric units may also be given (for clarity) by appending
"mm" and "dpmm" as appropriate, and may be
mixed with U.S. units:
4.9.2 Scaling Example
The GS1 General Specifications 26.0 Section 5.2.6.6 “Symbol
dimensions at nominal size” gives an example of an EAN-13 barcode using
the X-dimension of 0.33mm. To print that example as a PNG at 12 dpmm,
the approximate equivalent of 300 dpi (dpi = dpmm * 25.4),
specify a scale of 2, since 0.33 * 12 = 3.96 pixels, or 4
pixels rounding to the nearest pixel:
This will result in output of 37.29mm x 25.56mm (WxH) at 12 dpmm. The
same result can be achieved using the --scalexdimdp option
with
as 0.33mm is the default X-dimension for EAN, and 12 dpmm the default resolution.
4.9.3 MaxiCode Raster Scaling
For MaxiCode symbols, which use hexagons, the scale for raster output is multiplied by 10 before being applied. The 0.5 increment recommended for normal raster output does not apply.
The minimum scale is 0.2, so the minimum X-dimension is 2 pixels. However scales below 0.5 are not recommended and may produce symbols that are not within the following size ranges.
MaxiCode symbols have fixed size ranges of 24.82mm to 27.93mm in width, and 23.71mm to 26.69mm in height, excluding quiet zones. The default X-dimension is 0.88mm. For example, to output at the default X-dimension at 600 dpi specify:
4.10 Human Readable Text (HRT) Options
For linear barcodes the text present6 in
the output image can be removed by using the --notext
option. Note also that for raster output text will not be printed for
scales less than 1 (see 4.9
Adjusting Image Size (X-dimension)).
Text can be set to bold using the --bold option, or a
smaller font can be substituted using the --small option.
The --bold and --small options can be used
together if required, but only for vector output.
zint --bold -d "This Text" --smallThe gap between the barcode and the text can be adjusted using the
--textgap option, where the gap is given in X-dimensions,
and may be negative (minimum -5.0X, maximum 10.0X). The default gap is
1X. Note that a very small gap may cause accented texts to overlap with
the barcode:
zint -d "Áccent" --textgap=0.1For SVG output, the font preferred by Zint (monospaced “OCR-B” for
EAN/UPC, “Arimo” - a proportional sans-serif font metrically compatible
with “Arial” - for all others) can be embedded in the file for
portability using the --embedfont option:
zint -d "Áccent" --embedfont4.11 Input Modes
4.11.1 Unicode, Data, and GS1 Modes
By default all CLI input data is assumed to be encoded in UTF-8 format. Many barcode symbologies encode data using the Latin-1 (ISO/IEC 8859-1 plus ASCII) character set, so input is converted from UTF-8 to Latin-1 before being put in the symbol. In addition QR Code and its variants and Han Xin Code can by default encode Japanese (Kanji) or Chinese (Hanzi) characters which are also converted from UTF-8.
There are two exceptions to the Latin-1 default: Grid Matrix, whose default character set is GB 2312 (Chinese); and UPNQR, whose default character set is Latin-2 (ISO/IEC 8859-2 plus ASCII).
| Symbology | Default character sets | Alternate if input not Latin-1 |
|---|---|---|
| Aztec Code | Latin-1 | None |
| Codablock F | Latin-1 | None |
| Code 128 | Latin-1 | None |
| Code 16K | Latin-1 | None |
| Code One | Latin-1 | None |
| Data Matrix | Latin-1 | None |
| DotCode | Latin-1 | None |
| Grid Matrix | GB 2312 (includes ASCII) | N/A |
| Han Xin | Latin-1 | GB 18030 (includes ASCII) |
| MaxiCode | Latin-1 | None |
| MicroPDF417 | Latin-1 | None |
| Micro QR Code | Latin-1 | Shift JIS (includes ASCII7) |
| PDF417 | Latin-1 | None |
| QR Code | Latin-1 | Shift JIS (see above) |
| rMQR | Latin-1 | Shift JIS (see above) |
| Ultracode | Latin-1 | None |
| UPNQR | Latin-2 | N/A |
| All others | ASCII | N/A |
If Zint encounters characters which can not be encoded using the default character encoding then it will take advantage of the ECI (Extended Channel Interpretations) mechanism to encode the data if the symbology supports it - see 4.11.2 Input Modes and ECI below.
GS1 data can be encoded in a number of symbologies - see 4.11.3 GS1 Data Entry and Options.
Health Industry Barcode (HIBC) data may be encoded in the symbologies
Aztec Code, Codablock F, Code 128, Code 39, Data Matrix, MicroPDF417,
PDF417 and QR Code. Within this mode, the leading '+' and
the check character are automatically added by Zint, conforming to HIBC
Labeler Identification Code (HIBC LIC). For HIBC Provider Applications
Standard (HIBC PAS), preface the data with a slash '/'.
The --binary option encodes the input data as given.
Automatic code page translation to an ECI page is disabled, and no
validation of the data’s encoding takes place. This may be used for raw
binary or binary encrypted data. This switch plays together with the
built-in ECI logic and examples may be found below.
The --fullmultibyte option uses the multibyte modes of
QR Code, Micro QR Code, Rectangular Micro QR Code, Han Xin Code and Grid
Matrix for non-ASCII data, maximizing density. This is achieved by using
compression designed for Kanji/Hanzi characters; however some decoders
take blocks which are encoded this way and interpret them as Kanji/Hanzi
characters, thus causing data corruption. Symbols encoded with this
option should be checked against decoders before they are used. The
popular open-source ZXing decoder is known to exhibit this
behaviour.
4.11.2 Input Modes and ECI
If your data contains characters that are not in the default character set, you may encode it using an ECI-aware symbology and an ECI value from Table 9: ECI Codes below. The ECI information is added to your code symbol as prefix data. The symbologies that support ECI are:
| Aztec Code | Data Matrix | Grid Matrix | MaxiCode | PDF417 | rMQR |
| Code One | DotCode | Han Xin Code | MicroPDF417 | QR Code | Ultracode |
Be aware that not all barcode readers support ECI mode, so this can sometimes lead to unreadable barcodes. If you are using characters beyond those supported by the default character set then you should check that the resulting barcode can be understood by your target barcode reader.
The ECI value may be specified with the --eci switch,
followed by the value in the column "ECI Code" in the table
below. The input data should be UTF-8 formatted. Zint automatically
translates the data into the target encoding.
| ECI Code | Character Encoding Scheme (ISO/IEC 8859 schemes include ASCII) |
|---|---|
| 3 | ISO/IEC 8859-1 - Latin alphabet No. 1 |
| 4 | ISO/IEC 8859-2 - Latin alphabet No. 2 |
| 5 | ISO/IEC 8859-3 - Latin alphabet No. 3 |
| 6 | ISO/IEC 8859-4 - Latin alphabet No. 4 |
| 7 | ISO/IEC 8859-5 - Latin/Cyrillic alphabet |
| 8 | ISO/IEC 8859-6 - Latin/Arabic alphabet |
| 9 | ISO/IEC 8859-7 - Latin/Greek alphabet |
| 10 | ISO/IEC 8859-8 - Latin/Hebrew alphabet |
| 11 | ISO/IEC 8859-9 - Latin alphabet No. 5 (Turkish) |
| 12 | ISO/IEC 8859-10 - Latin alphabet No. 6 (Nordic) |
| 13 | ISO/IEC 8859-11 - Latin/Thai alphabet |
| 15 | ISO/IEC 8859-13 - Latin alphabet No. 7 (Baltic) |
| 16 | ISO/IEC 8859-14 - Latin alphabet No. 8 (Celtic) |
| 17 | ISO/IEC 8859-15 - Latin alphabet No. 9 |
| 18 | ISO/IEC 8859-16 - Latin alphabet No. 10 |
| 20 | Shift JIS (JIS X 0208 and JIS X 0201) |
| 21 | Windows 1250 - Latin 2 (Central Europe) |
| 22 | Windows 1251 - Cyrillic |
| 23 | Windows 1252 - Latin 1 |
| 24 | Windows 1256 - Arabic |
| 25 | UTF-16BE (High order byte first) |
| 26 | UTF-8 |
| 27 | ASCII (ISO/IEC 646 IRV) |
| 28 | Big5 (Taiwan) Chinese Character Set |
| 29 | GB 2312 (PRC) Chinese Character Set |
| 30 | Korean Character Set EUC-KR (KS X 1001:2002) |
| 31 | GBK Chinese Character Set |
| 32 | GB 18030 Chinese Character Set |
| 33 | UTF-16LE (Low order byte first) |
| 34 | UTF-32BE (High order bytes first) |
| 35 | UTF-32LE (Low order bytes first) |
| 170 | ISO/IEC 646 Invariant8 |
| 899 | 8-bit binary data9 |
An ECI value of 0 does not encode any ECI information in the code symbol (unless the data contains non-default character set characters). In this case, the default character set applies (see Table 7: Default Character Sets above).
If no ECI is specified or a value of 0 is given, and the data does
contain characters other than in the default character set, then Zint
will automatically insert the appropriate single-byte ECI if possible
(ECIs 3 to 24, excluding ECI 20), or failing that ECI 26 (UTF-8). A
warning will be generated. This mechanism is not applied if the
--binary option is given.
Multiple ECIs can be specified using the --segN options
- see 4.16 Multiple Segments.
Note: the --eci=3 specification should only be used for
special purposes. Using this parameter, the ECI information is
explicitly added to the symbol. Nevertheless, for ECI Code 3, this is
not usually required, as this is the default encoding for most barcodes,
which is also active without any ECI information.
4.11.2.1 Input Modes and ECI Example 1
The Euro sign U+20AC can be encoded in ISO/IEC 8859-15. The Euro sign
has the ISO/IEC 8859-15 codepoint hex "A4". It is encoded
in UTF-8 as the hex sequence: "E2 82 AC". Those 3 bytes are
contained in the file "utf8euro.txt". This command will
generate the corresponding code:
This is equivalent to the commands (using the --esc
switch):
zint -b DATAMATRIX --scale=10 --eci=17 --esc -d "\xE2\x82\xAC"
zint -b DATAMATRIX --scale=10 --eci=17 --esc -d "\u20AC"and to the command:
zint -b DATAMATRIX --eci=17 -d "€"4.11.2.2 Input Modes and ECI Example 2
The Chinese character with the Unicode codepoint U+5E38 can be
encoded in Big5 encoding. The Big5 representation of this character is
the two hex bytes: "B1 60" (contained in the file
"big5char.txt"). The generation command for Data Matrix
is:
This is equivalent to the command (using the --esc
switch):
and to the commands (no --binary switch so conversion
occurs):
zint -b DATAMATRIX --scale=10 --eci=28 --esc -d "\xE5\xB8\xB8"
zint -b DATAMATRIX --scale=10 --eci=28 --esc -d "\u5E38"
zint -b DATAMATRIX --scale=10 --eci=28 -d "常"zint -b DATAMATRIX --eci=28 -d "\u5E38" --esc4.11.2.3 Input Modes and ECI Example 3
Some decoders (in particular mobile app ones) for QR Code assume
UTF-8 encoding by default and do not support ECI. In this case supply
UTF-8 data and use the --binary switch so that the data
will be encoded as UTF-8 without conversion:
zint -b QRCODE --binary -d "\xE2\x82\xAC\xE5\xB8\xB8" --esc4.11.3 GS1 Data Entry and Options
The following symbologies accept GS1 data:
| Symbology | Implicit AI? | GS1 Data Assumed? | Supports GS1 Composite? |
|---|---|---|---|
| Aztec Code | No | No | No |
| Code 16K | No | No | No |
| Code 49 | No | No | No |
| Code One | No | No | No |
| Data Matrix | No | No | No |
| DotCode | No | No | No |
| EAN-13, EAN-8 | Yes (01) | Yes | Yes |
| EAN-14 | Yes (01) | Yes | No |
| GS1-128 | No | Yes | Yes |
| GS1 DataBar Expanded (including Stacked) | No | Yes | Yes |
| GS1 DataBar (all others) | Yes (01) | Yes | Yes |
| NVE-18 | Yes (00) | Yes | No |
| QR Code | No | No | No |
| rMQR | No | No | No |
| Ultracode | No | No | No |
| UPC-A, UPC-E | Yes (01) | Yes | Yes |
4.11.3.1 GS1 Data Entry
Those that encode an implicit AI take numeric data in their linear part without any further markup - see respective descriptions in 6. Types of Symbology.
GS1-128, GS1 DataBar Expanded (including Expanded Stacked), the matrix symbologies and the 2D component of GS1 Composite symbologies, all of which can encode multiple AIs, require markup in the data to distinguish AIs.
The traditional way in Zint of specifying GS1 data for these cases is to delimit the GS1 AIs in square brackets:
(Note that for the matrix symbologies the --gs1 option
must be given.)
Parentheses (round brackets) may be used instead by giving the
--gs1parens option:
If the data includes opening parentheses when using the latter
format, they must be escaped and the --esc option
given:
Closing parentheses may also be escaped for clarity.
For matrix symbologies, a GS1 Digital Link URI may be used:
A further way to specify GS1 input is “Unbracketed AI”, a GS1 Syntax
Engine format10 that uses carets (^)
to indicate any required FNC1s.11
The data must start with a caret:
The final way to specify input is the related “raw” mode using the
--gs1raw option. Here FNC1s are indicated by
Group Separators (GS, ASCII 29, escape sequence
\G). It does not start with a GS:
4.11.3.2 GS1 Options
Apart from --gs1, --gs1parens and
--gs1raw discussed above, there are two other GS1
options.
--gs1strict, which enables the use the GS1 Syntax Engine to strictly validate GS1 data, including GS1 Digital Link URIs (by default Zint does not validate Digital Links at all). It requires that thegs1encoderslibrary was present when Zint was built, otherwise the default built-in validation will be used.--gs1nocheck, for use with legacy systems that have data that does not conform to the current GS1 standard. Printable ASCII input is still checked for, as is the validity of GS1 data specified without AIs (e.g. linear data for GS1 DataBar Omnidirectional/Limited/etc.). Also checked is GS1 DataBar Expanded and GS1 Composite input that is not in the GS1 encodable character set 82 (see GS1 General Specifications 26.0 Table 7-2 “GS1 AI encodable character set 82”), otherwise encodation would fail. In “Unbracketed AI” and raw mode, overlong AI data will also fail.
All the GS1 options imply --gs1 (unlike their API
equivalents, for which see 5.11
Setting the Input Mode).
4.12 Batch Processing
Data can be batch processed by reading from a text file and producing
a separate barcode image for each line of text in that file. To do this
use the --batch switch together with -i to
select the input file from which to read data. For example
where "ean13nos.txt" contains a list of EAN-13 numbers
(GTINs), each on its own line. Zint will automatically detect the end of
a line of text (in either Unix or Windows formatted text files) and
produce a symbol each time it finds this.
Input files should end with a line feed character - if this is not present then Zint will not encode the last line of text, and will warn you that there is a problem.
By default Zint will output numbered filenames starting with
00001.png, 00002.png etc. To change this
behaviour specify the -o option using special characters in
the output filename as shown in the table below:
| Input Character | Interpretation |
|---|---|
~ | Insert a number or 0 |
# | Insert a number or space |
@ | Insert a number or * (or
+ on Windows) |
| Any other | Insert literally |
For instance
The following table shows some examples to clarify this method:
| Input | Filenames Generated |
|---|---|
-o "file~~~.svg" | "file001.svg",
"file002.svg", "file003.svg" |
-o "@@@@bar.png" | "***1.png",
"***2.png", "***3.png" (except Windows) |
-o "@@@@bar.png" | "+++1.png",
"+++2.png", "+++3.png" (on Windows) |
-o "my~~bar~.eps" | "my00bar1.eps",
"my00bar2.eps", "my00bar3.eps" |
-o "t###est.png" | "t 1est.png",
"t 2est.png", "t 3est.png" |
The special characters can span directories also, which is useful when creating a large number of barcodes:
| Input | Filenames Generated |
|---|---|
-o "dir~/file~~~.svg" | "dir0/file001.svg",
"dir0/file002.svg", … |
"dir0/file999.svg",
"dir1/file000.svg", … |
For an alternative method of naming output files see the
--mirror option in 4.14
Automatic Filenames below.
4.13 Direct Output to stdout
The finished image files can be output directly to stdout for use as
part of a pipe by using the --direct option. By default
--direct will output data as a PNG image (or GIF image if
libpng is not present), but this can be altered by
supplementing the --direct option with a
--filetype option followed by the suffix of the file type
required. For example:
This command will output the symbol as a PCX file to stdout. For the supported output file formats see Table 4: Output File Formats.
CAUTION: Outputting binary files to the command shell without catching that data in a pipe can have unpredictable results. Use with care!
4.14 Automatic Filenames
The --mirror option instructs Zint to use the data to be
encoded as an indicator of the filename to be used. This is particularly
useful if you are processing batch data. For example the input data
"1234567" will result in a file named
"1234567.png".
There are restrictions, however, on what characters can be stored in a filename, so the filename may vary from the data if the data includes non-printable characters, for example, and may be shortened if the data input is long.
To set the output file format use the --filetype option
as detailed above in 4.13 Direct
Output to stdout. To output to a specific directory use the
-o option giving the name of the directory (any filename
will be ignored, unless --filetype is not specified, in
which case the filename’s extension will be used).
4.15 Working with Dots
Matrix codes can be rendered as a series of dots or circles rather
than the normal squares by using the --dotty option. This
option is only available for matrix symbologies, and is automatically
selected for DotCode. The size of the dots can be adjusted using the
--dotsize option followed by the diameter of the dot, where
that diameter is in X-dimensions. The minimum dot size is 0.01, the
maximum is 20. The default size is 0.8.
The default and minimum scale for raster output in dotty mode is 1.
zint -b CODEONE -d "123456789012345678" --dotty --vers=94.16 Multiple Segments
If you need to specify different ECIs for different sections of the
input data, the --seg1 to --seg9 options can
be used. Each option is of the form --segN=ECI,data where
ECI is the ECI code (see Table 9: ECI Codes)
and data is the data to which this applies. This is in
addition to the ECI and data specified using the --eci and
-d options which must still be present and which in effect
constitute segment 0. For instance
specifies 3 segments: segment 0 with ECI 9 (Greek), segment 1 with ECI 7 (Cyrillic), and segment 2 with ECI 20 (Shift JIS). Segments must be consecutive.
Naturally the symbology must be ECI-aware (see Table 8: ECI-Aware Symbologies).
zint -b AZTEC --eci=9 -d "Κείμενο" --seg1=7,"Текст" --seg2=20,"文章"ECIs of zero may be given, in which case Zint will automatically determine an ECI if necessary, as described in section 4.11.2 Input Modes and ECI.
Multiple segments are not currently supported for use with GS1 data.
4.17 Structured Append
Structured Append is a method of splitting data among several symbols so that they form a sequence that can be scanned and re-assembled in the correct order on reading, and is available for Aztec Code, Code One, Data Matrix, DotCode, Grid Matrix, MaxiCode, MicroPDF417, PDF417, QR Code and Ultracode.
The --structapp option marks a symbol as part of a
Structured Append sequence, and has the format
zint -b DATAMATRIX -d "2nd of 3" --structapp="2,3,5006"where I is the index (position) of the symbol in the
Structured Append sequence, C is the count or total number
of symbols in the sequence, and ID is an optional
identifier (not available for Code One, DotCode or MaxiCode) that is the
same for all symbols belonging to the same sequence. The index is
1-based and goes from 1 to count. Count must be 2 or more. See the
individual symbologies for further details.
4.18 Help Options
There are three help options which give information about how to use
the command line. The -h or --help option will
display a list of all of the valid options available, and also gives the
exact version of the software (the version by itself can be displayed
with -v or --version).
The -t or --types option gives the table of
symbologies listing the symbol ID numbers and names.
The -e or --ecinos option gives a list of
the ECI codes.
4.19 Other Options
Zint can output a representation of the symbol data as a set of
hexadecimal values if asked to output to a text file
("*.txt") or if given the option
--filetype=txt or the option --dump. This can
be used for test and diagnostic purposes.
Also there’s the --verbose option which will output
debug information to stdout.
Additional options are available which are specific to certain symbologies. These may, for example, control the amount of error correction data or the size of the symbol. These options are discussed in section 6. Types of Symbology of this guide.