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
@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
– Henrique Clerici