Add replies to annotation

GroupDocs.Annotation provides an ability for several users to collaborate over document via annotations and annotation replies. Adding reply to an annotation via code is as easy as specifying reply content and related user object.

Here are the steps to add annotation replies:

  • Instantiate Annotator object with input document path or stream;
  • Instantiate User object;
  • Instantiate Reply object(s);
  • Instantiate annotation object of desired type. Available annotation types are listed here;
  • Assign User object to Reply. User property (or by default will be “Guest”);
  • Assign Reply object(s) to Replies collection of an annotation object created at previous steps;
  • Call Add method of Annotator object and pass annotation to it;
  • Call Save method with resultant document path or stream;

The following code demonstrates how to add replies to annotation:

using (Annotator annotator = new Annotator("input.pdf"))
{
	User user1 = new User
	{
		Id = 1,
		Name = "Tom",
		Email = "somemail@mail.com"
	};
	User user2 = new User
	{
		Id = 2,
		Name = "Jack",
		Email = "somebody@mail.com"
	};
	AreaAnnotation area = new AreaAnnotation
	{
		Box = new Rectangle(100, 100, 100, 100),
		CreatedOn = DateTime.Now,
		Message = "This is an area annotation",
		PageNumber = 0,
		Replies = new List<Reply>
		{
			new Reply
			{
				Id = 1,
				Comment = "First comment",
				RepliedOn = DateTime.Now,
				User = user1
			},
			new Reply
			{
				Id = 2,
				Comment = "Second comment",
				RepliedOn = DateTime.Now,
				User = user2,
			}
		}
	};
annotator.Add(area);
annotator.Save("result.pdf");
}

More resources

Advanced Usage Topics

To learn more about document annotating features, please refer to the advanced usage section.

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online App

Along with full-featured .NET library we provide simple but powerful free Apps. You are welcome to annotate your PDF, DOC or DOCX, XLS or XLSX, PPT or PPTX, PNG and other documents with free to use online GroupDocs Annotation App.