As of Camel 2.14
The barcode data format is based on the zxing library. The goal of this component is to create a barcode image from a String (marshal) and a String from a barcode image (unmarshal). You're free to use all features that zxing offers.
To use Bindy in your camel routes you need to add the a dependency on camel-barcode which implements this data format.
If you use maven you could just add the following to your pom.xml, substituting the version number for the latest & greatest release (see the download page for the latest versions).
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-barcode</artifactId>
<version>x.x.x</version>
</dependency>
First you have to initialize the barcode data fomat class. You can use the default constructor, or one of parameterized. The default values are:
Parameter |
Default Value |
image type (BarcodeImageType) |
PNG |
width |
100 px |
height |
100 px |
encoding |
UTF-8 |
barcode format (BarcodeFormat) |
QR-Code |
// QR-Code default
DataFormat code = new BarcodeDataFormat();
from("direct://code")
.marshal(code)
.to("file://barcode_out");
You can call the route from a test class with:
template.sendBody("direct://code", "This is a testmessage!");
You should find inside the 'barcode_out' folder this image:
![]()
The unmarshaller is generic. For unmarshalling you can use any BarcodeDataFormat instance. If you've two instances, one for (generating) QR-Code and one for PDF417, it doesn't matter which one will be used.