日期:2014-05-18 浏览次数:21074 次
List<XfFreePO> freelist = new ArrayList<XfFreePO>();
try {
freelist = dao.getFreexfList(xvo, "0", "0");
} catch (Exception e) {
e.printStackTrace();
}
ByteArrayOutputStream os = new ByteArrayOutputStream();
Document pdfDocument = new Document(PageSize.A4,20,20,20,20);
int submitAmount=2000;
PdfWriter writer=PdfWriter.getInstance(pdfDocument,os);
PdfHeaderFooter headerFooter = new PdfHeaderFooter();//建立模板建立页脚
writer.setBoxSize("art",PageSize.A4);
writer.setPageEvent(headerFooter);
try {
//设置中文字体和字体样式
BaseFont bfChinese1 = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
Font f4 = new Font(bfChinese1, 10, Font.NORMAL);
BaseFont bfChinese2 = BaseFont.createFont("C:/Windows/Fonts/Simli.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);//隶书
Font f1 = new Font(bfChinese2, 18, Font.BOLD);
Font f2 = new Font(bfChinese2, 14, Font.BOLD);
Font f3 = new Font(bfChinese2, 12, Font.BOLD);
//打开PDF文件流,并建立页脚
pdfDocument.open();
//创建一个N列的表格控件
PdfPTable pdfTable = new PdfPTable(11);
float[] widths = { 0.06f, 0.06f, 0.10f, 0.20f, 0.10f, 0.08f, 0.08f, 0.08f, 0.08f, 0.08f, 0.06f};
pdfTable.setWidths(widths);
//设置表格占PDF文档100%宽度
pdfTable.setWidthPercentage(100);
//水平方向表格控件左对齐
pdfTable.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);
//创建一个表格的表头单元格
PdfPCell Cell1 = new PdfPCell();
Cell1.setColspan(11);
Cell1.disableBorderSide(2);
Cell1.setPhrase(new Paragraph(tvo.getTabhead(), f1));
&nb