Add resource redaction annotation

On this page

Resource redaction annotation fills black rectangle with fixed position to hide a text as shown in the picture below:

You can use the following methods to set the properties of the ResourcesRedactionAnnotation class:

  • setBox() defines the annotation on the page

To add a resource redaction annotation, follow these steps:

  1. Instantiate the Annotator class. Specify the input document path or stream.
  2. Instantiate the ResourceRedactionAnnotation class. Specify the appropriate properties (position, page number, etc).
  3. Call the add() method. Specify the ResourceRedactionAnnotation class.
  4. Call the save() method. Specify the output document path or stream. 

The following code snippet shows how to add ResourcesRedactionAnnotation to the document:

// This example demonstrates adding resources redaction annotation.

// Create an instance of Annotator class
Annotator annotator = new Annotator("inputPath");
try {
    // Create an instance of Reply class and add comments
    Reply reply1 = new Reply();
    reply1.setComment("First comment");

    Reply reply2 = new Reply();
    reply2.setComment("Second comment");

    java.util.List<Reply> replies =  new ArrayList<Reply>();

    // Create an instance of ResourcesRedactionAnnotation class and set options
    ResourcesRedactionAnnotation resourcesRedaction = new ResourcesRedactionAnnotation();
    resourcesRedaction.setBox(new Rectangle(100, 100, 100, 100));
    resourcesRedaction.setMessage("This is resources redaction annotation");
    // Add annotation and save to file
} finally {
    if (annotator != null) {

On this page