Yes, there is a DrawString that has the ability to automatically wrap text. You can use the MeasureString method to check whether the specified string can be completely drawn on the page or not and how much space is required.
There is also a TextRenderer Class specifically for this purpose.
Here is an example:
Graphics gf = e.Graphics; SizeF sf = gf.MeasureString("shdadj asdhkj shad adas dash asdl asasdassa", new Font(new FontFamily("Arial"), 10F), 60); gf.DrawString("shdadj asdhkj shad adas dash asdl asasdassa", new Font(new FontFamily("Arial"), 10F), Brushes.Black, new RectangleF(new PointF(4.0F,4.0F),sf), StringFormat.GenericTypographic);
Here I have specified a maximum of 60 pixels as a width, and then measures the line, which will give me the size that will be needed to draw this line. Now, if you already have the size, you can compare with the returned size to see if it will be drawn correctly or truncated
Shekhar_Pro
source share