title: Convert a PDF file to image
body: <p>I wanted to convert PDF document into image. I was using Ghost4j.</p>
  
  <p><strong>Problem:</strong>  Ghost4J needs gsdll32.dll file at runtime, and I do <strong>not</strong> want to use the dll file.</p>
  
  <p><strong>Question 1:</strong> is there any way, in ghost4j to convert image without the dll?</p>
  
  <p><strong>Question 2:</strong> I found the solution in PDFBox API. <code>org.apache.pdfbox.pdmodel.PDPagep 
  have method</code>convertToImage()` which converts PDF page to Image format.</p>
  
  <pre><code>PDDocument doc = PDDocument.load(new File("/document.pdf"));
  List&lt;PDPage&gt;pages =  doc.getDocumentCatalog().getAllPages();
  PDPage page = pages.get(0);
  BufferedImage image =page.convertToImage();
  File outputfile = new File("/image.png");
  ImageIO.write(image, "png", outputfile);
  doc.close();
  </code></pre>
  
  <p>I have only text on the PDF document. and I have that Exception when I run this code:</p>
  
  <pre><code>Aug 12, 2013 6:00:24 PM org.apache.pdfbox.util.PDFStreamEngine processOperator
  INFO: unsupported/disabled operation: BDC
  Exception in thread "main" java.lang.ExceptionInInitializerError
      at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.getawtFont(PDTrueTypeFont.java:481)
      at org.apache.pdfbox.pdmodel.font.PDSimpleFont.drawString(PDSimpleFont.java:109)
      at org.apache.pdfbox.pdfviewer.PageDrawer.processTextPosition(PageDrawer.java:235)
      at org.apache.pdfbox.util.PDFStreamEngine.processEncodedText(PDFStreamEngine.java:496)
      at org.apache.pdfbox.util.operator.ShowTextGlyph.process(ShowTextGlyph.java:62)
      at org.apache.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngine.java:554)
      at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:268)
      at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:235)
      at org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:215)
      at org.apache.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:125)
      at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:781)
      at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:712)
      at ge.eid.esignature.adessa.pades.sign.PDFtoImage.main(PDFtoImage.java:25)
  Caused by: java.lang.IllegalArgumentException
      at java.nio.Buffer.position(Buffer.java:216)
      at sun.font.TrueTypeFont.lookupName(TrueTypeFont.java:1153)
      at sun.font.TrueTypeFont.getPostscriptName(TrueTypeFont.java:1205)
      at java.awt.Font.getPSName(Font.java:1156)
      at org.apache.pdfbox.pdmodel.font.FontManager.loadFonts(FontManager.java:101)
      at org.apache.pdfbox.pdmodel.font.FontManager.&lt;clinit&gt;(FontManager.java:53)
      ... 13 more
  </code></pre>