如何避免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);
如何删除第一个表和第二个表之间的空格?
答案 0 :(得分:0)
这应该在PdfTable table
table.setSpacingBefore();
table.setSpacingAfter();