Free Support Forum -

Field exists but can't access it (.NET)


I’d like to read a value of text from a textfield. When I try to access it I get an exception:

var field = document.Form["textField"];

To be sure that the field exists I tried to iterate it:

foreach (var field in document.Form.Fields)
    ... field.Name

The expected field exists. But when I access it by name the exception comes:

foreach (var field in document.Form.Fields)
    var field = document.Form[field.Name];

The strange thing is when I try to access with LINQ everything is fine:

TextBoxField textField = document.Form.Fields.ToList().FirstOrDefault(f => f.Name.Equals("textField")) as TextBoxField;

What do I wrong?

Best regards,


Thanks for contacting support.

Would you please share your sample PDF document along with the exception and stack trace you are getting, while accessing the form field. We will test the scenario in our environment and address it accordingly.