cellSpec = new Cell();//规范名字
Paragraph specNameText = new Paragraph(device.getSpecname(), contextFont);
cellSpec.add(specNameText);
tableSpecs.addCell(cellSpec);
cellSpec = new Cell();//规范内容
Paragraph specsText = new Paragraph(device.getSpecs(), contextFont);
cellSpec.add(specsText);
tableSpecs.addCell(cellSpec);
}
document.add(tableSpecs);
/**
* 设置页眉
*/
Image headerImage = Image.getInstance(imagepath);
Paragraph headerPara2 = new Paragraph(qybjCompany.getCompanyname(), titleFont);
headerPara2.setAlignment(HeaderFooter.ALIGN_CENTER);
RtfHeaderFooter header1 = new RtfHeaderFooter(headerImage);
Paragraph headerPara1 = new Paragraph();
headerPara1.add(headerPara2);
headerPara1.add(header1);
headerPara1.setAlignment(HeaderFooter.ALIGN_CENTER);
Phrase headerPara = new Phrase();
/**
* 插入表格
* 三列二行
*/
Table table = new Table(3,2);
table.setBorderWidth(1);
table.setBorder(0);
table.setBorderColor(Color.BLACK);
table.setPadding(0);
table.setSpacing(0);
// table.setAlignment(Table.ALIGN_MIDDLE);
table.setWidth(100f);
Cell cell = new Cell(headerPara1);//单元格
// cell.setBorderWidth(0f); //设置表格没有边框
cell.setHeader(true);
cell.setRowspan(2);//当前单元格占两行,纵向跨度
table.addCell(cell);
table.endHeaders();// 表头结束
Cell cellHeader = new Cell();
Paragraph produceTitle= new Paragraph(qybjProduce.getProducename(),titleFont);
produceTitle.setAlignment(HeaderFooter.ALIGN_CENTER);
cellHeader.add(produceTitle);
table.addCell(cellHeader);
cellHeader = new Cell();
Paragraph parafooter = new Paragraph();
parafooter.add(new Phrase("共"));
parafooter.add(new RtfTotalPageNumber());//共几页
parafooter.add(new Phrase("页"));
parafooter.setAlignment(1);
cellHeader.add(parafooter);
table.addCell(cellHeader);
cellHeader = new Cell();
Paragraph pTitle= new Paragraph("报价单",titleBaoFont);
pTitle.setAlignment(1);
cellHeader.add(pTitle);
cellHeader.setUseAscender(true);