CompatibilityOptions
Contents
[
Hide
]CompatibilityOptions class
Contains compatibility options (that is, the user preferences entered on the Compatibility tab of the Options dialog in Microsoft Word).
To learn more, visit the Detect File Format and Check Format Compatibility documentation article.
public class CompatibilityOptions
Properties
Name | Description |
---|---|
AdjustLineHeightInTable { get; set; } | Add Document Grid Line Pitch To Lines in Table Cells. |
AlignTablesRowByRow { get; set; } | Align Table Rows Independently. |
AllowSpaceOfSameStyleInTable { get; set; } | Allow Contextual Spacing of Paragraphs in Tables. |
ApplyBreakingRules { get; set; } | Use Legacy Ethiopic and Amharic Line Breaking Rules. |
AutofitToFirstFixedWidthCell { get; set; } | Allow Table Columns To Exceed Preferred Widths of Constituent Cells. |
AutoSpaceLikeWord95 { get; set; } | Emulate Word 95 Full-Width Character Spacing. |
BalanceSingleByteDoubleByteWidth { get; set; } | Balance Single Byte and Double Byte Characters. |
CachedColBalance { get; set; } | Use Cached Paragraph Information for Column Balancing. |
ConvMailMergeEsc { get; set; } | Treat Backslash Quotation Delimiter as Two Quotation Marks. |
DisableOpenTypeFontFormattingFeatures { get; set; } | Specifies to disable OpenType font formatting features. |
DisplayHangulFixedWidth { get; set; } | Always Use Fixed Width for Hangul Characters. |
DoNotAutofitConstrainedTables { get; set; } | Do Not AutoFit Tables To Fit Next To Wrapped Objects. |
DoNotBreakConstrainedForcedTable { get; set; } | Don’t Break Table Rows Around Floating Tables. |
DoNotBreakWrappedTables { get; set; } | Do Not Allow Floating Tables To Break Across Pages. |
DoNotExpandShiftReturn { get; set; } | Don’t Justify Lines Ending in Soft Line Break. |
DoNotLeaveBackslashAlone { get; set; } | Convert Backslash To Yen Sign When Entered. |
DoNotSnapToGridInCell { get; set; } | Do Not Snap to Document Grid in Table Cells with Objects. |
DoNotSuppressIndentation { get; set; } | Do Not Ignore Floating Objects When Calculating Paragraph Indentation. |
DoNotSuppressParagraphBorders { get; set; } | Do Not Suppress Paragraph Borders Next To Frames. |
DoNotUseEastAsianBreakRules { get; set; } | Do Not Compress Compressible Characters When Using Document Grid. |
DoNotUseHTMLParagraphAutoSpacing { get; set; } | Use Fixed Paragraph Spacing for HTML Auto Setting. |
DoNotUseIndentAsNumberingTabStop { get; set; } | Ignore Hanging Indent When Creating Tab Stop After Numbering. |
DoNotVertAlignCellWithSp { get; set; } | Don’t Vertically Align Cells Containing Floating Objects. |
DoNotVertAlignInTxbx { get; set; } | Ignore Vertical Alignment in Textboxes. |
DoNotWrapTextWithPunct { get; set; } | Do Not Allow Hanging Punctuation With Character Grid. |
FootnoteLayoutLikeWW8 { get; set; } | Emulate Word 6.x/95/97 Footnote Placement. |
ForgetLastTabAlignment { get; set; } | Ignore Width of Last Tab Stop When Aligning Paragraph If It Is Not Left Aligned. |
GrowAutofit { get; set; } | Allow Tables to AutoFit Into Page Margins. |
LayoutRawTableWidth { get; set; } | Ignore Space Before Table When Deciding If Table Should Wrap Floating Object. |
LayoutTableRowsApart { get; set; } | Allow Table Rows to Wrap Inline Objects Independently. |
LineWrapLikeWord6 { get; set; } | Emulate Word 6.0 Line Wrapping for East Asian Text. |
MWSmallCaps { get; set; } | Emulate Word 5.x for the Macintosh Small Caps Formatting. |
NoColumnBalance { get; set; } | Do Not Balance Text Columns within a Section. |
NoExtraLineSpacing { get; set; } | Do Not Center Content on Lines With Exact Line Height. |
NoLeading { get; set; } | Do Not Add Leading Between Lines of Text. |
NoSpaceRaiseLower { get; set; } | Do Not Increase Line Height for Raised/Lowered Text. |
NoTabHangInd { get; set; } | Do Not Create Custom Tab Stop for Hanging Indent. |
OverrideTableStyleFontSizeAndJustification { get; set; } | Specifies how the style hierarchy of the document is evaluated. |
PrintBodyTextBeforeHeader { get; set; } | Print Body Text before Header/Footer Contents. |
PrintColBlack { get; set; } | Print Colors as Black And White without Dithering. |
SelectFldWithFirstOrLastChar { get; set; } | Select Field When First or Last Character Is Selected. |
ShapeLayoutLikeWW8 { get; set; } | Emulate Word 97 Text Wrapping Around Floating Objects. |
ShowBreaksInFrames { get; set; } | Display Page/Column Breaks Present in Frames. |
SpaceForUL { get; set; } | Add Additional Space Below Baseline For Underlined East Asian Text. |
SpacingInWholePoints { get; set; } | Only Expand/Condense Text By Whole Points. |
SplitPgBreakAndParaMark { get; set; } | Always Move Paragraph Mark to Page after a Page Break. |
SubFontBySize { get; set; } | Increase Priority Of Font Size During Font Substitution. |
SuppressBottomSpacing { get; set; } | Ignore Exact Line Height for Last Line on Page. |
SuppressSpacingAtTopOfPage { get; set; } | Ignore Minimum Line Height for First Line on Page. |
SuppressSpBfAfterPgBrk { get; set; } | Do Not Use Space Before On First Line After a Page Break. |
SuppressTopSpacing { get; set; } | Ignore Minimum and Exact Line Height for First Line on Page. |
SuppressTopSpacingWP { get; set; } | Emulate WordPerfect 5.x Line Spacing. |
SwapBordersFacingPgs { get; set; } | Swap Paragraph Borders on Odd Numbered Pages. |
SwapInsideAndOutsideForMirrorIndentsAndRelativePositioning { get; set; } | Specifies to swap inside and outside for mirror indents and relative positioning. |
TransparentMetafiles { get; set; } | Specifies not to blank the area behind metafile pictures. |
TruncateFontHeightsLikeWP6 { get; set; } | Emulate WordPerfect 6.x Font Height Calculation. |
UICompat97To2003 { get; set; } | True to disable UI functionality which is not compatible with Word97-2003. Default value is false . |
UlTrailSpace { get; set; } | Underline All Trailing Spaces. |
UnderlineTabInNumList { get; set; } | Underline Following Character Following Numbering. |
UseAltKinsokuLineBreakRules { get; set; } | Use Alternate Set of East Asian Line Breaking Rules. |
UseAnsiKerningPairs { get; set; } | Use ANSI Kerning Pairs from Fonts. |
UseFELayout { get; set; } | Do Not Bypass East Asian/Complex Script Layout Code. |
UseNormalStyleForList { get; set; } | Do Not Automatically Apply List Paragraph Style To Bulleted/Numbered Text. |
UsePrinterMetrics { get; set; } | Use Printer Metrics To Display Documents. |
UseSingleBorderforContiguousCells { get; set; } | Use Simplified Rules For Table Border Conflicts. |
UseWord2002TableStyleRules { get; set; } | Emulate Word 2002 Table Style Rules. |
UseWord2010TableStyleRules { get; set; } | Specifies to use Word2010 table style rules. |
UseWord97LineBreakRules { get; set; } | Emulate Word 97 East Asian Line Breaking. |
WPJustification { get; set; } | Emulate WordPerfect 6.x Paragraph Justification. |
WPSpaceWidth { get; set; } | Specifies whether to set the width of a space as is done in WordPerfect 5.x. |
WrapTrailSpaces { get; set; } | Line Wrap Trailing Spaces. |
Methods
Name | Description |
---|---|
OptimizeFor(MsWordVersion) | Allows to optimize the document contents as well as default Aspose.Words behavior to a particular versions of MS Word. |
Examples
Shows how to vertically align the text contents of a text box.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.InsertShape(ShapeType.TextBox, 200, 200);
// Set the "VerticalAnchor" property to "TextBoxAnchor.Top" to
// align the text in this text box with the top side of the shape.
// Set the "VerticalAnchor" property to "TextBoxAnchor.Middle" to
// align the text in this text box to the center of the shape.
// Set the "VerticalAnchor" property to "TextBoxAnchor.Bottom" to
// align the text in this text box to the bottom of the shape.
shape.TextBox.VerticalAnchor = verticalAnchor;
builder.MoveTo(shape.FirstParagraph);
builder.Write("Hello world!");
// The vertical aligning of text inside text boxes is available from Microsoft Word 2007 onwards.
doc.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2007);
doc.Save(ArtifactsDir + "Shape.VerticalAnchor.docx");
Shows how to set an OOXML compliance specification for a saved document to adhere to.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// If we configure compatibility options to comply with Microsoft Word 2003,
// inserting an image will define its shape using VML.
doc.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2003);
builder.InsertImage(ImageDir + "Transparent background logo.png");
Assert.AreEqual(ShapeMarkupLanguage.Vml, ((Shape)doc.GetChild(NodeType.Shape, 0, true)).MarkupLanguage);
// The "ISO/IEC 29500:2008" OOXML standard does not support VML shapes.
// If we set the "Compliance" property of the SaveOptions object to "OoxmlCompliance.Iso29500_2008_Strict",
// any document we save while passing this object will have to follow that standard.
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions
{
Compliance = OoxmlCompliance.Iso29500_2008_Strict,
SaveFormat = SaveFormat.Docx
};
doc.Save(ArtifactsDir + "OoxmlSaveOptions.Iso29500Strict.docx", saveOptions);
// Our saved document defines the shape using DML to adhere to the "ISO/IEC 29500:2008" OOXML standard.
doc = new Document(ArtifactsDir + "OoxmlSaveOptions.Iso29500Strict.docx");
Assert.AreEqual(ShapeMarkupLanguage.Dml, ((Shape)doc.GetChild(NodeType.Shape, 0, true)).MarkupLanguage);
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
- class Document
- property CompatibilityOptions
- namespace Aspose.Words.Settings
- assembly Aspose.Words