Page 1 of 1

Simple docx is corrupt on Office 15.04701.1000

PostPosted: Mon Mar 30, 2015 8:10 pm
by carlosegomez
Hi,

I'm using docx4j version 3.2.1 to build docx files and I have a problem with a specific Office vesion (15.0.4701.1000). I run the basic example (CreateWordprocessingMLDocument.java) and the generated docx cannot be opened by this office version. Office shows the following message "We're sorry. We can't open OUT_CreateWordprocessingMLDocument because we found a problem with its contents". On error details: "The file is corrupt and cannot be opened".

I confirm that using Office version 15.0.46.93.1001 works.

Does anyone have the same problem?

Re: Simple docx is corrupt on Office 15.04701.1000

PostPosted: Mon Mar 30, 2015 10:56 pm
by jason
See the comment at line 21 of https://github.com/plutext/docx4j/blob/ ... properties

That's the only thing vaguely related I can think of right now... first, check the contents of the properties parts in the resulting docx.

The Office version you refer to - it seems to be Office 2013 SP1

Line 431 and following of https://github.com/plutext/docx4j/blob/ ... ckage.java adds properties parts:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
                DocPropsCorePart core = new DocPropsCorePart();
                org.docx4j.docProps.core.ObjectFactory coreFactory = new org.docx4j.docProps.core.ObjectFactory();
                core.setJaxbElement(coreFactory.createCoreProperties() );
                wmlPack.addTargetPart(core);
                       
               
                DocPropsExtendedPart app = new DocPropsExtendedPart();
                org.docx4j.docProps.extended.ObjectFactory extFactory = new org.docx4j.docProps.extended.ObjectFactory();
                app.setJaxbElement(extFactory.createProperties() );
                wmlPack.addTargetPart(app);    
 
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


If you comments one or both of those out in the source code, does it then work?

Re: Simple docx is corrupt on Office 15.04701.1000

PostPosted: Tue Mar 31, 2015 12:49 am
by carlosegomez
Hi Jason,

In fact, I'm using the bin that I found in docx4j site. I am configuring the docx4j library to apply your advises.

However, I want to add another comment. The same simple generated docx can be opened neither by Word 2010 nor by Word 2003. It only works on my installed Office (15.0.4693.1001).

do you think it´s another problem?

Thanks

Re: Simple docx is corrupt on Office 15.04701.1000

PostPosted: Tue Mar 31, 2015 1:42 am
by carlosegomez
Hi Jason,

I think I'm using a non-snapshot version if I understand well the comment on 21 line. I rebuilt the library (v 3.2.1 from master) and I continue with the same problem commenting the line 431 from https://github.com/plutext/docx4j/blob/master/src/main/java/org/docx4j/openpackaging/packages/WordprocessingMLPackage.java.

Any idea?

Thanks for your help

Re: Simple docx is corrupt on Office 15.04701.1000

PostPosted: Tue Mar 31, 2015 2:43 am
by carlosegomez
I add the generated docx. I hope it gives more clues ;)

PS. I note settings.xml is not included in the docx, is it not important?

Re: Simple docx is corrupt on Office 15.04701.1000

PostPosted: Tue Mar 31, 2015 8:07 am
by jason
The docx you attached works on my Word 2010 x64 (14.0.7106.5003)

And it contains app.xml, with:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
<properties:AppVersion>3.2.1</properties:AppVersion>
 
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


(which is what I suggested might be causing the problem)

Try the attached (which contains what Word 14 writes instead)

Re: Simple docx is corrupt on Office 15.04701.1000

PostPosted: Tue Mar 31, 2015 6:23 pm
by carlosegomez
Hi Jason,

That works!!! Thank you!!!

why do some Office have issues with this property? I also test in another version of Office 2010 and it opens my example without problems.

Re: Simple docx is corrupt on Office 15.04701.1000

PostPosted: Tue Mar 31, 2015 7:44 pm
by jason
So you just need to have a suitable setting in your docx4j.properties file

carlosegomez wrote:why do some Office have issues with this property?


You'd have to ask Microsoft...

Re: Simple docx is corrupt on Office 15.04701.1000

PostPosted: Tue Mar 31, 2015 8:20 pm
by carlosegomez
Yes that is!!! well, I hope there will not be more issues associated with Office ;)