I managed to modify the xml Document obtained with:
PDDocumentCatalog docCatalog = _pdfDocument.getDocumentCatalog();
PDAcroForm acroForm = docCatalog.getAcroForm();
PDXFAResource xfa = acroForm.getXFA();
org.w3c.dom.Document documentXML = xfa.getDocument();
But when i get to the point of creating a COSBase instance and map the xml document in it something goes wrong. I use the following command that i found on the web:
COSStream cosout = new COSStream(new ScratchFile(new File("/Users/lgraglia/Desktop/")));
TransformerFactory.newInstance().newTransformer().transform(new DOMSource(documentXML), new StreamResult(cosout.createUnfilteredStream()));
or:
StringWriter writer = new StringWriter();
TransformerFactory.newInstance().newTransformer().transform(new DOMSource(documentXML), new StreamResult(writer));
COSString aaa = new COSString(writer.toString());
But in both cases the PDXFAResource generated has problem and the resultant pdf file is broken. Can you help me with this issue? Thank you!