java – Interleaved 2 of 5 Barcode – Increase string size in parameter


Good morning friends!

I have a problem when passing the String with the barcode in the BarcodeInter25 parameter. This code is working but if I pass "23797685200000345000280090000014189301107610" it generates an Exception of java.lang.IllegalArgumentException: The text length must be even.

And I've already looked for several types and I don't think it's ideal, since my project needs to generate a barcode for bank slips with 44 positions in the ITF format.

 public static void main(String[] args) {
            Document document = new Document(PageSize.A4, 50, 50, 50, 50);
            try {
                PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("d:\\BarcodesInter25.pdf"));
                PdfContentByte cb = writer.getDirectContent();

                BarcodeInter25 code25 = new BarcodeInter25();
                Image image25 = code25.createImageWithBarcode(cb, null, null);

                document.add(new Phrase(new Chunk(image25, 0, 0)));
            catch (Exception de) {

Thanks !


"The text length must be even." It means that the amount of numbers you must pass must be odd. This is a problem we have with these ready-made libraries. It does not accept that you pass the verification digit. But if you don't pass, it generates the wrong code, without the digit. The way is to do everything by hand, observing the instructions passed by the bank to generate the verification digit in the correct position, because in the typed line it is in a different position from the one printed in the bar code. You have to create your own bar, converting value, maturity, transferor code, etc…

Scroll to Top