public class AnnotationRedaction extends Redaction
Represents a redaction that replaces annotation text (comments, etc.) matching a given regular expression.
Learn more
The following example demonstrates how to replace the name "John" with "[redacted]" in all annotations.
try (Redactor redactor = new Redactor("C:\\test.pdf"))
{
redactor.apply(new AnnotationRedaction("(?im:john)", "[redacted]"));
redactor.save()
}
| Constructor and Description |
|---|
AnnotationRedaction(Pattern regex,
String replacement)
Initializes a new instance of AnnotationRedaction class.
|
AnnotationRedaction(String pattern,
String replacement)
Initializes a new instance of AnnotationRedaction class.
|
| Modifier and Type | Method and Description |
|---|---|
RedactorLogEntry |
applyTo(DocumentFormatInstance formatInstance)
Applies the redaction to a given format instance.
|
String |
getDescription()
Returns a string, describing the redaction and its parameters.
|
Pattern |
getExpression()
Gets the regular expression to match.
|
String |
getReplacement()
Gets a textual replacement for matched text.
|
public AnnotationRedaction(Pattern regex, String replacement)
Initializes a new instance of AnnotationRedaction class.
regex - Regular expression to matchreplacement - Textual replacement for matched textpublic RedactorLogEntry applyTo(DocumentFormatInstance formatInstance)
Applies the redaction to a given format instance.
public String getDescription()
Returns a string, describing the redaction and its parameters.
getDescription in class Redactionpublic final Pattern getExpression()
Gets the regular expression to match.
public final String getReplacement()
Gets a textual replacement for matched text.
Copyright © 2025. All rights reserved.