var pdfReader = new PdfReader(fileName); var fieldList = GetFormFieldNames(pdfReader); var fieldList2 = GetFormFieldNamesWithValues(pdfReader); 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 + "=" + pdfReader.AcroFields.GetField(x.Key)) .ToArray()); } //I have also tried like this just to display the fields var pdf_filename = @"C:\DownloadTXT\DA9XGWKYB 5001.pdf"; using (var reader = new PdfReader(pdf_filename)) { var fields = reader.AcroFields.Fields; foreach (var key in fields.Keys) { var value = reader.AcroFields.GetField(key); Response.Write(key + " : " + value); } }
PdfReader reader = new PdfReader(src); PdfDictionary root = reader.Catalog; PdfDictionary form = root.GetAsDict(PdfName.ACROFORM); PdfArray fields = form.GetAsArray(PdfName.FIELDS); PdfDictionary page; PdfArray annots; for (int i = 1; i <= reader.NumberOfPages; i++) { page = reader.GetPageN(i); annots = page.GetAsArray(PdfName.ANNOTS); for (int j = 0; j < annots.Size; j++) { fields.Add(annots.GetAsIndirectObject(j)); } } PdfStamper stamper = new PdfStamper(reader, new FileStream(dest, FileMode.Create)); stamper.Close(); reader.Close();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)