We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Microsoft Word Table Formatting Issues with OOXML Specification using .NET

Hi,

We have Microsoft Word Table Formatting Issues with OOXML Specification using .NET

When we save some documents with OoxmlSaveOptions, the table layout present in them is different then when saved without the options.

Please see the code example and the sample document to replicate the issues.

Code to Reproduce Microsoft Word Table Formatting Issues

var doc = new Document(@"out.docx");
var options = new OoxmlSaveOptions { Compliance = OoxmlCompliance.Iso29500_2008_Strict };
doc.Save(@"outAfterOoxml.docx", options);

Thanks,out.zip (11.9 KB)

Lukasz

@acturisaspose

Please note that Aspose.Words mimics the behavior of MS Word. If you convert the document to strict compliance level using MS Word, you will get the same output. Please check the attached image for detail.
strict compliance.png (32.8 KB)

Hi,
thanks for you response. I understand, however, we introduced saving with this compatibility to solve issues we have seen in Imported shape is cropped in the output document.

Can you tell me what is the reason we need to save it with OoxmlCompliance.Iso29500_2008_Strict ?
How to avoid issue from Imported shape is cropped in the output document ?

Thanks,
Łukasz

@acturisaspose

The document you are using is created by old version of MS Word i.e. 2007. So, when you view it later versions of MS Word, the document will be opened in compatibility mode. To avoid compatibility issues, you need to save the document with OoxmlCompliance.Iso29500_2008_Strict compliance.

Can you tell me how I can check whether a document was created by an old version of MS Word?
Is there any way to check it programmatically with Aspose.Words?
Thanks,
Lukasz

@acturisaspose

The BuiltInDocumentProperties.Version is related to AppVersion property in app.xml and MS Word does not allow to change it. This property represents the version number of the application that created the document. Following are the version numbers for MS Word.

11.0000 = Word 2003
12.0000 = Word 2007
14.0000 = Word 2010
15.0000 = Word 2013
16.0000 = Word 2016

Please use BuiltInDocumentProperties.Version property as shown below to get the desired output.

Console.WriteLine(doc.BuiltInDocumentProperties.Version >> 16); 

You may also check the compliance level of document using Document.Compliance property. For your document, it is Ecma376_2006.

Document doc = new Document(MyDir + "out.docx");
Console.WriteLine(doc.Compliance);

@tahir.manzoor thank you for your help.

I have tried checking versions of the documents we have provided in this ticket and in Imported shape is cropped in the output document.

I have checked BuiltInDocumentProperties.Version for the following documents:

  • input.docx (from the other ticket) - version 16 - Compliance - Iso29500_2008_Transitional
  • out.docx (from this ticket) - version 16 - word 2016 - Compliance - Ecma376_2006
  • new Document()(object created with Aspose.Words - version 11 - word 2016 - Compliance - Ecma376_2006

Does it mean that we need to save documents that come with Iso29500_2008_Transitional Compliance as Iso29500_2008_Strict instead? And leave all other with Ecma376_2006 compliance? How would you recommend approaching the issues we are seeing in the two tickets?

You also mentioned here: “The document you are using is created by old version of MS Word i.e. 2007.” - how did you find it? I have checked the version and it is Word 2016.

Thanks,
Łukasz

@acturisaspose

By default, Aspose.Words saves the DOCX with Ecma376_2006 compliance.

By default, Aspose.Words uses MS Word 2007 empty document template for new Document().

You need to save the document according to your required compliance level. If you are using newer versions of MS Word to view the documents, we suggest you please use Iso29500_2008_Strict compliance.

You can use following line of code to find the version of MS Word that created the document.

Console.WriteLine(doc.BuiltInDocumentProperties.Version >> 16);