Interleaved 2 of 5 Barcode - Increase string size in parameter

2

Good morning, friends!

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

And I have already looked for several types and I do not think the ideal, since my project needs to generate a barcode for banking booth with 44 positions of 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"));
                document.open();
                PdfContentByte cb = writer.getDirectContent();

                BarcodeInter25 code25 = new BarcodeInter25();
                code25.setGenerateChecksum(true);
                code25.setCode("99-1234567890-001");
                Image image25 = code25.createImageWithBarcode(cb, null, null);

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

Thank you!

    
asked by anonymous 20.07.2016 / 15:25

1 answer

0

"The text length must be even." It means that the amount of numbers that you must pass has to 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 do not pass, it generates the wrong code without the digit. The way is to do everything in the hand, observing the instructions passed by the bank to generate the check digit in the correct position, because in the digitable line it is in a position different from the one printed in the bar code. You have to create your own bar, converting value, winning, transferor code, etc ...

    
06.08.2016 / 21:44