Using pdfChip to add barcodes and matrix codes

Although HTML doesn't support barcode generation beyond the usage of barcode fonts, pdfChip offers the possibility to add barcodes directly. The barcode functionality in callas pdfChip is based on the barcode generator TBarCode from TEC-IT Datenverarbeitung GmbH (www.tec-it.com). For extensive information about the various types of barcodes, please read the "Barcode Reference" (download link can be found below).

Portions of this article and the Barcode Reference offered below for download are Copyright TEC-IT Datenverarbeitung GmbH, Steyr/Austria, www.tec-it.com.

Quick lookup of supported barcodes

Running pdfChip with the parameter ./pdfChip --list-barcodes on the command line:

./pdfChip --list-barcodes

will output a list of all the barcodes supported by pdfChip. When using the TYPE value to request a barcode through the <param> entry in a barcode <object> make sure to copy everything between the quotes, leaving space characters intact.

Example output from using ./pdfChip --list-barcodes:

ID  TYPE                         Data                 
 1  "Code 11"                    "123456"             
 2  "Code 2 of 5 Standard"       "123456"             
 3  "Code 2 of 5 Interleaved"    "123456"             
 4  "Code 2 of 5 IATA"           "123456"             
 5  "Code 2 of 5 Matrix"         "123456"             
 6  "Code 2 of 5 DataLogic"      "123456"             
 7  "Code 2 of 5 Industry"       "123456"             
 8  "Code 39"  "ABCDEF"             
 ...

How to specify barcodes

Embedding happens using an <object> tag that has to be formatted as follows:

<object type="application/barcode">
    <param name="type" value="➔insert name of desired barcode type">
    <param name="data" value="➔insert value to be encoded by the barcode">
</object>

No barcode validation takes place, so a wrong value (e.g. incorrect checksum) for the data will result in an invalid barcode (for some barcodes the checksum will be computed automatically if left out from the provided value). Size and layout of the barcode can be adjusted using the usual HTML or CSS parameters. In addition the size and appearance of barcodes can also be controlled by using one or several of the optional parameters described below.

Supported types of barcodes

