Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-4227

java.util.zip.DataFormatException: invalid distance too far back

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.9
    • 2.0.10, 3.0.0 PDFBox
    • Utilities
    • None

    Description

      I get a zip exception with the attached PDF file, which renders successfully in a couple of PDF viewers I tried.

      ByteArrayInputStream pdfInputStream = new ByteArrayInputStream(pdfByteArray);
      PDFMergerUtility merger = new PDFMergerUtility();
      merger.addSource(pdfInputStream);

      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      merger.setDestinationStream(outputStream);
      merger.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly());

       

      PDF file attached.

      Stack Trace:

      java.io.IOException: java.util.zip.DataFormatException: invalid distance too far back
      at org.apache.pdfbox.filter.FlateFilter.decode(FlateFilter.java:83)
      at org.apache.pdfbox.filter.Filter.decode(Filter.java:87)
      at org.apache.pdfbox.cos.COSInputStream.create(COSInputStream.java:77)
      at org.apache.pdfbox.cos.COSStream.createInputStream(COSStream.java:175)
      at org.apache.pdfbox.cos.COSStream.createInputStream(COSStream.java:163)
      at org.apache.pdfbox.multipdf.PDFMergerUtility.appendDocument(PDFMergerUtility.java:516)
      at org.apache.pdfbox.multipdf.PDFMergerUtility.mergeDocuments(PDFMergerUtility.java:263)
      ...
      Caused by: java.util.zip.DataFormatException: invalid distance too far back
      at java.util.zip.Inflater.inflateBytes(Native Method)
      at java.util.zip.Inflater.inflate(Inflater.java:259)
      at java.util.zip.Inflater.inflate(Inflater.java:280)
      at org.apache.pdfbox.filter.FlateFilter.decompress(FlateFilter.java:108)
      at org.apache.pdfbox.filter.FlateFilter.decode(FlateFilter.java:74)
      ... 35 more

      Attachments

        1. testCorrupt.pdf
          391 kB
          Michael Miller

        Activity

          People

            tilman Tilman Hausherr
            michaelgmiller Michael Miller
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: