Extend supported extensions list

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

This method can be used when for some reason files have non-standard extensions or if its format is supported, but not pre-configured. For instance, all kinds of plain text files (batch, command files, etc.) could be opened. In this case you do not need to create your own format handler. As it is shown below, you can add file extension (e.g. “.dump”) as being handled by the same DocumentFormatInstance as all plain text files:

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


def extend_supported_extensions_list():
    # Add the .dump format to the list of supported formats, handled as plain text
    config = RedactorConfiguration.get_instance()

    settings = config.find_format(".txt")

    settings.extension_filter = settings.extension_filter + ",.dump"

    # Specify the redaction options
    repl_opt = ReplacementOptions("[redacted]")
    ex_red = ExactPhraseRedaction("Emily Johnson", repl_opt)

    # Load the document with the newly supported extension
    with Redactor("./sample.dump") as redactor:

        # Apply the redaction
        redactor.apply(ex_red)

        # Save the redacted document
        save_options = SaveOptions()
        save_options.add_suffix = True
        save_options.rasterize_to_pdf = True
        save_options.redacted_file_suffix = "redacted"
        result_path = redactor.save(save_options)
        print(f"Document redacted successfully.\nCheck output in {result_path}.")


if __name__ == "__main__":
    extend_supported_extensions_list()

sample.dump is the sample file used in this example. Click here to download it.

Binary file (PDF, 537 KB)

Download full output

In detail, creating your own document format instances is covered in another article.

On this page