title: Retrieve the page number of an image in pdf- IText
body: <p>I am using the code from the below link to render the images</p>
  
  <p><a href="http://itextpdf.com/examples/iia.php?id=283" rel="nofollow">MyImageRenderListener - IText</a></p>
  
  <p>Below is my <strong>try</strong>  block of the Code. What I am actually doing is finding the <strong>DPI</strong> of the image and if the dpi of the image is below 300 then writing it in a text file.</p>
  
  <p><strong>NOW</strong>, I also want to write the page numbers where these images are located in the PDF. How can I obtain the Page Number of that image?</p>
  
  <pre><code>    try {
              String filename;
              FileOutputStream os;
              PdfImageObject image = renderInfo.getImage();
              BufferedImage img = null;
              String txtfile = "results/results.txt";
              PdfDictionary imageDict = renderInfo.getImage().getDictionary();
              float widthPx = imageDict.getAsNumber(PdfName.WIDTH).floatValue(); 
              float heightPx = imageDict.getAsNumber(PdfName.HEIGHT).floatValue();
              float widthUu = renderInfo.getImageCTM().get(Matrix.I11);
              float heigthUu = renderInfo.getImageCTM().get(Matrix.I22);
              float widthIn = widthUu/72;
              float heightIn = heigthUu/72;
              float imagepdi = widthPx/widthIn;
              filename = String.format(path, renderInfo.getRef().getNumber(), image.getFileType());
              System.out.println(filename+"--&gt;"+imagepdi);
              if(imagepdi &lt; 300){
                  File file = new File("C:/Users/Abhinav/workspace/itext/results/result.txt");
  
  
  
                  if(filename != null){
                      if (!file.exists()) {
                          file.createNewFile();
                      }
  
                      FileWriter fw = new FileWriter(file.getAbsoluteFile(),true);
                      file.setReadable(true, false);
                      file.setExecutable(true, false);
                      file.setWritable(true, false);
                      BufferedWriter bw = new BufferedWriter(fw);
                      bw.write(filename);
                      bw.write("\r\n");
                      bw.close();
                  }
              }
  </code></pre>