Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep table in one piece MigraDoc / PDFsharp

I am using PDFsharp / MigraDoc to write tables and charts to PDF files. This worked great so far, however MigraDoc will always split my tables (vertically) when it should move the whole table to the next page in the document. How do I make sure the table will stay in one piece?

Table class of MigraDoc.DocumentObjectModel.Tables has a bool KeepTogether property however it seems to have no effect (either set to true or false).

Is there a way to do it manually? Is there any way to "measure" the distance from the end of the page and compare it to tables height? (Or any other way of knowing wether the table will be split or not)

Please note that I am using PDFsharp / MigraDoc for the first time. If there are any best practices I ought to know, please let me know. If there are some good examples out there (I saw those on PDFSharp's home page, but that's about it) I'd love to know about them!

like image 846
David Božjak Avatar asked Jul 09 '09 14:07

David Božjak


1 Answers

You can set the KeepWith property of a Table Row to specify blocks that must be kept together.

If you know the table fits on one page, you can set the KeepWith property of the first row to (table.Rows.Count - 1) when the table is finished.

like image 98
I liked the old Stack Overflow Avatar answered Oct 31 '22 14:10

I liked the old Stack Overflow