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

PDF with JPEG2000 image can't be rendered

    XMLWordPrintableJSON

Details

    Description

      There is an EOF exception:

          java.io.EOFException
          at javax.imageio.stream.ImageInputStreamImpl.readBits(ImageInputStreamImpl.java:687)
          at org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.fromAny(SampledImageReader.java:523)
          at org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.getRGBImage(SampledImageReader.java:217)
          at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:418)
          at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:400)
          at org.apache.pdfbox.rendering.PageDrawer.drawImage(PageDrawer.java:1021) 
      

      The EOF exception is because SampledImageReader expects a stream that is 3x longer than actually appears, because the colorspace is said to have 3 colors instead of 1. This is because the JPEG2000 plugin returns an image with IndexColorModel which references three colors.

      There are two ways to solve this and both worked: the slower is to convert to RGB which requires another change when reading the raster (because the raster is now made of integers), the faster is to force a gray colorspace. I use the later but keep the change I made in passing the integer RGB raster, we may need it some day.

      I'm making the change only for the trunk for now, and to the 2.0 branch after release of 2.0.12.

      Attachments

        1. PDFJS-10026.pdf
          26 kB
          Tilman Hausherr
        2. PDFJS-10026.jp2
          24 kB
          Tilman Hausherr

        Issue Links

          Activity

            People

              tilman Tilman Hausherr
              tilman Tilman Hausherr
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: