示例#1
0
        /// <summary>
        /// Updates the text in the annotation
        /// </summary>
        public static void EditTextFieldAnnotation()
        {
            try
            {
                //ExStart:EditTextFieldAnnotation
                // Create path finder
                IRepositoryPathFinder pathFinder = new RepositoryPathFinder();
                var documentRepository           = new DocumentRepository(pathFinder);

                // Create instance of annotator
                IAnnotator annotator = new Annotator(
                    new UserRepository(pathFinder),
                    new DocumentRepository(pathFinder),
                    new AnnotationRepository(pathFinder),
                    new AnnotationReplyRepository(pathFinder),
                    new AnnotationCollaboratorRepository(pathFinder));

                // 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);

                // Update text in the annotation
                SaveAnnotationTextResult saveTextFieldResult = annotator.SaveTextField(
                    createTextFieldAnnotationResult.Id,
                    new TextFieldInfo
                {
                    FieldText  = "new text",
                    FontFamily = "Colibri",
                    FontSize   = 12
                });


                // Set text field color
                SaveAnnotationTextResult saveTextFieldColorResult = annotator.SetTextFieldColor
                                                                        (createTextFieldAnnotationResult.Id, 16753920);
                //ExEnd:EditTextFieldAnnotation
            }
            catch (Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
        /// <summary>
        /// Updates the text in the annotation
        /// </summary>
        public static void EditTextFieldAnnotation()
        {
            try
            {
                //ExStart:EditTextFieldAnnotation
                // 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);

                // Update text in the annotation
                SaveAnnotationTextResult saveTextFieldResult = annotator.SaveTextField(
                    createTextFieldAnnotationResult.Id,
                    new TextFieldInfo
                {
                    FieldText  = "new text",
                    FontFamily = "Colibri",
                    FontSize   = 12
                });


                // Set text field color
                SaveAnnotationTextResult saveTextFieldColorResult = annotator.SetTextFieldColor
                                                                        (createTextFieldAnnotationResult.Id, 16753920);
                //ExEnd:EditTextFieldAnnotation
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
示例#3
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));
            }
        }