If you look at PDF creation, you'll find two different approaches:
These different approaches demand different software products.
The same goes for PDF manipulation.
iText is a tool that focuses on the automation side of things.
iText is an SDK that was developed to allow developers to do the following (and much more):
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.
Typically, iText is used in projects that have one of the following requirements:
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, to comply with specific industry standards (such as PAdES, PDF/A, or PDF/UA), or to reduce the file size.
Version | First release | Latest release | End-of-Life |
---|---|---|---|
0.30 - 0.99 | 2000-02-14 | 2003-05-01 | 2005-12-31 |
1.00 - 1.4.8 | 2003-06-25 | 2006-12-19 | 2009-12-31 |
2.00 - 2.1.7 | 2003-02-15 | 2009-07-07 | 2012-12-31 |
5.0.0 - 5.5.11 | 2009-12-07 | 2017-03-20 | 2018-12-31 |
7.0.0 - ... | 2016-05-03 | ... | 2025-12-31 |
This is a very simple program to create a PDF using iText 7 / Java:
//Initialize writer
PdfWriter writer = new PdfWriter(dest);
//Initialize document
PdfDocument pdfDoc = new PdfDocument(writer);
Document doc = new Document(pdfDoc);
//Add paragraph to the document
doc.add(new Paragraph("Hello World!"));
//Close document
doc.close();
(Listing_01_01_HelloWorld.java)
You can navigate to many other examples from that page.
And this is a very simple program to create a PDF using the precursor iText 5.5.x / Java:
// step 1
Document document = new Document();
// step 2
PdfWriter.getInstance(document, new FileOutputStream(filename));
// step 3
document.open();
// step 4
document.add(new Paragraph("Hello World!"));
// step 5
document.close();
There are many more examples to navigate from this page, too.
These two examples look pretty similar. The advantages of the re-designed iText 7 API will become apparent, though, as soon as one starts to look closer at less trivial examples. Thus, simply navigate through the example source code from the links above and compare.
Importing the iText jars from the Central Maven Repository is the best way to install iText 7. These simple videos explain how to do this using different IDEs:
In these tutorials, we only define the kernel
and the layout
projects as dependencies. Maven also automatically imports the io
jar because the kernel
packages depend on the io
packages.
This is the basic list of dependencies for standard use of iText 7:
<dependencies>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>kernel</artifactId>
<version>7.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>io</artifactId>
<version>7.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>layout</artifactId>
<version>7.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>forms</artifactId>
<version>7.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>pdfa</artifactId>
<version>7.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>pdftest</artifactId>
<version>7.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.18</version>
</dependency>
</dependencies>
Every dependency corresponds with a jar in Java and with a DLL in C#.
kernel
and io
: contain low-level functionality.layout
: contains high-level functionality.forms
: needed for all the AcroForm examples.pdfa
: needed for PDF/A-specific functionality.pdftest
: needed for the examples that are also a test.For more specific use of iText 7, you may need additional jars:
barcodes
: use this if you want to create bar codes.hyph
: use this if you want text to be hyphenated.font-asian
: use this is you need CJK functionality (Chinese / Japanese / Korean)sign
: use this if you need support for digital signatures.All the jars listed above are available under the AGPL license. You can also download these jars in a ZIP-file hosted on Github: https://github.com/itext/itext7/releases
If you want to use these jars, you have to add them to your CLASSPATH, just like you would add any other jar.
Additional iText 7 functionality is available through add-ons, which are delivered as jars under a commercial license. If you want to use any of these add-ons, or if you want to use iText 7 with your proprietary code, you need to obtain a commercial license key for iText 7 (see the legal section of the iText web site).
You can import such a license key using the license-key module. You can get the license-key jar like this:
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext-licensekey</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
Some functionality in iText is closed source. For instance, if you want to use PdfCalligraph, you need the typography
module. This module won't work without an official license key.
You can download a ZIP-file containing all the DLLs that are available under the AGPL. For more info about these DLLs, please read the Java documentation.