question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IndexOutOfBounds when encoding a PDF417

See original GitHub issue

I’m trying to encode a PDF417 and whenever I set the PDF417_COMPACTION to Compaction.TEXT I get this crash:

    java.lang.ArrayIndexOutOfBoundsException: length=128; index=8226
        at com.google.zxing.pdf417.encoder.PDF417HighLevelEncoder.isMixed(PDF417HighLevelEncoder.java:456)
        at com.google.zxing.pdf417.encoder.PDF417HighLevelEncoder.encodeText(PDF417HighLevelEncoder.java:298)
        at com.google.zxing.pdf417.encoder.PDF417HighLevelEncoder.encodeHighLevel(PDF417HighLevelEncoder.java:185)
        at com.google.zxing.pdf417.encoder.PDF417.generateBarcodeLogic(PDF417.java:649)
        at com.google.zxing.pdf417.PDF417Writer.bitMatrixFromEncoder(PDF417Writer.java:107)
        at com.google.zxing.pdf417.PDF417Writer.encode(PDF417Writer.java:87)
        at com.google.zxing.MultiFormatWriter.encode(MultiFormatWriter.java:102)

Here is the code for how I am trying to create the barcode:

        var hints: MutableMap<EncodeHintType, Any>?
        
        hints = EnumMap<EncodeHintType, Any>(EncodeHintType::class.java)
        
        hints[EncodeHintType.CHARACTER_SET] = "UTF-8" 
        hints[EncodeHintType.ERROR_CORRECTION] = 6
        hints[EncodeHintType.PDF417_COMPACTION] = Compaction.TEXT
        
        val writer = MultiFormatWriter()
        val result: BitMatrix
        try {
            result = writer.encode(contents, format, img_width, img_height, hints)
        } catch (iae: WriterException) {
            // Unsupported format
            return null
        }

Is this a bug or am i doing something wrong?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
hidethatbugcommented, Jun 16, 2019

I suspect it’s a bug, and I unfortunately have no idea what. I think there are a few latent bugs in the PDF417 parts. If you figure it out, feel free to open a PR. What language is this BTW?

i use java ,i work for android

2reactions
srowencommented, May 3, 2019

I suspect it’s a bug, and I unfortunately have no idea what. I think there are a few latent bugs in the PDF417 parts. If you figure it out, feel free to open a PR. What language is this BTW?

Read more comments on GitHub >

github_iconTop Results From Across the Web

IndexOutOfBounds when encoding a PDF417 - Stack Overflow
I'm trying to encode a PDF417 and ...
Read more >
Developers - IndexOutOfBounds when encoding a PDF417 -
I'm trying to encode a PDF417 and whenever I set the PDF417_COMPACTION to Compaction.TEXT I get this crash: java.lang.ArrayIndexOutOfBoundsException: ...
Read more >
PDF417 2D Barcode Information & Tutorial - BarcodeFAQ.com
The PDF417 barcode is a two-dimensional (2D), high-density symbology capable of encoding text, numbers, files and actual data bytes.
Read more >
Java barcode generator / Bugs - Barbecue - SourceForge
#. Sort A ‑> Z; Sort Z ‑> A Summary▾. Sort A ‑> Z; Sort Z ‑> A Milestone▾. Sort A ‑> Z;...
Read more >
OkapiBarcode Open-source barcode encoding prog @codeKK ...
Introduction: Open-source barcode encoding program written in Java ... avoid ArrayIndexOutOfBoundsException in some rare corner cases; PDF417: add ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found