我以编程方式填充使用Livecycle创建的PDF(以及通过Adobe Acrobat扩展的功能)。填充字段后,我想允许用户编辑和保存。
private void XMLFieldPopulate(PdfReader reader, Dictionary<string, string> listOfValues, PdfStamper stamper)
{
AcroFields form = reader.AcroFields;
XfaForm xfaform = form.Xfa;
XmlNode node = xfaform.DatasetsNode;
XmlNodeList list = node.ChildNodes;
do
{
node = list.Item(0);
list = node.ChildNodes;
} while (node.Name != "topmostSubform");
for (int i = 0; i < list.Count; i++)
{
string attribute = list[i].Name;
string value = string.Empty;
value = listOfValues.First(x => x.Key == attribute).Value;
list[i].InnerText = value;
}
xfaform.FillXfaForm(node);
xfaform.SetXfa(stamper.Writer);
我可以填充PDF并进行编辑,但不允许保存。