读到itext in action第6章6.1.3,有个函数getDefaultCell(),查看该函数的API
com.lowagie.text.pdf.
.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
- 大小: 5.9 KB
- 大小: 9.3 KB
分享到:
相关推荐
itext 生成pdf的中文帮助文档,具体有:图片、块(下划线/删除线、上标/下标)、短句、段落等。
itext2.17
iText核心包,iTextAsian_1.5.2支持中文jar包
iTextAsian_1.5.2iTextAsian_1.5.2iTextAsian_1.5.2
iText 是一个开源的PDF文件操作类库,它可以动态生成PDF文档以及对PDF文件进行编辑更改,比如:从XML文件或数据库生成动态PDF文档、添加/更改书签、页码、添加数字签名、页面排版操作等等。功能非常强大。
常用报表操作,itext_make_pdf,itext_make_word,jexcel_make_excel,poi_make_excel,pdf,Word,excel
IText PDF开发工具说明文档,使用很方便。
iText是著名的开放源码的站点sourceforge一个项目,是用于生成PDF文档的一个java类库。... iText的安装非常方便,下载iText.jar文件后,只需要在系统的CLASSPATH中加入iText.jar的路径,在程序中就可以使用iText类库了
iText7 原生方法制作带斜线表格
iText是一个JAVA中快速制作PDF文件的类库,如果你想用JAVA制作PDF文档,这个源码包可不要错过哟。
一段经典的处理iText打印pdf表格代码。
生成pdf的中文问题解决办法、导出pdf时,设置段落行间距方法,表单填充,使用itext方法填充相应表单域。
itext-1.4.8
NULL 博文链接:https://javajack.iteye.com/blog/878073
用Itext操作word,可以在word里画表格,也可以往word里插入图片
The iText 7 Core/Community release contains: kernel-x.y.z.jar: low-level functionality io-x.y.z.jar: low-level functionality layout-x.y.z.jar: high-level functionality forms-x.y.z.jar: AcroForms pdfa-...
该资源包括itext5.0.6,itextasin1.5.2,jfreechar1.0.13和jcommon_1.0.16,其中itext5.0.6和itextasin1.5.2是用于pdf编辑jar包,jfreechar1.0.13和jcommon_1.0.16是用于Java里图表操作的jar包,右击工程--》Bulid ...
java 使用iText生成word文档,包中带有源码与所用jar包,生成文档格式标准。可分页,可带页眉,可生成表格、图片和文字等word元素内容,文字带字号,字体,颜色等。
itext in action 的源代码,学习的好资源
java 使用IText导出PDF(包含图片、表格、文字等等Demo和依赖包),最全IText使用Demo,下载即可用