i want a simple code to be able to list all the PDF Forms fields and display their value (content). The attached code works for most of the fields but not for all of them.. i suspect that it doesn't work for the RichText AcroFileds. i'll be happy to know how to do it with iTextSharp.
private static void ListFieldNames(string pdfPath) {
// create a writer and open the file
TextWriter tw = new StreamWriter("PDF_fields.txt");
// create a new PDF reader based on the PDF template document
PdfReader pdfReader = new PdfReader(pdfPath);
MemoryStream stream = new MemoryStream();
// then create a PdfStamper from the created reader to modify the form fields
PdfStamper outStamper = new PdfStamper(pdfReader, stream);
AcroFields lcForm = outStamper.AcroFields;
String outST = "";
foreach (string key in lcForm.Fields.Keys)
{
outST += key + "---" + lcForm.GetField(key) + Environment.NewLine;
}
// write a line of text to the file
tw.WriteLine(outST);
}