You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by Pontus Hulin <po...@laidbacksolutions.se> on 2011/09/13 14:21:36 UTC
Problem with getImages, some images are missing
Hello
Im having som problems with the getImages function in the PDResources
resources. I works with some pdf document, but not others. Im attaching
a document where only one image gets listed, but the document contains
two images.
It's a 1.4 pdf file. Basically Im using the standare extracImages code.
Im not sure vere to upload the file to.
It to large to include in the mail.
Best regards
/ Pontus
Here is my code:
ListIterator pages =
pdfDoc.getDocumentCatalog().getAllPages().listIterator();
int i = 0;
while( pages.hasNext() )
{
PDPage page = (PDPage)pages.next();
PDResources resources = page.getResources();
Map images = null;
Map x_images = null;
try {
images = resources.getImages();
x_images = resources.getXObjects();
} catch(java.io.IOException ioEx) {
answer = "<filelist><error>Error No: 1102,
createPreviews resources.getImages() IOException</error></filelist>";
} catch(java.lang.NullPointerException npex) {
answer = "<filelist><error>Error No: 1103,
createPreviews resources.getImages()
NullPointerException</error></filelist>";
return answer;
}
int nofImages = images.size();
int nofKeys = images.keySet().size();
int imageIndex = 0;
imageIndex = 0;
if( images != null ) {
Iterator imageIter = images.keySet().iterator();
while( imageIter.hasNext())
{
String key = (String)imageIter.next();
imageIndex = imageIndex + 1;
PDXObjectImage image = (PDXObjectImage)images.get(
key );
}
}
}
RE: Problem with getImages, some images are missing
Posted by "Martinez, Mel - 1004 - MITLL" <m....@ll.mit.edu>.
Pontus,
Go to the PDFBox issue tracking project here:
https://issues.apache.org/jira/browse/PDFBOX
Register yourself an account (free) and create an 'issue'.
You can then describe the problem and also upload example files.
Cheers,
Mel
-----Original Message-----
From: Pontus Hulin [mailto:pontus.hulin@laidbacksolutions.se]
Sent: Tuesday, September 13, 2011 8:22 AM
To: dev@pdfbox.apache.org
Subject: Problem with getImages, some images are missing
Hello
Im having som problems with the getImages function in the PDResources
resources. I works with some pdf document, but not others. Im attaching
a document where only one image gets listed, but the document contains
two images.
It's a 1.4 pdf file. Basically Im using the standare extracImages code.
Im not sure vere to upload the file to.
It to large to include in the mail.
Best regards
/ Pontus
Here is my code:
ListIterator pages =
pdfDoc.getDocumentCatalog().getAllPages().listIterator();
int i = 0;
while( pages.hasNext() )
{
PDPage page = (PDPage)pages.next();
PDResources resources = page.getResources();
Map images = null;
Map x_images = null;
try {
images = resources.getImages();
x_images = resources.getXObjects();
} catch(java.io.IOException ioEx) {
answer = "<filelist><error>Error No: 1102,
createPreviews resources.getImages() IOException</error></filelist>";
} catch(java.lang.NullPointerException npex) {
answer = "<filelist><error>Error No: 1103,
createPreviews resources.getImages()
NullPointerException</error></filelist>";
return answer;
}
int nofImages = images.size();
int nofKeys = images.keySet().size();
int imageIndex = 0;
imageIndex = 0;
if( images != null ) {
Iterator imageIter = images.keySet().iterator();
while( imageIter.hasNext())
{
String key = (String)imageIter.next();
imageIndex = imageIndex + 1;
PDXObjectImage image = (PDXObjectImage)images.get(
key );
}
}
}