我正在尝试使用 nuget 包 MVCrazorToPdf 将自定义字体添加到我的 pdf 输出中,但我无法做到这一点,因为 iTextSharp 的文档不是很好,而且似乎都已经过时了。
我用于创建 pdf 的当前代码是:
return new PdfActionResult(
"test.cshtml",
new TestModel(),
(writer, document) =>
{
FontFactory.Register(HostingEnvironment.MapPath("~/content/fonts/vegur-regular-webfont.ttf"), "VegurRegular");
});
哪里writer
是一个PdfWriter
和document
是一个Document
所有使用显示的示例FontFactory
都需要使用,XmlWorker
但我无权访问,所以我想知道是否有任何方法可以使用writer
or更改文档字体document
?
我已经看到有该document.HtmlStyleClass
属性,但找不到任何关于如何在任何地方使用它的信息。
对此的任何帮助将不胜感激