How to Redact Text
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.
How to Redact Text
- Download the C# library to redact text
- Prepare the PDF document for text reduction
- Use the
RedactTextOnAllPages
method to redact text on the entire document - Use the
RedactTextOnPages
method to redact text from pages - Save or export PDF document as new document
Install with NuGet
Install-Package IronPdf
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")
Output PDF
Use RedactTextOnPage
and RedactTextOnPages
methods to redact text from a single or multiple pages, respectively.