title: How to increase the resolution of image in PDF renderer?
body: <p>I want to increase the resolution of a image. I used <a href="https://app.box.com/s/oacvuybl3qd20gsi6gfv" rel="nofollow noreferrer">PDFRenderer-0.9.0</a> jar . It is downloaded from <a href="https://java.net/projects/pdf-renderer/downloads" rel="nofollow noreferrer">java.net 
  </a> for converting PDF pages to images. </p>
  
  <p>I want to Convert <a href="https://app.box.com/s/igwcd0zey6aob1uevqhx" rel="nofollow noreferrer">46_2.pdf</a> PDF file to image . The converted <a href="https://app.box.com/s/vmg6eimlko3jcud53ujx" rel="nofollow noreferrer">46_2.png</a> image is small with dimensions <code>612 x 792 [ width x height ]</code>, </p>
  
  <p>So I want to increase the image dimensions to <code>1200 x 1400 [ width x height]</code>.</p>
  
  <p>I tried previously <strong>PdfBox</strong> for converting PDF page into PNG image file. There is a problem <code>only page is converted but text is missing</code>. So I tried <strong>PdfRenderer</strong> library for image conversion.</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>package com.pdfrenderer.examples;
  
  import java.awt.Graphics2D;
  import java.awt.Image;
  import java.awt.Rectangle;
  import java.awt.image.BufferedImage;
  import java.io.File;
  import java.io.RandomAccessFile;
  import java.nio.ByteBuffer;
  import java.nio.channels.FileChannel;
  
  import javax.imageio.ImageIO;
  
  import com.sun.pdfview.PDFFile;
  import com.sun.pdfview.PDFPage;
  
  public class ConvertPdfPagesToImage {
      public static void main(String[] args) {
          try {
              String sourceDir = "C:/PDFCopy/46_2.pdf";
              String destinationDir = "C:/PDFCopy/";
              File sourceFile = new File(sourceDir);
              String fileName = sourceFile.getName().replace(".pdf", "");
              if (sourceFile.exists()) {
                  RandomAccessFile raf = new RandomAccessFile(sourceFile, "r");
                  FileChannel channel = raf.getChannel();
                  ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
                  PDFFile pdf = new PDFFile(buf);
                  int pageNumber = 1;
                  for (int i = 0; i &lt; pdf.getNumPages(); i++) {
                      PDFPage page = pdf.getPage(i);
                      // create the image
                      Rectangle rect = new Rectangle(0, 0, (int) page.getBBox().getWidth(), (int) page.getBBox().getHeight());
                      BufferedImage bufferedImage = new BufferedImage(rect.width, rect.height, BufferedImage.TYPE_INT_RGB);
                      // image width, // image height, // clip rect, // null for the ImageObserver, // fill background with white, // block until drawing is done
                      Image image = page.getImage(rect.width, rect.height, rect, null, true, true );
                      Graphics2D bufImageGraphics = bufferedImage.createGraphics();
                      bufImageGraphics.drawImage(image, 0, 0, null);
                      ImageIO.write(bufferedImage, "png", new File( destinationDir + fileName +"_"+ pageNumber +".png"));
                      pageNumber++;
                  }
              } else {
                  System.err.println(sourceFile.getName() +" File not exists");
              }
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>