3

我在 CSS 中为我​​的网页使用 Google 字体“Open Sans,sans-serif”。​​我正在使用 evo pdf 生成 PDF。在此使用 TextElement 动态创建页眉和页脚。

我的问题是在 c# fontfamily 中没有这样的 Google 字体。如何在 c# fontfamily 中获得“Open Sans,sans-serif”?

TextElement footerText = new TextElement(0, 15, "Page &p; of &P;  ",
                new System.Drawing.Font(this.OpenSans,12, FontStyle.Regular, GraphicsUnit.Pixel));
footerText.TextAlign = HorizontalTextAlign.Right;
footerText.ForeColor = Color.Black;
footerText.EmbedSysFont = true;
htmlToPdfConverter.PdfFooterOptions.AddElement(footerText);
4

2 回答 2

0
TextElement footerText = new TextElement(0, pdfConverter.PdfFooterOptions.FooterHeight - 15, 
            "This is page &p; of &P;  ",
            new System.Drawing.Font(new System.Drawing.FontFamily("Times New Roman"), 

这不是您要找的吗:evo 字体使用指南

于 2015-02-11T10:58:47.847 回答
0

您实际上可以使用本地系统上未安装的字体。您只需要 .ttf 或 .otf 文件并从文件中加载字体,如下所示:

// Embed a True Type font from a local file in PDF document
PdfFont localTrueTypeFont = pdfDocument.AddFont(@"DemoAppFiles\Input\Fonts\TrueType.ttf");

// Add a text element using the local True Type font to PDF document
TextElement localFontTtfTextElement = new TextElement(xLocation, yLocation, "This text uses a True Type Font loaded from a local file", localTrueTypeFont);
addTextResult = pdfPage.AddElement(localFontTtfTextElement);

您还可以查看整个演示,其中包含更多用于文本和字体处理的代码示例。您必须在该页面中选择“示例代码”选项卡。

于 2015-07-11T13:39:53.853 回答