I'm using Java 8, added this to my build.gradle
- Code: Select all
compile "org.docx4j:docx4j-JAXB-Internal:8.2.0"
When refreshing my dependancies it pulls in the following:
- Code: Select all
Gradle: org.docx4j.org.apache:xalan-interpretive:8.0.0
Gradle: org.docx4j.org.apache:xalan-metainf:8.0.0
Gradle: org.docx4j.org.apache:xalan-serializer:8.0.0
Gradle: org.docx4j:docx4j-core:8.2.0
Gradle: org.docx4j:docx4j-JAXB-Internal:8.2.0
Gradle: org.docx4j:docx4j-openxml-objects:8.2.0
Gradle: org.docx4j:docx4j-openxml-objects-pml:8.2.0
Gradle: org.docx4j:docx4j-openxml-objects-sml:8.2.0
When doing the prepare, it fails with ClassNotFoundException: org.docx4j.jaxb.ri.NamespacePrefixMapper
- Code: Select all
WordprocessingMLPackage wordMLPackage;
try {
wordMLPackage = WordprocessingMLPackage.load(template);
MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
VariablePrepare.prepare(wordMLPackage);
documentPart.variableReplace(model);
resp.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
HttpResponseUtil.setHeadersForFileDownload(resp, model.get("filename"), null);
Save saver = new Save(wordMLPackage);
saver.save(resp.getOutputStream());
} catch (Docx4JException e) {
e.printStackTrace();
Thanks!
Hanlie