示例#1
0
        public static void HighlightText()
        {
            WordFile     wordFile = new WordFile();
            WordDocument document = wordFile.Import(File.ReadAllBytes("Sample.docx"));

            WordDocumentBuilder builder = new WordDocumentBuilder(document);

            //Apply new highlight style
            Action <CharacterState> action = new Action <CharacterState>((state) =>
            {
                state.HighlightColor = Colors.Yellow;
            });

            //Highlight all the "Page" text in the document
            builder.ReplaceStyling("Page", true, true, action);

            File.WriteAllBytes("HighlightText.docx", wordFile.Export(document));
        }