Search code examples
javalibreofficedocx4j

LibreOffice Writer cannot open docx4j output


I created an empty document with docx4j (docx4j-JAXB-ReferenceImpl 11.1.0):

var wordMLPackage = WordprocessingMLPackage.createPackage();    
Docx4J.save(wordMLPackage, new File("test.docx"));

But when I open it with LibreOffice Writer, it says "Due to an unexpected error, LibreOffice crashed.".

This happens both with libreoffice-still-6.1.6-1 and with libreoffice-fresh-de-6.2.4-1 on Arch Linux. With Word 2016 on a Windows machine it works.

How can I save a .docx document with docx4j so that LibreOffice Writer can open it?


Solution

  • I just ran https://github.com/plutext/docx4j/blob/master/docx4j-samples-docx4j/src/main/java/org/docx4j/samples/NewDocxHelloWorld.java which creates a simple "Hello World" docx.

    It opens fine on LO 6.2.4.2.0+ which is what I have right now on Manjaro Linux.

    I created this using current master, which is essentially 11.1.0 (but for Java 8), plus a fix for https://github.com/plutext/docx4j/issues/357