title: MVCRazorToPdf (iTextSharp) using custom font
body: <p>I am trying to add a custom font to my pdf output using the nuget package MVCRazorToPdf but I am having trouble with how to do this as the documentation for iTextSharp isn't great and all seems to be outdated.</p>
  
  <p>The current code I have for creating the pdf is:</p>
  
  <pre><code>return new PdfActionResult(
      "test.cshtml", 
      new TestModel(),
      (writer, document) =&gt;
      {
          FontFactory.Register(HostingEnvironment.MapPath("~/content/fonts/vegur-regular-webfont.ttf"), "VegurRegular");
      });
  </code></pre>
  
  <p>Where <code>writer</code> is a <code>PdfWriter</code> and <code>document</code> is a <code>Document</code></p>
  
  <p>All the examples of using the <code>FontFactory</code> show that you need to use the <code>XmlWorker</code> but I don't have access to that, so I was wondering if there was any way to change the documents font using the <code>writer</code> or <code>document</code>?</p>
  
  <p>I've seen that there is the <code>document.HtmlStyleClass</code> property but can't find anything about how to use this anywhere.</p>
  
  <p>Any help with this would be greatly appreciated</p>