My program draws a multi-line text into a box in a PrintDocument using the PrintPage event. The width is set but the height should grow depending on the size of the text.
int BoxHeight = (int)e.Graphics.MeasureString(StringToDraw, FontToUse, BoxWidth).Height;
This returns mostly double the height that im looking for most of the time, but not always. The e object is the System.Drawing.Printing.PrintPageEventArgs handed to the PrintDocument.PrintPage-event. I want the box to fit the text tightly, wasting no dead trees for printing white empty spaces.
I’ve searched for solutions but maybe theres something I didn’t understand because I couldn’t make them work for me.
Found the problem. I had set the BoxWidth as half of what it was supposed to be. Works great now.