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

PNG image page completely garbled

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.1.0
    • Component/s: PDModel
    • Labels:
      None

      Description

      [imported from SourceForge]
      http://sourceforge.net/tracker/index.php?group_id=78314&atid=552832&aid=1392196
      Originally submitted by nobody on 2005-12-28 11:09.

      Hi:

      Attached is a zip file containing a 1 page PDF scanned
      PDF doc and the image extracted using pdfBox.

      As you can see, the PDF file shows the document fine,
      but the image (which it saved with suffix png.png) is
      completely garbled.

      I have tried the following ways, all with the same
      result:

      (a) PDPage.convertToImage() --> BufferedImage -->
      ImageIO.write(image,"png",...)

      Code:

      PDDocument document = PDDocument.load("test3.pdf");
      List pages = document.getDocumentCatalog().getAllPages
      ();
      PDPage page = (PDPage)pages.get(0);
      BufferedImage image = page.convertToImage();
      ImageIO.write(image, "png", new File("test31.png"));

      (b) PDPage --> PDResources --> getImages() --> obtain
      the PDXObjectImage() from iterator --> getRGBImage() -
      -> BufferedImage --> ImageIO.write().

      PDDocument document = PDDocument.load("test3.pdf");
      List pages = document.getDocumentCatalog().getAllPages
      ();
      PDPage page = (PDPage)pages.get(0);
      PDResources resources = page.getResources();
      Map images = resources.getImages();
      if( images != null )
      {
      Iterator imageIter = images.keySet().iterator();
      while( imageIter.hasNext() )

      { String key = (String)imageIter.next(); PDXObjectImage image = (PDXObjectImage) images.get( key ); image.write2file("test3."+image.getSuffix()); BufferedImage bufImg = image.getRGBImage(); ImageIO.write(bufImg, "png", new File ("test31.png")); }

      }

      Please let me know!

      CONTACT: vick_venkat at yahoo dot com.

      [attachment on SourceForge]
      http://sourceforge.net/tracker/download.php?group_id=78314&atid=552832&aid=1392196&file_id=161339
      testdocs.zip (application/x-zip-compressed), 74080 bytes
      Contains PDF file with extracted garbled PNG image

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Anonymous
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: