Thursday, February 13, 2014

Reading fillable PDF form using iText APIs

 To follow this example you need to download itext libraries. You can do it from


import com.itextpdf.text.pdf.AcroFields;
import com.itextpdf.text.pdf.PdfReader;


import java.util.Set;

public class PDFUtil {
    public PDFUtil() {
    public static void main(String[] args) {
        String src = "D:\\Doc\\Filled_PDF_Form.pdf";
        PdfReader reader;
        try {
            reader = new PdfReader(src);
            AcroFields fields= reader.getAcroFields();
            Set<String> fieldKeys = fields.getFields().keySet();
            for(String itemKey : fieldKeys){
                System.out.println(itemKey + ": " + fields.getField(itemKey));
        } catch (IOException e) {
            System.out.println("IO Exception");


This program will show key value pair of each field. For example

key1: value1
key2: value2


NOTE: Before using iText libraries I would recommend to read  iText-licensing and pricing information.

Disclaimer: Any views or opinions presented in this blog are solely those of the author and do not necessarily represent those of the company.

No comments: