Filling a Dynamic XFA from XML using Aspose.PDF for .NET - Import XML data to XFA form

I have a dynamic XFA-based form that was developed in LiveCycle Designer. It was created using an XML structure as the data connection, and the fields are data-bound to that XML.


Is there a way to use Aspose to fill the form by supplying the XML, and using the binding information that is already present in the field elements? I would expect to find something like
XFADoc.Bind(XMLDataSource), where XMLDataSource = an XML tree containing the data values that should be filled into the form. The only Doc.Bind that I can find is actually performing an XSL transform, and chokes if the XML input is not already in PDF format.

For example, in the XDP you can see elements, which contain elements that specify the node in the XML that is supposed to supply the data value for that field. Thus far I have only seen methods for filling the form using Aspose that require iterating through the fields and manually assigning a value. That would essentially ignore all of the data binding information that’s already there. Is there really no other option?

thanks,

– Lisa

Hi Lisa,


Thanks for your inquiry. Please check following documentation link for filling PDF form using XML along with support of XFDF and FDF. Hopefully it will help you to accomplish the task.


Please feel free to contact us for any further assistance.

Best Regards,

How should I use these approaches with an XFA form? Could you explain further what the process would be?


I have a XFA-based form. It cannot be read/opened using the Facades API, as far as I know. These snippets appear to show creating or using a new PDF, then importing XML into it.

Where would the “standard” PDF come from? Are you suggesting I should convert it from XFA to Acroforms-based PDF first and then use these import statements?

thanks,

– Lisa

Hi Lisa,


Thanks for sharing the details and sorry for the confusion caused in previous message.

In earlier post, Tilal had an understanding that you need to fill forms with XML for XFDF files. However I recommend you to please visit the following link for required details on


Aspose.Pdf for .NET supports the feature to convert Dynamic XFA to Standard Acroform and once the form is converted to Standard or Static format, you can use our API to fill data inside it. For more information, please visit

Yes, thanks, I had already looked at that link. The only solution I see offered there for filling a field on an XFA form is to manually assign values, which is why I asked the question to confirm. I didn’t see anything there about how to use the existing data binding information already present in the XFA form to fill fields when given an XML tree containing the data & wanted to be certain I hadn’t missed something.


Based on that, I believe you are telling me that the answer to my original question is:

No. There is currently no way to fill XFA fields without iterating through them.

If you don’t want to iterate through the fields, your best option is to convert from XFA to an AcroForms-based file, at which point you have more options in the API.



Hi Lisa,


Thanks for sharing the details.

Yes you are correct. Currently our API cannot make use of existing data binding information already present in the XFA form to fill fields when given an XML tree containing the data. However can you please share some sample files which can help us in better understanding this requirement, so that we can further look into this requirement.

Hi Tilal,
Importing XML to XFA based forms
Do we have this functionality yet with a single call? OP had asked this on '15 so checking.
Thanks
Patrick

@patrick08

Yes, Aspose.PDF offers this functionality and you can find sample code in shared links as well. In case you need further assistance or facing any issue, please let us know.

Hi Asad, Can you post a working example for XFA form please? Non of the sample code allow me to fill XFA forms. Thanks
Patrick

@patrick08

Would you kindly share your sample XML and PDF document with us. We will test the scenario in our environment using same code snippet in the shared links and let you know about our feedback. If there is any issue, we will log it and share the issue ID with you so that you can track it for resolution.

MIR_form_v7.2.1b.pdf (178.3 KB)
Sample.pdf (12.4 KB)

Sample.pdf is XML that needs to be applied

@patrick08

Please check following code snippet which we used with Aspose.PDF for .NET 20.11 and obtained the attached PDF document as output. You can notice that form fields are filled in the attached PDF.

var doc = new Document(dataDir + "MIR_form_v7.2.1b.pdf");
var form = new Facades.Form();
form.BindPdf(doc);
form.ImportXml(new FileStream(dataDir + "sample.xml", FileMode.Open));
form.Save(dataDir + "output.pdf");
form.Dispose();

output.pdf (177.9 KB)

@asad.ali Thank you for quick turnaround. We were on holiday break so could not respond sooner.

It seems there is some issue of data being cutoff. I have attached new sample.xml (has pdf extension). sample.pdf (18.4 KB) and output
MIR_form_v7.2.1b-out.pdf (179.4 KB)

Pls look at section 2.6 in particular.

@asad.ali I think I know where the problem is. Let me evaluate more and I will get back if there is anything else I have question about.

@patrick08

Sure, please take your time to evaluate the API and let us know if you need some assistance.

A post was merged into an existing topic: Cannot check checkbutton in XFA form