In a recent logistics project, the customer asked us to build a Web site that allows users to query shipping information from a legacy system, with three major requirements:
1. Shipping information must be returned in the format of PDF document;
2.PDF file must be able to download through the browser;
3.PDF files must be readable by Adobe Acrobat Reader;
Although our team has a lot of Java Web application development experience, but in the PDF document processing is not much experience. We need to find a pure Java class library that can produce complex PDF documents in a server-side Web application. Finally, we find that IText (http://www.lowagie.com/iText/) can fully meet our needs.
1.iText Class Library
Itext is an open source pure Java class Library that creates and processes PDF documents. Bruno Lowagie and Paulo Soares led the project. The IText API enables Java developers to programmatically create PDF documents. Itext offers a number of features:
Support for PDF and FDF documents
Various page sizes
Landscape and vertical Layouts
Page margins
Form
Word breaker
Page Header
Footer
Page
Bar code
Font
Color
Document encryption
Jpeg,gif,png and WMF pictures
Ordered and unordered lists
Shadow
Watermarking
Document templates
Itext is an open source library. When writing this article, Itext can be used under two license agreements: Mozilla Public License and LGPL. For more information, refer to the Itext site. In this article, you will see the application of the Itext API. We will explain how to dynamically generate PDF documents using Itext and servlet in server-side applications.