On the AcroFroms I am using with saved default values, the initial value of the /V key on the Opt element of a RadioButton is the index of the value selected. The following line of code from line 61 of PdfRadioButtonFiled initially returns the slashed index value of the set item value from the opt.Elements array.
Code:
string value = Elements.GetString(Keys.V);
Therefore when IndexInOptStrings(value) - (see code in original post) is called on line 62, it is actually passing the value in that it should be returning. However, the IndexInOptStrings() method iterates through the array of opt.Elements which are the the actual values (not the indexes). Consequently, It does not find a match unless the opt.Elements array happens to include integer values and one of them is the same as the index value passed in.
Note: if the values of radio button options are not set, they appear to default to numbers starting with 1. Therefore in this case, the index returned is off by one as long as the value being sought is greater then 0 and within the array of opt.Elements. (see the example after the +++'s below)
In the PDF definition, has the value saved in the /V key ever been the set value associated with the selected option button or has it always been the index value of that set value?
As an example, my radio buttons have three date choices: June 26, July 10 and July 17. The opt.Elemnts array looks like the following:
0 "June 26"
1 "July 10"
2 "July 17" <= this is the defaulted value.
Upon initial entry into the document being processed by PDFSharp, the key /V value for this radio button group is "/2".
As the code currently is, executing the following line of code returns a -1 because "/2" is not found in the array of item values "June 26", "July 10", "July 17"
The fix is obvious to me but, I do not know if all AcroFroms store the key /V as the index versus the set item value. In my above example the question would be do any AcroForms store "July 17" versus "/2" as the value of key /V?
+++++++++++
If I had not set the values of each of the options in the radio button group, the opt.Elemnts array would look like the following:
0 "1"
1 "2"
2 "3"
In this case, the value at index 1 would have matched the value saved in the /V key however, it would be errouneous as the actual defaulted value should have been the value "3" found at the index value of 2.