Specify OOXML Compliance Level for Word Documents
Leave feedback
Overview
GroupDocs.Assembly for .NET allows you to control the OOXML compliance level when saving Word documents to OOXML formats (DOCX, DOCM, DOTX, DOTM, FlatOpc, etc.). You can explicitly specify the compliance level or let the system automatically preserve the original document’s compliance level.
Set the OoxmlCompliance property to the desired compliance level (or leave null for automatic preservation)
Use DocumentAssembler with the LoadSaveOptions to assemble the document
The output document will be saved with the specified compliance level
Note
The OoxmlCompliance property only applies to OOXML formats (DOCX, DOCM, DOTX, DOTM, FlatOpc, etc.) and is ignored for other file formats. When set to null (default), the system automatically preserves the original document’s compliance level if it was Transitional, otherwise uses Strict compliance.
Available OOXML Compliance Levels
The OoxmlCompliance enumeration provides three compliance levels:
Ecma: Specifies ECMA-376 compliance level
Transitional: Specifies ISO/IEC 29500:2008 Transitional compliance level (commonly used for compatibility)
Strict: Specifies ISO/IEC 29500:2008 Strict compliance level (fully compliant with the standard)
Specify Explicit OOXML Compliance Level
You can explicitly set the OOXML compliance level when assembling a document:
usingGroupDocs.Assembly;publicstaticvoidSpecifyExplicitCompliance(){DocumentAssemblerassembler=newDocumentAssembler();// Create LoadSaveOptions with explicit OOXML compliancevaroptions=newLoadSaveOptions(FileFormat.Docx);options.OoxmlCompliance=OoxmlCompliance.Strict;// or Ecma, Transitionalvardata=new{CompanyName="ABC Corp",Year=2024};assembler.AssembleDocument("Template.docx","Output.docx",options,newDataSourceInfo(data,"company"));}
Use Transitional Compliance
For maximum compatibility with older Office versions, use Transitional compliance:
When OoxmlCompliance is not explicitly set (default null), the system automatically preserves the original document’s compliance level if it was Transitional:
usingGroupDocs.Assembly;publicstaticvoidPreserveOriginalCompliance(){DocumentAssemblerassembler=newDocumentAssembler();// OoxmlCompliance is null by default - original compliance will be preservedvaroptions=newLoadSaveOptions(FileFormat.Docx);// options.OoxmlCompliance is null - automatic preservationvardata=new{Title="Document Title",Content="Document content"};// Output document will maintain Transitional compliance from template if it was Transitionalassembler.AssembleDocument("Template_Transitional.docx","Output.docx",options,newDataSourceInfo(data,"document"));}
Using with Different OOXML Formats
The OoxmlCompliance property works with all OOXML formats:
usingGroupDocs.Assembly;publicstaticvoidUseWithDifferentFormats(){DocumentAssemblerassembler=newDocumentAssembler();vardata=new{Name="Test Document",Value=100};// DOCX formatvardocxOptions=newLoadSaveOptions(FileFormat.Docx);docxOptions.OoxmlCompliance=OoxmlCompliance.Strict;assembler.AssembleDocument("Template.docx","Output.docx",docxOptions,newDataSourceInfo(data,"item"));// DOCM format (macro-enabled)vardocmOptions=newLoadSaveOptions(FileFormat.Docm);docmOptions.OoxmlCompliance=OoxmlCompliance.Transitional;assembler.AssembleDocument("Template.docm","Output.docm",docmOptions,newDataSourceInfo(data,"item"));// DOTX format (template)vardotxOptions=newLoadSaveOptions(FileFormat.Dotx);dotxOptions.OoxmlCompliance=OoxmlCompliance.Strict;assembler.AssembleDocument("Template.dotx","Output.dotx",dotxOptions,newDataSourceInfo(data,"item"));}
Using with Streams
You can also specify OOXML compliance when working with streams:
When explicitly set: The specified compliance level is used when saving to OOXML formats
When null (default):
If the original document had Transitional compliance, it is preserved
Otherwise, Strict compliance is used
For non-OOXML formats: The property is ignored (e.g., PDF, HTML, RTF)
usingGroupDocs.Assembly;publicstaticvoidDemonstrateComplianceBehavior(){DocumentAssemblerassembler=newDocumentAssembler();vardata=new{Title="Test",Content="Content"};// Explicit Strict compliancevarstrictOptions=newLoadSaveOptions(FileFormat.Docx);strictOptions.OoxmlCompliance=OoxmlCompliance.Strict;assembler.AssembleDocument("Template.docx","Output_Strict.docx",strictOptions,newDataSourceInfo(data,"doc"));// Automatic preservation (null)varautoOptions=newLoadSaveOptions(FileFormat.Docx);// autoOptions.OoxmlCompliance is null - will preserve if Transitionalassembler.AssembleDocument("Template.docx","Output_Auto.docx",autoOptions,newDataSourceInfo(data,"doc"));// Note: For PDF output, OoxmlCompliance is ignoredvarpdfOptions=newLoadSaveOptions(FileFormat.Pdf);pdfOptions.OoxmlCompliance=OoxmlCompliance.Strict;// Ignored for PDFassembler.AssembleDocument("Template.docx","Output.pdf",pdfOptions,newDataSourceInfo(data,"doc"));}
Warning
The OoxmlCompliance property only affects OOXML formats. When saving to other formats like PDF, HTML, or RTF, this property is ignored. The compliance level is determined by the output format, not the template format.
Advanced Usage Topics
To learn more about format-specific options, document conversion settings, and advanced compliance handling, please refer to the advanced usage section.
More resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples: