Cannot check checkbutton in XFA form

I have an XFA form with checkbutton groups. These groups are such that they act like radio groups, where you can also return no “no selection”. Using Adobe Reader, I can select and deselect each button, but when I attempt to set the button as “checked” via the API, the group shows as if no button has been selected.

@BradenC

Would you please share your sample PDF document along with sample code snippet that you are trying to set the value of radio button. We will test the scenario in our environment and address it accordingly.

Hello, I’m facing a similar problem. I have an XFA form with groups of checkboxes, and I cannot check them using this API. I believe the issue to be something related to the checkboxes having some data binding or JS tied to them that is causing trouble. I found this thread and tried the ImportXML method mentioned in your Nov '20 comment to no avail.

I used ExportXml() and discovered that the underlying data structure seems to be a string that is the id of the selected button repeated for the length of the buttons group. e.g. for a group where the second of three buttons is selected, the xml would contain <myGroup>222</myGroup>. However, when I edit this group by hand and import, the result is that no checkbutton is selected.

Can someone here please help me out with this?

@BradenC

Would you please share your sample PDF document along with the sample code snippet that you are trying to set the value of the radio button? We will test the scenario in our environment and address it accordingly.

Hey, thanks for stopping by.

The PDF in question is https://www.fsrao.ca/industry/mortgage-brokering-sector/mortgage-brokering-forms/mf-007.

The problematic check buttons are the last question of section 3, first question of section 4, and the large selection of buttons on page 29.

I tried a variety of code snippets. For Importing, I was building code based off of a comment from Filling a Dynamic XFA from XML using Aspose.PDF for .NET - Import XML data to XFA form - #9 by patrick08, specifically:

var doc = new Document(dataDir + "MIR_form_v7.2.1b.pdf");
var form = new Facades.Form();
form.BindPdf(doc);
form.ImportXml(new FileStream(dataDir + "sample.xml", FileMode.Open));
form.Save(dataDir + "output.pdf");
form.Dispose();

For checking buttons I tried a variety of pieces of code, all looking similar to

doc.XFA.Form["<somethingLike>.section3[0].q1[0].#field[0]"] = "2";
doc.XFA.Form["<somethingLike>.section3[0].q1[0].#field[1]"] = "2";
doc.XFA.Form["<somethingLike>.section3[0].q1[0].#field[2]"] = "2";

I’ve tried setting the buttons to the same value, different values, all “1”, “”, null, and a few other things. As well, I’ve tried updating the group directly, rather than the subfield (without the ending #field[0]) to no luck. I should mention that updating them all to some stringified number works for the radiobuttongroups, but not the checkbuttons. I also tried updating the isChecked property when using competing software, and found that not to work either.

Additionally, I have encountered difficulty setting values for the tables on pages 19-20. To use this product I would need to know how to insert data there in such a way as to cause the tables to grow.

Click button - XFA forms - c# shows that I am not alone in my wondering, but does not provide an answer. Also, I could not get the “just insert the data and the table will grow” solution to work.

Any help is greatly appreciated! Thanks.

I also tried converting to AcroForm, which did not work at all.

Based on

// Load PDF with XFA forms
Document document = new Document("XFAFormPDF.pdf");

// Set the form fields type as standard AcroForms
document.Form.Type = FormType.Standard;

// Save the resultant PDF with AcroForms
document.Save("XFA-to-AcroForms.pdf");

This would work in theory, if I could set the resizeable tables to an appropriate size first. e.g. add 8 rows or so, then convert to acroform.

@BradenC

We were able to replicate the issue in our environment after testing the scenario using 21.4v of the API. We also noticed that your PDF has JavaScript enabled upon editing the form fields. We have logged an issue as PDFNET-49834 in our issue tracking system for the sake of detailed investigation against this case. We will look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

Ok, looking forward to hearing if there’s any progress on the checkbutton issue.

Do you have anything to report on the table issue? I’m not sure if that’s a hole in the API, or if I’m just using it wrong. My attempts thus far have looked like

doc.XFA.Form["<page19-20ish>.Table[0].row[0].#field[0]"] = "foo";
doc.XFA.Form["<page19-20ish>.Table[0].row[0].#field[1]"] = "foo2";
doc.XFA.Form["<page19-20ish>.Table[0].row[1].#field[0]"] = "bar";
doc.XFA.Form["<page19-20ish>.Table[0].row[1].#field[1]"] = "bar2";

This code seems to have no affect on the XFA form, and I would appreciate any advice on what I might be doing wrong!

Thanks.

@BradenC

We have various tickets which were already logged in our issue management system for issues similar to yours. However, they are not yet resolved and new enhancements to the API could be added due to some technical difficulties. We have created a new ticket as PDFNET-49839 in our issue tracking system for your case so that it can further be investigated and resolved.

We will let you know once it is resolved. Please spare us some time. Also, if you have some XML template to import in this PDF, please share it with us as well. It would help us in investigating the ticket accordingly.