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

PDFRenderer ColorConverterOp Error

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 2.0.13
    • Fix Version/s: None
    • Component/s: Rendering
    • Labels:
      None

      Description

      I was trying the PDFRenderer.renderImageWithDPI function which worked well with a lot of documents, but on the attached document I get this error:

      java.lang.IllegalArgumentException: Numbers of source Raster bands and source color space components do not match
       at java.awt.image.ColorConvertOp.filter(Unknown Source)
       at com.sun.imageio.plugins.jpeg.JPEGImageReader.acceptPixels(Unknown Source)
       at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImage(Native Method)
       at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(Unknown Source)
       at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(Unknown Source)
       at org.apache.pdfbox.filter.DCTFilter.decode(DCTFilter.java:91)
       at org.apache.pdfbox.cos.COSInputStream.create(COSInputStream.java:77)
       at org.apache.pdfbox.cos.COSStream.createInputStream(COSStream.java:175)
       at org.apache.pdfbox.pdmodel.common.PDStream.createInputStream(PDStream.java:241)
       at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.createInputStream(PDImageXObject.java:729)
       at org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.from8bit(SampledImageReader.java:367)
       at org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.getRGBImage(SampledImageReader.java:225)
       at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:443)
       at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:424)
       at org.apache.pdfbox.rendering.PageDrawer.drawImage(PageDrawer.java:1034)
       at org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:62)
       at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:848)
       at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:503)
       at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:477)
       at org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:150)
       at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:254)
       at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:245)
       at org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI(PDFRenderer.java:179)
       at homedms.HomeDMS.createThumbs(HomeDMS.java:23)
       at homedms.HomeDMS.main(HomeDMS.java:36)
      

      Here is the source code to reproduce the issue:
       

      public static void createThumbs(String filename) throws InvalidPasswordException, IOException {
       File filein=new File(filename+".pdf");
       PDDocument doc = PDDocument.load(filein);
       PDFRenderer rend=new PDFRenderer(doc);
       for(int i=0;i<doc.getNumberOfPages();i++) {
        System.out.println(i);
        BufferedImage img=rend.renderImageWithDPI(i,32,ImageType.GRAY);
        File fileout=new File(filename+"_"+i+".png");
        ImageIO.write(img, "PNG", fileout);
       }
       doc.close();
      }

        Attachments

        1. BrokenPage.pdf
          37 kB
          Volker S.

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                VolkoV Volker S.
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: