【问题标题】:iText pdf functionality broken after lib upgrade - cannot merge tableslib 升级后 iText pdf 功能损坏 - 无法合并表
【发布时间】:2013-07-31 12:08:30
【问题描述】:

iText PDF library 从 2.0.4 升级到 5.4.1 破坏了我的应用程序中的现有功能。

不再将表合并为一个复杂表。

//Creating tables
Table table0 = new Table(2);
Table table1 = new Table(7);
Table table2 = new Table(17);
Table table3 = new Table(24);

//Setting widths for tables
table0.setWidths(widths0);
table3.setWidths(widths);
table1.setWidths(widths1);

//Inserting 3 tables into one
Cell cell;
cell = new Cell(table1);
table0.addCell(cell);
Cell cell2 = new Cell(table2);
table0.addCell(cell2);
Cell cell3 = new Cell(table3);
cell3.setColspan(2);
table0.addCell(cell3);

//Populating cells and data for table1, table2, table3...

//Adding table to my pdf document
document.add(table0);
document.close();

实际结果:添加到文档中的table0 根本不显示。 (我尝试分别添加表 1、2、3 并且它们出现了) 相同的代码适用于旧版本的 iText PDF。

BG 信息:java 版本也从 1.5 -> 1.7 升级,jBoss 从 4.0.4 -> 6.1 升级,但我认为这可能与我的问题无关。

非常感谢。

【问题讨论】:

标签: java pdf itext itextpdf


【解决方案1】:

Table 类已从 iText 中删除。它被PdfPTable 取代。你必须改变你的代码。 iText 2.0.4 和 5.4.1 之间已经过去了很多年。

【讨论】:

  • 嘿。是的,你是对的,我已经想通了,对我来说,要获得符合 5.4.1 的代码,似乎还有很多工作要做。所以我回滚到 2.0.4 并在现有类中恢复旧的“com.lowagie”库导入。对于任何新的开发,很可能会尝试使用 5.4.1 :)
  • 或5.4.3(昨天发布)
  • 也许值得对 2 年更新的 2.1.7 进行小幅升级。而且升级很容易,因为不需要进行任何更改...
猜你喜欢
  • 1970-01-01
  • 2016-01-20
  • 1970-01-01
  • 1970-01-01
  • 2014-03-24
  • 1970-01-01
  • 2013-02-18
  • 2018-06-19
  • 2014-12-14
相关资源
最近更新 更多