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:
fromgroupdocs.redactionimportRedactorfromgroupdocs.redaction.configurationimportRedactorConfigurationfromgroupdocs.redaction.optionsimportSaveOptionsfromgroupdocs.redaction.redactionsimportExactPhraseRedaction,ReplacementOptionsdefextend_supported_extensions_list():# Add the .dump format to the list of supported formats, handled as plain textconfig=RedactorConfiguration.get_instance()settings=config.find_format(".txt")settings.extension_filter=settings.extension_filter+",.dump"# Specify the redaction optionsrepl_opt=ReplacementOptions("[redacted]")ex_red=ExactPhraseRedaction("dolor",repl_opt)# Load the document with the newly supported extensionwithRedactor("./sample.dump")asredactor:# Apply the redactionredactor.apply(ex_red)# Save the redacted documentsave_options=SaveOptions()save_options.add_suffix=Truesave_options.rasterize_to_pdf=Truesave_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()