In an earlier post I described how to improve the XTextFormatter class for PDFsharp 1.32. The problem with that old version: the modified version of XTextFormatter has to be in an assembly with access to the internals of PDFsharp, so you have to compile PDFsharp in order to have an enhanced formatter.
With PDFsharp 1.50 beta things are simpler: all the XTextFormatter class needs is public now and you can use an enhanced version of XTextFormatter even if you are working with the NuGet package of PDFsharp.
My XTextFormatterEx2 has the measuring functionality from XTextFormatterEx. Additionally it allows to control the line spacing. Continue reading XTextFormatter revisited: XTextFormatterEx2 for PDFsharp 1.50 beta 2