PdfSharpCore icon indicating copy to clipboard operation
PdfSharpCore copied to clipboard

`KeepWithNext` and `KeepTogether` doesn't seem to work if the next element is a table

Open colejohnson66 opened this issue 3 years ago • 1 comments

As the title says, using ParagraphFormat.KeepWithNext and KeepTogether doesn't work if the next element is a table.

We've found that TopDownFormatter.NextElementsDontFit, when checking if the table is kept with the paragraph, the condition below evaluates to true and returns. Skipping over the block and moving to the next line causes the paragraph header to be kept with the table.

https://github.com/ststeiger/PdfSharpCore/blob/8b9076c465123bc195c0d844dcec81eafae4fa3f/MigraDocCore.Rendering/MigraDoc.Rendering/TopDownFormatter.cs#L330-L331

colejohnson66 avatar Oct 27 '22 20:10 colejohnson66

It seems the area check should be before the keep together/next check. We want to see if the table overflows before seeing if the next item should be computed. Regardless, the table has a rendered size of negative one point, so the overflow calculation never happens.

image

The X and Y values are correct; That's where the table would be if it didn't overflow. 3/4 inch margin on the left, and about 10 inches down the page.

colejohnson66 avatar Oct 28 '22 15:10 colejohnson66