itext Forms: iText 5 vs iText 7


iText 5 is a library that has grown organically. Many developers contributed code. For instance: one developer contributed code to create form fields from scratch, using classes such as TextField and PdfFormField; another developer contributed code to change existing form fields, using the AcroField class and a series of setFieldProperty() methods.

In iText 5, the classes used to create form fields cannot be used to change form fields, and vice-versa. There is no relationship whatsoever between the two sets of classes. That's confusing for many users. For instance: some users discover the TextField class, and assume they can use that class to change the properties of an existing text field. This isn't the case, they need to use the AcroFields class instead.

All of this is fixed in iText 7. We created a new set of classes such as PdfFormField and its subclass PdfTextField that can be used to create a new field, as well as to update an existing form field.

The iText 7 form field methods can be chained to make your code more compact, and they are much more intuitive than the corresponding methods in iText 5. Making the form functionality more elegant was one of the key reasons to rewrite iText from scratch.