ID TYPE Data Syntax inside HTML <object>
1 Code 11 123456 <param name="type" value="Code 11">
2 Code 2 of 5 Standard 123456 <param name="type" value="Code 2 of 5 Standard">
3 Code 2 of 5 Interleaved 123456 <param name="type" value="Code 2 of 5 Interleaved">
4 Code 2 of 5 IATA 123456 <param name="type" value="Code 2 of 5 IATA">
5 Code 2 of 5 Matrix 123456 <param name="type" value="Code 2 of 5 Matrix">
6 Code 2 of 5 DataLogic 123456 <param name="type" value="Code 2 of 5 DataLogic">
7 Code 2 of 5 Industry 123456 <param name="type" value="Code 2 of 5 Industry">
8 Code 39 ABCDEF <param name="type" value="Code 39">
9 Code 39 Full ASCII ABCabc <param name="type" value="Code 39 Full ASCII">
10 EAN 8 12345670 <param name="type" value="EAN 8">
11 EAN 8 + 2 Digits 1234567012 <param name="type" value="EAN 8 + 2 Digits">
12 EAN 8 + 5 Digits 1234567012345 <param name="type" value="EAN 8 + 5 Digits">
13 EAN 13 1234567890128 <param name="type" value="EAN 13">
14 EAN 13 + 2 Digits 123456789012812 <param name="type" value="EAN 13 + 2 Digits">
15 EAN 13 + 5 Digits 123456789012812345 <param name="type" value="EAN 13 + 5 Digits">
16 EAN/UCC 128 ABCabc <param name="type" value="EAN/UCC 128">
17 UPC 12 123456789012 <param name="type" value="UPC 12">
18 Codabar 2 Widths A123456A <param name="type" value="Codabar 2 Widths">
20 Code 128 ABCabc <param name="type" value="Code 128">
21 DP Leitcode 012345678 <param name="type" value="DP Leitcode">
22 DP Identcode 012345678 <param name="type" value="DP Identcode">
23 ISBN 13 + 5 Digits 978-1-23456-789-712345 <param name="type" value="ISBN 13 + 5 Digits">
24 ISMN 979-0-1234-5678-5 <param name="type" value="ISMN">
25 Code 93 ABCDEF <param name="type" value="Code 93">
26 ISSN 9771234567898 <param name="type" value="ISSN">
27 ISSN + 2 Digits 977123456789812 <param name="type" value="ISSN + 2 Digits">
28 Flattermarken 123456 <param name="type" value="Flattermarken">
29 GS1 DataBar (RSS-14) 00614141999996 <param name="type" value="GS1 DataBar (RSS-14)">
30 GS1 DataBar Limited (RSS) 00614141999996 <param name="type" value="GS1 DataBar Limited (RSS)">
31 GS1 DataBar Expanded (RSS) 0100614141999996 <param name="type" value="GS1 DataBar Expanded (RSS)">
32 Telepen Alpha ABCabc <param name="type" value="Telepen Alpha">
33 UCC 128 ABCabc <param name="type" value="UCC 128">
34 UPC A 123456789012 <param name="type" value="UPC A">
35 UPC A + 2 Digits 12345678901212 <param name="type" value="UPC A + 2 Digits">
36 UPC A + 5 Digits 12345678901212345 <param name="type" value="UPC A + 5 Digits">
37 UPC E 12345670 <param name="type" value="UPC E">
38 UPC E + 2 Digits 1234567012 <param name="type" value="UPC E + 2 Digits">
39 UPC E + 5 Digits 1234567012345 <param name="type" value="UPC E + 5 Digits">
40 USPS PostNet 5 (ZIP) 12345 <param name="type" value="USPS PostNet 5 (ZIP)">
41 USPS PostNet 6 (ZIP+cd) 123455 <param name="type" value="USPS PostNet 6 (ZIP+cd)">
42 USPS PostNet 9 (ZIP+4) 123456789 <param name="type" value="USPS PostNet 9 (ZIP+4)">
43 USPS PostNet 10 (ZIP+4+cd) 1234567895 <param name="type" value="USPS PostNet 10 (ZIP+4+cd)">
44 USPS PostNet 11 (ZIP+4+2) 12345678901 <param name="type" value="USPS PostNet 11 (ZIP+4+2)">
45 USPS PostNet 12 (ZIP+4+2+cd) 123456789014 <param name="type" value="USPS PostNet 12 (ZIP+4+2+cd)">
46 Plessey 123456 <param name="type" value="Plessey">
47 MSI 123456 <param name="type" value="MSI">
48 SSCC 18 012345678901234560 <param name="type" value="SSCC 18">
50 LOGMARS ABCDEF <param name="type" value="LOGMARS">
51 Pharmacode One-Track 123456 <param name="type" value="Pharmacode One-Track">
52 PZN7 1234562 <param name="type" value="PZN7">
53 Pharmacode Two-Track 123456 <param name="type" value="Pharmacode Two-Track">
54 Brazilian CEPNet 12345678 <param name="type" value="Brazilian CEPNet">
55 PDF417 ABCabc <param name="type" value="PDF417">
56 PDF417 Truncated ABCabc <param name="type" value="PDF417 Truncated">
57 MaxiCode ABCabc <param name="type" value="MaxiCode">
58 QR-Code ABCabc <param name="type" value="QR-Code">
59 Code 128 Subset A ABCabc <param name="type" value="Code 128 Subset A">
60 Code 128 Subset B ABCabc <param name="type" value="Code 128 Subset B">
61 Code 128 Subset C ABCabc <param name="type" value="Code 128 Subset C">
62 Code 93 Full ASCII ABCabc <param name="type" value="Code 93 Full ASCII">
63 Australian Post Custom 12345678 <param name="type" value="Australian Post Custom">
64 Australian Post Custom2 12345678ABab <param name="type" value="Australian Post Custom2">
65 Australian Post Custom3 12345678ABCabc <param name="type" value="Australian Post Custom3">
66 Australian Post Reply Paid 12345678 <param name="type" value="Australian Post Reply Paid">
67 Australian Post Routing 12345678 <param name="type" value="Australian Post Routing">
68 Australian Post Redirect 12345678 <param name="type" value="Australian Post Redirect">
69 ISBN 13 978-1-23456-789-7 <param name="type" value="ISBN 13">
70 Royal Mail 4 State (RM4SCC) ABCDEF1234 <param name="type" value="Royal Mail 4 State (RM4SCC)">
71 Data Matrix ABCabc <param name="type" value="Data Matrix">
72 EAN 14 (GTIN 14) 00614141999996 <param name="type" value="EAN 14 (GTIN 14)">
73 VIN / FIN VB1YYY1JX3M386752 <param name="type" value="VIN / FIN">
74 Codablock-F ABCabc <param name="type" value="Codablock-F">
75 NVE 18 012345678901234560 <param name="type" value="NVE 18">
76 Japanese Postal 1234567 <param name="type" value="Japanese Postal">
77 Korean Postal Authority 123456 <param name="type" value="Korean Postal Authority">
78 GS1 DataBar Truncated (RSS) 00614141999996 <param name="type" value="GS1 DataBar Truncated (RSS)">
79 GS1 DataBar Stacked (RSS) 00614141999996 <param name="type" value="GS1 DataBar Stacked (RSS)">
80 GS1 DataBar Stacked Omnidir (RSS) 00614141999996 <param name="type" value="GS1 DataBar Stacked Omnidir (RSS)">
81 GS1 DataBar Expanded Stacked (RSS) 0100614141999996 <param name="type" value="GS1 DataBar Expanded Stacked (RSS)">
82 PLANET 12 digit 123456789014 <param name="type" value="PLANET 12 digit">
83 PLANET 14 digit 12345678901239 <param name="type" value="PLANET 14 digit">
84 Micro PDF417 ABCabc <param name="type" value="Micro PDF417">
85 USPS Intelligent Mail Barcode (IM) 12345678901234567890 <param name="type" value="USPS Intelligent Mail Barcode (IM)">
86 Plessey Bidirectional 123456 <param name="type" value="Plessey Bidirectional">
87 Telepen 123456 <param name="type" value="Telepen">
88 GS1 128 (EAN/UCC 128) 01090999995432171512052110Abc123 <param name="type" value="GS1 128 (EAN/UCC 128)">
89 ITF 14 (GTIN 14) 00614141999996 <param name="type" value="ITF 14 (GTIN 14)">
90 KIX AaBbCcDdEe <param name="type" value="KIX">
91 Code 32 012345676 <param name="type" value="Code 32">
92 Aztec Code ABCabc <param name="type" value="Aztec Code">
93 DAFT Code DAFT <param name="type" value="DAFT Code">
94 Italian Postal 2 of 5 123456789012 <param name="type" value="Italian Postal 2 of 5">
96 DPD 0007110601632532948375179276 <param name="type" value="DPD">
97 Micro QR-Code ABCDEF <param name="type" value="Micro QR-Code">
98 HIBC LIC 128 +A99912345/9901510X3 <param name="type" value="HIBC LIC 128">
99 HIBC LIC 39 +A99912345/9901510X3 <param name="type" value="HIBC LIC 39">
100 HIBC PAS 128 +/EAH783/Z34H159 <param name="type" value="HIBC PAS 128">
101 HIBC PAS 39 +/EAH783/Z34H159 <param name="type" value="HIBC PAS 39">
102 HIBC LIC Data Matrix +A99912345/9901510X3 <param name="type" value="HIBC LIC Data Matrix">
103 HIBC PAS Data Matrix +/EAH783/Z34H159 <param name="type" value="HIBC PAS Data Matrix">
104 HIBC LIC QR-Code +A99912345/9901510X3 <param name="type" value="HIBC LIC QR-Code">
105 HIBC PAS QR-Code +/EAH783/Z34H159 <param name="type" value="HIBC PAS QR-Code">
106 HIBC LIC PDF417 +A99912345/9901510X3 <param name="type" value="HIBC LIC PDF417">
107 HIBC PAS PDF417 +/EAH783/Z34H159 <param name="type" value="HIBC PAS PDF417">
108 HIBC LIC Micro PDF417 +A99912345/9901510X3 <param name="type" value="HIBC LIC Micro PDF417">
109 HIBC PAS Micro PDF417 +/EAH783/Z34H159 <param name="type" value="HIBC PAS Micro PDF417">
110 HIBC LIC Codablock-F +A99912345/9901510X3 <param name="type" value="HIBC LIC Codablock-F">
111 HIBC PAS Codablock-F +/EAH783/Z34H159 <param name="type" value="HIBC PAS Codablock-F">
112 QR-Code 2005 ABCabc <param name="type" value="QR-Code 2005">
113 PZN8 12345678 <param name="type" value="PZN8">
115 DotCode ABCabc <param name="type" value="DotCode">
116 Han Xin Code ABCabc <param name="type" value="Han Xin Code">
117 USPS Intelligent Mail Package (IMpb) 9102805213683062522920 <param name="type" value="USPS Intelligent Mail Package (IMpb)">
118 Swedish Postal Shipment Item ID EM100027995SE <param name="type" value="Swedish Postal Shipment Item ID">


