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.
To view the supported types of barcodes, please go to.
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 top. For more details see section 4.4 Quiet Zone in the Barcode Reference.
Usage:
<param name="quietzonetop" value="0.5"><!-- **0**-->
Quiet zone bottom
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) |