Hello,
Hi Boris,
Thanks for your inquiry. Please use new DOM for creating PDF document. Both methods OpenFont() and FindFont() recognize same font name, and more. If you want to pass font name then need to remove spaces between font name. Please check sample code for your reference. Hopefully it will help you to accomplish the task.
//open document
Document pdfDocument = new Document();
Aspose.Pdf.Page section = pdfDocument.Pages.Add();
TextFragment t = new TextFragment("Sample
Text in Humnst777 BT font");
// to find font in system font folder
Aspose.Pdf.Text.Font font1 = FontRepository.OpenFont(@"C:\Users\Home\Downloads\fonts\HUM777N.ttf");
Console.WriteLine(font1.FontName);
Aspose.Pdf.Text.Font font = FontRepository.FindFont("Humanist777BT");
Console.WriteLine(font.FontName);
t.TextState.Font = font;
// to open a font with complete path
TextFragment t1 = new TextFragment("Sample
Text in OCR B 10 BT font");
// to find font in system font folder
t1.TextState.Font = FontRepository.FindFont("OCR-B10PitchBT");
section.Paragraphs.Add(t);
section.Paragraphs.Add(t1);
pdfDocument.Save(myDir + "Custom_Fonts_out.pdf");
Please feel free to contact us for any further assistance.
Best Regards,
Hello,
Hi Boris,