Save Word with OOXML compliance

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Redaction MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-redaction -- dnx GroupDocs.Redaction.Mcp --yes
Folders, licensing and more →

On this page

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.

from groupdocs.redaction import Redactor
from groupdocs.redaction.options import SaveOptions, WordProcessingComplianceLevel
from groupdocs.redaction.redactions import ExactPhraseRedaction, ReplacementOptions


def save_word_with_ooxml_compliance():
    with Redactor("./sample.docx") as redactor:
        redactor.apply(ExactPhraseRedaction("Emily Johnson", ReplacementOptions("[personal]")))

        options = SaveOptions()
        options.add_suffix = True
        options.rasterize_to_pdf = False  # keep the Word format
        options.redacted_file_suffix = "Strict"
        # Without this line the original document's compliance level is kept
        options.wordprocessing_save_options.ooxml_compliance = WordProcessingComplianceLevel.STRICT

        result_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.

Binary file (DOCX, 42 KB)

Download full output

On this page