How do I get a visible width for a character in PDF?

Q: I found that font.GetWidth() always return the advance width but
not the visible width in PDFTron’s help document. Then how to get the
visible width?


A: The visible width is not explicitly available in PDF. In this case
the page may be using individual glyph placement. You can obtain the
position of each glyph on a page from a CharIterator (for an example
please see ElementReaderAdv sample project). By finding differences
between successive characters you could calculate the apparent
‘visible’ width. The x/y corrdinates in the CharIterator are
represented in ‘text space’ so you need to multiply them with the text
matrix (element.GetTextMatrix()) and the CTM (element.GetCTM()).