Hello,

I have browsed the archives and am still stumped. I am trying to verify that
the DPI of images in a PDF are within a certain range. I have no control or
knowledge of how the PDF was created. I found and ran the following code
snippet:

                      PdfReader chartReader = new PdfReader(fileName);
                      int size = chartReader.getXrefSize();
                      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())) {
                                    byte[] image =
PdfReader.getStreamBytesRaw((PRStream) stream);
                                    String
filter=stream.get(PdfName.FILTER).toString();
                                    int width =
Integer.parseInt((stream.get(PdfName.WIDTH)).toString());
                                    int height =
Integer.parseInt((stream.get(PdfName.HEIGHT)).toString());
                                    int bpc =

 Integer.parseInt((stream.get(PdfName.BITSPERCOMPONENT)).toString());
                                    System.out.println("Height" + height);
                                    System.out.println("Width" + width);
                                    Image imageObject =
Image.getInstance(image);
                                    System.out.println("ResolutionX: " +
imageObject.getDpiX());
                                    System.out.println("ResolutionY: " +
imageObject.getDpiX());

                             }
                           }
                     }

The height and width (in pixels) are reported accurately (verified via
checking the images in the pdf in Acrobat Professional). However, the dpiX
and dpiY are always 0 (they shouldn't be as per Acrobat Professional. ). Any
ideas as to why this is the case? Thank you.
------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
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