XFAテンプレートとAcroFieldテンプレートの両方で読み取る必要があるC#アプリケーションを作成しています。会社の規模とアプリケーションに接続できる既存のPDFドキュメントの数のために、1つを選んでそれを使用することは問題外です。
現在、iTextSharpを使用してAcroFieldsを読み込んでいますが、実際には変更を保存していません。私はAcrobatProの試用版を使用してAcroFieldsを作成しました。
編集:(元の投稿をたくさん削除しました)
ある程度機能する回避策がありますが、XMLでDeapthFirstSearchを実行したくありません。また、テキストフィールド以外はまだ理解していません。
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;
}