How to populate the iTextSharp radio button

I have a group of radio stations that I am trying to populate using the library iTextSharp. When I opened the PDF in iText RUPS, I see the following:

enter image description here

Here's how to do it in a PDF file:

enter image description here

I have the following code that should fill in either the MALE or FEMALE switch:

if (reader.GetValue(4).ToString() == "M")
                        {
                            pdfFormFields.SetField("SEXpg2", "Yes");
                        }
                        else
                        {
                            pdfFormFields.SetField("SEXpg2", "Yes");
                        }

When I run the PDF form, no radio is populated. How can I change the code in the screenshot so that it fills any radio station based on the gender column from the SQL query?

I tried the following, but that did not work:

if (reader.GetValue(4).ToString() == "M")
                        {
                            pdfFormFields.SetField("MALEpg2", "Yes");
                        }
                        else
                        {
                            pdfFormFields.SetField("FEMALEpg2", "Yes");
                        }
+4
source share
1 answer

+1 to use iText RUPS!

You must be able to:

pdfFormFields.SetField("SEXpg2", "MALEpg2");

and

pdfFormFields.SetField("SEXpg2", "FEMALEpg2");
+3
source

Source: https://habr.com/ru/post/1548128/


All Articles