I am trying to fill an XFA type form using the Free Spire.PDF for .NET. The program works fine with the trial version of Spire.PDF for .NET. However, when using the Free version, the fields do not have the data.
The following is a snippet:
- Code: Select all
PdfDocument doc = new PdfDocument();
string dataDir = "D:/PDFTemplates/";
doc.LoadFromFile(dataDir + "LCD_XFA_Form.pdf");
PdfFormWidget formWidget = doc.Form as PdfFormWidget;
for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++)
{
PdfField field = formWidget.FieldsWidget.List[i] as PdfField;
if (field is PdfTextBoxFieldWidget)
{
PdfTextBoxFieldWidget textBoxField = field as PdfTextBoxFieldWidget;
switch (textBoxField.Name)
{
case "topmostSubform[0].Page1[0].Name[0]":
textBoxField.Text = "Someone";
break;
case "topmostSubform[0].Page1[0].ParcelID[0]":
textBoxField.Text = "1234-567";
break;
}
}
field.Flatten = true;
}
var saveFile = dataDir + "/test.pdf";
doc.SaveToFile(saveFile);
System.Diagnostics.Process.Start(saveFile);
Any assistance would be greatly appreciated!