How to list all fields in a PDF file in ITextSharp

Say I uploaded a PDF using iTextSharp:

PdfStamper p = GetDocument(); AcroFields af = ps.AcroFields; 

How to get a list of all field names in a document from af ?

+7
c # pdf itextsharp
source share
4 answers
 AcroFields af = ps.AcroFields; foreach (var field in af.Fields) { Console.WriteLine("{0}, {1}", field.Key, field.Value); } 
+10
source share
 PdfReader pdfReader = new PdfReader("c:\\ABC.pdf"); string TempFilename = Path.GetTempFileName(); AcroFields pdfFormFields = pdfReader.AcroFields; foreach (KeyValuePair<string, AcroFields.Item> kvp in pdfFormFields.Fields) { string fieldName = kvp.Key.ToString(); string fieldValue = pdfFormFields.GetField(kvp.Key.ToString()); Console.WriteLine(fieldName + " " + fieldValue); } pdfReader.Close(); 
+8
source share
 foreach (DictionaryEntry entry in af.Fields) { Console.WriteLine(entry.Key +" " +entry.Value); } 
+2
source share

It can only be me, but I do not get it.

 foreach (var field in af.Fields) { Console.WriteLine(field.Key +" "+ af.GetField(field.Key)); } 
+1
source share

All Articles