Search code examples
pdfsharpmigradoc

Multiple Wrapping on Single Space with MigraDoc


I have a table with a cell which contains a textframe which contains a table. In some of the cells inside the inside table, I have added a paragraph. Inside the paragraph I have placed text, via the addtext method, like "WordA WordB". The cell's size will cause a line break between "WordA" and "WordB".

The problem is that I am expecting:

WordA
WordB

What I am getting is:

WordA

WordB

Is there a setting somewhere to get what I expect or is this a bug in the renderer?


Solution

  • It was a bug in the paragraph rederer (ParagraphRenderer.cs). There were actually 2 bugs I found. The first is if the current line doesn't fit and the next "Text" is a blank (" "). The second is if the current line is a blank (" ") and the next line doesn't fit.

    The first bug was easy to fix, I changed the HandleNonFittingLine subroutine to keep advancing until it this.currentLeaf is not a blank (" ").

    The second bug was harder to figure out and fix. I had to get the Format function to find the next leaf and pass the Current property, of the Next Leaf, to the FormatElement (if the next leaf exists). I then had to modify the FormatElement function to optionally take a second parameter. Then I modified the FormatElement function by returning FormatResult.Ignore if the current leaf is a blank (" ") and the next leaf doesn't fit on the current line with the blank (" ").