Page 1 of 1

Corrupted file when creating Word document.

PostPosted: Wed Jun 18, 2014 8:00 pm
by ArcDexx
Hi everyone,

I'm quite new to docx4j. After installing everything, I tried creating an empty .docx file, and then write text in it. Here's the code :

WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
wordMLPackage.getMainDocumentPart().addParagraphOfText("Hello Word!");
wordMLPackage.save(new java.io.File("HelloWord1.docx"));

The file is succesfully created, but when I try to open it with Word 2010, I get an error message saying the file is corrupted. However, when I open it with WordPad, everything is fine, and the text is there. What could I do to solve this problem and open my created documents with Word 2010 ?

Re: Corrupted file when creating Word document.

PostPosted: Fri Jun 20, 2014 1:04 am
by jason
Works for me (Word 2010, 14.0.7106.5003 64-bit).

See further Ben's answer at your cross post http://stackoverflow.com/questions/2428 ... d-document

Re: Corrupted file when creating Word document.

PostPosted: Sat Oct 31, 2015 6:00 am
by andrey.philippov
http://www.docx4java.org/forums/docx-java-f6/getting-started-with-docx4j-t2261.html#p7849
Postby jason ยป Tue Oct 13, 2015 7:45 am
I suspect your target environment does not like docProps/app.xml which contains AppVersion like, for example:

<AppVersion>3.1.0</AppVersion>

More generally, it doesn't like n.n.n; it needs to be of the form XX.YYYY where X and Y represent numerical values.

Please check what you have?

To fix this for documents saved by docx4j, in your docx4j.properties file, set:

docx4j.AppVersion=3.2