// but unlike that sample uses hyperlinks collections
// rather than HYPERLINK fields.
publicclassHyperlinks
{
publicGcWordDocumentCreateDocx()
{
var doc =newGcWordDocument();
var section = doc.Body.Sections.First;
var pars = section.GetRange().Paragraphs;
// 0. Paragraph with an external hyperlink:
var p = pars.Add(
"It is easy to add hyperlinks to document content via Range.Hyperlinks collection. "+
"Following is a hyperlink to a web address. ");
// There are different Hyperlinks.Add() overloads that allow to specify
// different hyperlink options such as screen tips etc:
var hl0 = p.GetRange().Hyperlinks.Add(newUri("http://www.google.com"),null,"Click to go to www.google.com.");
// 1. Paragraph with an external hyperlink with its own style:
p = pars.Add("Next is another hyperlink, this time with its own style and a custom tooltip. ");
var hl1 = p.GetRange().Hyperlinks.Add(newUri("https://www.grapecity.com/en/"),null,"Click to go to www.grapecity.com.","Click to open GrapeCity web page");
// 2. Link to a bookmark within the document:
// We add bookmarks at the top and bottom of the document,
// and set up links to jump between them.
var bmkTop ="BookmarkTop";
var bmkBot ="BookmarkEnd";
p = pars.Add(
"Hyperlinks can also point to locations within the document. "+
"We add some filler paragraphs below, followed by a paragraph "+
$"with a bookmark named '{bmkBot}' attached to it. "+
"The next hyperlink jumps to that bookmark. ");
// Attach a bookmark to this paragraph so we can jump back here:
p.GetRange().Bookmarks.Add(bmkTop);
// A hyperlink to a bookmark:
var hl2 = p.GetRange().Hyperlinks.Add($"{bmkBot}", $"Click to jump to {bmkBot} at the end of the document.", $"Jumo to {bmkBot}");