public ActionResult Post(string file) { Response.AddHeader("Content-Type", "application/json"); AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler(); IDocumentDataHandler documentDataHandler = imageHandler.GetDocumentDataHandler(); String filename = file; Document doc = documentDataHandler.GetDocument(filename); long documentId = doc != null ? doc.Id : imageHandler.CreateDocument(filename); //StreamReader stream = new StreamReader(Request.InputStream); //string x = stream.ReadToEnd(); // added to view content of input stream AnnotationInfo annotation = new AnnotationInfo(); //Request.InputStream as AnnotationInfo; annotation.DocumentGuid = documentId; CreateAnnotationResult result = imageHandler.CreateAnnotation(annotation); return(Content(JsonConvert.SerializeObject( result, Formatting.Indented, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() } ), "application/json")); }
/// <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); } }
/// <summary> /// Resizes the existing annotations /// </summary> public static void ResizeAnnotationResult() { try { //ExStart:ResizeAnnotationResult // 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 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 (Exception exp) { Console.WriteLine(exp.Message); } }
/// <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); } }
public ActionResult Post(string file) { Response.AddHeader("Content-Type", "application/json"); AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler(); IDocumentDataHandler documentDataHandler = imageHandler.GetDocumentDataHandler(); String filename = file; Document doc = documentDataHandler.GetDocument(filename); long documentId = doc != null ? doc.Id : imageHandler.CreateDocument(filename); Request.InputStream.Seek(0, SeekOrigin.Begin); AnnotationInfo annotation = new JsonSerializer().Deserialize <AnnotationInfo>(new JsonTextReader(new StreamReader(Request.InputStream))); annotation.DocumentGuid = documentId; CreateAnnotationResult result = imageHandler.CreateAnnotation(annotation); return(Content(JsonConvert.SerializeObject( result, Formatting.Indented, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() } ), "application/json")); }
/// <summary> /// Maps annotations and creates dcocument data object in the storage /// </summary> public static void CreateAndGetAnnotation() { try { //ExStart:CreateAndGetAnnotation // 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 pointAnnotation = new AnnotationInfo { AnnotationPosition = new Point(852.0, 81.0), Box = new Rectangle(212f, 81f, 142f, 0.0f), Type = AnnotationType.Point, PageNumber = 0, CreatorName = "Anonym", DocumentGuid = documentId }; // Add annotation to storage CreateAnnotationResult createPointAnnotationResult = annotator.CreateAnnotation(pointAnnotation); //============================================================================= // 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); // Get annotation from storage GetAnnotationResult result = annotator.GetAnnotation(createPointAnnotationResult.Guid); //ExEnd:CreateAndGetAnnotation } catch (Exception exp) { Console.WriteLine(exp.Message); } }
/// <summary> /// Maps annotations and creates dcocument data object in the storage /// </summary> public static void CreateAndGetAnnotation() { try { //ExStart:CreateAndGetAnnotation // 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 pointAnnotation = new AnnotationInfo { AnnotationPosition = new Point(852.0, 81.0), Box = new Rectangle(212f, 81f, 142f, 0.0f), Type = AnnotationType.Point, PageNumber = 0, CreatorName = "Anonym", DocumentGuid = documentId }; // Add annotation to storage CreateAnnotationResult createPointAnnotationResult = annotator.CreateAnnotation(pointAnnotation); //============================================================================= // 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); // Get annotation from storage GetAnnotationResult result = annotator.GetAnnotation(createPointAnnotationResult.Guid); //ExEnd:CreateAndGetAnnotation } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }