The Zxing ("Zebra Crossing") module is used to create barcodes or QR codes and display them in image form in a document. This module uses the open-source Java ZXing framework: https://github.com/zxing/zxing.
It is based on ZXing version 3.5.1.
This module supports the creation of the following types of 1D or 2D (one- or two-dimensional) barcodes:
1D product |
1D industrial |
2D |
UPC-A |
Code 39 |
QR Code |
UPC-E |
Code 93 |
Data Matrix |
EAN-8 |
Code 128 | Aztec |
EAN-13 |
Codabar |
PDF 417 |
UPC/EAN Extension 2/5 | ITF |
MaxiCode |
RSS-14 |
||
RSS-Expanded |
The ZXing module is used in an APE template with the aid of an inclusion directive to insert at the start of the template:
<#import "/lib_xzingbarcode.ftl" as zxingModule/>
Note: The "zxingModule" namespace name is provided as an example and can be replaced by a name of your choosing (in accordance with Apache Freemarker namespaces syntax).
This module offers a macro called "barcode" to represent all the different types of supported barcodes. This macro has no content (no end tags). Barcodes are described by entering the barcode parameters:
- Required parameters:
Parameter type | Parameter name | Description |
String | type | 1D/2D barcode type from the following values:
|
String |
content |
Numeric or alphanumeric data to display in barcode form. |
Number |
width |
The required width in image pixels representing the barcode. The actual value can be slightly different from the required width according to the chosen format constraints. |
Number |
height |
The required height in image pixels representing the barcode. The actual value can be slightly different from the required height according to the chosen format constraints. |
- Optional parameters:
Parameter type | Parameter name | Description |
Hash |
hints |
Display options depending on the chosen type. Each option is defined by a name/value pair and all the options are grouped in a Hash object. See more detailed Java ZXing framework documentation on the subject: https://zxing.github.io/zxing/apidocs/com/google/zxing/EncodeHintType.html. The option name must be defined with one of the names in the following list:
|
Any |
inner* |
The barcode macro uses the foExternalGraphic macro to display the barcode image (in PNG format) in the APE template. Parameters specific to the generated foExternalGraphic macro can be specified by prefixing the parameter name with the "inner" string and putting the first letter of the parameter in upper case. |
For example:
<#-- Display a QRCode -->
<#assign hintsQRCode = {"error_correction": "H", "qr_mask_pattern": 2} />
<@zxingModule.barcode type="qr_code" content="https://www.hardis-group.com/" width=150 height=150 hints=hintsQRCode innerBorder="2px solid black" />
<#-- Display a Code 128 -->
<@zxingModule.barcode type="code_128" content="SW-02643/1" width=100 height=50 hints={"force_code_set" : "A"} />