What You Can Do with GroupDocs.Redaction for Java

Edit or Remove Text in DOCX Documents Using Java

Protect personal or business content in your DOCX files with Java and GroupDocs.Redaction for Java.

How to Redact Content in Docx Files

Use GroupDocs.Redaction for Java in your Java projects to clean up files before sharing.

  1. Create a Redactor and load the file.
  2. Choose your redaction options.
  3. Enter the text to search for and its replacement.
  4. Apply redactions and save the file.
// Redact content in a DOCX file

// Load the document using Redactor
final Redactor redactor = new Redactor("input.docx");
try
{
    // Set redaction options
    // Define what to find and replace
    ReplacementOptions opt = new ReplacementOptions("[redacted]");
    
    ExactPhraseRedaction redaction = new ExactPhraseRedaction("Text to hide", opt);

    // Apply redaction and save
    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

Redaction Options

GroupDocs.Redaction for Java lets you clean up sensitive content from many file types. Keep your documents safe without losing structure.

Tools for removing content

Replace text

Find specific content and replace it across the document.

Hide images or parts

Cover sensitive visuals with colored overlays.

Remove hidden data

Clear metadata such as author names, timestamps, or document properties.

Regex-Based Redaction

Use regular expressions to detect and redact patterns like phone numbers or emails.

Java

//  Load the document
final Redactor redactor = new Redactor("source.docx");
try
{
    // Set 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);
    
    // Run the redaction
    redactor.apply(redaction);

    // Save the clean file
    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

What Is GroupDocs.Redaction for Java?

GroupDocs.Redaction for Java helps Java developers clean and redact DOCX files. Remove text, pictures, comments, and hidden data with ease.
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.

Clean DOCX Files with Java

Redact or replace sensitive content in DOCX documents using the tools provided by 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