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: 20.9.0


public CompatibilityOptions CompatibilityOptions { get; }

Property Value

Type: CompatibilityOptions


Shows how to optimize the document for different versions of Microsoft Word.
public void OptimizeFor()
    Document doc = new Document();

    // This object contains an extensive list of flags unique to each document
    // that allow us to facilitate backward compatibility with older versions of Microsoft Word.
    CompatibilityOptions options = doc.CompatibilityOptions;

    // Print the default settings for a blank document.
    Console.WriteLine("\nDefault optimization settings:");

    // These settings can be accessed in Microsoft Word via File -> Options -> Advanced -> Compatibility options for...
    doc.Save(ArtifactsDir + "CompatibilityOptions.OptimizeFor.DefaultSettings.docx");

    // We can use the OptimizeFor method to ensure optimal compatibility with a specific Microsoft Word version.
    Console.WriteLine("\nOptimized for Word 2010:");

    Console.WriteLine("\nOptimized for Word 2000:");

/// <summary>
/// Groups all flags in a document's compatibility options object by state, then prints each group.
/// </summary>
private static void PrintCompatibilityOptions(CompatibilityOptions options)
    for (int i = 1; i >= 0; i--)
        Console.WriteLine(Convert.ToBoolean(i) ? "\tEnabled options:" : "\tDisabled options:");
        SortedSet<string> optionNames = new SortedSet<string>();

        foreach (System.ComponentModel.PropertyDescriptor descriptor in System.ComponentModel.TypeDescriptor.GetProperties(options))
            if (descriptor.PropertyType == Type.GetType("System.Boolean") && i == Convert.ToInt32(descriptor.GetValue(options)))

        foreach (string s in optionNames)

See Also