I am trying to read data from a odt file (created with LibreOffice). The requirement is to get the xml that is binded to an XForm included in the document. I am currently using the odfdom-java library to read the file. So far I have managed to read the values of the form field by parsing the document with jdom, but what I actually want is to get the whole xml with the form data. Alternatively, I can load the file as
OdfTextDocument.loadDocument("C://myFile.odt");
.
Does anyone know how I can get the XForm xml from there?
Alternatively, would it help if I converted the odt file to pdf programmatically? Using pdfbox I have managed to get the acroform
PDDocument pdDoc = PDDocument.loadNonSeq( new File("C://myFile.odt"), null);
PDDocumentCatalog pdCatalog = pdDoc.getDocumentCatalog();
PDAcroForm pdAcroForm = pdCatalog.getAcroForm();
but face the same problem afterwards (how to get the xml with the form data).
I have managed to do this via jdom (odfdom-java) was not used after all. The binded xml exists itself in the xml that represents the odt. All you need is to know the id of the form or the name of the tag, in order to get the proper node. Afterwards, a string is constructed that contains the xml with form data. My code is as follows: