I want to list the names of all my PDF fields with iTextSharp. That's what i got so far :
protected void btnPDF_click(object sender, EventArgs e)
{
MemoryStream ms = new MemoryStream();
PdfReader lecteur = new PdfReader(Server.MapPath("~/Img/f16.pdf"));
PdfStamper etampeur = new PdfStamper(lecteur, ms);
AcroFields af = lecteur.AcroFields;
foreach (KeyValuePair<string, AcroFields.Item> fil in af.Fields)
{
lblErreur.Text += fil.Key.ToString() + "<br />";
}
lecteur.Close();
etampeur.Close();
}
found everything on :
How do I enumerate all the fields in a PDF file in ITextSharp
But strangely, it does not work, that's the error i get :
InvalidCastException :
The specified cast is not valid.
I tried every workaround i knew... but i ran out of ideas...