Page 1 of 1

Cannot open generated document in Word 2007

PostPosted: Fri Sep 20, 2013 10:50 pm
by apnator
Hi,

I have trouble with generated document and Word 2007. A template for the document was made with Word 2007, then in the generation process the placeholders are replaced with images, diagrams etc.

For some reason this generated document does not open with Word 2007. Word 2010 and 2011 opens it without complains.
I can use "Open and repair" with Word 2007 to open the document, but this is not acceptable for my client.

I tried comparing the generated and "repaired" version of the documents but could not figure out what is causing the trouble.

Could you help me with this?

I'll attach a generated example.

Re: Cannot open generated document in Word 2007

PostPosted: Wed Sep 25, 2013 6:43 pm
by apnator
Ok, I have now narrowed down the problem.

Only difference that causes trouble is the data generated for smart art.

It's still a lot of differences and since I'm very new with this document format any help that would guide me in right direction would be appreciated.

I'll attach the working (template) data file and the non-working (generated) data file.

Is it some attribute or a tag perhaps?

Also if there is some kind of tool that would give me better error messages than what Word 2007 itself is giving, please let me know.

Re: Cannot open generated document in Word 2007

PostPosted: Tue Oct 01, 2013 8:06 pm
by jason
I opened your docx in Word 2010, then copied the SmartArt into a new docx, and saved it.

I found Word 2007 SP2 was able to open this new docx. Its data part is attached (fixed_data1.xml)

I replaced the data part with your generated_data1.xml, and verified Word 2007 could not open the resulting docx.

So now it is a matter of understanding the differences between your generated_data1.xml and the fixed_data1.xml.

XML differencing helps here; I just used Open XML SDK 2.0 Productivity Tool.

The first dgm:prSet is different:

<dgm:prSet loTypeId="urn:microsoft.com/office/officeart/2005/8/layout/hierarchy5" loCatId="hierarchy" qsTypeId="urn:microsoft.com/office/officeart/2005/8/quickstyle/simple4" qsCatId="simple" csTypeId="urn:microsoft.com/office/officeart/2005/8/colors/colorful1#2" csCatId="colorful" phldr="1"/>

versus

<dgm:prSet loTypeId="urn:microsoft.com/office/officeart/2005/8/layout/hierarchy5" loCatId="hierarchy" qsTypeId="urn:microsoft.com/office/officeart/2005/8/quickstyle/simple4" qsCatId="simple" csTypeId="urn:microsoft.com/office/officeart/2005/8/colors/colorful1#1" csCatId="colorful" phldr="true"/>

then on subsequent dgm:prSet where @custT="1" in the broken part it ="true"

There is also the same difference in attribute value in <a:rPr lang="en-US" sz="1200" b="1"/>

There are more substantially more changes after lines 1291 (when pretty printed)

I'm afraid you'll have to hand edit the data part to determine which are significant.

How did you create your generated data?

Re: Cannot open generated document in Word 2007

PostPosted: Tue Oct 01, 2013 9:39 pm
by apnator
Thank you for looking into this.

Yeah, I noticed the boolean value changes too. If the offending data is removed even Word 2007 is ok with both boolean values.

The chart data generation is custom made Java code (by a person not available at the moment) that first builds a tree data structure and then uses that to create the smart art data XML.

There are so many differences that the right approach would be generating a simplest possible smart art chart and then do the comparing. And then incrementally add elements to the chart.
Unfortunately I don't have the luxury of time here. We have rolled back to an earlier simpler non-smart art version of the chart.

I also asked this on Open XML developer forums and here is the answer in case someone stumbles upon similar challenge:
http://openxmldeveloper.org/discussions ... 61457.aspx

Re: Cannot open generated document in Word 2007

PostPosted: Tue Oct 01, 2013 10:22 pm
by jason
Maybe the tree data structure he uses is the one described at https://github.com/plutext/docx4j/blob/ ... x?raw=true

Re: Cannot open generated document in Word 2007

PostPosted: Tue Oct 08, 2013 6:22 pm
by apnator
Ok, I was finally able to find the problem.

The root cause was a bug in the generation code that resulted in some connection tags missing type="presParOf" attribute.

Ie. something that should have been:

Code: Select all
<dgm:cxn modelId="{AE2B3B01-523C-46A0-9749-C30297F78665}" type="presParOf" srcId="{D7A4C742-D927-4939-98A4-17E6E1653790}" destId="{000FF1CE-CAFE-BABE-571D-010000030000}" srcOrd="1" destOrd="0" presId="urn:microsoft.com/office/officeart/2005/8/layout/hierarchy5"/>

actually was:

Code: Select all
<dgm:cxn modelId="{AE2B3B01-523C-46A0-9749-C30297F78665}" srcId="{D7A4C742-D927-4939-98A4-17E6E1653790}" destId="{000FF1CE-CAFE-BABE-571D-010000030000}" srcOrd="1" destOrd="0" presId="urn:microsoft.com/office/officeart/2005/8/layout/hierarchy5"/>


What made this hard to find was that Word's repair changed modelIds and added lots of stuff that didn't actually matter at all.

I created as simple a smart art diagram as possible. And then one by one changed differences in "repaired" document to match the generated until I found the difference that "broke" the document.



Thanks for the help.