Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdf417 encode error java.lang.ArrayIndexOutOfBoundsException when using CHARACTER_SET ISO-8859-15 #1761

Open
cuongtranba opened this issue Feb 23, 2024 · 1 comment

Comments

@cuongtranba
Copy link

Hello,

I encountered an error while attempting to create a PDF417 barcode with character set ISO-8859-15. Here's the relevant code snippet:

String content = "€ 123,45";

Map<EncodeHintType, Object> hints = new HashMap<>();
hints.put(EncodeHintType.ERROR_CORRECTION, 4);
hints.put(EncodeHintType.PDF417_DIMENSIONS, new com.google.zxing.pdf417.encoder.Dimensions(7, 7, 1, 300));
hints.put(EncodeHintType.MARGIN, 0);
hints.put(EncodeHintType.CHARACTER_SET, "ISO-8859-15");
hints.put(EncodeHintType.PDF417_COMPACTION, com.google.zxing.pdf417.encoder.Compaction.TEXT);

MultiFormatWriter writer = new MultiFormatWriter();
BitMatrix bitMatrix = writer.encode(content, BarcodeFormat.PDF_417, 200, 100, hints);

The error message I received is as follows:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 8364 out of bounds for length 128
        at com.google.zxing.pdf417.encoder.PDF417HighLevelEncoder.isMixed(PDF417HighLevelEncoder.java:557)
        at com.google.zxing.pdf417.encoder.PDF417HighLevelEncoder.encodeText(PDF417HighLevelEncoder.java:325)
        at com.google.zxing.pdf417.encoder.PDF417HighLevelEncoder.encodeHighLevel(PDF417HighLevelEncoder.java:212)
        at com.google.zxing.pdf417.encoder.PDF417.generateBarcodeLogic(PDF417.java:659)
        at com.google.zxing.pdf417.PDF417Writer.bitMatrixFromEncoder(PDF417Writer.java:111)
        at com.google.zxing.pdf417.PDF417Writer.encode(PDF417Writer.java:90)
        at com.google.zxing.MultiFormatWriter.encode(MultiFormatWriter.java:102)
        at barcode.BarcodeGenerator.generate(BarcodeGenerator.java:48)
        at test.test.main(test.java:11)

thank you

@srowen
Copy link
Contributor

srowen commented Feb 23, 2024

Looks legitimate, but, I can't debug it. If you have a pull request, feel free to open it here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants