您的位置:首页 > 其它

利用itext 生成pdf 文件---cell 跨页问题

2011-11-20 14:04 447 查看
处理方法:
PdfPTable table = new PdfPTable(1);   
table.setSplitLate(false);   
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/*new Paragraph(bean.getTitle(), headerFont)*/);

   cell.setBorderWidth(0);

   table.addCell(cell);

  document.add(table); 

  document.close();

 

 

 

 

 

 

 

参考网址:http://tutorials.jenkov.com/java-itext/table.html

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  table string