Get replacement text in IRedactionCallback implementation

Hi Team,

I need to get text that is being replaced in my IRedactionCallback implementation to execute some logic conditionally based on the replacement text. To my surprise I got null. Is there anyway to get text being replaced. A sample unit test code is given below. Also attached document I am redacting.

System details
Groupdocs.Redaction : 23.9
Java : 17
OS : Windows 11

class RedactionDump implements IRedactionCallback {
    public RedactionDump() {
    }

    public boolean acceptRedaction(RedactionDescription description) {
        System.out.print(description.getRedactionType() + " redaction, " + description.getActionType()
            + " action, item " + description.getOriginalText() + ". ");
        if (description.getReplacement() != null) {
            System.out.print("Text " + description.getReplacement().getOriginalText() + " is replaced with "
                + description.getReplacement().getReplacement() + ". ");
        }
        System.out.println();
        return true;
    }
}

@Test
void card() throws Exception {
    try (InputStream data = getClass().getResourceAsStream("/Test Document.docx");
                    final Redactor redactor =
                        new Redactor(data, new LoadOptions(), new RedactorSettings(new RedactionDump()))) {
        redactor.apply(new RegexRedaction("4[0-9]{12}(?:[0-9]{3})?", new ReplacementOptions("[Credit Card]")));
        redactor.save();
    }
}

Test Document.docx (6.2 KB)

@shiva.k
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): REDACTIONJAVA-179

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@shiva.k

If you run your code, the output will be as follows:

Text redaction, Replacement action, item 4591500051104102.
Text redaction, Replacement action, item 4591500051104103.

Where 4591500051104102 and 4591500051104103 are credit card numbers being replaced. Just use description.getOriginalText() which contains text being replaced for all textual redactions (even if description.getReplacement() returns null).