When you save a Word document in its original format, you can set its OOXML compliance level through save_options.wordprocessing_save_options.ooxml_compliance (WordprocessingSaveOptions). The values come from WordProcessingComplianceLevel: ECMA, TRANSITIONAL or STRICT.
Without it, the compliance level of the original document is kept. A Strict document can be saved as Transitional, but not as Ecma.
The option applies to the OOXML Word formats: DOCX, DOCM, DOTX and DOTM. Set rasterize_to_pdf to False, so that the document is saved in its Word format instead of as a rasterized PDF.
fromgroupdocs.redactionimportRedactorfromgroupdocs.redaction.optionsimportSaveOptions,WordProcessingComplianceLevelfromgroupdocs.redaction.redactionsimportExactPhraseRedaction,ReplacementOptionsdefsave_word_with_ooxml_compliance():withRedactor("./sample.docx")asredactor:redactor.apply(ExactPhraseRedaction("Emily Johnson",ReplacementOptions("[personal]")))options=SaveOptions()options.add_suffix=Trueoptions.rasterize_to_pdf=False# keep the Word formatoptions.redacted_file_suffix="Strict"# Without this line the original document's compliance level is keptoptions.wordprocessing_save_options.ooxml_compliance=WordProcessingComplianceLevel.STRICTresult_path=redactor.save(options)print("Output saved to "+result_path)if__name__=="__main__":save_word_with_ooxml_compliance()
sample.docx is the sample file used in this example. Click here to download it.