Issue generating EAN128 code using Barcode4j for multiple AI and data sets

I am using barcode4j to generate EAN128 barcode. The barcode I need to generate contains multiple sets of app IDs and data, for example:

(410)000061000034(412)000001101593

      

The data length for 410

and 412

is 13 characters

. I am using checksum mode, as you can see in the above example, I only intend to provide 12 characters as data for each AI and would expect the checksum digit to be calculated and automatically added.

However, using the 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 it barcode4j

does NOT know where the data of the first one ends AI (410)

and therefore does NOT correctly identify the second set of AI and data.

I found there is a way to do this using an XML approach defining sth as:

<template>(410)n12+cd1(412)n12+cd1</template>

      

I'm just wondering if anyone knows a solution using the Java bean approach?

Any help and shedding light would be much appreciated!

+3


source to share


2 answers


It might be too late for this answer, but I solved it by simply adding a template to objEAN128Bean :

objEAN128Bean.setTemplate("(415)n13+(8020)n18+(3902)n10+cd");

      



and it will bind the string correctly.

+2


source


I don't know if this works for you, but in the barcode4j component of the Jasper report, you can start a new app id with a symbol \u00f1

.

"97XXX\u00f1916213514687"

      



He will give you a barcode like

(97) XXX (91) 6213514687

      

+1


source







All Articles