Aspose.PDF.Kit not filling in radio buttons (filling text fields works fine)

Hi,

I have a ASP.NET web form inC# with many TextBox and RadioButtonList, and a PDF form (created with Adobe Designer 7.0). I am using Aspose.PDF.Kit to fill the PDF with the webform data. I am able to successfully fill in text fields in the PDF form, but cannot get the radio buttons to fill in at all.

Here is an example:

ASP.NET Web form (design view):

Do you own safety footwear?
Yes No
Willing to purchase

ASP.NET Web form (code - RadioButtonList):

<asp:RadioButtonList ID="gfootwear" runat="server" RepeatDirection="Horizontal">

<asp:ListItem >Yes</asp:ListItem>

<asp:ListItem >No</asp:ListItem>

<asp:ListItem >Willing to purchase</asp:ListItem>

</asp:RadioButtonList>

The corresponding RadioButtonList in the PDF is named:

form1[0].ContactAndGeneral[0].GeneralInfo[0].gfootwear[0]

The radio buttons in the PDF RadioButtonList are as follows:

Item: form1[0].ContactAndGeneral[0].GeneralInfo[0].gfootwear[0].Yes[0]

Value: 1

Item: form1[0].ContactAndGeneral[0].GeneralInfo[0].gfootwear[0].No[0]

Value: 2

Item: form1[0].ContactAndGeneral[0].GeneralInfo[0].gfootwear[0].WillingtoPurchase[0]

Value: 3

The Aspose.PDF.Kit code I am using to A.) fill in a text field (works), and to B.) fill the correct radio button per the user's choice (doesn't work) is:

Aspose.Pdf.Kit.Form pdfForm = new Form("testForm.pdf", "output.pdf");

// Fill in text field in PDF

pdfForm.FillField("form1[0].ContactAndGeneral[0].GeneralInfo[0].gdateAvail[0]", gdateAvail.Text);

Response.Write(gfootwear.SelectedItem.Value + "=gfootwear.SelectedItem.Value
");

// Fill in user selected radio button in PDF; if not selected default to "No" choice

switch (gfootwear.SelectedItem.Value)

{

case "Yes":

pdfForm.FillField("form1[0].ContactAndGeneral[0].GeneralInfo[0].gfootwear[0])", "1");

break;

case "No":

pdfForm.FillField("form1[0].ContactAndGeneral[0].GeneralInfo[0].gfootwear[0])", "2");

break;

case "Willing to purchase":

pdfForm.FillField("form1[0].ContactAndGeneral[0].GeneralInfo[0].gfootwear[0]", "3");

break;

// Default is "No"

default:

pdfForm.FillField("form1[0].ContactAndGeneral[0].GeneralInfo[0].gfootwear[0])", "2");

break;

}

This code is executed when the submit button is clicked. gfootwear.SelectedItem.Value is passed correctly, and verifed by the Response.Write directly above the switch. While the text field form1[0].ContactAndGeneral[0].GeneralInfo[0].gdateAvail[0] correctly shows the data entered by the user, the radio buttons all appear blank in the PDF.

From the documentation and examples on the aspose.com site, it seems like this should work, but it does not. Any ideas on how to get it working?

Thanks!

Dear mlc,

Could you please attach the PDF form directly here for testing?

Our developers need to reproduce the error which will help to find out reasons quickly that may cause this problem.

Best Regards,

Dear mlc,

Thanks for considering Aspose.Pdf.Kit.

The problem should be a spelling mistake. As you posted above, in the case statement, FillField function is invoked as follows:

pdfForm.FillField("form1[0].ContactAndGeneral[0].GeneralInfo[0].gfootwear[0])", "1");

...

pdfForm.FillField("form1[0].ContactAndGeneral[0].GeneralInfo[0].gfootwear[0])", "2");

...

Actually the field name should be "form1[0].ContactAndGeneral[0].GeneralInfo[0].gfootwear[0]", a bracket ")" is appended unexpectedly.

Any other question is welcomed.

This typo is not the issue. Prior to your reply, the ) was removed, but the issue did not resolve. the code currently used is:

switch (gfootwear.SelectedItem.Value)

{

case "Yes":

pdfForm.FillField("form1[0].ContactAndGeneral[0].GeneralInfo[0].gfootwear[0]", "1");

break;

case "No":

pdfForm.FillField("form1[0].ContactAndGeneral[0].GeneralInfo[0].gfootwear[0]", "2");

break;

}

An example where there are more than 2 choices:

switch (edElemYears.SelectedItem.Value)

{

case "5":

pdfForm.FillField("form1[0].Education[0].Elementary[0].edElemYears[0].#field[0]", "1");

break;

case "6":

pdfForm.FillField("form1[0].Education[0].Elementary[0].edElemYears[0].#field[1]", "2");

break;

case "7":

pdfForm.FillField("form1[0].Education[0].Elementary[0].edElemYears[0].#field[2]", "3");

break;

case "8":

pdfForm.FillField("form1[0].Education[0].Elementary[0].edElemYears[0].#field[3]", "4");

break;

case "Other":

pdfForm.FillField("form1[0].Education[0].Elementary[0].edElemYears[0].#field[4]", "5");

break;

}

Dear mlc,

Please directly mail the PDF form to me via private message or attach the document here for testing.

We will try to reproduce the same error and solve it quickly.

Best regards,

Dear mlc,

Please new a C Sharp project and test the functional part separately. The test code is like the following:
Form form = new Form("Mr_Lube_Employment_Application.pdf", "Mr_Lube_Employment_Application_output.pdf");

form.FillField("form1[0].ContactAndGeneral[0].GeneralInfo[0].gdateAvail[0]", "This is a text.");


// form.FillField("form1[0].ContactAndGeneral[0].GeneralInfo[0].gfootwear[0]", "1");

form.FillField("form1[0].ContactAndGeneral[0].GeneralInfo[0].gfootwear[0]", "2");

form.Save();

In my experiment, both fields can be filled correctly. Please try and tell us the result. If it works, you should debug your other ASP.NET code carefully.

Waiting for your response.

Best regards.