@Suhabavan
Can you please make sure that you are using 22.3 version of the API? We used below code snippet to test the scenario and could not reproduce the issue that you have mentioned. For your kind reference, an output PDF is also attached:
string fontFile = dataDir + "Allura-Regular.ttf";
// Load input PDF file
Document doc = new Document();
// Create text fragment with sample string
TextFragment textFragment = new TextFragment("Hello world");
if (fontFile != "")
{
// Load the TrueType font into stream object
using (FileStream fontStream = System.IO.File.OpenRead(fontFile))
{
// Set the font name for text string
textFragment.TextState.Font = FontRepository.OpenFont(fontStream, FontTypes.TTF);
// Specify the position for Text Fragment
textFragment.Position = new Position(100, 600);
var page = doc.Pages.Add();
page.Paragraphs.Add(textFragment);
}
dataDir = dataDir + "LoadingFontFromStream_out.pdf";
// Save resulting PDF document
doc.Save(dataDir);
}
LoadingFontFromStream_out.pdf (23.9 KB)