/// <summary>
        /// Sets background color of annotation
        /// </summary>
        public static void SetBackgroundColorResult()
        {
            try
            {
                //ExStart:SetBackgroundColorResult
                // 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 textFieldAnnotation = new AnnotationInfo
                {
                    AnnotationPosition = new Point(852.0, 201.0),
                    FieldText          = "text in the box",
                    FontFamily         = "Arial",
                    FontSize           = 10,
                    Box          = new Rectangle(66f, 201f, 64f, 37f),
                    PageNumber   = 0,
                    Type         = AnnotationType.TextField,
                    CreatorName  = "Anonym",
                    DocumentGuid = documentId
                };

                //Add annotation to storage
                CreateAnnotationResult createTextFieldAnnotationResult = annotator.CreateAnnotation(textFieldAnnotation);

                // Set background color of annotation
                SaveAnnotationTextResult setBackgroundColorResult = annotator.SetAnnotationBackgroundColor(createTextFieldAnnotationResult.Id, 16711680);
                //ExEnd:SetBackgroundColorResult
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Updates the background color of the annotation
        /// </summary>
        /// <param name="connectionId">Socket connection identifier to validate user permissions for</param>
        /// <param name="fileId">The document path to update the background color for</param>
        /// <param name="annotationGuid">The annotation global unique identifier</param>
        /// <param name="color">The background color of the annotation</param>
        /// <returns>An instance of an object containing the operation result</returns>
        public SaveAnnotationTextResult SetAnnotationBackgroundColor(string connectionId, string fileId, string annotationGuid, int color)
        {
            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.SetAnnotationBackgroundColor(annotation.Id, color, document.Id, user.Id);

            _annotationBroadcaster.SetAnnotationBackgroundColor(collaboratorsInfo.Collaborators.Select(c => c.Guid).ToList(), fileId, connectionId, annotationGuid, color);

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