Let's say I've loaded a PDF file using iTextSharp:
PdfStamper p = GetDocument();
AcroFields af = ps.AcroFields;
How do I get a list of all field names on the document from af
?
AcroFields af = ps.AcroFields;
foreach (var field in af.Fields)
{
Console.WriteLine("{0}, {1}",
field.Key,
field.Value);
}
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With