/// <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); } }
/// <summary> /// Updates the text field color /// </summary> /// <param name="connectionId">Socket connection identifier to validate user permissions for</param> /// <param name="fileId">The document path to update the text field color for</param> /// <param name="annotationGuid">The annotation global unique identifier</param> /// <param name="fontColor">The font color of the text</param> /// <returns>An instance of an object containing the operation result</returns> public SaveAnnotationTextResult SetTextFieldColor(string connectionId, string fileId, string annotationGuid, int fontColor) { 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.SetTextFieldColor(annotation.Id, fontColor, document.Id, user.Id); _annotationBroadcaster.SetTextFieldColor(collaboratorsInfo.Collaborators.Select(c => c.Guid).ToList(), fileId, connectionId, annotationGuid, fontColor); return(_mapper.Map <SaveAnnotationTextResult>(result)); }