/// <summary> /// Removes annotations /// </summary> public static void RemoveAnnotation() { try { //ExStart:RemoveAnnotation // 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 }; // Get all annotations from storage ListAnnotationsResult listAnnotationsResult = annotator.GetAnnotations(documentId); // Get annotation var annotation = annotator.GetAnnotation(listAnnotationsResult.Annotations[0].Guid); // Delete single annotation var deleteAnnotationResult = annotator.DeleteAnnotation(annotation.Id); //Delete all annotations annotator.DeleteAnnotations(documentId); //ExEnd:RemoveAnnotation } 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 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); } }