I have extracted xml out of a docx document using below code
- Code: Select all
tempDir = correctDirectoryPath(tempDir);
bytes = IOUtils.toByteArray(inputStream);
file = new File(tempDir + fileName + this.formatter.format(new Date()) + ".pdf");
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new ByteArrayInputStream(bytes));
VariablePrepare.prepare(wordMLPackage);
MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
// write xml content in a file
try {
File fileContent = new File(tempDir + fileName + ".xml");
FileWriter myWriter = new FileWriter(fileContent);
myWriter.write(documentPart.getXML());
myWriter.close();
return fileContent;
}
catch (Exception e) {
}
Is there a way I can directly generate PDF from this xml, would that be faster?