public static void OTFFont()
{
// ExStart:OTFFont
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdf_Text();
// Create new document instance
Document pdfDocument = new Document();
// Add page to pages collection of PDF file
Aspose.Pdf.Page page = pdfDocument.Pages.Add();
// Create TextFragment instnace with sample text
TextFragment fragment = new TextFragment("Sample Text in OTF font");
// Find font inside system font directory
// Fragment.TextState.Font = FontRepository.FindFont("HelveticaNeueLT Pro 45 Lt");
// Or you can even specify the path of OTF font in system directory
fragment.TextState.Font = FontRepository.OpenFont(dataDir + "space age.otf");
// Specify to emend font inside PDF file, so that its displayed properly,
// Even if specific font is not installed/present over target machine
fragment.TextState.Font.IsEmbedded = true;
// Add TextFragment to paragraphs collection of Page instance
page.Paragraphs.Add(fragment);
dataDir = dataDir + "OTFFont_out.pdf";
// Save resulting PDF document.
pdfDocument.Save(dataDir);
// ExEnd:OTFFont
Console.WriteLine("\nOTF font used successfully.\nFile saved at " + dataDir);
}