User roles

GroupDocs.Annotation v22.11 and later allows you to specify a user role for each user.

You can specify a User object for any reply. This object represents the author of the reply. You can also set a role of the user:

  • Viewer - GroupDocs.Annotation does not add their replies to the document.
  • Editor - GroupDocs.Annotation adds their replies. Use this feature to control if a user can or cannot add comments to the document.

The following code snippet shows how to add a user role:


using (Annotator annotator = new Annotator("input.pdf-file"))
{
  AreaAnnotation area = new AreaAnnotation
  {
    BackgroundColor = 65535,
    Box = new Rectangle(100, 100, 100, 100),
    CreatedOn = DateTime.Now,
    Message = "This is area annotation",
    Opacity = 0.7,
    PageNumber = 0,
    Replies = new List<Reply>
    {
        new Reply 
        {
            Comment = "This comment will be applied",
            RepliedOn = DateTime.Now,
            User = new User(1, "Reviewer", Role.Editor)
        },
        new Reply
        {
            Comment = "This comment will NOT be applied",
            RepliedOn = DateTime.Now,
            User = new User(1, "Member", Role.Viewer)
        }
    }
  };

  annotator.Add(area);
  annotator.Save("result_export");
}