-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathBookmarksAndHyperlinks.cs
More file actions
56 lines (45 loc) · 2.13 KB
/
BookmarksAndHyperlinks.cs
File metadata and controls
56 lines (45 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
using System;
namespace RichEditDocumentServerAPIExample.CodeExamples
{
public static class BookmarksAndHyperlinksActions
{
public static Action<RichEditDocumentServer> InsertBookmarkAction = InsertBookmark;
public static Action<RichEditDocumentServer> InsertHyperlinkAction = InsertHyperlink;
static void InsertBookmark(RichEditDocumentServer wordProcessor)
{
#region #InsertBookmark
// Load a document from a file.
wordProcessor.LoadDocument("Documents\\Grimm.docx", DocumentFormat.OpenXml);
// Access a document.
Document document = wordProcessor.Document;
// Start to edit the document.
document.BeginUpdate();
// Create a bookmark at the start document position.
document.Bookmarks.Create(document.CreateRange(document.Range.Start, 0), "Top");
// Create a hyperlink that navigates to the created bookmark.
wordProcessor.Document.Paragraphs.Append();
DocumentRange hyperlinkRange = wordProcessor.Document.AppendText("get to the top");
document.Hyperlinks.Create(hyperlinkRange);
document.Hyperlinks[0].Anchor = "Top";
// Finalize to edit the document.
document.EndUpdate();
#endregion #InsertBookmark
}
static void InsertHyperlink(RichEditDocumentServer wordProcessor)
{
#region #InsertHyperlink
// Access a document.
Document document = wordProcessor.Document;
// Create a hyperlink at the specified position.
DocumentRange hyperlinkRange = document.InsertText(document.Range.Start, "Follow me!");
document.Hyperlinks.Create(hyperlinkRange);
// Specify the URI to which the hyperlink navigates.
document.Hyperlinks[0].NavigateUri = "https://devexpress.com";
// Specify the hyperlink tooltip.
document.Hyperlinks[0].ToolTip = "DevExpress";
#endregion #InsertHyperlink
}
}
}