iText嵌套在单元格内的表

Ave*_*oes 8 java pdf itext

我正在使用iText 2.1.0版创建PDF.我必须在表格的单元格中创建一个"细节"单元格.我在这个单元格内嵌了一个表.此方法的问题是嵌套表的边框不会触及容器单元格的边框.我正在寻找的是一个嵌套在单元格内的表格,该单元格的边框与嵌套表格边框不同.

我有这样的测试.我在循环中执行此操作以将单元格内的表添加到外部表:

PdfPCell testCell = new PdfPCell(new Paragraph("Test"));
//I want this border to touch the containerCell borders.
testCell.setBorder(PdfPCell.BOTTOM);
testTable =  new PdfPTable(2);

testTable.addCell(testCell);
testTable.addCell(testCell);
testTable.addCell(testCell);
testTable.addCell(testCell);

PdfPCell containerCell = new PdfPCell();
containerCell.addElement(testTable);
outerTable.addCell(containerCell);
Run Code Online (Sandbox Code Playgroud)

谢谢.

Ave*_*oes 20

我想我终于找到了:

testTable = new PdfPTable(1);
PdfPCell c2;
testTable.addCell("aaaa");
testTable.addCell("bbbb");

c2 = new PdfPCell (testTable);//this line made the difference
c2.setPadding(0);
outerTable.addCell(c2);
Run Code Online (Sandbox Code Playgroud)

这里的技巧是使用PdfPCell构造函数中的表.