com.groupdocs.redaction.redactions

Class AnnotationRedaction



  • 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 Detail

      • AnnotationRedaction

        public AnnotationRedaction(String pattern,
                           String replacement)

        Initializes a new instance of AnnotationRedaction class.

        Parameters:
        pattern - Regular expression to match
        replacement - Textual replacement for matched text
      • AnnotationRedaction

        public AnnotationRedaction(Pattern regex,
                           String replacement)

        Initializes a new instance of AnnotationRedaction class.

        Parameters:
        regex - Regular expression to match
        replacement - Textual replacement for matched text
    • Method Detail

      • getExpression

        public final Pattern getExpression()

        Gets the regular expression to match.

        Returns:
        The regular expression to match.
      • getReplacement

        public final String getReplacement()

        Gets a textual replacement for matched text.

        Returns:
        A textual replacement for matched text.
      • getDescription

        public String getDescription()

        Returns a string, describing the redaction and its parameters.

        Overrides:
        getDescription in class Redaction
        Returns:
        Text, containing redaction name and parameters.
      • applyTo

        public RedactorLogEntry applyTo(DocumentFormatInstance formatInstance)

        Applies the redaction to a given format instance.

        Specified by:
        applyTo in class Redaction
        Parameters:
        formatInstance - An instance of a document to apply redaction
        Returns:
        Status of the redaction: success/failure and error message if any