IText导出word之页眉页脚页码(二)

2014-11-24 10:16:55 · 作者: · 浏览: 5


Font contextFont = new Font(bfChinese, 10, Font.NORMAL);

// 正文标题1 风格

Font contextTitle1Font = new Font(bfChinese, 12, Font.NORMAL);

//设置加粗字体
Font boldFont = new Font(bfChinese, 10, Font.BOLD);



/**
* 测试部分
*/
// Paragraph title = new Paragraph("标题");
// // 设置标题格式对齐方式
// title.setAlignment(Element.ALIGN_CENTER);
// title.setFont(titleFont);
//// document.add(title);
// String contextString = "iText是一个能够快速产生PDF文件的java类库。iText的java类对于那些要产生包含文本,表格,图形的只读文档是很有用的。它的类库尤其与java Servlet有很好的给合。使用iText与PDF能够使你正确的控制Servlet的输出。";
// Paragraph context = new Paragraph(contextString);
// // 正文格式左对齐
// context.setAlignment(Element.ALIGN_LEFT);
// context.setFont(contextFont);
// // 离上一段落(标题)空的行数
// context.setSpacingBefore(20);
// // 设置第一行空的列数
// context.setFirstLineIndent(20);
//// document.add(context);


/**
* 设置正文
*/
Paragraph producename = new Paragraph(qybjProduce.getProducename(), titleFont);
document.add(producename);
Paragraph bjpriceText = new Paragraph(" 报 价:", titleFont);
Paragraph bjprice = new Paragraph(qybjProduce.getPrice(), underLineFont);
Paragraph bjdateText = new Paragraph(" 报价日期:", titleFont);
Paragraph bjdate = new Paragraph(qybjProduce.getBjdate(), underLineFont);
Paragraph customerText = new Paragraph(" 客户单位:", titleFont);
Paragraph customer = new Paragraph(qybjProduce.getCompany(), underLineFont);
Paragraph linkManText = new Paragraph(" 联 系 人:", titleFont);
Paragraph linkMan = new Paragraph(qybjProduce.getLinkman(), underLineFont);


Paragraph faxText = new Paragraph(" 传 真:", titleFont);
Paragraph fax = new Paragraph(qybjProduce.getLinkfax(), underLineFont);
Paragraph linkPhoneText = new Paragraph(" 联系电话:", titleFont);
Paragraph linkPhone = new Paragraph(qybjProduce.getLinkphone(), underLineFont);




Paragraph bjCol=new Paragraph();
bjCol.add(bjpriceText);
bjCol.add(customerText);
bjCol.add(faxText);

/**
* 用table
*/
Table tableProduce = new Table(4,3);
float[] widths = { 0.2f, 0.4f, 0.2f, 0.2f };
tableProduce.setWidths(widths);
tableProduce.setBorderWidth(1);
tableProduce.setBorder(0);
tableProduce.setBorderColor(Color.BLACK);
tableProduce.setPadding(0);
tableProduce.setSpacing(0);
tableProduce.setWidth(100f);

Cell cell0 = new Cell();//报价标签单元格
cell0.add(bjpriceText);
// cell0.setBorderWidth(0f);
table