Reputation: 83
I am stuck here. actually I am trying to fill a PDF form using asp.net. I get some help and write the following code:
private void fillForm()
{
try
{
string formFile = Server.MapPath("") + @"\Forms\fw4.pdf";
string savepath = Server.MapPath("") + @"\Forms\new_fw4.pdf";
PdfReader pdfReader = new PdfReader(formFile);
using (FileStream stream = new FileStream(savepath, FileMode.Create))
{
PdfStamper pdfStamper = new PdfStamper(pdfReader, stream);
AcroFields formFields = pdfStamper.AcroFields;
foreach (DictionaryEntry de in formFields.Fields)
{
formFields.SetField("field name", "field value");
}
pdfStamper.FormFlattening = true;
pdfStamper.Close();
}
}
catch
{
}
}
I want the program to show all fields in a List. I am unable to iterate all available fields using the foreach loop. Its giving me this error:
Cannot convert type System.Collections.Generic.KeyValuePair<string,iTextSharp.text.pdf.AcroFields.Item>
to System.Collections.DictionaryEntry
any help would be greatly appreciated.
Upvotes: 0
Views: 2692
Reputation: 9950
As you have updated KeyValuePair try using item.Key & item.Value
Upvotes: 2