DocumentCompatibilityOptions Property
Provides access to document compatibility options (that is, the user preferences entered on the Compatibility tab of the Options dialog in Word).

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.9
Syntax
public CompatibilityOptions CompatibilityOptions { get; }

Property Value

Type: CompatibilityOptions
Examples
Shows how to optimize our document for different word versions.
[C#]

Document doc = new Document();
CompatibilityOptions co = doc.CompatibilityOptions;

// Here are some default values
Assert.AreEqual(true, co.GrowAutofit);
Assert.AreEqual(false, co.DoNotBreakWrappedTables);
Assert.AreEqual(false, co.DoNotUseEastAsianBreakRules);
Assert.AreEqual(false, co.SelectFldWithFirstOrLastChar);
Assert.AreEqual(false, co.UseWord97LineBreakRules);
Assert.AreEqual(true, co.UseWord2002TableStyleRules);
Assert.AreEqual(false, co.UseWord2010TableStyleRules);

// This example covers only a small portion of all the compatibility attributes 
// To see the entire list, in any of the output files go into File > Options > Advanced > Compatibility for...
doc.Save(ArtifactsDir + "DefaultCompatibility.docx");

// We can hand pick any value and change it to create a custom compatibility
// We can also change a bunch of values at once to suit a defined compatibility scheme with the OptimizeFor method
doc.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2010);

Assert.AreEqual(false, co.GrowAutofit);
Assert.AreEqual(false, co.GrowAutofit);
Assert.AreEqual(false, co.DoNotBreakWrappedTables);
Assert.AreEqual(false, co.DoNotUseEastAsianBreakRules);
Assert.AreEqual(false, co.SelectFldWithFirstOrLastChar);
Assert.AreEqual(false, co.UseWord97LineBreakRules);
Assert.AreEqual(false, co.UseWord2002TableStyleRules);
Assert.AreEqual(true, co.UseWord2010TableStyleRules);

doc.Save(ArtifactsDir + "Optimised for Word 2010.docx");

doc.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2000);

Assert.AreEqual(true, co.GrowAutofit);
Assert.AreEqual(true, co.DoNotBreakWrappedTables);
Assert.AreEqual(true, co.DoNotUseEastAsianBreakRules);
Assert.AreEqual(true, co.SelectFldWithFirstOrLastChar);
Assert.AreEqual(false, co.UseWord97LineBreakRules);
Assert.AreEqual(true, co.UseWord2002TableStyleRules);
Assert.AreEqual(false, co.UseWord2010TableStyleRules);

doc.Save(ArtifactsDir + "Optimised for Word 2000.docx");
See Also