Merge entire XML data with XFA form - not field by field!

We have 1000's of interactive XFA based forms created with Adobe LiveCycle Forms Designer. They all have XML schemas associated with them. We also have Reader Extensions. We are attempting to avoid buy the LiveCycle server just to pre-populate forms.

I need to be able to merge XML data with each form in an efficient and generic manner. For example I would like to create a web service with two input parameters:

Parameter #1 - the name or path to the XFA form

Parameter #2 - the XML data or path to the XML data file

Return = a prepopulated PDF document.

I was able to achieve this within in a 90 minutes of downloading iText; having never heard of iText. Luckily for you we already own Aspose products and I'm being forced to use it.

A Java and .NET code sample to achieve this would be appreciated. I'm a Java guy but my colleagues are .NET.

myForm.importXml(xmlInputStream); does the minimum…after 3 hours of searching your documentation…not impressed yet.

Now how do I retain Reader Extension usage rights. Again I’ve been able to do this with iText in a very short period of time.

Hi Brian,

Thanks for contacting support and sorry for the delayed response.

Aspose.Pdf for .NET and Aspose.Pdf for Java support the feature to import XML data into PDF forms. Now concerning to your requirement on preserving extended rights feature while importing data into Forms, please follow the instructions specified over following links.

.NET

For above examples, first load the form into Document object and then fill the data using Aspose.Pdf.Facades.Form and then again, save the final output using Document object so that user extended rights are preserved.

For Java, you can use easily convert the .NET code to Java as we have same class structure for API’s over these platform. In case you encounter any issue, please feel free to contact.

I have tried what you suggested but it doesn't work for me. Here is my code sample:

public static void main(String[] args) {
fillForm(args[0],args[1]);
}

public static void fillForm(String pdf, String data){<?xml:namespace prefix = "o" ns = "urn:schemas-microsoft-com:office:office" />

try {
InputStream xmlInputStream = new FileInputStream(data);

//------------------------------------

// By m
aking the source and target the same
it results in an error
// com.aspose.pdf.exceptions.InvalidPdfFileFormatException:
Incorect file format


//------------------------------------

Form myForm = new Form(pdf,pdf) ;

String dest = pdf.substring(0,pdf.length()-4) + “_Filled.pdf”;
//Form myForm = new Form(pdf,dest) ; //this works but removes usage rights<o:p></o:p>

myForm.importXml(xmlInputStream);
xmlInputStream.close();
myForm.save();

} catch (IOException e) {
e.printStackTrace()
}

}

Hi Brian,


Thanks for your feedback. We have already noticed the issue and logged it in our issue tracking, that you also highlighted in other thread. We will keep you updated about the issue progress in original post.

We are sorry for the inconvenience caused.

Best Regards,