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? |
|
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!