Hi, Tilal.
The response you provided does not seem to be the case on my end. I cannot find my Aspose.Total.Net version number, but if you need it, please let me know how to find it.
I have attached a pdf form for you to use to see if you get expected results on your end.
In the attached PDF Form, there are 2 pages. Page 1 has a TextBoxField (Name) and 2 RadioButtonOptionFields (Group1.Choice1 [male] and Group1.Choice2 [female]).
Page 2 also has these same fields, with the same names.
In my version, Form.Fields shows me only 5 fields. 4 are the 4 RadioButtonOptions, and the 5th is the TextBoxField.
Note: As you stated, the Name field appears only once in Form.Fields, even though it has 2 instances (one in Page 1 and the other in Page 2). This is not the case with RadioButtonOptions. Even though they are named identically, each of the 4 instances appears in Form.Fields.
Earlier in a prior report to Aspose, I demonstrated that when a Form.Field has multiple instances (as in our example), the Field.Rect property is erroneous. The reason is because there is no single Field.Rect when there are multiple instances. Which Rect would you use? (This is merely a rhetorical question as the answer is obviously "neither").
What I showed was that Field.Rect is actually returning the smallest containing rectangle of both instances. For example, if Instance 1 had (100,100,200,120) and Instance 2 had (200,50,300,70), Field.Rect would return (100,50, 300,120). This result matches neither of the 2 instances. It is simply the smallest containing rectangle for both instances. You can try this and test for yourself.
So, with this error in mind, I set out to find a way around it. The work-around is to examine the Page.Annotations. Unlike the field, each annotation is its own instance. Not all annotations are fields, however, for every field, there are one or more annotations.
What I did was process each Annotation. For each Annotation of type field, I retrieved its Annotation.Rect. This Rect turned out to be correct since it is the Rect for the specific instance. Then, I searched the FieldCollection for Field.FullName == Annotation.FullName. On that basis, I was able to get the rest of the field information for each annotation - i.e., to match the annotation to its field.
This worked fine to a point. The point where it fails is with RadioButtonOptionFields. Form.Fields shows each of the 4 RadioButtonOptions in the example PDF. However, since the work-around requires processing each annotation for each page, there needs to be a way to get from the radio option's annotation back to its respective RadioButtonOption field.
Look at each Page.Annotation. You will see that each Annotation has Annotation.FullName. This property works fine for the TextBoxes. It does not work for RadioButtonOption. The RadioButtonOptionField has FullName = Group1 and OptionName = Choice1 (or Choice2, as applicable). However, the Annotation only has FullName = Group1. Annotation does not reveal OptionName. Therefore, we are unable to trace the given Annotation to its specific RadioButtonOptionField. So, we were able to obtain the valid rectangle for the given annotation, but we do not know how to tell which field renders in that rectangle. Annotation.Fullname = Group1. There are no other meaningful properties in the Annotation which I could find. How do we tell which RadioButtonOptionField belongs to the given Annotation?
It appears to me that the concept of a "Field" is not well-considered in that it was not designed to take into account that multiple instances of the Field exist in the form. Therefore, properties like Rect, PageIndex are meaningless at this level. How do you give a PageIndex to a field which has instances on both Page 1 and Page 2? (This is also a rhetorical question to emphasize the design flaw). The assignment of either page to the field is arbitrary and inaccurate.
Has the naming been fixed on your end (making my version obsolete)? Or are you seeing the same results/issues as me?
Basically, if I am looking at an Annotation, how do I find out which of the 4 RadioButtonOptions it represents?
Thanks.