We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Index was out of range.

This is what I currently have...

private PDFDocument _document;
_document = new PDFDocument("Something.pdf");
foreach (IPDFField field in _document.Form.Fields)
{
_PDFControls.Add(field.Name);
if(((IPDFLoadedField)_document.Form.Fields[field.Name]).Type == PDFFieldTypeEnum.Signature)
_PDFSignableControls.Add(field.Name);
}


When I pause the debugger at the if statement, I get no problem seeing what is in _document.Form.Fields[0]... The fields name is "SignatureFieldEmployee[0]"... but when I try to find out what _document.Form.Fields["SignatureFieldEmployee[0]"] I get the following error:

"Index was out of range. Must be a non-negative and less than the size of the colleciton. Parameter name: index"

Why can i find the field by using and integral indexer, but not the name of the field? I have been using the name of the field 5-10 times in other places in my code...

1 Reply

DK Dhivya K Syncfusion Team January 10, 2007 01:22 PM UTC

Hi Miles,

I agree that when you can get/set values for the field index, it should be possible to read values from the field names too. I tried testing this issue with the files that you have provided me in Direct trac and was not able to reproduce the issue with those files.
I did the following:
1. Fixed a break point at the "if" statement
2. Added watch and found the properties of the signature field both with its index and with its name. Both displays the properties.
Could you please let me know if I have done something wrong or provide me a sample to reproduce the issue? So that I can investigate further on this issue.

Thanks,
Dhivya.

Loader.
Live Chat Icon For mobile
Up arrow icon