如何获取PDF字段名称?

how to get PDF fields names?

我想用 iTextSharp 列出我所有 PDF 域的名称。这就是我到目前为止得到的:

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();
}

在 :

上找到所有内容

How do I enumerate all the fields in a PDF file in ITextSharp

但是 st运行gely,它不起作用,这是我得到的错误:

InvalidCastException :

The specified cast is not valid.

我尝试了我知道的所有解决方法...但是我 运行 没有想法...

好的,我对此有感触:

http://www.4guysfromrolla.com/articles/030211-1.aspx

似乎这样可行:

using System.Collections;

foreach (DictionaryEntry fil  in af.Fields)
{
    lblErreur.Text += fil.Key.ToString() + "<br />";
}

抱歉...我在发布问题后发现正确...