Page 1 of 1

Word 2007 can't open docx

PostPosted: Mon Sep 14, 2015 10:58 pm
by Imre
Hi Jason,

I try docx4j first with Maven, but it failed, then try to set it manually, in Eclipse 4.4, versions:

docx4J 3.2.2
log4j-1.2.17
slf4j-1.7.5
jaxb-ri-2.2.11
eclipselink-2.6.0.v20150309-bf26070

(All Jars copied to a dir and add it to the classpath of my project,
if you have a link for a detailed description, it would be great)


I made a 'jaxb.properties' with the following content:
javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory

My 'Hello word!' type code is:
try {
WordprocessingMLPackage wordMLPackage;

wordMLPackage = WordprocessingMLPackage.createPackage();
wordMLPackage.getMainDocumentPart().addParagraphOfText("Hello Word!");
wordMLPackage.save(new java.io.File("src/HelloWord.docx"));
} catch (Docx4JException e) {
e.printStackTrace();
}

All compile and runtime bug done, but I can not open the writen docx file with Office 2007 ('file is not complate').
The file and the log is in the attachment.

Now I see it is an announcement, excuse me, please move it to the topic section or offer a forum, if you do not treat problems like this.

Regards,
Imre

Re: Getting started with docx4j

PostPosted: Wed Sep 16, 2015 9:45 am
by jason
Your docx opens in Word 2010.

I don't have Word 2007 handy right now, so I can't tell you what it doesn't like at the moment.

Maybe

Code: Select all
<w15:collapsed w:val="false"/>


in /word/document.xml?

Re: Word 2007 can't open docx

PostPosted: Wed Sep 16, 2015 11:22 pm
by Imre
Thank you to repair my mistake of placing my first post.

I saw document.xml in notepad++ it did not show errors.
I do not familiar with Word 2007 xml contents (so I did not tried to fix it manually).

I tried 'ImageAdd' sample code (docx4j/src/samples/docx4j/org/docx4j/samples/ImageAdd.java), the result is also not opened with my Word 2007.
(The message also ~ 'The file is damaged).

The file is created by the 'docx4j/src/samples/xlsx4j/org/xlsx4j/samples/CreateSimpleSpreadsheet.java' sample.
It is ok, I can it open with my Excel 2007.

Regards,
Imre

Re: Word 2007 can't open docx

PostPosted: Sun Sep 20, 2015 9:32 pm
by jason
Your docx worked for me, on Word 2007 installation I tested, which is 2007 SP2.

Re: Word 2007 can't open docx

PostPosted: Tue Sep 22, 2015 1:54 am
by Imre
My system is Windows 7 (6.1.7601 Service Pack 1 build 7601) and Word 2007 version is in the attachment.
Both is up to date, we tried it on and another machine (Win XP + Word 2007) with the same solution.

Re: Word 2007 can't open docx

PostPosted: Tue Sep 22, 2015 12:12 pm
by jason
You are using SP3. So I tried your docx on that, and it worked for me.

Could you please double check/verify that the docx you attached to this thread is indeed broken for you?

If it is, then since I can't replicate, the only way forward is for you to examine the docx.

Either there is something in your docx your Word doesn't like, or something missing from it which Word wants.

You can create a simple docx in your instance of Word, and compare its contents with the problematic docx, then modify the problematic docx until it works. The easiest way to do this is in Visual Studio, with the OpenXML tool installed.

Re: Word 2007 can't open docx

PostPosted: Tue Sep 22, 2015 11:04 pm
by Imre
I made it as you wished:
1. The file is not damaged in my file system (I downloaded it).
2. It was not enough to copy contents of word\document.xml (I tried partially but as writen I do not familiar with its structure),
there is another files and a dir (screen is in attachment).
2. After copy them (settings.xml, fontTable.xml ...) my Word offer to repair HelloWord.docx (and opened it)

Maybe the difference is between our Office 2007 edition is that language of mine instance is Hungarian.
I ran a diagnostic inside of Word, it found a problem what repaired, but the file not open.

Re: Word 2007 can't open docx

PostPosted: Tue Oct 13, 2015 7:45 am
by jason
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