我正在编写一个需要在XFA和AcroField模板中读取的C#应用程序 . 由于公司的规模和可能连接到应用程序的现有PDF文档的数量,选择一个并继续使用它是不可能的 .
我目前正在使用iTextSharp读取AcroFields,但它实际上并没有保存更改 . 我使用Acrobat Pro的试用版制作了AcroFields .
编辑:(我删除了很多原创帖子)
我有一个解决方法有点工作,但我宁愿不在XML上进行Deapth First Search . 我还没有找到除文本字段之外的任何内容 .
public List<String> getKeys(AcroFields af)
{
XfaForm xfa = af.Xfa;
List<String> Keys = new List<string>();
foreach (var field in af.Fields)
{
Keys.Add(field.Key);
}
if (xfa.XfaPresent)
{
System.Xml.XmlNode n = xfa.DatasetsNode.FirstChild;
if (n == null) return Keys;
// drill down in to the children
while (n.FirstChild != null) { n = n.FirstChild; }
// if the node is filled in data, grab the parent
if ((n.Name.ToCharArray(0, 1))[0] == '#') n = n.ParentNode;
while ((n = n.NextSibling) != null)
{
Keys.Add(n.Name);
}
}
return Keys;
}
1 回答
好的,我想出了如何获取XFA和AcroField PDF文档的字段名称,这是我原来的问题 .
我还使用了一个名为
myKey
的类 . 它有 Value 和关键 . 我重写.equals
只是比较键值,并写了我自己的.ToString
.