Skip to main content
Skip table of contents

How can I find code examples for specific iText versions or releases?

One of the great things about iText is the wealth of resources on the Internet. Whether you’re using traditional search methods, trawling through Stack Overflow, or asking AI chatbots how to do something with iText, you’re guaranteed to find plenty of information and helpful code examples for whatever you’re trying to achieve.

However, due to the API differences in each major version of iText—particularly since we completely rewrote the codebase after iText 5—it might be tricky to find an up-to-date code sample, or one for the version of iText you’re using.

There is a solution though. In addition to the repositories for iText Core and the open-source add-ons or related projects on GitHub, we have dedicated repositories for examples showcasing a wide range of iText functionalities. If we introduce new functionality, we also write new examples to demonstrate how it works.

It’s important to note that as part of our standardized release procedures, these examples are constantly tested to maintain compatibility with each release. If we introduce new APIs or deprecate old ones, the code samples are regularly updated to use the latest features.

Whether you’re looking for examples for the latest iText releases, or examples compatible with specific releases, here are some tips on navigating GitHub to find what you need.

Switching between branches

If you’re browsing one of our GitHub repositories, the develop branch is default and contains changes to be merged for the upcoming release. If you change the branch to master, it will display code which is tied to the latest release.

Using Tags for specific releases

Alternatively, you can access the Tags tab as shown below to see a list of tags for every quarterly release of iText. Using these, you can see what a code sample looked like at an earlier point in time.

A screenshot of an iText example repository, showing a list of release tags

The Wtpdf.java example shown here contains PDF/UA API updates

For instance the Wtpdf.java example was updated to take advantage of the PDF/UA improvements in iText Core 9.2.0. If you’re using iText Core 9.0.0, these new APIs did not exist, so you’ll want a version without these improvements. By selecting the tag for 9.0.0, you’ll get he version of the code sample tested with that release.

A screenshot of of the Wtpdf.java example tied to the release of iText Core 9.0.0

The Wtpdf.java example at the time of the iText Core 9.0.0 release

If you want local copies of all code samples in a repository, you can use tags to do this too. From the root folder of the repository (for example itext/itext-publications-examples-java), clicking Tags will display a list of release tags and commits, along with zip and tar.gz archives.

These archives contain the entire contents of the repository, including all resources (fonts, HTML, etc.) required by each example.

What kind of examples can I find on GitHub?

Java

The README in itext/itext-java has shortcuts to a selection of helpful examples showing commonly-used iText functionality.

You can find the majority of our code samples in itext/itext-publications-examples-java. In sandbox you’ll find examples for a wide range of use cases, and htmlsamples contains the examples referenced in iText: Converting HTML to PDF with pdfHTML.

In addition, we have the following repositories:

itext/itext-publications-jumpstart-java

  • This contains the examples referenced in iText: Jump-Start Tutorial for Java. They provide a quick overview of basic iText functionalities, helping new users get started with PDF creation and manipulation.

itext/itext-publications-highlevel-java

  • This repository includes the examples referenced in iText: Building Blocks. These demonstrate how to use iText’s high-level building blocks for creating and manipulating PDF documents.

itext/itext-publications-book-java

  • Examples from the book "iText in Action - Second Edition". The original iText 5 examples were ported to iText 7 and later versions, and cover a wide range of PDF functionalities.

itext/itext-publications-signing-examples-java

itext/itext-publications-signatures-java

.NET

The README in itext/itext-dotnet has shortcuts to a selection of helpful examples showing commonly-used iText functionality.

itext/itext-publications-samples-dotnet

  • This repository contains all C# ports of the samples from the Java repositories listed above.

By referring to these resources, you can be sure you have access to the latest and greatest iText code samples—or not, if you prefer.

Happy coding!

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.