title: PDFBox: Convert PDF to Image is slower than expected
body: <p>I am currently using this code to convert a pdf to an image:</p>
  
  <pre><code>@SuppressWarnings("unchecked")
  public static Image convertPDFtoImage(ByteArrayInputStream bais) {
  
      Image convertedImage = null;
  
      try {
  
          PDDocument document = PDDocument.load(bais);
          List&lt;PDPage&gt; list = document.getDocumentCatalog().getAllPages();
          PDPage page = list.get(0);
  
          BufferedImage image = page.convertToImage(BufferedImage.TYPE_INT_RGB, 64);
          convertedImage = SwingFXUtils.toFXImage(image, null);
  
          document.close();
  
      } 
      catch (Exception e) {
          e.printStackTrace();
      }
  
      return convertedImage;
  }
  </code></pre>
  
  <p>Then, I show the convertedImage in an JavaFX ImageView.</p>
  
  <p>Further, I need to import these two packages, while I am not using them:</p>
  
  <pre><code>import org.apache.commons.logging.LogFactory;
  import org.apache.fontbox.afm.AFMParser;
  </code></pre>
  
  <p>Two questions:</p>
  
  <ul>
  <li><strong>Does it normally take two to three seconds to convert a simple one page PDF to Image where the DPI is set on 64 (which is not that high in my opinion)?</strong> It seems to be a bit slow.</li>
  <li><strong>Why do I need those two imports while I am not using them?</strong> If I don't import them, I get a lot of errors and the conversion does not work.</li>
  </ul>
  
  <p>I would like to show a PDF quickly in JavaFX, and two to three seconds is just too long. Any other ways of showing a PDF in JavaFX (other than convert it to an image) are very welcome.</p>
  
  <p>Any help is greatly appreciated!</p>