2015-02-10 3 views
3

Я использую шрифт Google «Open Sans, sans-serif» в CSS для моей веб-страницы. Я использую evo pdf для создания PDF. В этом динамическом создании верхнего и нижнего колонтитула с помощью TextElement.FontFamily issue in C#

Моя проблема в C# fontfamily нет такого шрифта Google. Как я могу получить «Open Sans, sans-serif» в C# fontfamily?

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); 

ответ

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 guide to using fonts

+0

Джеймс специально хотел шрифт Google, а не стандартный Times New Roman. –

+0

да, мне нужен шрифт google в C# – James

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); 

Вы также можете увидеть всю демонстрацию с more code samples for text and fonts handling. Вы должны выбрать вкладку «Пример кода» на этой странице.