How to Redact Text

by Chaknith Bin

Redact text involves the process of permanently removing or obscuring sensitive or confidential information from a document. This is typically done by covering the text with a black box or using a tool to delete the text entirely. Redaction ensures that the information cannot be accessed or viewed, providing privacy and security for sensitive content.


C# NuGet Library for PDF

Install with NuGet

Install-Package IronPdf
or
C# PDF DLL

Download DLL

Download DLL

Manually install into your project

Redact Text Example

Text reduction can be easily accomplished with the help of IronPdf. Use the RedactTextOnAllPages method to remove the specified phrase from the entire document. Let's use a sample PDF authored by Lena Bourne.

:path=/static-assets/pdf/content-code-examples/how-to/redact-text-redact-text.cs
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");

// Redact 'are' phrase from all pages
pdf.RedactTextOnAllPages("are");

pdf.SaveAs("redacted.pdf");
Dim pdf As PdfDocument = PdfDocument.FromFile("novel.pdf")

' Redact 'are' phrase from all pages
pdf.RedactTextOnAllPages("are")

pdf.SaveAs("redacted.pdf")
VB   C#

Output PDF

Use RedactTextOnPage and RedactTextOnPages methods to redact text from a single or multiple pages, respectively.

Chaknith Bin

Software Engineer

Chaknith is the Sherlock Holmes of developers. It first occurred to him he might have a future in software engineering, when he was doing code challenges for fun. His focus is on IronXL and IronBarcode, but he takes pride in helping customers with every product. Chaknith leverages his knowledge from talking directly with customers, to help further improve the products themselves. His anecdotal feedback goes beyond Jira tickets and supports product development, documentation and marketing, to improve customer’s overall experience.When he isn’t in the office, he can be found learning about machine learning, coding and hiking.