3

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!

Kristijan Iliev
  • 4,901
  • 10
  • 28
  • 47

2 Answers2

2

I do not know if it is relevant for you, but in Jasper report's barcode4j component, you can start a new application identifier with the \u00f1 character.

"97XXX\u00f1916213514687"

It will give you a barcode like

(97) XXX (91) 6213514687
Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
Brimstedt
  • 3,020
  • 22
  • 32
  • Yes. In barcode4j barcodes, you can "enter" a 2nd, 3rd, etc. Application Identifier by prefixing its "code" with either an ASCII 29 (hex : 0x1D) character, or a ñ character. For instance 97XXX916213514687 or 97XXXñ916213514687 will result in barcodes with 97 and 91 AI. – FCA69 Feb 07 '23 at 13:23
2

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.

pringi
  • 3,987
  • 5
  • 35
  • 45
File_life
  • 56
  • 5