Compatibility

Compatibility enumeration

Specifies names of compatibility options.

public enum Compatibility

Values

NameValueDescription
NoTabHangInd0No Tab Hang Indent
NoSpaceRaiseLower1No Space Raise Lower
SuppressSpBfAfterPgBrk2Suppress Space Before Paragraph Break
WrapTrailSpaces3Wrap Trailing Spaces
PrintColBlack4Print Column Background
NoColumnBalance5No Column Balancing
ConvMailMergeEsc6Convert Mail Merge Escapes
SuppressTopSpacing7Suppress Top Spacing
UseSingleBorderforContiguousCells8Use Single Border for Contiguous Cells
TransparentMetafiles9Transparent Metafiles
ShowBreaksInFrames10Show Breaks in Frames
SwapBordersOddFacingPgs11Swap Borders on Odd-Facing Pages
DoNotLeaveBackslashAlone12Do Not Leave Backslash Alone
DoNotExpandOnShiftReturn13Do Not Expand on Shift Return
UlTrailSpace14Underline Trailing Space
BalanceSingleByteDoubleByteWidth15Balance Single-Byte and Double-Byte Widths
SuppressTopSpacingAtTopOfPage16Suppress Top Line Spacing in WordPerfect
SpacingInWholePoints17Spacing in Whole Points
PrintBodyTextBeforeHeader18Print Body Text Before Header
NoLeading19No Leading
SpaceForUL20Space for Underline
MWSmallCaps21MW Small Caps
SuppressTopLineSpacingWP22Suppress Top Line Spacing in WordPerfect
TruncateFontHeightLikeWP623Truncate Font Height Like WordPerfect 6
SubFontBySize24Substitute Font by Size
LineWrapLikeWord625Line Wrap Like Word 6
DoNotSuppressParagraphBorder26Do Not Suppress Paragraph Border
NoExtraLineSpacing27No Extra Line Spacing
SuppressBottomSpacing28Suppress Bottom Spacing
WPSpaceWidth29WordPerfect Space Width
WPJustification30WordPerfect Justification
UsePrinterMetrics31Use Printer Metrics
ShapeLayoutLikeWW832Shape Layout Like Word 2000
FootnoteLayoutLikeWW833Footnote Layout Like Word 2000
DoNotUseHtmlParagraphAutoSpacing34Do Not Use HTML Paragraph Auto Spacing
AdjustLineHeightInTable35Adjust Line Height in Table
ForgetLastTabAlignment36Forget Last Tab Alignment
AutoSpaceLikeWord9537Auto Space Like Word 95
AlignTableRowByRow38Align Table Rows by Rule
LayoutRawTableWidth39Layout Raw Table Width
LayoutTableRowsApart40Layout Table Rows Apart
UseWord97LineBreakRules41Use Word 97 Line Break Rules
DoNotBreakWrappedTables42Do Not Break Wrapped Tables
doNotSnapToGridInCell43Do Not Snap to Grid in Cells
SelectFldWithFirstOrLastChar44Select Field with First or Last Character
ApplyBreakingRules45Apply Breaking Rules
DoNotWrapTextWithPunct46Do Not Wrap Text with Punctuation
DoNotUseEastAsianBreakRules47Do Not Use East Asian Break Rules
UseWord2002TableStyleRules48Use Word 2002 Table Style Rules
GrowAutofit49Grow AutoFit
UseNormalStyleForList50Use Normal Style for List
DoNotUseIndentAsNumberingTabStop51Do Not Use Indent as Numbering Tab Stop
UseAltKinsokuLineBreakRules52Use Alt Kinsoku Line Break Rules
AllowSpaceOfSameStyleInTable53Allow Space of Same Style in Table
DoNotSuppressIndentation54Do Not Suppress Indentation
DoNotAutofitConstrainedTables55Do Not AutoFit Constrained Tables
AutofitToFirstFixedWidthCell56AutoFit to First Fixed-Width Cell
UnderlineTabInNumList57Underline Tab in Numbered List
DisplayHangulFixedWidth58Display Hangul Fixed Width
SplitPgBreakAndParaMark59Split Page Break and Paragraph Mark
DoNotVertAlignCellWithSp60Do Not Vertically Align Cell with Spacing
DoNotBreakConstrainedForcedTable61Do Not Break Constrained Forced Tables
DoNotVertAlignInTxbx62Do Not Vertically Align in Textboxes
UseAnsiKerningPairs63Use ANSI Kerning Pairs
CachedColBalance64Cached Column Balancing
UseFELayout65Use Far East Layout
UICompat97To200366User Interface Compatibility Mode from Word 97 to Word 2003
OverrideTableStyleFontSizeAndJustification67Override Table Style Font Size and Justification
DisableOpenTypeFontFormattingFeatures68Disable OpenType Font Formatting Features
SwapInsideAndOutsideForMirrorIndentsAndRelativePositioning69Swap Inside and Outside for Mirror Indents and Relative Positioning
UseWord2010TableStyleRules70Use Word 2010 Table Style Rules

