Here's a quick bit of code to help you extract data from a PDF with form fields:

Open the PDF:

var pdfReader = new PdfReader(filename);


Read the field names:

var fieldList = GetFormFieldNames(pdfReader);

Read the field names with values:

var fieldList = GetFormFieldNamesWithValues(pdfReader);


The code that does all of the work:

private static string GetFormFieldNames(PdfReader pdfReader)
    return string.Join("\r\n", pdfReader.AcroFields.Fields
                                   .Select(x => x.Key).ToArray());

private static string GetFormFieldNamesWithValues(PdfReader pdfReader)
    return string.Join("\r\n", pdfReader.AcroFields.Fields
                                   .Select(x => x.Key + "=" + 

Both of these methods will return a list of fields and possibly values, each separated by carriage return/line feed so that each field is on it's own line.




only 1 comment untill now

  1. [...] You just finished reading Reading PDF form fields using iTextSharp! Consider leaving a comment!Follow me on Twitter @mitchmilam. Read my new book: Dynamics Deep Dive: [...]

Add your comment now

Sign up for our new KnowledgeBits service and get news, tips and tricks and more, delivered straight to your inbox.