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() )
}
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