title: PDFSharp: Measuring height of long text with word wrap
body: <p>PDFSharp supports automatic text wrapping when drawing long text portions:</p>
  
  <pre><code>textFormatter.DrawString(text, font, XBrushes.Black, new XRect(x, y, textAreaWidth, 1000), XStringFormats.TopLeft);
  </code></pre>
  
  <p>This will wrap the text if it is longer than <code>textAreaWidth</code>.</p>
  
  <p>How can I get the height of the text that has just been drawn?</p>
  
  <p>I tried it with <code>gfx.MeasureString()</code>, but there is no overload that supports specifying a maximal width. <code>gfx.MeasureString()</code> returns the size of the text without text wrapping.</p>
  
  <p>Thanks for any hints.</p>