What You Can Do with GroupDocs.Redaction for Java

Edit or Remove Text in WORD Files with Java

Protect important content in your WORD files using GroupDocs.Redaction for Java and Java. Redact business, legal, or personal data with confidence.

Steps to Redact Word Documents

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

  1. Create a Redactor and load the Word document.
  2. Set your preferred redaction options.
  3. Choose the text you want to find and replace.
  4. Apply the redaction and save your file.
// Redacting a WORD document

// Load the file using Redactor
final Redactor redactor = new Redactor("input.docx");
try
{
    // Choose your redaction rules
    // Enter the search and replacement text
    ReplacementOptions opt = new ReplacementOptions("[redacted]");
    
    ExactPhraseRedaction redaction = new ExactPhraseRedaction("Text to hide", opt);

    // Run 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 can help you clean up sensitive info from different file types. Remove text, pictures, and hidden metadata quickly.

Redact text, images, and metadata

Search and replace text

Find specific content and replace or delete it across the whole file. Regex supported.

Cover parts of pages

Use overlays to hide photos or sections of the document.

Clear metadata

Erase extra info like author, timestamps, or tracked edits.

Redaction with Regex Patterns

Search for text using regular expressions to hide content like phone numbers, dates, or IDs.

Java

//  Load your document
final Redactor redactor = new Redactor("source.docx");
try
{
    // Set an EMAIL regex pattern and replacement value
    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 the redaction
    redactor.apply(redaction);

    // Save the updated document
    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 gives Java developers a reliable way to redact WORD files. Clean up text, images, comments, and hidden details with just a few lines of code.
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 Content in WORD with Java

Hide or remove personal and private content from WORD documents using Java. A simple way to keep your files safe.

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