title: Adding fonts to Apache Pdfbox?
body: <p>Is there a way to add additional font styles into Apache Pdfbox?</p>
  
  <p>We're currently trying to work around printing PDFs in our system (currently being done with <a href="https://java.net/projects/pdf-renderer" rel="noreferrer">PDF-Renderer</a>.) I have been looking at various alternatives (<a href="http://pdfbox.apache.org/" rel="noreferrer">pdfbox</a>, <a href="http://www.jpedal.org/" rel="noreferrer">jpedal</a>, <a href="http://www.qoppa.com/pdfprint/" rel="noreferrer">jPDFPrint</a>)</p>
  
  <p>Our hope is for a free GPL compatible library to use, and as such we're leaning towards pdfbox. I have been able to write some sample code to print out the pdf which 'works'. See below:</p>
  
  <pre><code>PDDocument doc;
  try {
          doc = PDDocument.load("test.pdf");
          doc.print();
      } catch (Exception e) {
          // Come up with better thing to do on fail.
          e.printStackTrace();
      }
  </code></pre>
  
  <p>As I mentioned, this works but the problem I'm running into is that PdfBox doesn't seem to be recognizing the fonts used in the pdf, and as such changes the font being used. As a result the document looks very odd (spacing and character size are different and look bizarre).  I routinely see the following log message, or things like it:</p>
  
  <p><strong>Apr 16, 2014 2:56:21 PM org.apache.pdfbox.pdmodel.font.PDSimpleFont drawString
  WARNING: Changing font on &lt; > from &lt; NimbusMono > to the default font</strong></p>
  
  <p>Does anyone know of a way (or a reference) on how to approach adding a new fonttype into pdfbox? Or barring that, how to change the default font type? </p>
  
  <p>From what I can tell, pdfbox supports <a href="http://pdfbox.apache.org/cookbook/workingwithfonts.html" rel="noreferrer">14 standard fonts</a>. Unfortunately NimbusMono is not one of them. Any guidance would be appreciated.</p>