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

Free Support Forum - aspose.com

PDF Checkbox

Hi,


I am programatically trying to turn a check box on in this document with our success.

The field in question is Line2a_ICE[0]

the code I am using goes like this. I have tries on, true etc to no avial.


foreach (Aspose.Pdf.InteractiveFeatures.Forms.Field fld in pdfDocument.Form.Fields) {

if (fld.GetType() == typeof(Aspose.Pdf.InteractiveFeatures.Forms.CheckboxField)) {
pdfForm.FillField(fld.PartialName, true);
}
}

Can you please help?

Hi Bruce,


Thanks for your inquiry. After initial investigation we have logged a ticket PDFNEWNET-36066 for further investigation and rectification. We will notify you as soon as we resolve the issue.

We are sorry for the inconvenience caused.

Best Regards,

Hi Bruce,


Thanks for your patience. Please note CheckBox field in XFA has child node items which contains possible values for the field. You can obtain these valuse 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);

XmlNodeList items = tmpl.SelectNodes("tpl:items/*", doc.Form.XFA.NamespaceManager);

List<string> res = new List<string>();

foreach (XmlNode item in items)

{

res.Add(item.InnerText);

}

return res;

}

Document doc = new Document("BCTR Main.pdf");

List<string> items = GetCheckBoxValues(doc, "BSAForm[0].Header[0].TypeOfFiling[0].initialReport[0]");

doc.Form.XFA["BSAForm[0].Header[0].TypeOfFiling[0].initialReport[0]"] = items[0];

doc.Save("result.pdf");


Please feel free to contact us for any further assistance.

Best Regards,