I have a XFA based pdf form that we need to be populate using java. Can you suggest the best approach. I was able to generate the xfa xml for the pdf using iText.
public void readXfa(String srcPdfFilename, String destXMLFilename) throws IOException, ParserConfigurationException, SAXException, TransformerFactoryConfigurationError, TransformerException {
PdfReader reader = new PdfReader(srcPdfFilename);
XfaForm xfa = new XfaForm(reader);
Document doc = xfa.getDomDocument();
Transformer tf = TransformerFactory.newInstance().newTransformer();
tf.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
tf.setOutputProperty(OutputKeys.INDENT, "yes");
FileOutputStream os = new FileOutputStream(destXMLFilename);
tf.transform(new DOMSource(doc), new StreamResult(os));
reader.close();
}
I have the Pdf and Xfa XML generated from code above. Can you please suggest me how to proceed further as I seem to be out of ideas. I tried to check the XFA documentation but does not seem right. I do not have an xml and the pdf is very complex as it has many fields and is a dynamic XFA pdf form.
Your help and suggestions will be sincerely appreciated.