// For complete examples and data files, please go to https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-.NET
// Create instance of annotator.
AnnotationConfig cfg = CommonUtilities.GetConfiguration();
//Create annotation handler
AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
IUserDataHandler userRepository = annotator.GetUserDataHandler();
IDocumentDataHandler documentRepository = annotator.GetDocumentDataHandler();
if (!Directory.Exists(cfg.StoragePath))
{
Directory.CreateDirectory(cfg.StoragePath);
}
// Create a user that will be an owner.
// Get user from the storage
var owner = userRepository.GetUserByEmail("john@doe.com");
// If user doesn’t exist in the storage then create it.
if (owner == null)
{
userRepository.Add(new User { FirstName = "John", LastName = "Doe", Email = "john@doe.com" });
owner = userRepository.GetUserByEmail("john@doe.com");
}
// Get document data object in the storage
var document = documentRepository.GetDocument("Document.pdf");
// If document already created or it hasn’t owner then delete document
if (document != null && document.OwnerId != owner.Id)
{
documentRepository.Remove(document);
document = null;
}
// Get document id if document already created or create new document
long documentId = document != null ? document.Id : annotator.CreateDocument("Document.pdf", DocumentType.Pdf, owner.Id);
// Create reviewer.
var reviewerInfo = new ReviewerInfo
{
PrimaryEmail = "judy@doe.com", //user email, unique identifier
FirstName = "Judy",
LastName = "Doe",
AccessRights = AnnotationReviewerRights.All
};
// Get document collaborators.
var getCollaboratorsResult = annotator.GetCollaborators(documentId);
// Get document collaborator by email
var getCollaboratorsResultByEmail = annotator.GetDocumentCollaborator(documentId, reviewerInfo.PrimaryEmail);
// Get collaborator metadata
var user = userRepository.GetUserByEmail(reviewerInfo.PrimaryEmail);
ReviewerInfo collaboratorMetadataResult = annotator.GetCollaboratorMetadata(user.Guid);