I have spent a lot of time on Docx4j those last days, and 2 days ago my code was working perfectly.
But yersterday, it's start to not working at all, without a apparent change.
Trying to isolated the non working code, I finally came to this :
(the test1.docx file is a blank file, just created and saved)
- Code: Select all
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new File("D:\\test1.docx"));
org.docx4j.wml.ObjectFactory wmlObjectFactory = Context.getWmlObjectFactory();P p = wmlObjectFactory.createP();
R r = wmlObjectFactory.createR();
Text text = wmlObjectFactory.createText();
text.setValue("sdfgsdlffgsdl");
p.getContent().add(r);
r.getContent().add(text);
wordMLPackage.getMainDocumentPart().addObject(p);
wordMLPackage.save(new File("D:\\test2.docx"));
And it still produce corrupted docx : the file is created, but when I try to open it, Word announce the file is corrupted, and can't be open.
BUT, this problem only appear when the file "test1.docx" is made with Word 2016. The code is still perfectly working with W2013, and 2010.
Is there a incompatibility with the last update of W2016 (from the 06/14) ?