#10 Error decoding stream

v1.0 (example)


I am trying to parse a pdf using jPod and I get this exception:
de.intarsys.pdf.cos.COSRuntimeException: error decoding stream
at de.intarsys.pdf.cos.COSStream.getDecodedBytes(COSStream.java:778)
at de.intarsys.pdf.content.CSContent.createFromCos(CSContent.java:137)
at de.intarsys.pdf.pd.PDPage.getContentStream(PDPage.java:395)
Caused by: java.io.EOFException: Unexpected end of ZLIB input stream
at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:223)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:141)
at java.io.FilterInputStream.read(FilterInputStream.java:90)
at de.intarsys.tools.stream.StreamTools.copyStream(StreamTools.java:184)
at de.intarsys.pdf.filter.StreamBasedFilter.decode(StreamBasedFilter.java:74)
at de.intarsys.pdf.filter.FlateFilter.decode(FlateFilter.java:201)
at de.intarsys.pdf.filter.Filter.decode(Filter.java:129)

The pdf file can be opened in Acrobat reader. This looks like bug 94 of PDFBOX (https://issues.apache.org/jira/browse/PDFBOX-94, you may download a sample pdf file which shows the issue).



  • mtraut

    mtraut - 2013-12-12

    Thank you for providing the information.

    We can confirm the behavior and added a "fix" - i think this should be much the same as what PDFBox did. Simply catch the exception and go on.

    I didn't go into the zlib implementation and why this specific stream might deviate from the Java way of interpreting it. If someone has more information on the "why", please provide it...

    So far, overriding the "read" method in PDFInflaterOutputStream will fix this behavior.

    public int read(byte[] b, int off, int len) throws IOException {
        try {
            return super.read(b, off, len);
        } catch (EOFException e) {
            // this is a workaround for a bug when decoding a FlateFilter
            // stream where, after completely decoding, java zlib complains
            // about EOF - maybe someone should someday get into this
        } catch (ZipException e) {
            // now that we are already filtering exceptions...
        return -1;
  • mtraut

    mtraut - 2013-12-12
    • status: open --> closed-fixed
    • assigned_to: mtraut

Log in to post a comment.