【发布时间】:2011-03-03 18:46:51
【问题描述】:
假设我使用 iTextSharp 加载了一个 PDF 文件:
PdfStamper p = GetDocument();
AcroFields af = ps.AcroFields;
如何从af获取文档中所有字段名称的列表?
【问题讨论】:
标签: c# pdf itextsharp
假设我使用 iTextSharp 加载了一个 PDF 文件:
PdfStamper p = GetDocument();
AcroFields af = ps.AcroFields;
如何从af获取文档中所有字段名称的列表?
【问题讨论】:
标签: c# pdf itextsharp
AcroFields af = ps.AcroFields;
foreach (var field in af.Fields)
{
Console.WriteLine("{0}, {1}",
field.Key,
field.Value);
}
【讨论】:
PdfReader pdfReader = new PdfReader("c:\\ABC.pdf");
string TempFilename = Path.GetTempFileName();
AcroFields pdfFormFields = pdfReader.AcroFields;
foreach (KeyValuePair<string, AcroFields.Item> kvp in pdfFormFields.Fields)
{
string fieldName = kvp.Key.ToString();
string fieldValue = pdfFormFields.GetField(kvp.Key.ToString());
Console.WriteLine(fieldName + " " + fieldValue);
}
pdfReader.Close();
【讨论】:
foreach (DictionaryEntry entry in af.Fields) {
Console.WriteLine(entry.Key +" " +entry.Value);
}
【讨论】:
可能只是我,但我不再获得 .Value。
foreach (var field in af.Fields)
{
Console.WriteLine(field.Key +" "+ af.GetField(field.Key));
}
【讨论】: