Beispiel #1
0
        public static void AddLinkInsideDocument()
        {
            WordDocument        document = new WordDocument();
            WordDocumentBuilder builder  = new WordDocumentBuilder(document);

            //Add hyperlink navigate to bookmark inside this document by bookmark's name
            builder.InsertHyperlinkToBookmark("this is hyerlink", "bookmark1", "go to bookmark1");

            //Add a bookmark in the second page
            builder.InsertBreak(BreakType.PageBreak);
            TextInline textBookmark = builder.InsertText("This is bookmark1. ");

            builder.InsertBookmark("bookmark1", textBookmark, textBookmark);

            WordFile wordFile = new WordFile();

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