GroupDocs.Redaction for .NET is an easy to use document redaction class library which allows to remove sensitive and classified information from the documents of different formats - DOC/DOCX, XLS/XLSX, PPT/PPTX and others. The library provides powerful sanification features. The sensitive content will be safely removed and resultant document can be saved in original format or rasterized PDF which produces resultant documents which is even more safe to share.
$ dotnet add package GroupDocs.Redaction
GroupDocs.Redaction for .NET is a powerful API designed to redact classified or sensitive data from a variety of document types within your .NET applications. It supports multiple redaction types including text, metadata, annotations, and image redactions. The API also integrates with OCR engines for redacting text within images and provides the ability to remove pages and embedded images, ensuring the comprehensive redaction of confidential information. GroupDocs.Redaction is highly versatile, supporting a wide range of document formats, making it an essential tool for any organization dealing with sensitive information.
Exact Phrase Redaction
Search and redact specific phrases or text strings with case-sensitivity options.
Regex Redaction
Redact text based on regular expressions for flexible text matching.
Right-to-Left Support
Redaction of right-to-left text such as Arabic and Hebrew.
Erase Metadata
Remove all metadata from a document, such as author, date created, and comments.
Metadata Search Redaction
Remove sensitive information from metadata fields using regular expressions.
Delete Annotations
Remove annotations, comments, and other markup from documents.
Redact Annotation Text
Redact sensitive data in annotations while keeping the annotations intact.
Cell and Column Redaction
Redact specific cells or entire columns within Excel spreadsheets.
Filter by Worksheet
Apply redactions to specific worksheets in Excel files.
Image Area Redaction
Cover specific areas of images, such as headers or footers, with a colored box.
OCR-Based Redaction
Use Optical Character Recognition (OCR) to recognize and redact text embedded in images.
EXIF Data Removal
Remove metadata (e.g., EXIF data) from images, acting as an "EXIF eraser."
Remove Pages
Remove specific pages from documents such as PDFs, slideshows, or spreadsheets.
Page Area Filters
Apply redactions to specific areas on a page using coordinates.
Embedded Image Redaction
Redact embedded images in documents, including PDF, Microsoft Office, and OpenOffice files.
Convert to Raster Images
Redact sensitive data and save documents as raster images, making all data unsearchable.
Document Saving Options
Save redacted documents in either original format for further editing or in raster format for increased security.
Third-Party OCR Integration
Integrate third-party OCR engines (e.g., Aspose.OCR or Microsoft Azure Computer Vision API) to recognize and redact text from images or image-based PDFs.
Document Info Retrieval
Retrieve metadata and page counts for any document format.
The following table indicates the file formats supported by GroupDocs.Redaction for .NET.
| Format | Description | Document body | Metadata | Annotations (comments) | Remarks | Embedded images | OCR | Remove Page | Page Filters |
|---|---|---|---|---|---|---|---|---|---|
| Saves the document as PDF (Adobe Portable Document) format | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ||
| DOC | Microsoft Word 97 - 2007 Document. | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ||
| DOT | Microsoft Word 97 - 2007 Template. | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ||
| DOCX | Office Open XML WordprocessingML Document (macro-free) | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ||
| DOCM | Office Open XML WordprocessingML Macro-Enabled Document | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ||
| DOTX | Office Open XML WordprocessingML Template (macro-free) | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ||
| DOTM | Office Open XML WordprocessingML Macro-Enabled Template | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ||
| RTF | RTF format. | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |||
| XLSX | OOXML 2007-2010 | ✔️ | ✔️ | ✔️ | ✔️ | ||||
| XLSM | OOXML Macro Enabled Workbook | ✔️ | ✔️ | ✔️ | ✔️ | ||||
| XLTX | OOXML Workbook Template | ✔️ | ✔️ | ✔️ | ✔️ | ||||
| XLTM | OOXML Macro Enabled Workbook Template | ✔️ | ✔️ | ✔️ | ✔️ | ||||
| XLS | Excel Workbook 97-2003 | ✔️ | ✔️ | ✔️ | ✔️ | ||||
| XLT | Excel Workbook Template 97-2003 | ✔️ | ✔️ | ✔️ | ✔️ | ||||
| CSV | CSV (Comma Separated Value) file. | ✔️ | ✔️ | ✔️ | |||||
| PPTX | OOXML Microsoft PowerPoint Presentations format | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
| PPT | PowerPoint Presentation 97-2003 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
| PPSX | PowerPoint Open XML | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
| POT | PowerPoint template files | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
| PPS | Microsoft PowerPoint 97-2003 Slide Show | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
| PPTM | Microsoft PowerPoint Open XML Macro-Enabled Presentation file | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
| PPSM | Microsoft PowerPoint Open XML Macro-Enabled Slide Show file | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
| POTM | Microsoft PowerPoint template | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
| JPEG | The image file format was standardized by the Joint Photographic Experts Group. | ✔️ | ✔️ | ✔️ | ✔️ | ||||
| TIF/TIFF | Tagged Image File Format | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |||
| PNG | Portable Network Graphics Image | ✔️ | ✔️ | ✔️ | ✔️ | ||||
| BMP | Bitmap Image Files | ✔️ | ✔️ | ✔️ | ✔️ | ||||
| GIF | Graphical Interchange Format Image | ✔️ | ✔️ | ✔️ | |||||
| DJVU | DjVu Document Format | ✔️ | ✔️ |
Below is an overview of the key steps and code examples that will help you begin using the API in your .NET applications.
Package Manager GUI:
Package Manager Console:
Install-Package GroupDocs.Redaction
GroupDocs.Redaction.dll file.This code sample demonstrates how to apply an exact phrase redaction to a document, replacing a specific phrase with a custom string or a colored rectangle. This C# example shows how to redact sensitive information from a document by replacing exact phrases using GroupDocs.Redaction for .NET.
// Learn how to apply an exact phrase redaction to a document using GroupDocs.Redaction for .NET. Replace sensitive phrases with custom text or a color block.
// Import necessary namespaces
using GroupDocs.Redaction;
using GroupDocs.Redaction.Options;
namespace RedactionExample
{
class Program
{
static void Main(string[] args)
{
// Load the document from the local file system
using (Redactor redactor = new Redactor("sample.docx"))
{
// Apply an exact phrase redaction
// Replace "John Doe" with "[personal]" in the document
RedactorChangeLog result = redactor.Apply(new ExactPhraseRedaction("John Doe", new ReplacementOptions("[personal]")));
// Check if the redaction was applied successfully
if (result.Status != RedactionStatus.Failed)
{
// Save the redacted document
redactor.Save();
}
}
}
}
}
This example demonstrates how to remove sensitive data from a document's metadata using a regular expression. It targets specific metadata fields like the author's name. This C# example demonstrates how to redact metadata in a document by targeting specific fields such as the author’s name using GroupDocs.Redaction for .NET.
// Redact metadata in a document using GroupDocs.Redaction for .NET. Remove or replace sensitive metadata fields like author names.
// Import necessary namespaces
using GroupDocs.Redaction;
using GroupDocs.Redaction.Redactions;
using GroupDocs.Redaction.Options;
namespace RedactionExample
{
class Program
{
static void Main(string[] args)
{
// Load the document from the local file system
using (Redactor redactor = new Redactor("sample.docx"))
{
// Create a metadata redaction targeting the author's name
MetadataSearchRedaction redaction = new MetadataSearchRedaction("Company Ltd.", "--company--");
// Apply the redaction to the document's metadata
redactor.Apply(redaction);
// Save the redacted document
redactor.Save();
}
}
}
}
This C# example demonstrates how to redact a specific area of an image embedded in a document by placing a colored rectangle using GroupDocs.Redaction for .NET.
// Redact specific areas within images embedded in documents using GroupDocs.Redaction for .NET. Overlay colored rectangles on sensitive image regions.
// Import necessary namespaces
using GroupDocs.Redaction;
using GroupDocs.Redaction.Redactions;
using System.Drawing;
namespace RedactionExample
{
class Program
{
static void Main(string[] args)
{
// Load the document containing the image from the local file system
using (Redactor redactor = new Redactor("sample.docx"))
{
// Define the area of the image to be redacted (coordinates and size)
Point samplePoint = new Point(516, 311);
Size sampleSize = new Size(170, 35);
// Apply the redaction by placing a blue rectangle over the specified area
RedactorChangeLog result = redactor.Apply(new ImageAreaRedaction(samplePoint, new RegionReplacementOptions(Color.Blue, sampleSize)));
// Check if the redaction was applied successfully
if (result.Status != RedactionStatus.Failed)
{
// Save the redacted document
redactor.Save();
}
}XX
}
}
}
Please check the GitHub Repository for other common usage scenarios.
.NET API | Document Redaction | Sensitive Data Removal | Text Redaction | Metadata Redaction | Image Redaction | OCR Redaction | Regex Redaction | Annotation Redaction | Page Redaction | Document Privacy | Redact PDF | Redact Word Documents | Redact Excel Spreadsheets | EXIF Data Removal | Raster Image Conversion | Secure Document Redaction | Document Anonymization | Cross-Platform Redaction | API for Data Security | GroupDocs.Redaction | Document Cleanup | Microsoft Word Redaction | Excel File Redaction | PowerPoint Redaction | PDF Security | Data Sanitization