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(String pattern, String replacement)
Initializes a new instance of AnnotationRedaction class.
pattern
- Regular expression to matchreplacement
- Textual replacement for matched textpublic final Pattern getExpression()
Gets the regular expression to match.
public final String getReplacement()
Gets a textual replacement for matched text.
public String getDescription()
Returns a string, describing the redaction and its parameters.
getDescription
in class Redaction
public RedactorLogEntry applyTo(DocumentFormatInstance formatInstance)
Applies the redaction to a given format instance.