What is iText®?
If you look at PDF creation, you'll find that graphical designers use desktop applications such as Adobe Acrobat or Adobe InDesign to create a document in a manual or semimanual process. In another context, PDF documents are created programmatically, using an API to produce PDFs directly from software applications, withoutor with minimalhuman intervention. Sometimes the document is created in an intermediary format first, and then converted to PDF. These different approaches demand different software products. The same goes for PDF manipulation. You can update a PDF manually in Adobe Acrobat, but there are also tools that allow forms to be filled out automatically based on information from a database.
iText is a tool that focuses on the automation side of things.
iText is a PDF library
iText is an API that was developed to allow developers to do the following (and much more):
- Generate documents and reports based on data from an XML file or a database
- Create maps and books, exploiting numerous interactive features available in PDF
- Add bookmarks, page numbers, watermarks, and other features to existing PDF documents
- Split or concatenate pages from existing PDF files
- Fill out interactive forms
- Serve dynamically generated or manipulated PDF documents to a web browser
iText is not an end-user tool. You have to build iText into your own applications so that you can automate the PDF creation and manipulation process.
When to use iText?
Typically, iText is used in projects that have one of the following requirements:
- The content isn't available in advance: it's calculated based on user input or real-time database information.
- The PDF files can't be produced manually due to the massive volume of content: a large number of pages or documents.
- Documents need to be created in unattended mode, in a batch process.
- The content needs to be customized or personalized; for instance, the name of the end user has to be stamped on a number of pages.
Often you'll encounter these requirements in web applications, where content needs to be served dynamically to a browser. Normally, you'd serve this information in the form of HTML, but for some documents, PDF is preferred over HTML for better printing quality, for identical presentation on a variety of platforms, for security reasons, or to reduce the file size.
Quick functionality overview
The diagram below shows an overview of the things you can do with PDF.
The functionality covered by iText is marked with the following dots:
|Supported by iText|
|Partly supported by iText|
iText's main purpose is to create and manipulate PDF documents.
PdfWriterclass, you can create PDF documents from scratch from a database, an XML file, or any other data source. You can do this in three different ways:
- using high-level objects such as
List, and so on. These objects are often referred to as iText's basic building blocks.
- using low-level functionality. This is done with
PdfContentByte, a class that consists of a series of methods that map to every operator and operand available in Adobe's imaging model. This class also has numerous convenience methods to draw arcs, circles, rectangles and text at absolute positions.
PdfGraphics2Dwhich is iText's implementation of the abstract
Graphics2Dclass in Java (not available in iTextSharp).
iText ships with a plethora of classes that support ecnryption, different image types, color spaces, fonts. There's functionality to enhance the accessibility of the PDF file, support for the integration of Flash apps into the PDF, and so on.
iText can convert an XML or an XHTML/CSS file to PDF (using XML Worker). Converting documents from one format to another is outside the scope of iText. And no: iText does not convert Word documents to PDF!
You always need a
PdfReaderinstance to access an existing document. You can use this reader in combination with
PdfStamperto stamp extra content on the existing PDF document: page numbers, a watermark, annotations, and so on.
PdfStamperis also the class you'll use to fill out interactive forms. iText has almost complete support for AcroForms, but as soon as you have a form involving the XML Forms Architecture, the possibilities are limited.
You can split and merge PDF documents with
PdfCopyFields, and even using
PdfImportedPageobjects in combination with
Converting a PDF document to another format is outside the scope of iText, but you can convert a PDF to XML if the PDF was tagged and contains a structure tree. Depending on how the PDF was created, you can also extract plain text from a page.
iText can also be used to sign existing PDF documents, as well as to encrypt them.
iText isn't a PDF viewer, iText can't convert PDF to an image, nor can iText be used to print a PDF, but the
PdfReaderclass can give you access to the objects that form a PDF document and to the the content stream of each page. This content stream can be parsed and if the content wasn't added as rasterized text, you can convert a page to plain text. Note that iText doesn't do OCR.
Who's using iText?
For those who want to hear more about digital signatures: meet us at the PDF Technical Conference 2013 in Königwinter.published on 2013-04-30
iText 5.4.1 has been released. This release brings new functionality and fixes based on feedback of our customers.published on 2013-04-12
Many people ask me: is EchoSign a competitor of iText with respect to digital signatures? I always answer: no, EchoSign is an iText user and promotes digital signing using iText.published on 2013-03-27
Content © 2010-2013 1T3XT BVBA