Interleaved 2 of 5 Barcode - Increase string size in parameter

Asked

Viewed 419 times

3

Good morning, my friends!

I’m having a problem when passing the String with the bar code in the parameter of Barcodeinter25 , In 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 looked for several types and I don’t think it’s ideal, since my project needs to generate a bank ticket 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 !

  • I have no way to test here, but I believe you have to set the size of 44 as a size allowed in the library, it would be something like this: Map<DecodeHintType, Object> hints = new HashMap<DecodeHintType,Object>(); hints.put(DecodeHintType.ALLOWED_LENGTHS, new int[]{44});

  • @Math, this project does not allow me to make any kind of changes or include in the standard library. I have tried using Barcode128 and Barcodeean, they all generate a different bar code of type ITF

1 answer

-1

"The text length must be Even." It means that the amount of numbers you must pass on has to be odd. This is a problem we have with these ready-made libraries. It does not accept that you pass the type checker. 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 given by the bank to generate the check digit in the correct position, because in the digitable line it is in a different position than printed in the bar code. You have to create your own bar, converting value, maturity, originator code, etc...

  • 1

    "The text length must be Even" = "The text size has to be par".

Browser other questions tagged

You are not signed in. Login or sign up in order to post.