Meaning of values provided under "Data"

The values provided in the "Data" column roughly indicate what kind of data can be represented by the respective barcode type. For full details please see the Barcode Reference in the Annex of the Reference Manual.

  • ABCabc: lower and uppercase characters and digits; may also support punctuation characters or even arbitray binary data
  • ABCDEF: uppercase characters and digits; may also support some punctuation characters
  • 123456: digits only; various rules about maximum number of digits and constraints on some of digits may apply

Optional parameters

pdfChip supports various additional optional parameters that provide more fine grained control over the size, appearance and other aspects of 1D and 2D codes. Not all parameter are meaningful for all types of 1D and 2D codes – for full details see the Barcode Reference in the Annex of this Reference Manual.

An example for using optional parameters for the generation of an "EAN 13" code is shown below:

<object type="application/barcode">
	<param name="data" value="123456789012">
	<param name="type" value="EAN 13">
	<param name="modulewidth" value="0.33mm">
	<param name="barwidthreduction" value="10%">
	<param name="textplacement" value="none">
</object>

String formatting

Provides control over how strings are formatted. For more details see section 4.6 Format in the Barcode Reference.

Usage:

<param name="format" value="A##B###C&">

Module width

Provides control over the Module width. For more details see section 4.2 Module Width in the Barcode Reference.

