在切换到 AWS 后,我们现在可以使用这种方法,但我收到一个奇怪的错误:
public static Dictionary<string, string> GetFormFieldNames(string pdfPath)
{
var fields = new Dictionary<string, string>();
foreach (DictionaryEntry entry in reader.AcroFields.Fields)
{
fields.Add(entry.Key.ToString(), string.Empty);
}
return fields;
}
Cannont convert type
System.Collections.Generic.KeyValuePair<String.iTextSharp.text.pdf.AcroFields.item>
toSystem.CollectionsEntry
我知道错误很明显,但我似乎无法正确输入。为什么这种方法会停止工作?我在这里做错了什么?
最佳答案
您可以使用 var 而不是类型定义,然后让 Intellisense 为您完成。
public static Dictionary<string, string> GetFormFieldNames(string pdfPath)
{
var fields = new Dictionary<string, string>();
foreach (var entry in reader.AcroFields.Fields)
{
fields.Add(entry.*use intellisense here*, string.Empty);
}
return fields;
}
关于c# - 循环遍历 iTextsharp 中的字典项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42377122/