Hi,
I am trying to redact a pdf file which is giving redaction status as failed for regex redaction. Attached file and regex pattern below.
Regex: (\\d{14,16})|(\\d{4}[ ]?\\n?\\d{4}[ ]?\\n?\\d{4}[ ]?\\n?\\d{4})|(\\d{4}[-]?\\n?\\d{4}[-]?\\n?\\d{4}[-]?\\n?\\d{4})
System details
Groupdocs redaction : 21.12
Java : 8
Error: Redaction status is failed and redaction log has NullPointerException.
Unit Test
@Test
void redactPdf() {
try {
License l = new License();
l.setLicense(getClass().getResourceAsStream("/groupdocs.lic"));
Redactor redactor = new Redactor(getClass().getResourceAsStream(
"/GitHub - drmonkeyninja_test-payment-cards_ Cheatsheet of test payment cards for various payment gateways-2.pdf"));
RegexRedaction r = new RegexRedaction("(\\d{14,16})|(\\d{4}[ ]?\\n?\\d{4}[ ]?\\n?\\d{4}[ ]?\\n?\\d{4})|(\\d{4}[-]?\\n?\\d{4}[-]?\\n?\\d{4}[-]?\\n?\\d{4})", new ReplacementOptions("[secret]"));
RedactorChangeLog redactLog = redactor.apply(r);
assertEquals(RedactionStatus.Failed, redactLog.getStatus());
System.out.println(redactLog.getStatus());
System.out.println(redactLog.getRedactionLog().stream().map(rl -> rl.getResult().getErrorMessage())
.collect(joining("\n")));
RasterizationOptions ro = new RasterizationOptions();
ro.setEnabled(false);
redactor.save(new ByteArrayOutputStream(), ro);
} catch (Exception e) {
fail(e);
}
}