Beispiel #1
0
        /// <summary>
        /// Updates the document global annotation permissions
        /// </summary>
        /// <param name="fileId">The document path to update the permissions for</param>
        /// <param name="rights">The annotation permissions</param>
        public void SetDocumentAccessRights(string fileId, AnnotationReviewerRights rights)
        {
            var  document   = _documentSvc.GetDocument(fileId);
            long documentId = document != null ? document.Id : _annotator.CreateDocument(fileId);

            _annotator.SetDocumentAccessRights(documentId, rights);
        }
        /// <summary>
        /// Gets annotations from the storage file
        /// </summary>
        /// <returns>Returns a list of annotations</returns>
        public static ListAnnotationsResult GetAllDocumentAnnotation()
        {
            try
            {
                //ExStart:GetAllAnnotation
                // 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");

                // Get annotation from storage
                ListAnnotationsResult result = annotator.GetAnnotations(documentId);

                return(result);
                //ExEnd:GetAllAnnotation
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
                return(null);
            }
        }
        /// <summary>
        /// Creates a document data object in the storage
        /// </summary>
        public static void CreateDocument()
        {
            try
            {
                //ExStart:CreateDocument
                // 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("sample.pdf");
                long documentId = document != null ? document.Id : annotator.CreateDocument("sample.pdf");

                Console.WriteLine("Document ID : " + documentId);
                //ExEnd:CreateDocument
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
        /// <summary>
        /// Assigns/sets document access rights
        /// </summary>
        public static void AssignAccessRights()
        {
            try
            {
                //ExStart:AssignAccessRight
                // 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");

                // Set document access rights
                annotator.SetDocumentAccessRights(documentId, AnnotationReviewerRights.All);
                //ExEnd:AssignAccessRight
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Beispiel #5
0
        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"));
        }
        //ExEnd:GetImageRepresentation

        //ExStart:GetTextCoordinatesInImage
        /// <summary>
        /// Gets text coordinates in image representation of document
        /// </summary>
        /// <param name="CommonUtilities.filePath">Source file path</param>
        public static void GetTextCoordinates(string filePath)
        {
            try
            {
                // Set configuration
                AnnotationConfig cfg = GetConfiguration();

                // Initialize annotator
                AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
                try
                {
                    annotator.CreateDocument(filePath);
                }
                catch { }

                var documentInfoContainer = annotator.GetDocumentInfo(filePath);

                // Go through all pages
                foreach (PageData pageData in documentInfoContainer.Pages)
                {
                    Console.WriteLine("Page number: " + pageData.Number);

                    //Go through all page rows
                    for (int i = 0; i < pageData.Rows.Count; i++)
                    {
                        RowData rowData = pageData.Rows[i];

                        // Write data to console
                        Console.WriteLine("Row: " + (i + 1));
                        Console.WriteLine("Text: " + rowData.Text);
                        Console.WriteLine("Text width: " + rowData.LineWidth);
                        Console.WriteLine("Text height: " + rowData.LineHeight);
                        Console.WriteLine("Distance from left: " + rowData.LineLeft);
                        Console.WriteLine("Distance from top: " + rowData.LineTop);

                        // Get words
                        string[] words = rowData.Text.Split(' ');

                        // Go through all word coordinates
                        for (int j = 0; j < words.Length; j++)
                        {
                            int coordinateIndex = j == 0 ? 0 : j + 1;
                            // Write data to console
                            Console.WriteLine(string.Empty);
                            Console.WriteLine("Word:'" + words[j] + "'");
                            Console.WriteLine("Word distance from left: " + rowData.TextCoordinates[coordinateIndex]);
                            Console.WriteLine("Word width: " + rowData.TextCoordinates[coordinateIndex + 1]);
                            Console.WriteLine(string.Empty);
                        }
                        Console.ReadKey();
                    }
                }
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
            //ExEnd:GetTextCoordinatesInImage
        }
        /// <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>
        /// Adds reply to the annotation, edits reply, creates child reply
        /// </summary>
        public static void AddAnnotationReply()
        {
            try
            {
                //ExStart:AddAnnotationReply
                // 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
                var createPointAnnotationResult = annotator.CreateAnnotation(pointAnnotation);

                // Add simple reply to created annotation
                var addSimpleReplyResult = annotator.CreateAnnotationReply(createPointAnnotationResult.Id, "first question");

                // Edit created reply
                var editReplyResult = annotator.EditAnnotationReply(addSimpleReplyResult.ReplyGuid, "changed question");

                // Create child reply. This reply will be linked to previously created reply.
                var addChildReplyResult = annotator.CreateAnnotationReply(createPointAnnotationResult.Id, "answer", addSimpleReplyResult.ReplyGuid);

                // Delete annotation reply by guid
                var deleteReplyResult = annotator.DeleteAnnotationReply(addChildReplyResult.ReplyGuid);

                // Delete all replies from annotation
                annotator.DeleteAnnotationReplies(createPointAnnotationResult.Id);

                // List of replies after deleting all replies
                var listRepliesResultAfterDeleteAll = annotator.ListAnnotationReplies(createPointAnnotationResult.Id);
                //ExEnd:AddAnnotationReply
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Beispiel #9
0
        public ActionResult UploadFile(string user_id, string fld, string fileName, bool?multiple = false, string callback = null)
        {
            var user = UnityConfig.GetConfiguredContainer().Resolve <AnnotationImageHandler>().GetUserDataHandler().GetUserByGuid(user_id) ??
                       new User();

            try
            {
                var files     = HttpContext.Request.Files;
                var uploadDir = Path.Combine(Server.MapPath("~/App_Data"), fld);
                var filePath  = Path.Combine(uploadDir, fileName ?? files[0].FileName);

                Directory.CreateDirectory(uploadDir);

                using (var stream = System.IO.File.Create(filePath))
                {
                    ((multiple ?? false) ? HttpContext.Request.InputStream : files[0].InputStream).CopyTo(stream);
                }

                var fileId = Path.Combine(fld, fileName ?? files[0].FileName);
                AnnotationImageHandler annotator = UnityConfig.GetConfiguredContainer().Resolve <AnnotationImageHandler>();
                try
                {
                    annotator.CreateDocument(fileId, DocumentType.Pdf, user.Id);
                }
                catch (AnnotatorException e)
                {
                    if (annotator.RemoveDocument(fileId))
                    {
                        annotator.CreateDocument(fileId, DocumentType.Pdf, user.Id);
                    }
                }
                return(this.JsonOrJsonP(new FileResponse(fileId), callback));
            }
            catch (Exception e)
            {
                return(this.JsonOrJsonP(new FailedResponse {
                    success = false, Reason = e.Message
                }, callback));
            }
        }
        /// <summary>
        /// Removes annotations
        /// </summary>
        public static void RemoveAnnotation()
        {
            try
            {
                //ExStart:RemoveAnnotation
                // 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
                };

                // 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 (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
        public static FileResponse UploadFile(string user_id, string fld, string fileName, bool?multiple = false)
        {
            var user = UnityConfig.GetConfiguredContainer().Resolve <AnnotationImageHandler>().GetUserDataHandler().GetUserByGuid(user_id) ??
                       new User();

            try
            {
                var files     = HttpContext.Current.Request.Files;
                var uploadDir = Path.Combine(pathFinder.GetApplicationPath() + "_layouts/15/GroupDocs_Annotation_SharePoint_WebPart/App_Data", fld);
                var filePath  = Path.Combine(uploadDir, fileName ?? files[0].FileName);

                Directory.CreateDirectory(uploadDir);

                using (var stream = System.IO.File.Create(filePath))
                {
                    ((multiple ?? false) ? HttpContext.Current.Request.InputStream : files[0].InputStream).CopyTo(stream);
                }

                var fileId = Path.Combine(fld, fileName ?? files[0].FileName);
                try
                {
                    annotator.CreateDocument(fileId, DocumentType.Pdf, user.Id);
                }
                catch (AnnotatorException e)
                {
                    if (annotator.RemoveDocument(fileId))
                    {
                        annotator.CreateDocument(fileId, DocumentType.Pdf, user.Id);
                    }
                }
                return(new FileResponse(fileId));
            }
            catch (IOException e)
            {
                return(null);
            }
        }
        /// <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 static Document findDocumentByName(string filename)
        {
            AnnotationImageHandler imageHandler        = Utils.createAnnotationImageHandler();
            IDocumentDataHandler   documentDataHandler = imageHandler.GetDocumentDataHandler();
            Document doc = documentDataHandler.GetDocument(filename);

            if (doc != null)
            {
                return(doc);
            }

            long documentId = imageHandler.CreateDocument(filename);

//            using (FileStream original = new FileStream(Utils.getStoragePath() + "/" + filename,FileMode.Create)) {
//                imageHandler.ImportAnnotations(original, documentId);
//            }
            return(documentDataHandler.Get(documentId));
        }
Beispiel #14
0
        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>
        /// Manages collaborator rights
        /// </summary>
        public static void ManageCollaboratorRights()
        {
            try
            {
                //ExStart:ManageCollaboratorRights
                // Create instance of annotator.
                AnnotationConfig cfg = CommonUtilities.GetConfiguration();

                //Create annotation handler
                AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);

                IUserDataHandler userRepository = annotator.GetUserDataHandler();

                IDocumentDataHandler documentRepository = annotator.GetDocumentDataHandler();
                if (!Directory.Exists(cfg.StoragePath))
                {
                    Directory.CreateDirectory(cfg.StoragePath);
                }

                // Create owner.
                var johnOwner = userRepository.GetUserByEmail("*****@*****.**");
                if (johnOwner == null)
                {
                    userRepository.Add(new User {
                        FirstName = "John", LastName = "Doe", Email = "*****@*****.**"
                    });
                    johnOwner = userRepository.GetUserByEmail("*****@*****.**");
                }

                // Create document data object in storage
                var  document   = documentRepository.GetDocument("Document.pdf");
                long documentId = document != null ? document.Id : annotator.CreateDocument("Document.pdf", DocumentType.Pdf, johnOwner.Id);

                // Create reviewer.
                var reviewerInfo = new ReviewerInfo
                {
                    PrimaryEmail = "*****@*****.**",
                    FirstName    = "Judy",
                    LastName     = "Doe",

                    // Can only get view annotations
                    AccessRights = AnnotationReviewerRights.CanView
                };

                // Add collaboorator to the document. If user with Email equals to reviewers PrimaryEmail is absent it will be created.
                var addCollaboratorResult = annotator.AddCollaborator(documentId, reviewerInfo);

                // Get document collaborators
                var getCollaboratorsResult = annotator.GetCollaborators(documentId);
                var judy = userRepository.GetUserByEmail("*****@*****.**");

                // 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 A."
                };

                // John try to add annotations. User is owner of the document.
                var johnResult = annotator.CreateAnnotation(pointAnnotation, documentId, johnOwner.Id);

                // Judy try to add annotations
                try
                {
                    var judyResult = annotator.CreateAnnotation(pointAnnotation, documentId, judy.Id);
                }

                //Get exceptions, because user can only view annotations
                catch (AnnotatorException e)
                {
                    Console.Write(e.Message);
                    Console.ReadKey();
                }

                // Allow Judy create annotations.
                reviewerInfo.AccessRights = AnnotationReviewerRights.CanAnnotate;
                var updateCollaboratorResult = annotator.UpdateCollaborator(documentId, reviewerInfo);

                // Now user can add annotations
                var judyResultCanAnnotate = annotator.CreateAnnotation(pointAnnotation, documentId, judy.Id);
                //ExEnd:ManageCollaboratorRights
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
        /// <summary>
        /// Deletes document collaborator
        /// </summary>
        public static void DeleteCollaborator()
        {
            try
            {
                //ExStart:DeleteCollaborator
                // Create instance of annotator.
                AnnotationConfig cfg = CommonUtilities.GetConfiguration();

                //Create annotation handler
                AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);

                IUserDataHandler userRepository = annotator.GetUserDataHandler();

                IDocumentDataHandler documentRepository = annotator.GetDocumentDataHandler();
                if (!Directory.Exists(cfg.StoragePath))
                {
                    Directory.CreateDirectory(cfg.StoragePath);
                }

                // Create a user that will be an owner.
                // Get user from the storage
                var owner = userRepository.GetUserByEmail("*****@*****.**");

                // If user doesn’t exist in the storage then create it.
                if (owner == null)
                {
                    userRepository.Add(new User {
                        FirstName = "John", LastName = "Doe", Email = "*****@*****.**"
                    });
                    owner = userRepository.GetUserByEmail("*****@*****.**");
                }

                // Get document data object in the storage
                var document = documentRepository.GetDocument("Document.pdf");

                // If document already created or it hasn’t owner then delete document
                if (document != null && document.OwnerId != owner.Id)
                {
                    documentRepository.Remove(document);
                    document = null;
                }

                // Get document id if document already created or create new document
                long documentId = document != null ? document.Id : annotator.CreateDocument("Document.pdf", DocumentType.Pdf, owner.Id);

                // Create reviewer.
                var reviewerInfo = new ReviewerInfo
                {
                    PrimaryEmail = "*****@*****.**", //user email, unique identifier
                    FirstName    = "Judy",
                    LastName     = "Doe",
                    AccessRights = AnnotationReviewerRights.All
                };

                // Delete collaborator
                var deleteCollaboratorResult = annotator.DeleteCollaborator(documentId, reviewerInfo.PrimaryEmail);
                //ExEnd:DeleteCollaborator
            }
            catch (System.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);
            }
        }