Triggering an event in XFA form from C#

Hello everyone,

I have an XFA form. I can successfully populate fields from my C# code, but there are some checkboxes, which seem to have attached events, which show or hide certain fields when clicked.

I can populate those checkbox values too, but in the filled form hidden fields are not showing.

Is there any way to programmatically trigger an event, associated with the checkbox?

Thanks
Archie

@agogava

Could you please share your sample source PDF document along with the code snippet you are using to populate the form fields? We will further investigate the scenario and share our feedback with you.

Hello Asad,

I placed the template at

[https://office.argosoft.com/Shared/aoi.pdf]

Code looks like this:

 private void button6_Click(object sender, EventArgs e)
        {
            try
            {
                string fileName = "c:\\temp\\aoi.pdf";
                Aspose.Pdf.Document doc = new Document(fileName);
                string[] names = doc.Form.XFA.FieldNames;
                doc.Form.XFA[names[83]] = "1";
                doc.Save("c:\\temp\\out.pdf");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

Field 83 is a checkbox on page 1, section 4, Address. Checking the Standard Address checkbox should be causing certain additional fields to appear. That’s what happens if you check it manually, but it does not happen when we do it using the code above.

Thanks in advance
Archie

@agogava

We were able to replicate the similar issue in our environment. Therefore, have logged it as PDFNET-50611 in our issue management system for the sake of correction. We will further check it in detail and let you know as soon as it is fixed. Please be patient and spare us some time.

We are sorry for the inconvenience.

1 Like