Redaction is the process of obscuring or deleting classified information in a document. The redacted information is usually considered to be sensitive, private, or classified. Therefore, redaction is often used to maintain or improve file security and privacy by keeping sensitive information from getting compromised. Redaction may also be used to remove personal data from documents, such as social security numbers, addresses, or passwords for legal, financial, or official documents.
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 library, look no further than GroupDocs.Redaction for .NET. This 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 GroupDocs.Redaction for .NET 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 of the popular use cases for the redaction of data and classified information from your documents.
Text redaction is the most commonly used option when it comes to concealing or removing important information from a document. This can be done for various reasons, such as protecting sensitive information or simply cleaning up a document before sharing it with someone. There are a few different ways to redact text, including using a replacement text (in place of the redacted content) or inserting colored boxes. 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 can often contain sensitive data such as comments, notes, or even revisions. To ensure keeping the contents of your document annotations secure, you may need to redact them. GroupDocs.Redaction for .NET lets you redact the annotation text or completely remove the actual annotation itself.
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 redact or remove private information from them. This could be anything from a social security number to a person’s face of a person. Redaction for .NET can work as the perfect 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, please use the C# code shown below. While we are using a JPG image in this sample code, 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 GroupDocs.Redaction for .NET. 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(); }; }
When redacting a document or image, it is important to make sure that the information is hidden in such a way that it cannot be recovered or become visible. This helps maintain the integrity of the redacted content. So, once you are done redacting a file of your choice, the next phase is to save it appropriately. Using GroupDocs.Redaction for .NET, you can save the redacted file in its original format, overwrite the original file, and save it as a rasterized PDF or to a stream.
This sample code shows how to save a Word document in its original format after redacting it:
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 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