Created
9/30/2011
Tags
Generate PDF Manipulate PDF

When the content of a cell is very long and it has no spaces then it cannot be broken/hyphenated by the default hyphenation algorithm. Consequently, the cell will expand to fit the content and potentially expand beyond the page boundary and break the table layout settings. This article shows how to use the LineBreak event to customize hyphenation.

Here is how this looks:

You can overcome this by using the LineBreak event of the TextParagraph:

The LineBreak event fires whenever the layout engine has reached the preferred width of the cell. The following LineBreak event handler simply inserts a hyphen two characters to the left of the current position:

static void textParagraph_LineBreak(Fragment sender, LineBreakEventArgs args) { args.BreakAt = args.BreakBefore - 2; args.InsertHyphen = true; }

]]>

Here is the result: