How do I get a height (size) of a text element?

Q:

I need the height of a text element. By calling:

GState gs = elemet.GetGState ();
int db = gs.GetFontSize ();

I don't get the correct height in all PDF documents. For some
documents I receive '1' as value for all elements. How do I get a
height of a text element?
----

A:

If you want to get the font size as it appears on the page you need to
scale GetFontSize() with text matrix (Element.GetTextMatrix()) , as
well as, current transformation matrix (CTM):

double scale_factor = Math.sqrt(mtx.m_b*mtx.m_b + mtx.m_d*mtx.m_d);
double page_font_sz = gs.GetFontSize() * scale_factor;

Please see: http://www.pdftron.com/net/faq.html#getfontsize_why1

You can also use element.GetBBox() to obtain a non-tight bounding box
for the entire text run (i.e. element). The resulting rectangle lies
in PDF user space (i.e. PDF page coordinate system).

In case you need to obtain the tight bounding box for each character
in the text run please see the following KB article:
  http://groups.google.com/group/pdfnet-sdk/browse_thread/thread/3413960fa977a75c/67c298997d44294d

  or search for 'minimum bounding box for each character' in
http://groups.google.com/group/pdfnet-sdk.