itext设置默认NO_BORDER表格
来源:互联网 发布:西南交通网络大学是985 编辑:程序博客网 时间:2024/05/20 06:23
读到itext in action第6章6.1.3,有个函数getDefaultCell(),查看该函数的API
PdfPCell com.lowagie.text.pdf.PdfPTable.getDefaultCell()
Gets the default PdfPCell
that will be used as reference for all the addCell
methods except addCell(PdfPCell)
.
那么就是说你使用new PdfPCell就有border
那再查看PdfPCell的构造函数。以PdfPCell()和PdfPCell(Phrase)为例,发现的确有默认的border。
参照第6章的代码PdfPTableWithoutBorders做小小的改动
/* chapter06/PdfPTableWithoutBorders.java */package org.study.itext.table;import java.io.FileOutputStream;import java.io.IOException;import com.lowagie.text.Document;import com.lowagie.text.DocumentException;import com.lowagie.text.Paragraph;import com.lowagie.text.pdf.PdfPCell;import com.lowagie.text.pdf.PdfPTable;import com.lowagie.text.pdf.PdfWriter;/** * @blog http://reymont.iteye.com/ * @author reymont.li * @version create time:2011-7-18 下午04:13:47 */public class PdfPTableWithoutBorders {public static void main(String[] args) {Document document = new Document();try {PdfWriter.getInstance(document,new FileOutputStream("resource/pdfptable_without_borders.pdf"));document.open();PdfPTable table = new PdfPTable(3);table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);PdfPCell cell = new PdfPCell(new Paragraph("header with colspan 3"));//cell.setColspan(3);table.addCell(cell);table.addCell(new Paragraph("header with colspan 3"));table.addCell("1.1");table.addCell("2.1");table.addCell("3.1");table.addCell("1.2");table.addCell("2.2");table.addCell("3.2");document.add(table);} catch (DocumentException de) {System.err.println(de.getMessage());} catch (IOException ioe) {System.err.println(ioe.getMessage());}document.close();}}
可得到。
请注意addCell(new PdfPCell())和addCell(new Paragraph())的区别
PdfPCell cell = new PdfPCell(new Paragraph("header with colspan 3"));table.addCell(cell);table.addCell(new Paragraph("header with colspan 3"));
参考资料:
- itext in action 2006版
- itext-2.0.8
阅读全文
0 0
- itext设置默认NO_BORDER表格
- powerdesigner15设置表格默认字体
- iText系列(二) iText---表格
- itext表格控制
- iText 生成复杂表格
- iText输出表格
- iText制作表格
- itext表格(转载)
- iText的简单应用-表格
- 利用itext创建PDF表格
- Java iText 生成PDF表格
- java IText 导出word表格
- iText如何设置行距
- ITEXT字体设置
- iText 字体设置错误
- ITEXT字体设置
- ITEXT字体设置
- 设置cell选中颜色以及表格默认选中某行
- java实现oracle函数rpad和lpad
- HTML/CSS学习记录(6)
- itext Chunk Phrase Paragraph区别
- 项目中加入人脸识别功能
- Python3 循环
- itext设置默认NO_BORDER表格
- cannot find class for bean with name的一种解决记录
- css设置图片逐渐消失
- itext pdftemplate使用
- oracle split_for_array 用法示例
- itext使用rtf格式生成word,使用image为页眉
- jquery tree循环渲染数据,控制checkbox显示与隐藏,点击无效效果
- 创建itext document&横向打印
- 第三章:3.6 使用 Session