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

"premature EOF, image will be incomplete"

    XMLWordPrintableJSON

Details

    Description

      I am trying to extract all the embeded images from Pdf file. But some times the images extracted are throwing warnings below.

      [main] WARN  o.a.p.p.g.image.SampledImageReader - premature EOF, image will be incomplete
      

      The extracted images are half-complete(half- greyed out)

      I would like to know if any solution available for this. Below is my code snippet

      Any Help is greatly appreciated.

      	public static void testPDFBoxExtractImages() throws Exception {
      	    PDDocument document = PDDocument.load(new File(fileName));
      	    PDPageTree list = document.getPages();
      	    for (PDPage page : list) {
      	        PDResources pdResources = page.getResources();
      	        System.out.println(page.getRotation());
      	        for (COSName c : pdResources.getXObjectNames()) {
      	            PDXObject o = pdResources.getXObject(c);
      	            if (o instanceof org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject) {
      	                File file = new File("C:/temp/" + System.nanoTime() + ".png");
      	                ImageIO.write(((org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject)o).getImage(), "png", file);
      	            }
      	        }
      	    }
      	}
      

      Attachments

        1. screenshot-1.png
          8 kB
          Tilman Hausherr

        Issue Links

          Activity

            People

              tilman Tilman Hausherr
              raviopen Ravi
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: