How to control OOXML compliance for WordProcessing documents
How to control OOXML compliance for WordProcessing documents
Leave feedback
On this page
Some downstream OOXML tooling supports only specific compliance levels. For example, Docx4j does not read ISO/IEC 29500:2008 Strict output, so consumers that rely on such libraries need the signed document produced in Transitional (or ECMA-376) form instead.
Starting with GroupDocs.Signature for .NET 26.6, the Signature class preserves the OOXML compliance level of the source WordProcessing document on save, and lets you override it through WordProcessingSaveOptions.
How OOXML compliance is handled
The source OoxmlCompliance value is detected when the document is loaded and preserved on save by default.
Create a new instance of Signature class and pass source document path or stream as a constructor parameter.
Instantiate required signature options (for example TextSignOptions).
Instantiate WordProcessingSaveOptions and set the OoxmlCompliance property to the required level (Ecma, Transitional, or Strict).
Call Sign method of Signature class instance and pass signature options and WordProcessingSaveOptions object to it.
Example — force ISO/IEC 29500:2008 Strict on save
using(Signaturesignature=newSignature(filePath)){TextSignOptionssignOptions=newTextSignOptions("John Smith"){Left=100,Top=100,Width=200,Height=60};// Force ISO 29500:2008 Strict on save regardless of the source's compliance.// Other allowed values: OoxmlCompliance.Ecma, OoxmlCompliance.Transitional.WordProcessingSaveOptionssaveOptions=newWordProcessingSaveOptions(WordProcessingSaveFileFormat.Docx){OoxmlCompliance=OoxmlCompliance.Strict};SignResultresult=signature.Sign(outputFilePath,signOptions,saveOptions);}
Example — save as Transitional for downstream compatibility
Use OoxmlCompliance.Transitional when the consumer of the signed document only reads ISO/IEC 29500:2008 Transitional (or ECMA-376) DOCX — for example when the file will be post-processed by a library that does not support Strict.
Leave OoxmlCompliance unset (or explicitly null) to preserve whatever compliance level the loaded document was authored in.
using(Signaturesignature=newSignature(filePath)){TextSignOptionssignOptions=newTextSignOptions("John Smith"){Left=100,Top=100,Width=200,Height=60};// OoxmlCompliance not set => source compliance is preserved on save.WordProcessingSaveOptionssaveOptions=newWordProcessingSaveOptions(WordProcessingSaveFileFormat.Docx);signature.Sign(outputFilePath,signOptions,saveOptions);}
More resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples: