【发布时间】:2014-07-11 06:04:38
【问题描述】:
如何避免 iText 中两个表格之间的空间或间隙 使用类 com.lowagie.text.table
Table table;
com.lowagie.text.Cell cell;
table = new Table(2);
table.setPadding(2);
table.setWidths(new int[] {100});
table.setWidth(100);
cell = new com.lowagie.text.Cell(new Phrase(
"sample text1", FontFactory
.getFont(FontFactory.HELVETICA, commonfontsize)));
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
cell.setBorder(0);
table.addCell(cell);
document.add(table);
table = new Table(2);
table.setPadding(2);
table.setWidths(new int[] {50,50});
table.setWidth(100);
cell = new com.lowagie.text.Cell(new Phrase(
"sample text1", FontFactory
.getFont(FontFactory.HELVETICA, commonfontsize)));
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
cell.setBorder(0);
table.addCell(cell);
cell = new com.lowagie.text.Cell(new Phrase(
"sample text2", FontFactory
.getFont(FontFactory.HELVETICA, 10)));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBorder(0);
table.addCell(cell);
document.add(table);
如何去除第一张表和第二张表之间的空间?
【问题讨论】:
-
Table类在很多年前就被废弃了。您正在使用的 iText 版本也是如此。我建议您开始使用PdfPTable而不是Table(真的必须!)并且您升级到在包名称中没有提及我的名字的iText 版本。 (我是你在代码中提到的 Lowagie!)
标签: itext