itextPdf Creation: iText 5 versus iText 7


Remarks

In the original design for iText, it was possible to create a high-level Document object, and then have different DocListener objects listening to that Document object. This was achieved by using different writers: a PdfWriter, an HTMLWriter, and an RtfWriter. When using a PdfWriter, a PdfDocument was created internally. This low-level class took care of all PDF-related structures. More or less the same was true for the other formats.

Over the years, iText specialized and it became a pure PDF library. The creation of HTML and RTF was abandoned, hence it was no longer necessary to create a Document before creating a PdfWriter, but we had to stick to the original architecture because we weren't ready to break the API.

Over the years, we added more and more PDF functionality to iText, and the fact that PdfDocument was a class for internal use only became problematic. We used workarounds so that we could introduce new PDF features that belonged in the PdfDocument class up until the point that we reached the ceiling of what we considered acceptable as workarounds.

That's when we decided to rewrite iText from scratch and to create a completely new architecture for iText. Now we have a clear distinction between the PdfDocument (for low-level operations) and the Document (for high-level functionality). We no longer have to open the document, and if we use the try-with-resources approach, we don't even have to close it ourselves.

Want to know more? Get the free ebook!