Hello,

I am using the following code to extract image from a pdf file

PdfReader reader = new PdfReader(
                                ((File)
getValue("srcfile")).getAbsolutePath());
                        for (int i = 0; i < reader.getXrefSize(); i++) {
                            PdfObject pdfobj = reader.getPdfObject(i);
                            if (pdfobj != null) {
                                if (pdfobj.isStream()) {
                                    PdfStream pdfdict = (PdfStream) pdfobj;
                                    PdfObject pdfsubtype = pdfdict
                                            .get(PdfName.SUBTYPE);
                                    if (pdfsubtype == null) {
                                        continue;
                                    }
                                    if (!pdfsubtype.toString().equals(
                                            PdfName.IMAGE.toString())) {
                                        continue;
                                    }

System.out.println("total_number_of_pictures:
"
                                            + total_number_of_pictures);
                                    System.out.println("height:"
                                            + pdfdict.get(PdfName.HEIGHT));
                                    System.out.println("width:"
                                            + pdfdict.get(PdfName.WIDTH));
                                    System.out.println("bitspercomponent:"
                                            + pdfdict.get(
PdfName.BITSPERCOMPONENT));
                                    byte[] barr = PdfReader
                                            .getStreamBytesRaw((PRStream)
pdfdict);
                                    java.awt.Image im = Toolkit

.getDefaultToolkit().createImage(barr);

=========================================================
However, it will get ALL image of the pdf file. How could I get the page no
of each image?

Any help would be appreciated

Thanks
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to