There is no particular method to get the height and width of the text at the time of PDF generation. You can however measure the width of a string by using the MeasureString() method. Can you please share the detail of complete scenario that why you need to get the height of the HtmlFragment? Please share the complete code snippet along with complete requirements detail so that we can better understand the situation and provide the feedback accordingly.
Once a PDF file is generated, the added text or HTML string would not be recognized as HTML String. You can extract it as a plain text using TextFragmentAbsorber and obtain its position or coordinates like below:
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "inbput.pdf");
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("searchString");
doc.Pages.Accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
// Loop through the fragments
foreach (TextFragment textFragment in textFragmentCollection)
{
var rect = textFragment.Rectangle;
}