3

Web ページの 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 に答える