Office software is closely linked to the PDF,the PDF is also must have to control!      Set home Page  Add to Favorites  
You are here:Home > PDF Application > PDF Development
PDF Development
Dynamic Web applications how to create a PDF file?
Finishing by: Date:2009-4-17 20:31:35 Popularity: Tags:

Web applications dynamically create PDF documents?

In a recent project in logistics, customer requires us to allow users to build a legacy system from a query shipping information Web site, there are three major needs:
1. Shipping information must be returned to the format of PDF documents;
2.PDF documents must be downloaded through the browser;
3.PDF file must use Adobe Acrobat Reader to read;
Although our team a lot of J2EE Web application development experience, but in the handling of PDF documents do not have much experience of it. We need to find a server-side Web application in the complex where the PDF document of pure Java class library. Finally, we found that iText ( to fully meet our needs.

1.iText Class Library

iText is a PDF document creation and processing of open-source pure Java class library. Bruno Lowagie and Paulo Soares led the project. IText API enables Java developers to programmatically create PDF documents. iText provides a lot of features:
  • support of PDF and FDF files
  • a variety of page sizes
  • horizontal and vertical layout

  • forms

  • page first

  • page
  • bar code
  • font
  • color
  • document encryption
  • JPEG, GIF, PNG and WMF picture
  • list of ordered and disordered
  • the shadow of

  • document template
    iText is an open source database. At this time, iText can be used under two licensing agreements: Mozilla Public License and the LGPL. If you want more information, please refer to iText site. In this article, you will see the application of the iText API. We will set out how the use of server-side applications iText and servlet dynamically generated PDF documents.

    2. started (Getting Started)

    First of all, you need a iText Jar file. IText visit site and download the latest version. At this moment, the latest version is 0.99. iText site provides the API documentation and a comprehensive guide.
    In addition to iText, we have to use servlet. If you are not familiar with the servlet, you can book through Jason Hunter's "Java Servlet Programming" to learn it. You need a J2EE application server or can run independently of the servlet engine. Open source Tomcat, Jetty and Jboss is a good choice. Below assume that you are using the Jakarta Tomcat 4.1.
    1.iText API

    easy-to-use iText API. Through the use of iText, you can create a custom PDF documents. iText library from a number of package components below:
    In order to generate PDF documents, you need only two packets com.lowagie.text and com.lowagie.text.pdf.
    We used these examples of iText category:
    The key is the Document and the PdfWriter. In the creation of PDF documents, you will often use these two categories. Document is a PDF document based on the description of the object. You can call methods provided by Document type to add content to the document. object through PdfWriter object associated with the Document together.

    3. in Web applications iText

    At the design stage, you must decide how to use iText. We use the bottom of the technological development of our Web applications.

    1.A technology

    File system on the server to create PDF documents. Applications wrote the document on the server file system. Users through the HTTP GET method to download the file.

    2.B technology use in memory to create PDF documents. Application through the servlet output stream of bytes of the PDF document sent to the client.
    As a result of the application documents do not need to write file system so that services can guarantee the environment in the cluster can work properly, so I prefer to use B technology. If your application environment running on clusters and server clusters do not provide the function of session affinity, A technology may lead to failure.
  • there isArticle InformationsComment Information
    Category column

    Site Help | Site Map | Feedback |
    OAPDF.COM Copyright 2009 V1.1