/// <summary>
        /// Resizes the existing annotations
        /// </summary>
        public static void ResizeAnnotationResult()
        {
            try
            {
                //ExStart:ResizeAnnotationResult
                // 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 areaAnnotation = new AnnotationInfo
                {
                    AnnotationPosition = new Point(852.0, 271.7),
                    BackgroundColor    = 3355443,
                    Box          = new Rectangle(466f, 271f, 69f, 62f),
                    PageNumber   = 0,
                    PenColor     = 3355443,
                    Type         = AnnotationType.Area,
                    CreatorName  = "Anonym",
                    DocumentGuid = documentId
                };

                //Add annotation to storage
                CreateAnnotationResult createAreaAnnotationResult = annotator.CreateAnnotation(areaAnnotation);

                //Resize annotation
                ResizeAnnotationResult resizeResult = annotator.ResizeAnnotation(createAreaAnnotationResult.Id, new AnnotationSizeInfo
                {
                    Height = 80,
                    Width  = 60
                });
                //ExEnd:ResizeAnnotationResult
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Exemple #2
0
        /// <summary>
        /// Resisizes the annotation
        /// </summary>
        /// <param name="connectionId">Socket connection identifier to validate user permissions for</param>
        /// <param name="fileId">The document path to resize the annotation for</param>
        /// <param name="annotationGuid">The annotation global unique identifier</param>
        /// <param name="width">The new width of the annotation</param>
        /// <param name="height">The new height of the annotation</param>
        /// <returns>An instance of an object containing the operation result</returns>
        public ResizeAnnotationResult ResizeAnnotation(string connectionId, string fileId, string annotationGuid, double width, double height)
        {
            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 = _annotator.GetCollaborators(document.Id);

            var annotation = _annotator.GetAnnotation(annotationGuid, document.Id, user.Id);
            var result     = _annotator.ResizeAnnotation(annotation.Id, new AnnotationSizeInfo {
                Width = width, Height = height
            }, document.Id, user.Id);

            _annotationBroadcaster.ResizeAnnotation(collaboratorsInfo.Collaborators.Select(c => c.Guid).ToList(), fileId, connectionId, annotationGuid, width, height);

            return(_mapper.Map <ResizeAnnotationResult>(result));
        }