【iText 生成PDF基础知识介绍】

1、iText简介

iText是著名的开放源码的站点sourceforge一个项目,是用于生成PDF文档的一个java类库。通过iText不仅可以生成PDF或rtf的文档,而且可以将XML、Html文件转化为PDF文件。 iText的安装非常方便,下载iText.jar文件后,只需要在系统的CLASSPATH中加入iText.jar的路径,在程序中就可以使用iText类库了。

Standards for administration, archiving, invoicing and compliance increasingly rely on PDF. iText is the right partner to help you automate your documentation processes. We offer powerful and flexible tools for PDF creation, editing and inspection, and have been doing so for over 15 years. With the release of iText 7, redesigned from the ground up, even more features and functionalities are now at developers' fingertips. iText serves over 5,000 customers across the world, including finance, governmental, technology and logistics companies. With us, you can truly take your documentation needs to the next level.

在企业的信息系统中,报表处理一直占比较重要的作用,本文将介绍一种生成PDF报表的Java组件--iText。通过在服务器端使用Jsp或JavaBean生成PDF报表,客户端采用超链接显示或下载得到生成的报表,这样就很好的解决了B/S系统的报表处理问题。



 

2、iText 的需求分析

一般情况下,iText使用在有以下一个要求的项目中:

内容无法提前利用:取决于用户的输入或实时的数据库信息。

由于内容,页面过多,PDF文档不能手动生成。

文档需在无人参与,批处理模式下自动创建。

扫描二维码关注公众号,回复: 581619 查看本文章

内容被定制或个性化;例如,终端客户的名字需要标记在大量的页面上

3、iText 生成PDF步骤

//第一步:创建一个document对象。    

Document document = new Document();                 

// 第二步: 创建一个PdfWriter实例,    将文件输出流指向一个文件。    

PdfWriter.getInstance(document,new FileOutputStream("C:\\HelloWorld.pdf"));    

// 第三步:打开文档。    

 document.open();    

// 第四步:在文档中增加一个段落。    

document.add(new Paragraph("Hello World"+","+"Hello iText"+","+"Hello xDuan"));                  

// 第五步:关闭文档。    

document.close();    

猜你喜欢

转载自gaojingsong.iteye.com/blog/2323850
今日推荐