Created
October 7, 2021 12:37
-
-
Save GroupDocsGists/15992c7e04f496134f00ffb297514c75 to your computer and use it in GitHub Desktop.
Redact or Black out Text in Image within PDF using C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Redact Text in PDF and Text in Image like scanned document using Java | |
RedactorSettings settings = new RedactorSettings(new AsposeCloudOcrConnector()); | |
try (Redactor redactor = new Redactor("path/document.pdf", new LoadOptions(), settings)) | |
{ | |
ReplacementOptions marker = new ReplacementOptions(java.awt.Color.BLACK); | |
Redaction redactions[] = new Redaction[] { | |
new RegexRedaction("(?<=Dear\\s)([^,]+)", marker), // cardholder name | |
new RegexRedaction("\\d{2}/\\d{2}", marker), // valid thru | |
new RegexRedaction("\\d{4}", marker) // card number parts | |
}; | |
RedactorChangeLog result = redactor.apply(redactions); | |
if (result.getStatus() != RedactionStatus.Failed) | |
{ | |
redactor.save(new SaveOptions(false, "redacted")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment