【问题标题】:A new row in pdfptablepdfptable 中的新行
【发布时间】:2011-06-20 23:10:56
【问题描述】:

我正在使用 iText 库在 pdf 文件中以表格格式打印某些数据。我有 11 列,可以有多行。在为每列的标题创建标题后,如何在 pdfptable 中创建一个新行,以便我可以在单独的行上打印真实数据。

【问题讨论】:

    标签: java pdf itext


    【解决方案1】:

    在 PdfPTable 的构造函数中,您可以指定一行中的列数。

    PdfPTable table = new PdfPTable(4) // 4 Columns
    PdfPCell cell;
    cell = new PdfPCell( new Phrase("Cell with colspan of 4") ) ;
    cell. setColspan(4) ; // an entire row
    
    anotherCell = new PdfPCell( new Phrase("Cell with colspan of 4") );
    anotherCell.setColspan(4); // a second row
    

    如您所见,当您到达当前行中的 colspan 时,会创建一个新行。

    【讨论】:

    • 我想我是通过使用 table.completeRow();所以它完成了这一行并开始新的一行。
    • tks 非常多,事实上,只有当你到达 colspan 时才会创建一个新行。这很重要!
    猜你喜欢
    • 1970-01-01
    • 2013-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-10
    • 2014-05-18
    • 2011-01-20
    • 1970-01-01
    相关资源
    最近更新 更多