Skip to content

Instantly share code, notes, and snippets.

View erichillah's full-sized avatar

Eric Hillah erichillah

View GitHub Profile
@erichillah
erichillah / PdfSharpExtension.cs
Last active August 31, 2023 13:35
Extension method to calculate the exact needed Height in which to draw a string using PdfSharp
/// <summary>
/// Enhanced measure string function for PdfSharp Xgraphics
/// wich take to account lineBreaks to calculate the real string
/// height in a rectagle
/// </summary>
/// <param name="gfx"></param>
/// <param name="text">Text to measure</param>
/// <param name="maxWitdh">Maximum allowed width</param>
/// <returns></returns>
public static XSize MeasureStringExact(this XGraphics gfx, string content, XFont font, double maxWidth)