/// <summary> /// Removes annotations /// </summary> public static void RemoveAnnotation() { try { //ExStart:RemoveAnnotation // Create instance of annotator. AnnotationConfig cfg = CommonUtilities.GetConfiguration(); AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); IDocumentDataHandler documentRepository = annotator.GetDocumentDataHandler(); if (!Directory.Exists(cfg.StoragePath)) { Directory.CreateDirectory(cfg.StoragePath); } // Create document data object in storage. var document = documentRepository.GetDocument("Document.pdf"); long documentId = document != null ? document.Id : annotator.CreateDocument("Document.pdf"); // Create annotation object AnnotationInfo pointAnnotation = new AnnotationInfo { AnnotationPosition = new Point(852.0, 81.0), Box = new Rectangle(212f, 81f, 142f, 0.0f), Type = AnnotationType.Point, PageNumber = 0, CreatorName = "Anonym", DocumentGuid = documentId }; // Get all annotations from storage ListAnnotationsResult listAnnotationsResult = annotator.GetAnnotations(documentId); // Get annotation var annotation = annotator.GetAnnotation(listAnnotationsResult.Annotations[0].Guid); // Delete single annotation var deleteAnnotationResult = annotator.DeleteAnnotation(annotation.Id); //Delete all annotations annotator.DeleteAnnotations(documentId); //ExEnd:RemoveAnnotation } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
public ActionResult Delete(string guid) { Response.AddHeader("Content-Type", "application/json"); AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler(); long annotationId = imageHandler.GetAnnotation(guid).Id; DeleteAnnotationResult result = imageHandler.DeleteAnnotation(annotationId); return(Content(JsonConvert.SerializeObject( result, Formatting.Indented, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() } ), "application/json")); }
public ActionResult Get(string file) { Response.AddHeader("Content-Type", "application/json"); AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler(); String filename = file;// request.getParameter("file"); long annotationId = long.Parse(Request.Params["annotationId"]); DeleteAnnotationResult result = imageHandler.DeleteAnnotation(annotationId); return(Content(JsonConvert.SerializeObject( result, Formatting.Indented, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() } ), "application/json")); }
/// <summary> /// Removes an annotation from a document /// </summary> /// <param name="connectionId">Socket connection identifier to validate user permissions for</param> /// <param name="fileId">The document path to remove the annotation from</param> /// <param name="annotationGuid">The annotation global unique identifier</param> /// <returns>An instance of an object containing the removed annotation metadata</returns> public DeleteAnnotationResult DeleteAnnotation(string connectionId, string fileId, string annotationGuid) { var reviewer = _annotationBroadcaster.GetConnectionUser(connectionId); if (reviewer == null) { throw new AnnotatorException("There is no such reviewer."); } var user = _userSvc.GetUserByGuid(reviewer.Value.UserGuid); var document = GetDocument(fileId, user.Id); var collaboratorsInfo = _mapper.Map <GetCollaboratorsResult>(_annotator.GetCollaborators(document.Id)); var annotation = _annotator.GetAnnotation(annotationGuid, document.Id, user.Id); var result = _annotator.DeleteAnnotation(annotation.Id, document.Id, user.Id); _annotationBroadcaster.DeleteAnnotation(collaboratorsInfo.Collaborators.Select(c => c.Guid).ToList(), fileId, connectionId, annotationGuid); return(_mapper.Map <DeleteAnnotationResult>(result)); }