Reputation: 1249
I am trying to put a string that is retrieved from my database, so it's kind of hard to split the string.
XRect rect = new XRect(page8margin, page8margin + 60 + (3 * page8margin), 300, 300);
gfx8.DrawRectangle(XBrushes.LightGray, rect);
tf.DrawString(interview.Job.Summary, smallerFont, XBrushes.Black, rect, XStringFormats.TopLeft);
But it seems like the string is just ignoring the border and just written in one single line. How can I split the string and make it jump to a new line after a certain number of characters?
Upvotes: 0
Views: 654
Reputation: 21689
The class XTextFormatter
(which you are probably using, judging by the variable name tf
- thanks for showing that much code) breaks lines at blank characters.
Source code for XTextFormatter
is included, so you can adapt it to your needs.
The text showing on the screen shot has one very long word and the default implementation of XTextFormatter
does not break words, no matter how long they are.
It is a special requirement to break long words, but you can adapt the XTextFormatter
class for that purpose. Or use the XTextFormatter
class as inspiration to write your own code.
Maybe you just have to test with a "Lorem ipsum ..." paragraph to solve the issue.
Upvotes: 1