Hi All,
Is it possible to use docx4j to recreate/create a docx from a document.xml file?
Thanks
//Erik
It is currently Tue Jan 28, 2025 12:45 am
String inputfilepath = "/home/fiorenzo/test_docx.docx";
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage
.load(new java.io.File(inputfilepath));
// Create temp file.
java.io.File temp = java.io.File.createTempFile("output", ".pdf");
OutputStream os = new java.io.FileOutputStream(temp);
OutputStream os2 = new java.io.FileOutputStream(
"/home/fiorenzo/test_docx2.html");
javax.xml.transform.stream.StreamResult result = new javax.xml.transform.stream.StreamResult(
os2);
org.docx4j.convert.out.html.HtmlExporter.html(wordMLPackage, result,
inputfilepath + "_files");
wordMLPackage.pdf(os);
os.close();
WordprocessingMLPackage wmlPack = WordprocessingMLPackage.createPackage();
wmlPack.getMainDocumentPart().setContentType(new ContentType(ContentTypes.WORDPROCESSINGML_DOCUMENT_MACROENABLED));
wmlPack.save(new File("withMacro.docm"));
, but in real I find there this:<Override PartName="/word/document.xml" ContentType="application/vnd.ms-word.document.macroEnabled.main+xml" />
<Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" />
Total posts 10120 • Total topics 2847 • Total members 2077