Retrieve form fields and their values from PDF in C# using Aspose.PDF for .NET

I have downloaded your library but couldn’t get the required functionality. Our requirements is to add the text fields on PDF templates and later on get the name of the field and pass data to template and generate the PDF.

Can you please advice if you have similar functionality.

@Tauqerr,

Can you please share desired result in form of sample so that we may further investigate to help you out.

We need to read all the form field from pdf file including text items, Listbox and radio options and store the result in the JSON format. For exampleimages (8).jpeg (8.7 KB)

[{ “FieldName” : “Value”,
“FieldType” : “Textbox”,
“Fieldvalue” : “”
},
{ “FieldName” : “Gender”,
“FieldType” : “ListBox”,
“Fieldvalue” : {“Male”,“Female” }
},
{ “FieldName” : “Language”,
“FieldType” : “CheckBox”,
“Fieldvalue” : {“Deutch”,“English”,“Français” ,“Latin”}
},

and so on.

@Tauqerr

You may please use following code snippet to read form fields and their values;

Document pdfDocument = new Document(dataDir + "Dropdowns and Images.pdf");
//get values from all fields
foreach (Field formField in pdfDocument.Form.Fields)
{
 var value = formField.Value;
 var name = formField.FullName;
 var type = formField.AnnotationType;
}

In case you face any difficulty while reading the form fields, please share your sample PDF document with us. We will test the scenario in our environment and address it accordingly.