【问题标题】:How to make the table non breaking using iTextSharp如何使用 iTextSharp 使表格不中断
【发布时间】:2011-12-31 01:39:35
【问题描述】:

我有一张桌子

  PdfPTable tblSummary = new PdfPTable(1);  

它确实有 2 个嵌套在其中的表。如何使tblSummary 整体显示(行不得中断到另一页)或如果当前​​页面不适合将整个表转移到另一页。

我试过SplitLateSplitRows

而我的代码是这样的

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 的高度,因此可以确定表的内容不会超过页面高度。

任何建议都会很有帮助。

【问题讨论】:

    标签: c# itextsharp pdfptable


    【解决方案1】:

    你试过了吗:

    tblSummary.KeepTogether = true;
    

    【讨论】:

    • 谢谢回复,之前没试过,效果很好。
    • 谢谢谢谢谢谢。这太棒了。这适用于使用 document.Add(pdfptable) 方法的 PDFPTable。
    【解决方案2】:
    PdfPTable tabla = new PdfPTable(2);
    float[] anchosTablaTituloDescripcion = new float[] { 4f, 4f };
    tabla.SetWidths(anchosTablaTituloDescripcion);
    tabla.WidthPercentage = 100;
    tabla.KeepTogether = true;
    

    【讨论】:

    • 请解释这将如何帮助以及问题所在。
    猜你喜欢
    • 1970-01-01
    • 2013-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多