What makes you think that all images in a PDF are JPEGs? What makes you think
that all images in a PDF can be represented w/o modification as a standard
raster format? What makes you think that all images in a PDF are raster (vs.
vector)?
Basically, you have a limited frame of understanding about images in PDF - and
you need to read up on the subject (a lot!) to understand why your methodology
is flawed...
Leonard
From: rajasekhar.pal...@accenture.com [mailto:rajasekhar.pal...@accenture.com]
Sent: Tuesday, August 25, 2009 5:00 AM
To: itext-questions@lists.sourceforge.net
Subject: [iText-questions] Images extraction.
Hi Team,
I am trying to get the images from PDF file, I am using he below API to do it
but I am getting 'Invalid Image'
PdfReader chartReader = new PdfReader("C:\\Raj\\Test\\signtest.pdf");
for (int i = 0; i < chartReader.getXrefSize(); i++) {
PdfObject pdfobj = chartReader.getPdfObject(i);
if (pdfobj != null && pdfobj.isStream()) {
PdfStream stream = (PdfStream) pdfobj;
PdfObject pdfsubtype = stream.get(PdfName.SUBTYPE);
//System.out.println("Stream subType: " +
pdfsubtype);
if (pdfsubtype != null &&
pdfsubtype.toString().equals(PdfName.IMAGE.toString())) {
writeToFile(stream, i);
}
}
}
private static void writeToFile(PdfStream stream, int i) throws IOException {
byte[] image = PdfReader.getStreamBytesRaw((PRStream) stream);
System.out.println("Image bytes length:"+image.length);
//byte[] image = PdfReader.getStreamBytes((PRStream) stream);
FileOutputStream fw = new
FileOutputStream("C:\\Raj\\Test\\beastpics\\" + i + ".jpg");
fw.write(image);
fw.flush();
fw.close();
}
Can you please help to fix the problem? Please find the attached pdf file and
output images file.
Thanks for your support.
Rajasekhar
BestBuy Accenture IDC | Desk +91 80 418 63392 | Mobile +91 94482 26670 | AIM:
paletiraja
This message is for the designated recipient only and may contain privileged,
proprietary, or otherwise private information. If you have received it in
error, please notify the sender immediately and delete the original. Any other
use of the email by you is prohibited.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/