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)