PdfPtable只能合并列,不能合并行
public static void main(String[] args) throws Exception {
Document document = new Document();
FileOutputStream writer = new FileOutputStream("e:/2.pdf");
PdfWriter.getInstance(document, writer);
document.open();
//创建有两列的table
PdfPTable table = new PdfPTable(2);
PdfPCell cell=new PdfPCell();
cell.setPhrase(new Phrase("11111"));
cell.setColspan(2);//合并单元格
PdfPCell pCell1 = new PdfPCell();
pCell1.setPhrase(new Phrase("22222"));
PdfPCell pCell2 = new PdfPCell();
pCell2.setPhrase(new Phrase("3333"));
table.addCell(cell);
table.addCell(pCell1);
table.addCell(pCell2);
document.add(table);
document.close();
}版权声明:本文为jjkang_原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。