Bookmarks and Hyperlinks

Bookmarks are used to record a location in a document and hyperlinks are used to jump to a recorded location or to an external content.

Following example demonstrates how to insert a bookmark to a document and a hyperlink that links to a bookmark.

Bookmarks and Hyperlinks Screenshot
using GemBox.Document;

class Program
{
    static void Main(string[] args)
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        DocumentModel document = new DocumentModel();

        string bookmarkName = "LinkToTop";

        document.Sections.Add(
            new Section(document,
                new Paragraph(document,
                    new BookmarkStart(document, bookmarkName),
                    new Run(document, "GemBox.Document"),
                    new BookmarkEnd(document, bookmarkName)),
                new Paragraph(document,
                    new Hyperlink(document, "https://www.gemboxsoftware.com/document", "GemBox.Document"),
                    new Run(document, " is a .NET component that enables developers to read, write, convert and print document files (DOCX, DOC, PDF, HTML, XPS, RTF and TXT) from .NET applications in a simple and efficient way.")),
                 new Paragraph(document),
                 new Paragraph(document),
                 new Paragraph(document),
                 new Paragraph(document,
                     // When user clicks on this link it will jump to the text between BookmarkStart and BookmarkEnd.
                     new Hyperlink(document, bookmarkName, "To Top")
                     {
                         IsBookmarkLink = true
                     })));

        document.Save("Bookmarks and Hyperlinks.%OutputFileType%");
    }
}
Imports GemBox.Document

Module Program

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        Dim document As DocumentModel = New DocumentModel

        Dim bookmarkName As String = "LinkToTop"

        ' When user clicks on this link it will jump to the text between BookmarkStart and BookmarkEnd. 
        document.Sections.Add(
            New Section(document,
                New Paragraph(document,
                    New BookmarkStart(document, bookmarkName),
                    New Run(document, "GemBox.Document"),
                    New BookmarkEnd(document, bookmarkName)),
                New Paragraph(document,
                    New Hyperlink(document, "https://www.gemboxsoftware.com/document", "GemBox.Document"),
                    New Run(document, " is a .NET component that enables developers to read, write, convert and print document files (DOCX, DOC, PDF, HTML, XPS, RTF and TXT) from .NET applications in a simple and efficient way.")),
                New Paragraph(document),
                New Paragraph(document),
                New Paragraph(document),
             New Paragraph(document,
                 New Hyperlink(document, bookmarkName, "To Top") With {
        .IsBookmarkLink = True
                })))

        document.Save("Bookmarks and Hyperlinks.%OutputFileType%")

    End Sub

End Module

Check next example or download examples from GitHub.