I have an Adobe LiveCycle form which is dynamically composed. We need to load XML data into this form. I tried that with IText and it worked. But after filling the form it has lost its interactivity. How do I fill the form so that it still generates the fields when opened and executes the JavaScript behind it? For the filling I used the following code snippet (template Itext):
public class FillXFA
{
public static readonly String DEST = "dest/path";
public static readonly String SRC = "src/path";
public static readonly String XML = "xml/path";
public static void Main(String[] args)
{
FileInfo file = new FileInfo(DEST);
file.Directory.Create();
new FillXFA().ManipulatePdf(DEST);
}
protected void ManipulatePdf(string dest)
{
PdfDocument pdfdoc = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest));
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfdoc, true);
XfaForm xfa = form.GetXfaForm();
// Method fills this object with XFA data under datasets/data.
xfa.FillXfaForm(new FileStream(XML, FileMode.Open, FileAccess.Read));
xfa.Write(pdfdoc);
pdfdoc.Close();
}
}