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

JPXFilter fails to decode some Jpeg2000 images

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0
    • 2.0.0
    • Rendering

    Description

      Most of the images in the attached PDF are missing when rendered via PDFBox (tested in 2.0 head). The reason is a NullPointerException in ImageIO:
      java.lang.NullPointerException
      at com.sun.media.imageioimpl.plugins.jpeg2000.J2KMetadata.replace(J2KMetadata.java:962)
      at com.sun.media.imageioimpl.plugins.jpeg2000.J2KMetadata.addNode(J2KMetadata.java:631)
      at jj2000.j2k.fileformat.reader.FileFormatReader.readFileFormat(FileFormatReader.java:279)
      at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.initializeRead(J2KReadState.java:418)
      at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.<init>(J2KReadState.java:189)
      at com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader.read(J2KImageReader.java:443)
      at javax.imageio.ImageReader.read(Unknown Source)
      at org.apache.pdfbox.filter.JPXFilter.readJPX(JPXFilter.java:84)
      at org.apache.pdfbox.filter.JPXFilter.decode(JPXFilter.java:58)
      ...

      To avoid the problem, the ImageIO has to be instructed to skip reading metadata of the image, i.e. use reader.setInput(iis, true, true) instead of reader.setInput(iis) as shown in the attached patch. This is also what ImageIO.read(stream) does - the method that was used before the commit 1570806.

      Attachments

        1. JPXFilter.java.patch
          0.7 kB
          Petr Slaby
        2. 000001_MTEXT_CS6.pdf
          923 kB
          Petr Slaby

        Activity

          People

            lehmi Andreas Lehmkühler
            pslabycz Petr Slaby
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: