Skip to end of metadata
Go to start of metadata
Contents Summary

The code in below examples uses some methods defined in the Common Utilities.

Working with File Extensions

Using GroupDocs.Redaction API, you can also work with non-standard extensions. 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 (logs, dumps etc) could be opened with text processors like MS Word/Open Office. 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. ".txt") as being handled by the same DocumentFormatInstance as MS Word files.

The Recipe

  • Initialize RedactionConfiguration instance using RedactorConfiguration.GetInstance()

  • Initialize DocumentFormatConfiguration using RedactionConfiguration.FindFormat(".docx") 

  • Set ExtentionFilter using DocumentFormatConfiguration.ExtensionFilter + ",.txt"

  • Load Document using Redactor.Load(@"C:\sample.docx")

  • Perform exact phrase redaction using Document.RedactWith(new ExactPhraseRedaction("John Doe", new ReplacementOptions("[personal]")))

  • Save document using Document.Save() 

The Code

  • No labels