Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fill in radio button with iTextSharp

I have a radio group which I am trying to fill using iTextSharp library. When I opened the PDF in iText RUPS I see the following:

enter image description here

This is how it is in the PDF file:

enter image description here

I have the following code-behind which is supposed to populate either MALE or FEMALE radio button:

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

When I run the PDF form, none of the radio is populated. How can I modify the code from the screenshot so it populates either radio based on the gender column from the sql query?

I tried the following but that didn't work:

if (reader.GetValue(4).ToString() == "M")
                        {
                            pdfFormFields.SetField("MALEpg2", "Yes");
                        }
                        else
                        {
                            pdfFormFields.SetField("FEMALEpg2", "Yes");
                        }
like image 466
Si8 Avatar asked Sep 30 '22 08:09

Si8


1 Answers

+1 for using iText RUPS!

You should be able to do:

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

and

pdfFormFields.SetField("SEXpg2", "FEMALEpg2");
like image 74
Chris Haas Avatar answered Oct 18 '22 13:10

Chris Haas