Usage:

<param name="modulewidth" value="0.33mm">
<!-- **-1**, units: mm, ", mils, **pixel**-->

Horizontal resolution

Providing the horizontal resolution triggers an optimisation of the module width for best possible consistency of bars and gaps in the barcode and thus the barcode readability. For more details see section 4.2 Module Width in the Barcode Reference.

Usage:

<param name="hres" value="600">
<!-- **-1**-->

Vertical resolution

Providing the vertical resolution triggers an optimisation of the module width for best possible consistency of bars and gaps in the barcode and thus the barcode readability. For more details see section 4.2 Module Width in the Barcode Reference.

Usage:

<param name="vres" value="600">
<!-- **-1**-->

Text placement

Provides control over the positioning of the human readable text relative to the barcode proper. Applies only to 1D codes.

Usage:

<param name="textplacement" value="none"><!-- above, **below**, none-->

Text distance

Provides control over the distance of the human readable text from the barcode proper. Applies only to 1D codes.

Usage:

<param name="textdistance" value="0.5mm"><!-- **-1**, units: mm, ", mils, **pixel**-->

Bearer bars

Provides control over the presence and position of bearer bars. For more details see section 3.3 Barcode Glossary, Bearer Bars, 6.1.43 ITF-14 and 6.1.66 UPC SCS (Shipping Container Symbols)in the Barcode Reference.

Usage:

<param name="bearerbars" value="topbottom"><!-- **none**, top, bottom, topbottom-->

Bearer width

Provides control over the width of bearer bars. For more details see section 3.3 Barcode Glossary, Bearer Bars, 6.1.43 ITF-14 and 6.1.66 UPC SCS (Shipping Container Symbols) in the Barcode Reference.

Usage:

<param name="bearerwidth" value="0.5mm"><!-- **-1**, units: mm, ", mils, **pixel**-->

Notch height

Provides control over the notch height. For certain types of barcodes like e.g. "EAN 13", some of the bars are typically longer than the rest of the bars. This parameter provides control over by how much they will be longer.

Usage:

<param name="notchheight" value="0.5mm"><!-- **-1**, units: mm, ", mils, **pixel**-->

Bar width reduction (BWR)

Provides control over the bar width reduction. For more details see section 4.3 Bar Width Reduction (Pixel Shaving) in the Barcode Reference.

Usage:

<param name="barwidthreduction" value="1%"><!-- **0**, units: %, mm, ", mils, **pixel**-->

