Crop the word Drawstring or display all text

This is the result that I get when I use DrawString.

I = Smith, John II = Johnson, Mark III = Anderson, James IV = William, Craig V = Ford, he ...

page - floating point data type whose value is based on e.PageSettings.Margins.Left;

e.Graphics.DrawString (text, new System.Drawing.Font ("Arial", 8F, FontStyle.Regular), Brushes.Black, page, 30);

In the above example, this is

e.Graphics.DrawString(Text, new System.Drawing.Font("Arial", 8F, FontStyle.Regular), Brushes.Black, page, 30); 

I tried using this

 StringFormat format = new StringFormat(); format.FormatFlags = StringFormatFlags.FitBlackBox; e.Graphics.DrawString(Text, new System.Drawing.Font("Arial", 8F, FontStyle.Regular), Brushes.Black, page, 30, format); 

How do I expand / hyphenate so that in the end I can have whole words instead of "..."?

I = Smith, John II = Johnson, Mark III = Anderson, James IV = William, Craig V = Ford, Henry

+8
source share
1 answer

You can โ€œwrap textโ€ with text using the bounding box.

Use the Graphics.DrawString Method (String, Font, Brush, RectangleF, StringFormat)

RectangleF indicates the drawing area, and it will automatically โ€œwrapโ€ your text for you.

+18
source share

All Articles