Hi Team,
I was trying to autofile the attached PDF using spire through asp.net application, but i am getting a blank PDF created instead of autofill. below is the code for your reference, could you please let me know what would be the issues. We are planning to finish this tech Spike before going for purchase. I am suing spire.pdf dll and product version is 3.6.0.5020 :
private void LoadPDFform()
{
//Create a pdf document
PdfDocument doc = new PdfDocument();
//Load from file
doc.LoadFromFile(@"C:\Program Files (x86)\e-iceblue\Spire.Pdf\Demos\CS\Web\Pension_Tfn_Declaration_form1.pdf");
//Get form
PdfFormWidget formWidget = doc.Form as PdfFormWidget;
for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++)
{
PdfField field = formWidget.FieldsWidget.List[i] as PdfField;
//Fill the data for textBoxField
if (field is PdfTextBoxFieldWidget)
{
PdfTextBoxFieldWidget textBoxField = field as PdfTextBoxFieldWidget;
switch (textBoxField.Name)
{
case "topmostSubform[0].Page1[0].txtLastName[0]":
textBoxField.Text = "Nagendra";
break;
case "TopmostSubform[0].Page1[0].nPostcode[0]":
// textBoxField.Password = true;
textBoxField.Text = "3146";
break;
case "topmostSubform[0].Page1[0].txtEmail[0]":
// textBoxField.Password = true;
textBoxField.Text = "[email protected]";
break;
}
}
}
//Save the document to file in PDF format
doc.SaveToFile(@"C:\Program Files (x86)\e-iceblue\Spire.Pdf\Demos\CS\Web\Pension_Tfn_Declaration_form1_filled.pdf");
//Launch the file
System.Diagnostics.Process.Start(@"C:\Program Files (x86)\e-iceblue\Spire.Pdf\Demos\CS\Web\Pension_Tfn_Declaration_form1_filled.pdf");
}