In order to reject or approve specific changes during redaction process or to keep a full log of changes in the document, you need to provide an instance of IRedactionCallback to a constructor of RedactorSettings class. The interface contains only one method, AcceptRedaction(), which receives detailed information about proposed redaction and returns Boolean value, accepted or not.
Below, we create a callback class, dumping changes to system console:
C#
publicclassRedactionDump:IRedactionCallback{publicRedactionDump(){}publicboolAcceptRedaction(RedactionDescriptiondescription){Console.Write("{0} redaction, {1} action, item {2}. ",description.RedactionType,description.ActionType,description.OriginalText);if(description.Replacement!=null){Console.Write("Text {0} is replaced with {1}. ",description.Replacement.OriginalText,description.Replacement.Replacement);}Console.WriteLine();// you can return "false" here to prevent particular change during redaction processreturntrue;}}
The instance of this class is to be passed to a constructor of the Redactor class:
C#
using(Redactorredactor=newRedactor("\\Sample.docx",newLoadOptions(),newRedactorSettings(newRedactionDump()))){// Assign an instance before using Redactorredactor.Apply(newExactPhraseRedaction("John Doe",newReplacementOptions("[personal]")));redactor.Save();}
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.