Пример #1
0
        public static void AddComment()
        {
            WordDocument        document = new WordDocument();
            WordDocumentBuilder builder  = new WordDocumentBuilder(document);

            builder.InsertLine("First paragraph in this document.");

            //Insert some content before comment
            builder.InsertText("Second paragraph start. ");
            //Select the content you want to comment
            TextInline textComment = builder.InsertText("Text has comment. ");

            //Insert some content after comment
            builder.InsertText("Second paragraph end.");

            //Add comment with selected content
            Comment comment = builder.InsertComment("Comment details here", textComment, textComment);

            comment.Author = "iDiTect";
            comment.Date   = DateTime.Now;

            WordFile wordFile = new WordFile();

            using (var stream = File.OpenWrite("AddComment.docx"))
            {
                wordFile.Export(document, stream);
            }
        }