Free Support Forum - aspose.com

Saving DOCX Not in Compatible mode C#

I am using the latest version of Aspose and merging WORD documents into SharePoint.

The issue I am having is that, no matter what I do WORD Online is saying that my DOCX is in compatible mode:
image.png (21.6 KB)

I can convert the document in WORD 2016 and open it in WORD ONLINE and it works perfectly. The problem is when its in compatibility mode in WORD ONLINE the tables are skewy.

Here is what I have tried:

OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(SaveFormat.saveOptions.Compliance = 
OoxmlCompliance.Iso29500_2008_Transitional;
doc.Save(ms, saveOptions);

The above has no effect, it still saves as “compatible mode”

OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(SaveFormat.saveOptions.Compliance = 
OoxmlCompliance.saveOptions.Compliance = OoxmlCompliance.Iso29500_2008_Strict;
doc.Save(ms, saveOptions);

The above code wont even open in WORD online.

var doc = new Document(templateFile);
doc.CompatibilityOptions.UseWord2010TableStyleRules = true;

The above code has no effect

@Michael-11,

Please ZIP and attach your input Word document and Aspose.Words generated output document showing the undesired behavior here for testing. We will investigate the issue on our end and provide you more information.

Thanks for your response.
Attached is the template & the merge filetemplate.zip (1.8 MB)
Incompatable Result.zip (2.0 MB)

@Michael-11,

The problem occurs because you are using an old version of Aspose.Words for .NET on your end i.e. 17.10. We suggest you please upgrade to the latest version of Aspose.Words for .NET i.e. 18.4 via NuGet and try running the following simple code. Hope, this helps.

Document doc = new Document(MyDir + @"Template\FSATemplate.docx");
doc.Save(MyDir + @"Template\18.4-normal.docx");

Try opening this 18.4 generated output file (18.4-normal.zip (1.8 MB)) with Word Online.

I have updated to Version 18.4 and am still getting the same issue. I’ve tried a few different options with CompabilityOption and the plain code you provided.

Attached is the output that comes from version 18.4 when I run the following script

                doc.Save(@"C:\inetpub\Seymour.App\test.docx");   //this is the output I have attached
                doc.Save(ms, SaveFormat.Docx);
                FileModel fileModel = new FileModel(fileName, ms.ToArray());
                return fileModel;

test.zip (1.8 MB)

I solved this by this line:

            doc.CompatibilityOptions.OptimizeFor(Aspose.Words.Settings.MsWordVersion.Word2016);

@Michael-11,

It is great you were able to resolve this issue on your end. In case you have further inquiries or need any help, please let us know.