public ActionResult CreateAnnotation(string connectionId, string userId, string privateKey, string fileId, byte type, string message, Rectangle rectangle, int pageNumber, Point annotationPosition, string svgPath, DrawingOptions drawingOptions, FontOptions font, string callback = null) { try { var result = _annotationSvc.CreateAnnotation(connectionId, fileId, type, message, rectangle, pageNumber, annotationPosition, svgPath, drawingOptions, font); return this.JsonOrJsonP(result, callback); } catch(AnnotatorException e) { return this.JsonOrJsonP(new FailedResponse { Reason = e.Message }, callback); } }
public void CreateAnnotation(IList<string> collaboratorGuids, string connectionIdToExclude, string userGuid, string userName, string documentGuid, AnnotationType annotationType, string annotationGuid, byte access, string replyGuid, int pageNumber, Rectangle box, Point? annotationPosition, string svgPath, DrawingOptions drawingOptions, FontOptions font) { Array.ForEach( _annotationsHub.GetConnectionIdsToCall(connectionIdToExclude, collaboratorGuids), x => GetClient(x).createAnnotationOnClient(connectionIdToExclude, new { userName, pageNumber, box, annotationPosition, documentGuid, annotationGuid, access, annotationType, replyGuid, userGuid, svgPath, serverTime = GetJavascriptDateTime(DateTime.UtcNow), drawingOptions = (drawingOptions != null ? new { penColor = drawingOptions.PenColor, penWidth = drawingOptions.PenWidth, penStyle = drawingOptions.PenStyle, brushColor = drawingOptions.BrushColor } : null), font = (font != null ? new { family = font.Family, size = font.Size } : null) })); }
/// <summary> /// Creates a new annotation for a document /// </summary> /// <param name="connectionId">Socket connection identifier to validate user permissions for</param> /// <param name="fileId">The document path to create the annotation for</param> /// <param name="type">The annotation type</param> /// <param name="message">The annotation text message</param> /// <param name="rectangle">The annotation bounds</param> /// <param name="pageNumber">The document page number to create the annotation at</param> /// <param name="annotationPosition">The annotation left-top position</param> /// <param name="svgPath">The annotation SVG path</param> /// <param name="options">The annotation drawing options (pen color, width etc.)</param> /// <param name="font">The annotation text font</param> /// <returns>An instance of an object containing information about a created annotation</returns> public CreateAnnotationResult CreateAnnotation(string connectionId, string fileId, byte type, string message, Rectangle rectangle, int pageNumber, Point annotationPosition, string svgPath, DrawingOptions options, FontOptions font) { 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 caller = collaboratorsInfo.Collaborators.FirstOrDefault(c => c.Guid == reviewer.Value.UserGuid); var annotation = new GroupDocs.Annotation.Domain.AnnotationInfo { Type = (AnnotationType) type, Box = new GroupDocs.Annotation.Domain.Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height), PageNumber = pageNumber, AnnotationPosition = new GroupDocs.Annotation.Domain.Point(annotationPosition.X, annotationPosition.Y), SvgPath = svgPath, PenColor = options?.PenColor, PenWidth = options?.PenWidth, PenStyle = options != null ? (byte?) options.DashStyle : null, BackgroundColor = options?.BrushColor, FontFamily = font?.Family, FontSize = font?.Size }; if(!string.IsNullOrWhiteSpace(message)) { annotation.Replies = new[] { new GroupDocs.Annotation.Domain.AnnotationReplyInfo { Message = message } }; } var result = _annotator.CreateAnnotation(annotation, document.Id, user.Id); _annotationBroadcaster.CreateAnnotation( collaboratorsInfo.Collaborators.Select(c => c.Guid).ToList(), connectionId, reviewer.Value.UserGuid, caller != null ? caller.PrimaryEmail : _authenticationSvc.AnonymousUserName, fileId, annotation.Type, result.Guid, (byte) result.Access, result.ReplyGuid, pageNumber, _mapper.Map<Rectangle>(rectangle), annotationPosition, svgPath, options, font); return _mapper.Map<CreateAnnotationResult>(result); }
private static string GetToolFontOptions(FontOptions options) { return string.Format("{{ size: {0}, family: {1} }}", options.Size, string.IsNullOrEmpty(options.Family) ? "null" : string.Format("'{0}'", options.Family)); }