如何使表不打破使用iTextSharp
本文关键字:iTextSharp 何使表 | 更新日期: 2023-09-27 18:15:01
我有一个表
PdfPTable tblSummary = new PdfPTable(1);
它确实有两个表嵌套在其中。如何使tblSummary
作为一个整体出现(行不能中断到另一个页面)或整个表被转移到另一个页面,如果它不适合当前页面。
我试过SplitLate
和SplitRows
我的代码是这样的
PdfPTable tblSummary = new PdfPTable(1);
PdfPCell csummarycell = new PdfPCell();
PdfPTable tblSummaryFirst = new PdfPTable(3);
.
.
csummarycell.AddElement(tblSummaryFirst);
.
.
tblSummary.AddCell(csummarycell);
tblSummary.SplitLate = true;
tblSummary.SplitRows = false;
像这样,我在tblSummary中添加了一个(多个)表,而结果表的高度总是小于pagesize的高度,因此可以肯定表的内容不会超过页面高度。
任何建议都会很有帮助。
你试过了吗:
tblSummary.KeepTogether = true;
PdfPTable tabla = new PdfPTable(2);
float[] anchosTablaTituloDescripcion = new float[] { 4f, 4f };
tabla.SetWidths(anchosTablaTituloDescripcion);
tabla.WidthPercentage = 100;
tabla.KeepTogether = true;