XFA Form Filling Only Allows One Value to Be Set?

I'm getting an 'System.IndexOutOfRangeException' in Aspose.Pdf.dll" when I try to save two separate XFA Fields. If I use only one field, this works correctly. Both of the fields exist and I can swap the lines of code and it will error on the second setting of the data field. Am I doing this incorrectly? Is there a workaround? I saw something in Facades... is that a better way? Any advice will be appreciated. I'm using version 7.7 Code is as below. Attached is the form I'm trying to fill and it is set to not allow the user to save the form which I'm not sure if that is a problem or not.

private void GetPDFFormFields()
{
Aspose.Words.License license = new Aspose.Words.License();
license.SetLicense("Aspose.Words.lic");

//Open pdf file
doc = new Aspose.Pdf.Document("input.pdf");

//Get the PDF form
Aspose.Pdf.InteractiveFeatures.Forms.Form form = doc.Form;

//Display Field names
foreach (string field in doc.Form.XFA.FieldNames)
{
listBox1.Items.Add(" Name: " + field);
}
}

private void outputButton_Click(object sender, EventArgs e)
{
doc.Form.XFA["form1[0].#subform[0].TextField1[0]"] = "1st";
doc.Form.XFA["form1[0].#subform[0].TextField1[1]"] = "2nd";

doc.Save("output.pdf");
}

private void GetPDFFormFields()
{
Aspose.Words.License license = new Aspose.Words.License();
license.SetLicense("Aspose.Words.lic");

//Open pdf file
doc = new Aspose.Pdf.Document("input.pdf");

//Get the PDF form
Aspose.Pdf.InteractiveFeatures.Forms.Form form = doc.Form;

//Display Field names
foreach (string field in doc.Form.XFA.FieldNames)
{
listBox1.Items.Add(" Name: " + field);
}
}

private void outputButton_Click(object sender, EventArgs e)
{
doc.Form.XFA["form1[0].#subform[0].TextField1[0]"] = "1st";
doc.Form.XFA["form1[0].#subform[0].TextField1[1]"] = "2nd";

doc.Save("output.pdf");
}

Hi Mike,


Thanks for your inquiry. I’ve tested your code its working fine. I’ve noticed you are using Aspose.Word license instead of Aspose.Pdf. Please re-try after applying proper license, hopefully your issue will resolved.

Please feel free to contact us for any further assistance.

Best Regards,

That was the issue! Thanks for the quick reply!