Here's an example code, based on the tutorial.
//during the foreach loop
//doc is the template PDF file.
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 statement to insert into field, this is potentially sensitive data so I'm leaving it out.
}
}
}
//page is incremented each step, not important.
doc.SaveToFile(workingDir + page.ToString() + ".pdf"); //Saving increases the file size by 6KB each