Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawstring word wrap or display entire text

This is the output i get when i use DrawString.

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

page is a float datatype which 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, it 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/word wrap so that i can have the entire words instead of '...' at the end?

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

like image 649
Sharpeye500 Avatar asked Feb 29 '12 22:02

Sharpeye500


People also ask

How do you text wrap?

Select the image you want to wrap text around. The Format tab will appear on the right side of the Ribbon. On the Format tab, click the Wrap Text command in the Arrange group. Then select the desired text wrapping option.

How to break long text in HTML?

The <wbr> element If you know where you want a long string to break, then it is also possible to insert the HTML <wbr> element. This can be useful in cases such as displaying a long URL on a page. You can then add the property in order to break the string in sensible places that will make it easier to read.

How do I make text not wrap in CSS?

If you want to prevent the text from wrapping, you can apply white-space: nowrap; Notice in HTML code example at the top of this article, there are actually two line breaks, one before the line of text and one after, which allow the text to be on its own line (in the code).


1 Answers

You can "word wrap" the text by using a bounding rectangle.

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

The RectangleF specifies the draw area and it will automatically "wrap" your text for you.

like image 150
Sorean Avatar answered Oct 28 '22 08:10

Sorean