【问题标题】:Generating pdf file using java, Itext使用java,Itext生成pdf文件
【发布时间】:2010-08-05 12:30:29
【问题描述】:

我的要求是生成 pdf,如果数据更多,从数据库中检索的数据应该在页面之间拆分,而不是在新页面中创建整个数据。

例如,有时必须在另一页上拆分表格时,拆分行的某些单元格应出现在前一页上,而其他单元格应出现在下一个页面上。

请对此提供帮助。

【问题讨论】:

    标签: java pdf pdf-generation itext


    【解决方案1】:

    你考虑过iReport吗?

    【讨论】:

      【解决方案2】:

      也许你应该考虑看看Jasper Reports

      【讨论】:

      • Thierry-Dimitri Roy 的反应速度更快
      【解决方案3】:

      PdfPTable 跨页面拆分自身。构建其中一个相当容易。

      缺点是根据您的特定需求设置表格样式可能会很痛苦。你可能需要为它写一些抽象。

      获得文档后,添加表格/单元格非常简单:

      Document document = // some document
      PdfPTable table = new PdfPTable(columns);
      table.addCell(new PdfPCell("data goes here));
      

      【讨论】:

        【解决方案4】:

        如果您在Java 中使用手动iText 编码,我认为您将需要:

        PdfPTable table; // your table
        
        table.setKeepTogether(false); // allows table to split table
        table.setHeaderRows(1);       // rows of header
        table.setFooterRows(2);       // rows of footer
        

        有关footers and headers 的更多信息和示例,请参见表check iText official website

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2013-06-05
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-10-13
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多