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 Custom File Format

Using GroupDocs.Redaction API, you can also work different file formats. If the format is not supported, you will need to implement a handler for it by inheriting from DocumentFormatInstance class. Depending on the document's features and required redactions, you will also need to implement one or several interfaces, allowing GroupDocs.Redaction to work with this document format.

ITextualFormatInstanceRequired for document text redactions to work, replaces occurrences of the given regular expression with text or a color block
IMetadataAccessRequired for metadata redactions, reads metadata and changes specific metadata item
IAnnotatedDocumentRequired for annotation redactions, changes or deletes annotations, matching given a regular expression
IRasterizableDocumentRequired to rasterize (save a document as a PDF with page images)

To support only textual redactions, you can use DocumentFormatInstance to create PlainTextDocument class.

PlainTextDocument Class

The Recipe

  • Initialize DocumentFormatConfiguration using instance using DocumentFormatConfiguration() { ExtensionFilter = ".txt", DocumentType = typeof(PlainTextDocument)}

  • Load Document using Redactor.Load(@"C:\sample.txt", new LoadOptions(DocumentFormatConfiguration ))

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

  • Save document using Document.Save(new SaveOptions(false, "AnyText"))

The Code

  • No labels