AnnotationRedaction

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

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()
 }
 

Constructors

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.

Methods

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.

AnnotationRedaction(String pattern, String replacement)

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

AnnotationRedaction(Pattern regex, String replacement)

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

getExpression()

public final Pattern getExpression()

Gets the regular expression to match.

Returns: java.util.regex.Pattern - The regular expression to match.

getReplacement()

public final String getReplacement()

Gets a textual replacement for matched text.

Returns: java.lang.String - A textual replacement for matched text.

getDescription()

public String getDescription()

Returns a string, describing the redaction and its parameters.

Returns: java.lang.String - Text, containing redaction name and parameters.

applyTo(DocumentFormatInstance formatInstance)

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