如何避免在iText的 两个表之间的空间或间隙使用类com.lowagie.text.tableiText的PDF与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!) –