将表格合二为一MigraDoc/PDFsharp [英] Keep table in one piece MigraDoc / PDFsharp

查看:278
本文介绍了将表格合二为一MigraDoc/PDFsharp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PDFsharp/MigraDoc将表和图表写入PDF文件.到目前为止,这种方法效果很好,但是当MigraDoc将整个表移到文档的下一页时,它将始终(垂直)拆分我的表.我如何确保桌子能合而为一?

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?

MigraDoc.DocumentObjectModel.Tables的表类具有bool KeepTogether属性,但是似乎没有效果(设置为true或false).

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)

请注意,我是第一次使用PDFsharp/MigraDoc.如果有任何我应该知道的最佳做法,请告诉我.如果有一些很好的例子(我在PDFSharp的主页上看到了,但是仅此而已),我很想知道它们!

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!

推荐答案

您可以设置表RowKeepWith属性,以指定必须保留在一起的块.

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

如果您知道表格适合放在一页上,则可以在表格完成后将第一行的KeepWith属性设置为(table.Rows.Count - 1).

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.

这篇关于将表格合二为一MigraDoc/PDFsharp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