I'm using barcode4j to generate EAN128 barcode. The barcode I need to generate contains multiple sets of Application Identifiers and data, for example:
(410)000061000034(412)000001101593
The data length for both 410
and 412
is 13 characters
.
I'm using add checksum mode, so as you can see in above example I only intend to provide 12 characters as the data for each AI and would expect a checksum digit would be calculated and automatically appended.
However by using below code, it does NOT generate the correct code for me:
dpi = 200;
// barcode
objEAN128Bean.setModuleWidth(0.21);
objEAN128Bean.setHeight(15);
// objEAN128Bean.setWideFactor(3);
objEAN128Bean.doQuietZone(true);
objEAN128Bean.setQuietZone(2);
// human-readable
objEAN128Bean.setFontName("Helvetica");
objEAN128Bean.setFontSize(3);
// checksum
objEAN128Bean.setChecksumMode(objCheckSum.CP_ADD);
BitmapCanvasProvider canvas = new BitmapCanvasProvider(out,
"image/jpeg", dpi, BufferedImage.TYPE_BYTE_BINARY, true, 0);
objEAN128Bean.generateBarcode(canvas, "410000061000034412000001101593");
canvas.finish();
It looks like the barcode4j
does NOT know where the data of the first AI (410)
ends and thus does NOT correctly identify the second set of AI and data.
I found there is a way to do it by using the XML approach specifying sth like:
<template>(410)n12+cd1(412)n12+cd1</template>
I'm just wondering if anyone knows a solution by using the Java bean approach?
Any help and shed of light would be much appreciated!
Maybe it's too late for this answer but I've solved it just by adding the template to the objEAN128Bean:
objEAN128Bean.setTemplate("(415)n13+(8020)n18+(3902)n10+cd");
and it will bind the string properly.