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

It won't catch the exception when read the CMYK image in PDF for DCTFilter.class

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Incomplete
    • 2.0.7
    • None
    • None
    • Windows/Liunx

    Description

      In below code of DCTFilter.class, can't catch the IIOException because the right Exception is IOException.

      And when I change the code, in my testing, when I convert the PDF to image, I found the CMYK image will be lost in converted image, it's very strange when I set "String numChannels = '2'", I got positive result.

                  if ("3".equals(numChannels) || numChannels.isEmpty())
                  {
                      try
                      {
                          // I'd like to use ImageReader#readRaster but it is buggy and can't read RGB correctly
                          BufferedImage image = reader.read(0);
                          raster = image.getRaster();
                      }
                      catch (IIOException e)
                      {
                          // JAI can't read CMYK JPEGs using ImageReader#read or ImageIO.read but
                          // fortunately ImageReader#readRaster isn't buggy when reading 4-channel files
                          raster = reader.readRaster(0, null);
                      }
                  }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            cdfly813 austinchen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: