Add text redaction annotation

On this page

Text redaction annotation fills part of text with black rectangle to hide content as shown in the picture below:

You can specify the following properties of the TextRedactionAnnotation class:

  • Points defines annotation positions as array of points

To add a text redaction annotation, follow these steps:

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

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

//Add text redaction annotation to the document from local disk
using (Annotator annotator = new Annotator("input.pdf"))
{
	TextRedactionAnnotation textRedaction = new TextRedactionAnnotation
    {
    	CreatedOn = DateTime.Now,
        Message = "This is text redaction annotation",
        FontColor = 16761035,
        PageNumber = 0,
        Points = new List<Point>
        {
        	new Point(80, 730), new Point(240, 730), new Point(80, 650), new Point(240, 650)
        },
        Replies = new List<Reply>
        {
        	new Reply
            {
            	Comment = "First comment",
                RepliedOn = DateTime.Now
            },
            new Reply
            {
            	Comment = "Second comment",
                RepliedOn = DateTime.Now
            }
         }
     };
     annotator.Add(textRedaction);
     annotator.Save("result.pdf");
}

On this page