I am able to update the text fields but facing issues in updating the checkboxes in the first form in attached document. Its been a struggle from days. please guide me on this.
I have tried something like
string[] names = doc.Form.XFA.FieldNames;
//set field values
doc.Form.XFA[names[13]] = “Off”;
tried this also, seems the field tracking is wrong
pdfForm.FillField(“form1[0].name[13]”, “Off”);
Thanks.
Hi there,
List<string> GetCheckBoxValues(Document doc, string fieldName)<o:p></o:p>
{<o:p></o:p>
XmlNode tmpl = doc.Form.XFA.GetFieldTemplate(fieldName);<o:p></o:p>
XmlNodeList items = tmpl.SelectNodes(“tpl:items/*”, doc.Form.XFA.NamespaceManager);<o:p></o:p>
List<string> res = new List<string>();<o:p></o:p>
foreach (XmlNode item in items)<o:p></o:p>
{<o:p></o:p>
res.Add(item.InnerText);<o:p></o:p>
}<o:p></o:p>
return res;<o:p></o:p>
}<o:p></o:p>
<o:p> </o:p>
Document doc = new Document(“g-28.pdf”);<o:p></o:p>
List<string> items = GetCheckBoxValues(doc, “form1[0].#subform[0].Line4_Checkbox[0]”);<o:p></o:p>
doc.Form.XFA[“form1[0].#subform[0].Line4_Checkbox[0]”] = items[0];<o:p></o:p>
doc.Save(“result.pdf”);<o:p></o:p>
<o:p> </o:p>
Please feel free to contact us for any further assistance.
Thank you very much. This is what I need.
Hi,
In continuation to my above query, there are other checkboxes which are in group, they are no working if I use same logic which you have shared
List items1 = GetCheckBoxValues(doc, “form1[0].#subform[0].Line3b_Unit[2]”);
doc.Form.XFA[“form1[0].#subform[0].Line3b_Unit[2]”] = items1[0];
I wanted to check the “Petitioner” checkbox option, below is the logic I tried-didn’t work, where as if I select the “applicant” checkbox option it is working
List items = GetCheckBoxValues(doc, “form1[0].#subform[0].Line4_Checkbox[2]”);
doc.Form.XFA[“form1[0].#subform[0].Line4_Checkbox[2]”] = items[0];
Thanks for the support.
Hi there,
…
List<string> items = GetCheckBoxValues(doc, "form1[0].#subform[0].Line4_Checkbox[2]");
doc.Form.XFA["form1[0].#subform[0].Line4_Checkbox[0]"] = items[0];
//List items = GetCheckBoxValues(doc, "form1[0].#subform[0].Line3b_Unit[2]");
//doc.Form.XFA["form1[0].#subform[0].Line3b_Unit[0]"] = items[0];
//List items = GetCheckBoxValues(doc, "form1[0].#subform[1].Line12b_Unit[2]");
//doc.Form.XFA["form1[0].#subform[1].Line12b_Unit[0]"] = items[0];
.....
Hi ,
I have tried same approach to check the checkbox but I am not able to see the checked checkbox
after saving document.
What can be the reason?
Thanks,
Vinod
Kindly send us your source PDF document and code. We will investigate and share our findings with you.