title: setting ttf for PDF to Image on PDFbox
body: <p>i'm trying to set an external ttf , to be able to render an image out of a pdf containing arabic caracters , the font i need to set is "Arial" , having done that the console keeps on informing that it's using the defaultFont instead of arial.</p>
  
  <pre><code> org.apache.pdfbox.pdmodel.font.PDSimpleFont drawString
  ATTENTION: Changing font on &lt;3&gt; from &lt;Arial&gt; to the default font
  </code></pre>
  
  <p>here's my code :</p>
  
  <pre><code>import java.awt.image.BufferedImage;
  import java.io.File;
  import java.io.IOException;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  
  import javax.imageio.ImageIO;
  
  import org.apache.pdfbox.pdmodel.PDDocument;
  import org.apache.pdfbox.pdmodel.PDPage;
  import org.apache.pdfbox.pdmodel.PDResources;
  import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;
  import org.apache.pdfbox.pdmodel.font.PDFont;
  import org.apache.pdfbox.pdmodel.font.PDTrueTypeFont;
  import org.apache.pdfbox.pdmodel.font.PDType1Font;
  import org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage;
  
      public class PdfBoxTest
       {
          public static void main(String[] args)
          {
              PdfBoxTest obj = new PdfBoxTest();
                  try 
                  {
                      obj.read_pdf();
                  }
  
                  catch (IOException ex)
                  {
                      System.out.println("" + ex);
                  }
  
          }
  
          void read_pdf() throws IOException 
          {
                  PDDocument document = null; 
                  try 
                  {
                      document = PDDocument.load("c:/result.pdf");
                  }
                  catch (IOException ex)
                  {
                      System.out.println("" + ex);
                  }
  
  
                  int i =1;
                  String name = null;
                  PDFont font = PDTrueTypeFont.loadTTF(document, new File( "c:/arial.ttf" ));
                  font.setWidths(PDType1Font.HELVETICA.getWidths());
                  List&lt;PDPage&gt;pages =  document.getDocumentCatalog().getAllPages();
                  Iterator&lt;PDPage&gt; iter =  pages.iterator(); 
                  while (iter.hasNext()) 
                  {
                      PDPage page = (PDPage) iter.next();
  
  
                      BufferedImage img = page.convertToImage();
                      ImageIO.write(img, "png", new
                               File("C:/" + i + ".png"));
  
  
                  }
  
              }
  
       } 
  </code></pre>