Page 1 of 1

cannot open docx4j generated docx in Word 2007

PostPosted: Fri Aug 10, 2018 9:33 am
by glively
I am creating MS Word docs, from scratch, with docx4j, 6.0.1.

The docs open fine in Libre Office, Open Office, Google docs, and many different (newer) versions of Word; just not Word 2007. I am not using anything special, as far as I know. The problem I have is, a client uses Word 2007 and cannot open the docs, but I do not have Word 2007, and have no idea how I would test this. I attached a sample docx file that cannot be opened in 2007. If anyone can provide any insight, it would be greatly appreciated.

I've asked the client to send me a simple, natively created Word 2007 docx file so I can do some comparisons, but have yet to receive the doc.

Thank you in advance.

Re: cannot open docx4j generated docx in Word 2007

PostPosted: Fri Aug 10, 2018 1:59 pm
by jason
Please ask your client what error message Word 2007 gives, exactly.

At a quick glance your document does look pretty innocuous, except perhaps for:

Code: Select all
      <w:pgSz w:w="12240" w:h="15840" w:code="1"></w:pgSz>

Re: cannot open docx4j generated docx in Word 2007

PostPosted: Sat Aug 11, 2018 1:19 am
by glively
Thank you for your quick response Jason.

All the client tells me is when they try to open the docx files, they get an error "cannot be opened because there are problems with the contents".

I apologize for my ignorance, but where does this XML clip come from?

Code: Select all
<w:pgSz w:w="12240" w:h="15840" w:code="1"></w:pgSz>


When I create the doc, I use:

wordMLPackage = WordprocessingMLPackage.createPackage(PageSizePaper.LETTER, false);

However, this doc does contain a Table, and I do specify column widths for the table cells.

Thank you!

Re: cannot open docx4j generated docx in Word 2007

PostPosted: Mon Sep 10, 2018 11:07 am
by jason
Having dusted off an old machine running Word 2007, opening it, if you click the "details" button on the problems dialog, it says "error at line 1, column 3320", which corresponds to:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
<w:trHeight w:hRule="auto"></w:trHeight>
 
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


(so in case of further problems, please ask your customer to click the "details" button, if it is there! Sometimes it isn't - it depends on the class of error)

For whatever reason, Word 2007 does not like that w:trHeight, although it should be OK: http://webapp.docx4java.org/OnlineDemo/ ... eight.html

(And if you open and re-save the document in Word 2010, it strips that element out, presumably because its redundant).

So, if you want your docx to work in Word 2007, you should avoid using w:trHeight/@w:hRule="auto"