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 it null to keep the template’s level)
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 it is not set (null by default), the report keeps the compliance level of the template, whatever it is: an Ecma-376 template gives an Ecma-376 report, a Transitional template a Transitional report, and a Strict template a Strict report.
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 report keeps the compliance level of the template (Ecma, Transitional or Strict):
usingGroupDocs.Assembly;publicstaticvoidPreserveOriginalCompliance(){DocumentAssemblerassembler=newDocumentAssembler();// OoxmlCompliance is null by default - the template's compliance level is keptvaroptions=newLoadSaveOptions(FileFormat.Docx);// options.OoxmlCompliance is null - automatic preservationvardata=new{Title="Document Title",Content="Document content"};// The output document keeps the compliance level of the templateassembler.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): The report keeps the template’s compliance level (Ecma, Transitional or Strict)
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 - the template's compliance level is keptassembler.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: