0
如果您看到下表,我已将两个单元格分开,将一个单元格添加为左侧单元格(名称),并将另外一个单元格添加为表格。通过删除左侧单元格重新设计输出
我曾尝试下面的代码:
我用包作为进口com.lowagie.text.pdf *;
PdfWriter.getInstance(document,
new FileOutputStream("C:/Temp/TableWidthAlignment.pdf"));
document.open();
//Main table
PdfPTable mainTable = new PdfPTable(2);
mainTable.setWidths(new int[] { 10,90 });
//cell one is Name cell
PdfPCell innerCellKeyName = new PdfPCell(new Phrase("Name", boldFont));
//innerCellKeyName.setBorder(Rectangle.NO_BORDER);
mainTable.addCell(innerCellKeyName);
PdfPTable table = new PdfPTable(3);
PdfPCell cell = new PdfPCell(new Paragraph("header with colspan 3"));
cell.setColspan(3);
table.addCell(cell);
table.addCell("1.1");
table.addCell("2.1");
table.addCell("3.1");
table.addCell("1.2");
table.addCell("2.2");
table.addCell("3.2");
table.addCell("4.1");
table.addCell("4.2");
table.addCell("4.3");
//cell two is as table
PdfPCell cell2 = new PdfPCell(table);
mainTable.addCell(cell2);
document.add(mainTable);
输出是:
预期输出是:交叉箱需要被移除形式盒在左单元。
你知道你使用的是旧版本的iText的,自2009年12月,7年前已寿命结束? –
是的,这是真的,这是旧的应用程序,这是我们必须遵循旧规则的原因。 – Arun
我们现在已经7年了。也许是时候升级了。使用行跨度是行之有效的方法,但在您过时的iText版本中,“PdfPTable”不支持行跨度。 –