The iText supports RTF, XML and HTML document and you are free to use variety of fonts and colors in document. It is necessary to use import com.lowagie.text.*package to work with iText Java Development.
Generating PDF files in today’s enterprise applications is quite common. Doing this with Java is not an easy task as Java does not gives default api’s to handlePDF files. No worries, iText jar is for you.
iText is a free Java-PDF library that allows you to generate PDF files on the fly(dynamically). iText is an ideal library for developers looking to enhance web- and other applications with dynamic PDF document generation and/ormanipulation. iText is not an end-user tool. Typically you won’t use it on your Desktop as you would use Acrobat or any other PDF application. Rather, you’ll build iText into your own applications so that you can automate the PDF creation and manipulation process.
iText (Java-PDF Library) can be used to:
- Serve PDF to a browser
- Generate dynamic documents from XML files or databases
- Use PDF’s many interactive features
- Add bookmarks, page numbers, watermarks, etc.
- Split, concatenate, and manipulate PDF pages
- Automate filling out of PDF forms
- Add digital signatures to a PDF file
Technical Requirements to use iText
You should have JDK 1.4 or later to integrate iText PDF generation in your application.
Create and Manipulate PDF using iText
First of all, it is necessary for Java developers to import all necessary packages for creating and using PDF in Java program. These packages are
java.io.*;
com.lowagie.text.pdf.*;
com.lowagie.text.*;
Now create a document class “HelloworldPDF” and objects of document class. The document class has the methods like
add (),
open (),
close (),
getPageNumber (),
getPageSize () ..... etc.
The next step is to add content in PDF file using document writer object OutputStream. Open the content using document.open () method and write content to PFD file. At the same time, Java Developers can set the file size using setPageSize () method. The size of PDF file varies from A0 to A10. After modifying the content close the file using document.close () method otherwise program will show error.
Now set the background color for PDF file using “color” class. For using “color” class, it is necessary to importjava.awt.Color package. Now set the background color of file using setbackgroundColor () and at the end close the PDF file using document.close () method. The iText Chunk is smallest and most significant part of the program that can be added to text for making it more attractive. If you are interested in adding superscript and subscript text, then I can be made possible through Chunk class only.
This is the time to work with images in PDF file. First of all, import com.itextpdf.text.Image package for adding images to PDF file. You can also customize images using multiple image objects in iText Java Development. You can browse images either though file or particular URL. Similarly we can perform other actions like creating tables, changing font size, creating tables with images, copying content from one PDF to other etc. using iText in Java.
No comments:
Post a Comment