Hi , I am able to extract images in JPEG(.jpg, .jpeg, .jpe) format only not 
other. 

public void extractImages(){
                
                try{
                        PdfReader chartReader = new PdfReader("myPdf.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.equals(PdfName.IMAGE)) 
{
                                byte[] image = 
PdfReader.getStreamBytesRaw((PRStream) stream);
                                System.out.println("Image bytes 
length:"+image.length);
                                // byte[] image = 
PdfReader.getStreamBytes((PRStream) stream);
                                FileOutputStream fw = new FileOutputStream(i + 
".jpg");
                                fw.write(image);
                                fw.flush();
                                fw.close();
                    }
                  }
                }
                }catch(Exception e){
                        e.printStackTrace();
                }               
        }



--
This message was sent on behalf of [email protected] at 
openSubscriber.com
http://www.opensubscriber.com/message/[email protected]/12728223.html

------------------------------------------------------------------------------
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
[email protected]
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/

Reply via email to