Examples

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:");
    PrintCompatibilityOptions(options);

    // We can access these settings 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.
    doc.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2010);
    Console.WriteLine("\nOptimized for Word 2010:");
    PrintCompatibilityOptions(options);

    doc.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2000);
    Console.WriteLine("\nOptimized for Word 2000:");
    PrintCompatibilityOptions(options);
}

/// <summary>
/// Groups all flags in a document's compatibility options object by state, then prints each group.
/// </summary>
private static void PrintCompatibilityOptions(CompatibilityOptions options)
{
    IList<string> enabledOptions = new List<string>();
    IList<string> disabledOptions = new List<string>();
    AddOptionName(options.AdjustLineHeightInTable, "AdjustLineHeightInTable", enabledOptions, disabledOptions);
    AddOptionName(options.AlignTablesRowByRow, "AlignTablesRowByRow", enabledOptions, disabledOptions);
    AddOptionName(options.AllowSpaceOfSameStyleInTable, "AllowSpaceOfSameStyleInTable", enabledOptions, disabledOptions);
    AddOptionName(options.ApplyBreakingRules, "ApplyBreakingRules", enabledOptions, disabledOptions);
    AddOptionName(options.AutoSpaceLikeWord95, "AutoSpaceLikeWord95", enabledOptions, disabledOptions);
    AddOptionName(options.AutofitToFirstFixedWidthCell, "AutofitToFirstFixedWidthCell", enabledOptions, disabledOptions);
    AddOptionName(options.BalanceSingleByteDoubleByteWidth, "BalanceSingleByteDoubleByteWidth", enabledOptions, disabledOptions);
    AddOptionName(options.CachedColBalance, "CachedColBalance", enabledOptions, disabledOptions);
    AddOptionName(options.ConvMailMergeEsc, "ConvMailMergeEsc", enabledOptions, disabledOptions);
    AddOptionName(options.DisableOpenTypeFontFormattingFeatures, "DisableOpenTypeFontFormattingFeatures", enabledOptions, disabledOptions);
    AddOptionName(options.DisplayHangulFixedWidth, "DisplayHangulFixedWidth", enabledOptions, disabledOptions);
    AddOptionName(options.DoNotAutofitConstrainedTables, "DoNotAutofitConstrainedTables", enabledOptions, disabledOptions);
    AddOptionName(options.DoNotBreakConstrainedForcedTable, "DoNotBreakConstrainedForcedTable", enabledOptions, disabledOptions);
    AddOptionName(options.DoNotBreakWrappedTables, "DoNotBreakWrappedTables", enabledOptions, disabledOptions);
    AddOptionName(options.DoNotExpandShiftReturn, "DoNotExpandShiftReturn", enabledOptions, disabledOptions);
    AddOptionName(options.DoNotLeaveBackslashAlone, "DoNotLeaveBackslashAlone", enabledOptions, disabledOptions);
    AddOptionName(options.DoNotSnapToGridInCell, "DoNotSnapToGridInCell", enabledOptions, disabledOptions);
    AddOptionName(options.DoNotSuppressIndentation, "DoNotSnapToGridInCell", enabledOptions, disabledOptions);
    AddOptionName(options.DoNotSuppressParagraphBorders, "DoNotSuppressParagraphBorders", enabledOptions, disabledOptions);
    AddOptionName(options.DoNotUseEastAsianBreakRules, "DoNotUseEastAsianBreakRules", enabledOptions, disabledOptions);
    AddOptionName(options.DoNotUseHTMLParagraphAutoSpacing, "DoNotUseHTMLParagraphAutoSpacing", enabledOptions, disabledOptions);
    AddOptionName(options.DoNotUseIndentAsNumberingTabStop, "DoNotUseIndentAsNumberingTabStop", enabledOptions, disabledOptions);
    AddOptionName(options.DoNotVertAlignCellWithSp, "DoNotVertAlignCellWithSp", enabledOptions, disabledOptions);
    AddOptionName(options.DoNotVertAlignInTxbx, "DoNotVertAlignInTxbx", enabledOptions, disabledOptions);
    AddOptionName(options.DoNotWrapTextWithPunct, "DoNotWrapTextWithPunct", enabledOptions, disabledOptions);
    AddOptionName(options.FootnoteLayoutLikeWW8, "FootnoteLayoutLikeWW8", enabledOptions, disabledOptions);
    AddOptionName(options.ForgetLastTabAlignment, "ForgetLastTabAlignment", enabledOptions, disabledOptions);
    AddOptionName(options.GrowAutofit, "GrowAutofit", enabledOptions, disabledOptions);
    AddOptionName(options.LayoutRawTableWidth, "LayoutRawTableWidth", enabledOptions, disabledOptions);
    AddOptionName(options.LayoutTableRowsApart, "LayoutTableRowsApart", enabledOptions, disabledOptions);
    AddOptionName(options.LineWrapLikeWord6, "LineWrapLikeWord6", enabledOptions, disabledOptions);
    AddOptionName(options.MWSmallCaps, "MWSmallCaps", enabledOptions, disabledOptions);
    AddOptionName(options.NoColumnBalance, "NoColumnBalance", enabledOptions, disabledOptions);
    AddOptionName(options.NoExtraLineSpacing, "NoExtraLineSpacing", enabledOptions, disabledOptions);
    AddOptionName(options.NoLeading, "NoLeading", enabledOptions, disabledOptions);
    AddOptionName(options.NoSpaceRaiseLower, "NoSpaceRaiseLower", enabledOptions, disabledOptions);
    AddOptionName(options.NoTabHangInd, "NoTabHangInd", enabledOptions, disabledOptions);
    AddOptionName(options.OverrideTableStyleFontSizeAndJustification, "OverrideTableStyleFontSizeAndJustification", enabledOptions, disabledOptions);
    AddOptionName(options.PrintBodyTextBeforeHeader, "PrintBodyTextBeforeHeader", enabledOptions, disabledOptions);
    AddOptionName(options.PrintColBlack, "PrintColBlack", enabledOptions, disabledOptions);
    AddOptionName(options.SelectFldWithFirstOrLastChar, "SelectFldWithFirstOrLastChar", enabledOptions, disabledOptions);
    AddOptionName(options.ShapeLayoutLikeWW8, "ShapeLayoutLikeWW8", enabledOptions, disabledOptions);
    AddOptionName(options.ShowBreaksInFrames, "ShowBreaksInFrames", enabledOptions, disabledOptions);
    AddOptionName(options.SpaceForUL, "SpaceForUL", enabledOptions, disabledOptions);
    AddOptionName(options.SpacingInWholePoints, "SpacingInWholePoints", enabledOptions, disabledOptions);
    AddOptionName(options.SplitPgBreakAndParaMark, "SplitPgBreakAndParaMark", enabledOptions, disabledOptions);
    AddOptionName(options.SubFontBySize, "SubFontBySize", enabledOptions, disabledOptions);
    AddOptionName(options.SuppressBottomSpacing, "SuppressBottomSpacing", enabledOptions, disabledOptions);
    AddOptionName(options.SuppressSpBfAfterPgBrk, "SuppressSpBfAfterPgBrk", enabledOptions, disabledOptions);
    AddOptionName(options.SuppressSpacingAtTopOfPage, "SuppressSpacingAtTopOfPage", enabledOptions, disabledOptions);
    AddOptionName(options.SuppressTopSpacing, "SuppressTopSpacing", enabledOptions, disabledOptions);
    AddOptionName(options.SuppressTopSpacingWP, "SuppressTopSpacingWP", enabledOptions, disabledOptions);
    AddOptionName(options.SwapBordersFacingPgs, "SwapBordersFacingPgs", enabledOptions, disabledOptions);
    AddOptionName(options.SwapInsideAndOutsideForMirrorIndentsAndRelativePositioning, "SwapInsideAndOutsideForMirrorIndentsAndRelativePositioning", enabledOptions, disabledOptions);
    AddOptionName(options.TransparentMetafiles, "TransparentMetafiles", enabledOptions, disabledOptions);
    AddOptionName(options.TruncateFontHeightsLikeWP6, "TruncateFontHeightsLikeWP6", enabledOptions, disabledOptions);
    AddOptionName(options.UICompat97To2003, "UICompat97To2003", enabledOptions, disabledOptions);
    AddOptionName(options.UlTrailSpace, "UlTrailSpace", enabledOptions, disabledOptions);
    AddOptionName(options.UnderlineTabInNumList, "UnderlineTabInNumList", enabledOptions, disabledOptions);
    AddOptionName(options.UseAltKinsokuLineBreakRules, "UseAltKinsokuLineBreakRules", enabledOptions, disabledOptions);
    AddOptionName(options.UseAnsiKerningPairs, "UseAnsiKerningPairs", enabledOptions, disabledOptions);
    AddOptionName(options.UseFELayout, "UseFELayout", enabledOptions, disabledOptions);
    AddOptionName(options.UseNormalStyleForList, "UseNormalStyleForList", enabledOptions, disabledOptions);
    AddOptionName(options.UsePrinterMetrics, "UsePrinterMetrics", enabledOptions, disabledOptions);
    AddOptionName(options.UseSingleBorderforContiguousCells, "UseSingleBorderforContiguousCells", enabledOptions, disabledOptions);
    AddOptionName(options.UseWord2002TableStyleRules, "UseWord2002TableStyleRules", enabledOptions, disabledOptions);
    AddOptionName(options.UseWord2010TableStyleRules, "UseWord2010TableStyleRules", enabledOptions, disabledOptions);
    AddOptionName(options.UseWord97LineBreakRules, "UseWord97LineBreakRules", enabledOptions, disabledOptions);
    AddOptionName(options.WPJustification, "WPJustification", enabledOptions, disabledOptions);
    AddOptionName(options.WPSpaceWidth, "WPSpaceWidth", enabledOptions, disabledOptions);
    AddOptionName(options.WrapTrailSpaces, "WrapTrailSpaces", enabledOptions, disabledOptions);
    Console.WriteLine("\tEnabled options:");
    foreach (string optionName in enabledOptions)
        Console.WriteLine($"\t\t{optionName}");
    Console.WriteLine("\tDisabled options:");
    foreach (string optionName in disabledOptions)
        Console.WriteLine($"\t\t{optionName}");
}

private static void AddOptionName(Boolean option, String optionName, IList<string> enabledOptions, IList<string> disabledOptions)
{
    if (option)
        enabledOptions.Add(optionName);
    else
        disabledOptions.Add(optionName);
}

See Also