加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

利用itext 生成pdf,处理cell 跨页问题

(2012-06-11 11:58:42)
标签:

text

pdf

cell

跨页

it

分类: java技术
处理方法:
  1. PdfPTable table new PdfPTable(1);   
  2. table.setSplitLate(false);   
  3. table.setSplitRows(true); 

 

 

开发中的例子:

    document = new Document();
    String separator = System.getProperties().getProperty("file.separator");
    out = new FileOutputStream(Const.getSystemExchangePath() + separator + fileName + ".pdf");
   
    PdfWriter.getInstance(document, out);
    document.open();

   table = new PdfPTable(4); 
   table.setWidthPercentage(100);
   table.getDefaultCell().setPadding(6);

 

cell 跨页处理:


   table.setSplitLate(false);
   table.setSplitRows(true);
   PdfPCell cell = new PdfPCell();
   
   cell.setColspan(4);
   cell.setUseAscender(true);
   cell.setHorizontalAlignment(Element.ALIGN_CENTER);
   cell.setVerticalAlignment(Element.ALIGN_TOP);

标题居中处理:


   Paragraph title = new Paragraph(bean.getTitle(), headerFont);
   title.setAlignment(Element.ALIGN_CENTER);
   cell.addElement(title);
   cell.setBorderWidth(0);
   table.addCell(cell);

  document.add(table); 

  document.close();

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有