IronPDF How-Tos Redact Text & Regions How to Redact Text and Regions ByCurtis Chau February 27, 2024 Updated June 22, 2025 Share: View the IronPDF YouTube Playlist Your business is spending too much on yearly subscriptions for PDF security and compliance. Consider IronSecureDoc, which provides solutions for managing SaaS services like digital signing, redaction, encryption, and protection, all for a one-time payment. Explore IronSecureDoc documentation and features Redacting text involves permanently removing or obscuring sensitive or confidential information from a document. This is usually 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. Similarly, redacting a region obscures the specified areas on the document. This process requires a bit more work since the coordinates, width, and height of the region must be provided. Get started with IronPDF Start using IronPDF in your project today with a free trial. First Step: Start for Free How to Redact Text and Regions Download the C# library to redact text and regions Prepare the PDF document for redaction Use the RedactTextOnAllPages method to redact text on the entire document Use the RedactRegionsOnAllPages method to redact regions on every page of the document Save or export the PDF document as a new document Redact Text Example Text redaction can be easily accomplished with the help of IronPDF. Use the RedactTextOnAllPages method to remove a specified phrase from the entire document. Let's use a PDF example document. :path=/static-assets/pdf/content-code-examples/how-to/redact-text-redact-text.cs using IronPdf; // Import the IronPdf namespace to use its PDF manipulation functionalities // Create a PdfDocument object from an existing PDF file named "novel.pdf". // The PdfDocument.FromFile method is used to load the PDF document. PdfDocument pdf = PdfDocument.FromFile("novel.pdf"); // Redact the phrase 'Alaric' from all pages of the PDF document. // The RedactTextOnAllPages method replaces the specified text with a black bar to obscure it. // This method is useful for obscuring confidential or sensitive information within the document. pdf.RedactTextOnAllPages("Alaric"); // Save the modified PDF document to a new file named "redacted.pdf". // The SaveAs method writes the changes to the specified file path. pdf.SaveAs("redacted.pdf"); Imports IronPdf ' Import the IronPdf namespace to use its PDF manipulation functionalities ' Create a PdfDocument object from an existing PDF file named "novel.pdf". ' The PdfDocument.FromFile method is used to load the PDF document. Private pdf As PdfDocument = PdfDocument.FromFile("novel.pdf") ' Redact the phrase 'Alaric' from all pages of the PDF document. ' The RedactTextOnAllPages method replaces the specified text with a black bar to obscure it. ' This method is useful for obscuring confidential or sensitive information within the document. pdf.RedactTextOnAllPages("Alaric") ' Save the modified PDF document to a new file named "redacted.pdf". ' The SaveAs method writes the changes to the specified file path. pdf.SaveAs("redacted.pdf") $vbLabelText $csharpLabel Output PDF Result PDF from redacting the 'Alaric' phrase from all pages. Use RedactTextOnPage and RedactTextOnPages methods to redact text from a single or multiple pages, respectively. Here are the parameters of the redact text methods and their purposes: ReplaceText: This is the text string that you want to redact. CaseSensitive: A boolean value indicating whether the search should be case-sensitive. If true, it will match capital and lower-case letters exactly. The default is false. OnlyMatchWholeWords: A boolean value specifying whether to match only whole words. The default is true. DrawRectangles: A boolean value determining whether to draw black rectangles around the redacted areas. The default is true. ReplacementText: This is the text that will be written in place of the redacted items. The default replacement text is "*". Redact Regions Example Redacting specific regions on the document works really well. Invoke the RedactRegionsOnAllPages method with the RectangleF object to redact the region of the targeted document. Let's use the same PDF example document from the example above. :path=/static-assets/pdf/content-code-examples/how-to/redact-text-redact-region.cs // Import necessary namespaces using IronPdf; using IronSoftware.Drawing; using System.Drawing; // Ensure the code is executed in the proper context or application // Create a PDF document object by loading an existing file. // "novel.pdf" should be placed in the same directory as this executable or provide the full path. PdfDocument pdf = PdfDocument.FromFile("novel.pdf"); // Define a rectangular region to redact with specified coordinates and dimensions. // Coordinates (x, y) are in points and the dimensions width and height should be adjusted according to the specific region that needs redaction. RectangleF rectangle = new RectangleF(5, 700, 50, 50); // Redact the specified region on all pages of the PDF document. // This function applies the defined rectangle redaction over every page in the document. pdf.RedactRegionsOnAllPages(rectangle); // Save the modified PDF to a new file with redacted regions. // "redactedRegion.pdf" will be created in the same directory. If a file of the same name exists, it will be overwritten. pdf.SaveAs("redactedRegion.pdf"); ' Import necessary namespaces Imports IronPdf Imports IronSoftware.Drawing Imports System.Drawing ' Ensure the code is executed in the proper context or application ' Create a PDF document object by loading an existing file. ' "novel.pdf" should be placed in the same directory as this executable or provide the full path. Private pdf As PdfDocument = PdfDocument.FromFile("novel.pdf") ' Define a rectangular region to redact with specified coordinates and dimensions. ' Coordinates (x, y) are in points and the dimensions width and height should be adjusted according to the specific region that needs redaction. Private rectangle As New RectangleF(5, 700, 50, 50) ' Redact the specified region on all pages of the PDF document. ' This function applies the defined rectangle redaction over every page in the document. pdf.RedactRegionsOnAllPages(rectangle) ' Save the modified PDF to a new file with redacted regions. ' "redactedRegion.pdf" will be created in the same directory. If a file of the same name exists, it will be overwritten. pdf.SaveAs("redactedRegion.pdf") $vbLabelText $csharpLabel Output PDF The result PDF is from redacting a region on the coordinates (5,700) with a width and height of 50 pixels. Use RedactRegionOnPage and RedactRegionOnPages methods to redact regions from a single or multiple pages, respectively. Frequently Asked Questions What is text redaction in PDFs? Text redaction involves permanently removing or obscuring sensitive or confidential information from a document, ensuring privacy and security by making the information inaccessible. How can I start redacting text and regions in PDFs? To start redacting text and regions, download the IronPDF library, prepare your PDF document, and use methods like RedactTextOnAllPages and RedactRegionsOnAllPages to remove sensitive information. What is the method used for redacting text on all pages of a PDF? The method used is RedactTextOnAllPages in IronPDF, which allows you to redact specified phrases from the entire document. How can I redact a specific region in a PDF? To redact a specific region, use the RedactRegionsOnAllPages method in IronPDF with a RectangleF object to specify the coordinates, width, and height of the area to be redacted. What parameters can be used with the redact text methods? Parameters in IronPDF include ReplaceText, CaseSensitive, OnlyMatchWholeWords, DrawRectangles, and ReplacementText, each controlling different aspects of the redaction process. Is it possible to redact text from a single page? Yes, you can use the RedactTextOnPage method in IronPDF to redact text from a single page. What is the default replacement text when redacting? The default replacement text in IronPDF is '*', which is used to replace redacted items unless specified otherwise. Can both text and region redaction be performed? Yes, IronPDF supports both text and region redaction, providing methods to handle each type of redaction effectively. Curtis Chau Chat with engineering team now Technical Writer Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.Beyond development, Curtis has a strong interest in the Internet of Things (IoT), exploring innovative ways to integrate hardware and software. In his free time, he enjoys gaming and building Discord bots, combining his love for technology with creativity. Ready to Get Started? Free NuGet Download Total downloads: 14,143,061 View Licenses