gettinig PDF form field names

If you have a PDF and want to fill the pdf programmatic-ally, You can but you need those pdf’s form fields.

Here’s a simple Java Class which can help you. I am using iText as my PDF library.

import java.util.HashMap;
import java.util.Iterator;
import com.lowagie.text.pdf.*;

public class iTextSample {
public static void main(String[] args) throws Exception{
PdfReader reader = new PdfReader(“/Users/Admin/Public/jars/a.pdf”);
boolean test = reader.isEncrypted();


AcroFields form = reader.getAcroFields();
HashMap fields = form.getFields();
System.out.println(“Total Fields: ” + fields.size());
String key;
for (Iterator i = fields.keySet().iterator(); i.hasNext(); ) {
key = (String);
switch(form.getFieldType(key)) {

case AcroFields.FIELD_TYPE_TEXT:
System.out.print(key + “: “);
System.out.print(“, At Page:” + form.getFieldItem(key).getPage(0));
System.out.println(“, at tab:” + form.getFieldItem(key).getTabOrder(0));


Join the Conversation


  1. Pingback: Shadow
  2. Pingback: Sergey
  3. hello there, i just discovered your blog via yahoo, and i must tell that you compose exceptionally good via your blog. i am actually taken by the mode that you compose, and the content is excellent. anyway, i would also love to know whether you would love to exchange links with my web portal? i will be to the great extent than willing to reciprocate and insert your link off in the link section. looking for your reply, i give my sincere thanks and gooday!

Leave a comment

Your email address will not be published. Required fields are marked *