.netformattingpdfsharp

Calculate text height based on available width and font?


We are creating PDF documents on the fly from the database using PDFsharp.

I need to know the best way to calculate the height of the text area based on the font used and the available width.

I need to know the height so I can process page breaks when required.


Solution

  • In .NET you can call Graphics.MeasureString to find out how large the drawn text is going to be.

    Right, but when using PDFsharp you call XGraphics.MeasureString.