Quiet zone left

Provides control over the quiet zone on the left. For more details see section 4.4 Quiet Zone in the Barcode Reference.

Usage:

<param name="quietzoneleft" value="0.5"><!-- **0**-->

Quiet zone right

Provides control over the quiet zone on the right. For more details see section 4.4 Quiet Zone in the Barcode Reference.

Usage:

<param name="quietzoneright" value="0.5"><!-- **0**-->

Quiet zone top

Provides control over the quiet zone at the bottom. For more details see section 4.4 Quiet Zone in the Barcode Reference.

Usage:

<param name="quietzonebottom" value="0.5"><!-- **0**-->

Quiet zone unit

Provides control over the unit used for controlling the quiet zone. For more details see section 4.4 Quiet Zone in the Barcode Reference.

Usage:

<param name="quietzoneunit" value="X"><!-- **X**, mm, ", mils, pixel. X: multiples of module width-->

Escaping

For some types of 1D and 2D codes it is possible to encode binary data. Where such binary data includes non-printable characters, such characters need to be provided in an escaped fashion. Several escaping mechanisms can be used. For example, "\h0A" represents the hexadecimal value of "0x0A". Es the escaping mechanisms make use of the backslash character, any occurrence of the actual backslash character must be written as a double backslash ("\\") to avoid unwanted un-escaping.

Escape sequence Description Valid for Barcode Symbology
\a Bell (alert) All
\b Backspace All
\f Form feed All
\n New Line All
\r Carriage Return All
\t Horizontal Tab All
\v Vertical Tab All
\\ The backslash \ itself All
\0 Zero Byte (if subsequent char is non-numeric); Available in TBarCode V10+ All
\0ooo ASCII-character in octal notation: ooo … up to 3 octal digits (0..7); First digit is always zero. All
\ddd ASCII-character in decimal notation: ddd … up to decimal digits (0..9); First digit must not be zero. All
\xhh For encoding bytes or ASCII-characters in hexadecimal notation; hh … hexadecimal digits (0..F) All
\Crrggbb Color selection See Pharmacode
\Ce Reset the color to default See Pharmacode
\F FNC1 (Function Number Character 1) used as field separator GS-128, Codablock-F – MicroPDF417: a special FNC1 codeword is inserted when using emulation mode for GS1-128 or Code-128 – Data Matrix: a special FNC1 codeword is inserted
\F Inserts a Gs (Group Separator) or ASCII 1DHex. Don’t encode the \x1d directly! PDF417, MaxiCode and in QR-Code – QR-Code: When using format UCC/EAN/GS1 Gs is inserted in Byte Mode, a % is inserted in alphanumeric mode.
\Ennnnnn Extended Channel Interpretation (ECI). nnnnnn … 6 digit ECI number with leading zeros. Used for defining the character set (code page) for subsequent encoded data – see C.1 ECI MaxiCode, Data Matrix, QR-Code, PDF417, MicroPDF417, Aztec Code
\EB, \EE Special ECI identifiers for nesting ECIs. \EB (ECI Begin) opens a nesting level, \EE (ECI End) closes it. QR-Code
\G Global Language Identifier (GLI), similar to ECI (see \E). PDF417
\S Symbol separator character for C128 emulation
\ Function sequence. Currently FNC1, FNC2, FNC3, FNC4 are implemented. \ is equal to \F.
\210 FNC1 Code128, GS1-128, Codablock-F
\211 FNC2 Code128, GS1-128, Codablock-F
\212 FNC3 Code128, GS1-128, Codablock-F
\213 FNC4 Code128, GS1-128, Codablock-F
\x11 DC1 Code93, Code93Ext
\x12 DC2 Code93, Code93Ext
\x13 DC3 Code93, Code93Ext
\x14 DC4 Code93, Code93Ext
\x1e Rs (Record Separator), ASCII 1EHex PDF417, QR-Code, Data Matrix, MaxiCode (Mode 3,4 SCM)
\x1d Gs (Group Separator), ASCII 1DHex PDF417, QR-Code, Data Matrix, MaxiCode (Mode 3,4 SCM)
\x04 Eot (End of Transmission), ASCII 04Hex PDF417, QR-Code, Data Matrix, MaxiCode (Mode 3,4 SCM)