|
Rank: Newbie Groups: Member
Joined: 3/6/2014 Posts: 3
|
I have a radio button group in a form called "Reduction in Employees Exceed 10% during past/upcoming 12 months?" One choice is "Yes - Question 3" and the other choice is "No - Question 3". I'm unable to get my code working so that it selects the proper radio button. Here are some code snippets I have tried: the following code compiles, but leave the radio button unchecked
Code: C#
field = doc.Fields["Reduction in Employees Exceed 10% during past/upcoming 12 months?"]
field.Value = "Yes - Question 3";
The following code results in an exception - Unable to cast object of type 'EO.Pdf.PdfGenericField' to type 'EO.Pdf.PdfRadioButtonField'.
Code: C#
field = doc.Fields["Reduction in Employees Exceed 10% during past/upcoming 12 months?"];
((EO.Pdf.PdfRadioButtonField)field).SelectedIndex = 0;
I wasn't able to figure out anything else from reading the documentation. What am I missing? Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
Your second method is the correct way to do it. However you will need to find the correct PdfRadioButtonField first. doc.Fields indexer takes the field name, not the field text (it's possible that the author of the file just use the field text as field name though). In any case, you will want to examine doc.Fields collection with an debugger so that you can see all the fields in the document and their name. Note that each fields can have children fields. So your PdfRadioButtonField can be a child of your "Reduction in Employees ..." field. So you will want to search each field's Children collection recursively.
Once you find the right PdfRadioButtonField, you would use SelectedIndex to check the item.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/6/2014 Posts: 3
|
The field index/name is correct. As far as I can tell, the problem is that your library gives this field a type of "PdfGenericField" and it's not allowing me to cast it to PdfRadioButtonField. I wrote some code walks through all the form fields and prints their name and type: Quote: Name of Applicant - EO.Pdf.PdfTextField Voluntary Employee Terminations - EO.Pdf.PdfTextField Involuntary Employee Terminations - EO.Pdf.PdfTextField Employee Layoffs - EO.Pdf.PdfTextField Reduction in Employees Exceed 10% during past/upcoming 12 months? - EO.Pdf.PdfGenericField Child Level 1: - EO.Pdf.PdfRadioButtonOption Child Level 1: - EO.Pdf.PdfRadioButtonOption Voluntary Employee Reduction - EO.Pdf.PdfTextField Involuntary Employee Reduction - EO.Pdf.PdfTextField Reduction via Layoff - EO.Pdf.PdfTextField Use of Employment App for Every Prospective Employee? - EO.Pdf.PdfGenericField Child Level 1: - EO.Pdf.PdfRadioButtonOption Child Level 1: - EO.Pdf.PdfRadioButtonOption Policy Against Unlawful Discrimination/Harassment? - EO.Pdf.PdfGenericField Child Level 1: - EO.Pdf.PdfRadioButtonOption Child Level 1: - EO.Pdf.PdfRadioButtonOption Consult with Outside Counsel Before Adverse Action Against Employee? - EO.Pdf.PdfGenericField Child Level 1: - EO.Pdf.PdfRadioButtonOption Child Level 1: - EO.Pdf.PdfRadioButtonOption Policies/Procedures for Employee Conduct? - EO.Pdf.PdfGenericField Child Level 1: - EO.Pdf.PdfRadioButtonOption Child Level 1: - EO.Pdf.PdfRadioButtonOption Policies/Procedures for Responding to Complaints? - EO.Pdf.PdfGenericField Child Level 1: - EO.Pdf.PdfRadioButtonOption Child Level 1: - EO.Pdf.PdfRadioButtonOption No Warranty Information Exceptions - EO.Pdf.PdfCheckBoxField No Claims, Suits or Demands - EO.Pdf.PdfCheckBoxField _es_:signer1:fullname - EO.Pdf.PdfTextField _es_:signer1:title - EO.Pdf.PdfTextField _es_:signer1:signature - EO.Pdf.PdfTextField _es_:signer1:date - EO.Pdf.PdfTextField
So, the top-level field is reported as "PdfGenericField" but its children are PdfRadioButtonOption (with an empty string for a name). I am willing to email you the PDF file in question if that would help? Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Sure. Please send us the PDF file and we will look into it. We will PM you as to where to send the PDF file.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/6/2014 Posts: 3
|
Sent the file...thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Thank you very much for the file. We have found the root of the problem and will post a new build with the fix very soon. We will post again when the new build is posted.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
We have posted a new build that should fix this problem. You can download the new build from our download page.
Thanks!
|
|