Exemple #1
0
        public ActionResult Post()
        {
            Response.AddHeader("Content-Type", "application/json");
            AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler();
            String         guid           = Request.Params["guid"];
            String         section        = Request.Params["guid"];
            AnnotationInfo annotationInfo = imageHandler.GetAnnotation(guid).Annotation;
            long           annotationId   = imageHandler.GetAnnotation(guid).Id;

            switch (section)
            {
            case "fieldtext":
                var jsonString = String.Empty;
                using (var inputStream = new StreamReader(Request.InputStream))
                {
                    jsonString = inputStream.ReadToEnd();
                }
                TextFieldInfo info = JsonConvert.DeserializeObject <TextFieldInfo>(jsonString);

                SaveAnnotationTextResult result = imageHandler.SaveTextField(annotationId, info);
                return(Content(JsonConvert.SerializeObject(
                                   result,
                                   Formatting.Indented,
                                   new JsonSerializerSettings {
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                }
                                   ), "application/json"));

            case "position":
                var jsonStringPos = String.Empty;
                using (var inputStream = new StreamReader(Request.InputStream))
                {
                    jsonStringPos = inputStream.ReadToEnd();
                }
                Point point = JsonConvert.DeserializeObject <Point>(jsonStringPos);

                MoveAnnotationResult moveresult = imageHandler.MoveAnnotationMarker(annotationId, point, annotationInfo.PageNumber);
                return(Content(JsonConvert.SerializeObject(
                                   moveresult,
                                   Formatting.Indented,
                                   new JsonSerializerSettings {
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                }
                                   ), "application/json"));

            default:
                return(Content(null));
            }
        }
        /// <summary>
        /// Moves annotation marker
        /// </summary>
        public static void MoveAnnotationResult()
        {
            try
            {
                //ExStart:MoveAnnotationResult
                // 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);

                //Move annotation marker
                MoveAnnotationResult moveAnnotationResult = annotator.MoveAnnotationMarker(createAreaAnnotationResult.Id,
                                                                                           new Point(200, 200), /*NewPageNumber*/ 1);
                //ExEnd:MoveAnnotationResult
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Exemple #3
0
        /// <summary>
        /// Moves the annotation marker to a new position
        /// </summary>
        /// <param name="connectionId">Socket connection identifier to validate user permissions for</param>
        /// <param name="fileId">The document path to move the annotation marker for</param>
        /// <param name="annotationGuid">The annotation global unique identifier</param>
        /// <param name="left">The X coordinate of the annotation</param>
        /// <param name="top">The Y coordinate of the annotation</param>
        /// <param name="pageNumber">The document page number to move the annotation to</param>
        /// <returns>An instance of an object containing the operation result and annotation metadata</returns>
        public MoveAnnotationResult MoveAnnotationMarker(string connectionId, string fileId, string annotationGuid, double left, double top, int?pageNumber)
        {
            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 position   = new Point {
                X = left, Y = top
            };
            var result = _annotator.MoveAnnotationMarker(annotation.Id, new GroupDocs.Annotation.Domain.Point(position.X, position.Y), pageNumber, document.Id, user.Id);

            _annotationBroadcaster.MoveAnnotationMarker(collaboratorsInfo.Collaborators.Select(c => c.Guid).ToList(), connectionId, annotationGuid, position, pageNumber);

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