问题
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!
回答1:
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.
来源:https://stackoverflow.com/questions/1104227/keep-table-in-one-piece-migradoc-pdfsharp