Create Simple PDF using iText

iText provides flexible ways for creation and manipulation of PDF files. We will start with steps on how to create simple PDF using itext with some examples.


Setup can be done by adding Maven dependency.
Add the below dependency into your pom.xml

Or you can directly download the latest itext jar and add it to your class path. Download from maven – iText download

Example on how to create simple PDF using iText

Important classes used are
a) com.itextpdf.text.Document
b) com.itextpdf.text.pdf.PdfWriter

Create a object of the Document class. Create a PdfWriter instance and use the document for writing the pdf to a specified location. For writing into the Pdf, you need to first open the document and then use the add() method. Once writing is done close() the document.


Create Simple PDF using iText

In our next few posts we will see some more examples on iText.


1. iText developers guide