The process of obscuring or removing confidential data from a file is known as redaction. The redacted data is usually considered sensitive, private, or classified. Improving file security and maintaining the privacy of the information contained within data files are two of the core purposes of redaction. Document redaction could also help secure sensitive personal data such as bank accounts or social security numbers, passwords, addresses, and much more.
Considering the ever-increasing concerns about data privacy, redaction tools, and software have gained much importance. Such tools allow users to electronically redact or hide different types of user data from their multi-format documents. If you are also looking for a feature-rich document redaction tool, look no further than GroupDocs.Redaction for .NET. This document redaction API packs a set of very useful, easy-to-use features for redacting text, annotation, and metadata from PDF, DOCX, XLSX, PPTX, ODT, RTF, PNG, JPG, GIF, and TIFF files.
Before you start redacting your documents using GroupDocs.Redaction for .NET, please ensure having installed the correct API version and any other prerequisites. You have a few options for installing the .NET redaction API such as using NuGet or obtaining the MSI installer from the downloads section. You can also install it via the Package Manager Console:
For further help and information, please check this guide.
After successfully setting up GroupDocs.Redaction for .NET on your system, let’s now check some use cases of the document redaction API for classified information redaction from your documents.
Redacting text is one of the commonly used methods for masking sensitive information in a document. You can use text redaction to protect personal or financial details mentioned in a document (in textual form) by simply concealing or deleting the text that contains such confidential data. Text redaction provides a simple yet effective way of safeguarding your important data. GroupDocs.Redaction for .NET allows you to the exact phrase or a regular expression to redact specified text from your PDF and Word documents, Excel spreadsheets, and PowerPoint presentations.
If you are looking to replace text containing important personal details from a file with custom text using the exact phrase, please use the C# code given below. This code will replace the name 'John Doe' with the specified text thus redacting the name of the person from the document:
using (Redactor redactor = new Redactor(@"sample.docx")) { redactor.Apply(new ExactPhraseRedaction("John Doe", new ReplacementOptions("[personal]"))); redactor.Save(); }
For applying a rectangular black-colored box over the redacted text instead of a replacement string, please use the following code snippet:
You can also use a regular expression for redacting. The below-given C# code will redact text which matches the regular expression sequence of 'two digits, space, two digits, space again and six digits' (example: 12 34 567890) while also inserting a blue-colored rectangular box in place of the redacted text:
Annotations added to a document may contain information that could be classified as sensitive. Therefore, you may want to protect the content of the document annotations. GroupDocs.Redaction for .NET lets you redact the annotation text or remove the annotation altogether.
Please utilize the following C# code to redact the contents of annotations from your .NET documents of PDF, Word, Excel, PowerPoint, RTF, and many other formats:
Just like redacting what’s contained within the annotations, you can completely remove the annotations if needed. Please use the code given below to achieve this:
When working with images, you may encounter a situation where you must remove or redact sensitive information from them. This could be anything from a social security number to the face of a person. Redaction for .NET can work as the perfect image redaction tool for you to sanitize PNG, GIF, TIFF, and JPG images by redacting specific areas in image files, searching and redacting text in an image, or redacting embedded images in .NET.
To redact a certain area in an image using the .NET redaction API, please use the C# code shown below. While we are using a JPG file in this sample code for image redaction, you may use any of the other supported image formats such as PNG, GIF, TIFF, or BMP:
using (Redactor redactor = new Redactor("D:\\sample.jpg")) { System.Drawing.Point samplePoint = new System.Drawing.Point(516, 311); System.Drawing.Size sampleSize = new System.Drawing.Size(170, 35); RedactorChangeLog result = redactor.Apply(new ImageAreaRedaction(samplePoint, new RegionReplacementOptions(System.Drawing.Color.Blue, sampleSize))); if (result.Status != RedactionStatus.Failed) { redactor.Save(); }; }
Along with the usual image redaction, you can also redact images embedded in a document using the .NET redaction API. To redact images embedded with a Microsoft Word file, please use the following code snippet:
using (Redactor redactor = new Redactor("D:\\sample.docx")) { System.Drawing.Point samplePoint = new System.Drawing.Point(516, 311); System.Drawing.Size sampleSize = new System.Drawing.Size(170, 35); RedactorChangeLog result = redactor.Apply(new ImageAreaRedaction(samplePoint, new RegionReplacementOptions(System.Drawing.Color.Blue, sampleSize))); if (result.Status != RedactionStatus.Failed) { redactor.Save(); }; }
Redacting data in documents and images not only enhances content safety but helps with data integrity as well. Redaction is also a way of protecting your sensitive data from getting misused. Now that you have learned all about redacting classified information from different types of files, let’s review saving redacted files using GroupDocs.Redaction for .NET. This document redaction API for .NET allows saving the redacted file in its original format, overwriting the original file, and saving it as a rasterized PDF or to a stream.
This sample code performs Word document redaction and shows how to save a Word document in its original format:
using (Redactor redactor = new Redactor(@"sample.docx")) { // Applying redactions redactor.Apply(new ExactPhraseRedaction("John Doe", new ReplacementOptions("[personal]"))); // Saving to original format by adding the date as a suffix redactor.Save(new SaveOptions() { AddSuffix = true, RasterizeToPDF = false, RedactedFileSuffix = DateTime.Now.ToShortDateString() }); }
You may save the file after Word document redaction as a rasterized PDF, please use the following code to do this:
using (Redactor redactor = new Redactor(@"sample.docx")) { // Applying redactions redactor.Apply(new ExactPhraseRedaction("John Doe", new ReplacementOptions("[personal]"))); // Saving the redacted file as a rasterized PDF redactor.Save(new SaveOptions() { AddSuffix = false, RasterizeToPDF = true }); }
We also provide Free Online Apps for instantly redacting PDF, Word, Excel, PowerPoint, OpenDocument, PNG, JPG, GIF, TIFF, and many other files using your mobile or desktop devices so, please be sure to check them out.
You can easily export data to Microsoft Excel from various available sources such as JSON, and CSV.
Continue ReadingYou have several Excel workbooks, and you want to combine them together into one file for reporting or to keep data in one place
Continue ReadingConverting Word documents including DOC or DOCX in .NET is a very common requirement
Continue Reading