我与 iText 做生意,我创建了一个有 9 列的表,我将前 4 列分组为 1,然后我将接下来的 4 分组为一个,最后留一个,该点被分配 cell.setBorderwidth = 2 in所有单元格,生成文档的边缘不匹配。希望您能够帮助我。
这是使用的代码:
public PdfPTable createTable5() throws DocumentException {
PdfPTable table = new PdfPTable(10);
table.setTotalWidth(540);
//table.setWidthPercentage(105);
table.setHorizontalAlignment(Element.ALIGN_LEFT);
table.setLockedWidth(true);
table.setWidths(new float[]{26.16f,48.77f,48.77f,48.77f,40.06f,56.64f,78.41f,53.1f,59.2f,80.11f});
PdfPCell cell;
cell = new PdfPCell(new Phrase(" ",subFont));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setVerticalAlignment(Element.ALIGN_CENTER);
cell.setBorderWidth(0);
//cell.setBorderWidthRight(0);
//cell.setColspan(4);
table.addCell(cell);
cell = new PdfPCell(new Phrase("Cantidades por material",subFont));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setUseAscender(true);
cell.setBorderWidth(2);
cell.setBorderWidthRight(0);
cell.setColspan(4);
cell.setFixedHeight(g);
table.addCell(cell);
cell = new PdfPCell(new Phrase("Costo por material",subFont));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setUseAscender(true);
cell.setBorderWidth(2);
cell.setBorderWidthRight(0);
cell.setColspan(4);
cell.setFixedHeight(g);
table.addCell(cell);
cell = new PdfPCell(new Phrase("Total",subFont));// Error in Border
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setUseAscender(true);
cell.setBorderWidth(2);
//cell.setColspan(1);
cell.setFixedHeight(g);
//cell.setBorderWidthRight(0);
table.addCell(cell);
return table;
}