We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Unable to check the checkbox

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”);


Hi there,

Thanks for your query. Please note CheckBox field in XFA has child node items which contains possible values for the field. You can obtain these values and set one of these values as following.

List<string> GetCheckBoxValues(Document doc, string fieldName)<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>




return res;<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>


<o:p> </o:p>

Please feel free to contact us for any further assistance.

Best Regards,

Thank you very much. This is what I need.


Thanks for the acknowledgement.

We are glad to hear that your requirement is accomplished. Please continue using our API and in the event of any further query, please feel free to contact.

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,

Thanks for your inquriy. Please note in checkbox group you need to assign value to first checkbox, it will check appropriate checkbox accordingly. Please check following code snippet, it will help you to accomplish the task.

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];


Please feel free to contact us for any further assistance.

Best Regards,

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?



Kindly send us your source PDF document and code. We will investigate and share our findings with you.