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.
The current code I have for creating the pdf is:
return new PdfActionResult(
"test.cshtml",
new TestModel(),
(writer, document) =>
{
FontFactory.Register(HostingEnvironment.MapPath("~/content/fonts/vegur-regular-webfont.ttf"), "VegurRegular");
});
Where writer
is a PdfWriter
and document
is a Document
All the examples of using the FontFactory
show that you need to use the XmlWorker
but I don't have access to that, so I was wondering if there was any way to change the documents font using the writer
or document
?
I've seen that there is the document.HtmlStyleClass
property but can't find anything about how to use this anywhere.
Any help with this would be greatly appreciated