How to get RadioButton index from Annot

Product: PdfTron.Net.x64

Product Version: 10.10.0

Please give a brief summary of your issue:
I don’t know how to get RadioButton Index from an Annot

Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)
I have a Pdf with 3 page.
On this Pdf there is a RadioGroup with 3 RadioButtons.
Every page contains 1 RadioButton.
The RadioButtons order is not equale to the page order.
So if I call RadioButtonGroup.GetButton(1), I get the RadioButton on the 3rd page.

While I’m iterating all the pages of a Pdf like said in this ticket
https://community.apryse.com/t/cannot-get-acrofieldpage/10421
I get one Annot per page, I can check that

annot.GetType() == Annot.Type.e_Widget

I can get the field and check its type

Field field = new Widget(annot).GetField();
bool isRadio = field.GetType() == Type.e_radio;

Is there a safe way to get the RadioButton index?

Please provide a link to a minimal sample where the issue is reproducible:
m29_l1.pdf (1.2 MB)

P.S. Incorrectly marked as spam

Hi,

Thanks for reaching out to us.

The behavior you are seeing is happening due to how the buttons were encoded within the PDF. When you are calling RadioButtonGroup.GetButton(1), the SDK is returning the second indexed button in the array which in this case is not on page 1. For this PDF, the 0th place is page 2, 1 is page 3, and 2 is page 1. This listing is working as intended and GetButton() is returning correctly in this test case.

Examining your PDF shows that you have a single annotation of type Widget on each page. You can look into referencing your annotations differently. When iterating between annotations present in a PDF file, you’ll generally want to load a page and in your case then look for the widget annotation present on the page. This is because the annotation is saved within that single page.

You can use our sample as reference to this
Annot annot = page.GetAnnot(i);
annot.GetType();
Annotationtest | Apryse Documentation

Since you know that the annotation is saved per page, you can use this fundamental knowledge to help in referencing them. With each subsequent annotation that is added on a page, the index you can use to reference them using GetAnnot() is increased by 1:
Class Page

In summary, you can leverage GetAnnot() and search each page individually through a loop to reliably get access to your Widget annotations.