AnnotationRedaction
Leave feedback
On this page
Inheritance: java.lang.Object, com.groupdocs.redaction.Redaction
public class AnnotationRedaction extends Redaction
Represents a redaction that replaces annotation text (comments, etc.) matching a given regular expression.
Learn more
- More details about applying redactions: Redaction basics
- More details about document annotation redactions: Annotation redactions
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 | Description |
|---|---|
| AnnotationRedaction(String pattern, String replacement) | Initializes a new instance of AnnotationRedaction class. |
| AnnotationRedaction(Pattern regex, String replacement) | Initializes a new instance of AnnotationRedaction class. |
| Method | Description |
|---|---|
| getExpression() | Gets the regular expression to match. |
| getReplacement() | Gets a textual replacement for matched text. |
| getDescription() | Returns a string, describing the redaction and its parameters. |
| applyTo(DocumentFormatInstance formatInstance) | Applies the redaction to a given format instance. |
public AnnotationRedaction(String pattern, String replacement)
Initializes a new instance of AnnotationRedaction class.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| pattern | java.lang.String | Regular expression to match |
| replacement | java.lang.String | Textual replacement for matched text |
public AnnotationRedaction(Pattern regex, String replacement)
Initializes a new instance of AnnotationRedaction class.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| regex | java.util.regex.Pattern | Regular expression to match |
| replacement | java.lang.String | Textual replacement for matched text |
public final Pattern getExpression()
Gets the regular expression to match.
Returns: java.util.regex.Pattern - The regular expression to match.
public final String getReplacement()
Gets a textual replacement for matched text.
Returns: java.lang.String - A textual replacement for matched text.
public String getDescription()
Returns a string, describing the redaction and its parameters.
Returns: java.lang.String - Text, containing redaction name and parameters.
public RedactorLogEntry applyTo(DocumentFormatInstance formatInstance)
Applies the redaction to a given format instance.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| formatInstance | DocumentFormatInstance | An instance of a document to apply redaction |
Returns: RedactorLogEntry - Status of the redaction: success/failure and error message if any
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.