What You Can Do with GroupDocs.Redaction for Java

Remove Sensitive Data from PDF Files with Java

Clean up PDF files using Java and GroupDocs.Redaction for Java. Redact personal, legal, or business content easily.

How to Redact Text in Pdf Files

With GroupDocs.Redaction for Java, Java developers can remove sensitive content in just a few steps.

  1. Create a Redactor and load your Pdf file.
  2. Choose the redaction settings you want.
  3. Enter the text to search for and its replacement.
  4. Apply redaction and save the file.
// How to clean up a PDF file

// Create a Redactor and load the document
final Redactor redactor = new Redactor("input.pdf");
try
{
    // Set your redaction rules
    // Add the text to remove and what to replace it with
    ReplacementOptions opt = new ReplacementOptions("[redacted]");
    
    ExactPhraseRedaction redaction = new ExactPhraseRedaction("Text to hide", opt);

    // Apply the redaction and save the new file
    redactor.apply(redaction);
    redactor.save();
}
finally { redactor.close(); }
<dependencies> <dependency> <groupId>com.groupdocs</groupId> <artifactId>groupdocs-redaction</artifactId> <version>24.6</version> </dependency> </dependencies> <repositories> <repository> <id>repository.groupdocs.com</id> <name>GroupDocs Repository</name> <url>https://repository.groupdocs.com/repo/</url> </repository> </repositories>
click to copy
copied
More examples Documentation

More Redaction Features

GroupDocs.Redaction for Java removes sensitive info across many formats. Redact text, images, and metadata while keeping files readable.

Tools for text and image redaction

Find and replace text

Search for any words or phrases and replace them. Works with plain text or regex.

Cover image content

Hide pictures or parts of images using colored overlays.

Clean metadata

Remove author names, dates, or other hidden details before sharing.

Redact Text with Regex

Use regex to find and hide patterns like emails, IDs, or custom formats.

Java

//  Open the document you want to edit
final Redactor redactor = new Redactor("source.pdf");
try
{
    // Add an EMAIL regex pattern and replacement text
    ReplacementOptions repl_opt = new ReplacementOptions("[redacted]");
    String emailRegex = "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}";

    RegexRedaction redaction = new RegexRedaction(emailRegex, repl_opt);
    
    // Apply redaction to matching content
    redactor.apply(redaction);

    // Save the redacted version
    SaveOptions saveOptions = new SaveOptions();
    saveOptions.setAddSuffix(true);
    saveOptions.setRasterizeToPDF(false);
    redactor.save(saveOptions);
}
finally { redactor.close(); }
<dependencies> <dependency> <groupId>com.groupdocs</groupId> <artifactId>groupdocs-redaction</artifactId> <version>24.6</version> </dependency> </dependencies> <repositories> <repository> <id>repository.groupdocs.com</id> <name>GroupDocs Repository</name> <url>https://repository.groupdocs.com/repo/</url> </repository> </repositories>
click to copy
copied
More examples Documentation

About GroupDocs.Redaction for Java

GroupDocs.Redaction for Java gives Java developers a simple way to clean PDF files. Remove or replace text, images, comments, and hidden data.
Learn more
About illustration

Ready to get started?

Download GroupDocs.Redaction for free or get a trial license for full access!

Useful resources

Explore documentation, code samples, and community support to enhance your experience.

Redact PDF Files with Java

Protect personal or business information by redacting PDF content with tools from Java.

Temporary license tips

1
Sign up with your work email.
Free mail services are not allowed.
2
Use Get a temporary license button on the second step.
 English