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:
Python
importgroupdocs.redactionasgrimportgroupdocs.redaction.optionsasgroimportgroupdocs.redaction.redactionsasgrrimportgroupdocs.redaction.configurationasgrcdefrun():# Add .dump format to the list of supported formatsconfig=grc.RedactorConfiguration.get_instance()settings=config.find_format(".txt")settings.extension_filter=settings.extension_filter+",.dump";# Specify the redaction optionsrepl_opt=grr.ReplacementOptions("[redacted]")ex_red=grr.ExactPhraseRedaction("dolor",repl_opt)# Load the document to be redactedwithgr.Redactor("source.dump")asredactor:# Apply the redactionresult=redactor.apply(ex_red)# Save the redacted documentredactor.save()
In detail, creating your own document format instances is covered in another article.
More resources
GitHub examples
You may easily run the code above and see the feature in action in our GitHub examples:
Along with full featured .NET library we provide simple, but powerful free Apps.
You are welcome to perform redactions for various document formats like PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, Emails and more with our free online Free Online Document Redaction App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.