I have a PDF with forms whose values are accessible using iTextSharp 5.5.11's PDFReader.AcroFields.GetField() method. But I can't figure out how to just iterate over the fields and print the keys and values. I've tried the methods mentioned in this question: How do I enumerate all the fields in a PDF file in ITextSharp
...but no dice. I've also tried using an enumerator:
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using iTextSharp.text;
using iTextSharp.text.pdf;
class DoStuff
{
static void Main(string[] args)
{
string fileName = args[0];
PdfReader reader = new PdfReader(fileName);
AcroFields pdfFormFields = reader.AcroFields;
var enumerator = pdfFormFields.Fields.GetEnumerator();
Console.WriteLine(pdfFormFields.Fields.GetType()); // So it's a 'LinkedDictionary', how do I iterate through that and get keys and values?
while (enumerator.MoveNext()) // Evidently not like this...
{
Console.WriteLine("There are fields in the document, but this never prints");
}
}
}
...but that doesn't seem to work either. What's the current way to do this?