Nevron Open Vision Documentation
Rich Text Editor / Document Model / Inlines / Hyperlink Inlines
In This Topic
    Hyperlink Inlines
    In This Topic

    Hyperlinks inline elements are similar to the anchor tag elements in HTML. They allow you to associate a URL to text, which when clicked in a browser navigates the browser to a different URL. Hyperlinks can also be used as bookmarks.

     Creating Hyperlinks

    Hyperlink inline elements are represented by instances of the NHyperlinkInline class. The following example shows how to create a hyperlink that points to www.nevron.com:

    Creating hyperlink inlines
    Copy Code
    NSection section = new NSection();
    NParagraph paragraph = new NParagraph();
    
    NHyperlinkInline hyperlinkInline = new NHyperlinkInline();
    hyperlinkInline.Hyperlink = new NUrlHyperlink("https://www.nevron.com", ENUrlHyperlinkTarget.SameWindowSameFrame);
    hyperlinkInline.Text = "Jump to www.nevron.com";
    
    paragraph.Inlines.Add(hyperlinkInline);
    section.Blocks.Add(paragraph);
    
    richTextView.Content.Sections.Clear();
    richTextView.Content.Sections.Add(section);
    

    The url hyperlink target values are described in the following table:

    ENUrlHyperlinkTarget Description
    NewWindow Opens the Url in a new browser window
    SameWindowParentFrame Opens the Url in the same browser window, but in the parent frame
    SameWindowSameFrame Opens the Url in the same browser window and frame
    SameWindowTopFrame Opens the Url in the full body of the window
     Creating Image Hyperlinks

    Image inline elements have a Hyperlink property, which you can set to create image hyperlinks. The following example demonstrates how to create an image hyperlink that points to www.mydraw.com.

    Creating image hyperlinks
    Copy Code
    NSection section = new NSection();
    NParagraph paragraph = new NParagraph();
    
    NImageInline imageInline = new NImageInline();
    imageInline.Image = Nevron.Nov.Diagram.NResources.Image_Other_MyDrawLogo_png;
    imageInline.Hyperlink = new NUrlHyperlink("https://www.mydraw.com", ENUrlHyperlinkTarget.SameWindowSameFrame);
    
    paragraph.Inlines.Add(imageInline);
    section.Blocks.Add(paragraph);
    
    richTextView.Content.Sections.Clear();
    richTextView.Content.Sections.Add(section);
    
     Creating Bookmarks 

    Bookmarks in the NOV rich text editor are represented by the NBookmarkInline class. It has a property called Name, which can be referred to from hyperlinks or used by the user to position the control view on that bookmark. The following example shows how to create a bookmark inline:

    Creating bookmarks
    Copy Code
    NParagraph paragraph = new NParagraph();
    
    NBookmarkInline bookmark = new NBookmarkInline();
    bookmark.Name = "MyBookmark";
    bookmark.Text = "This is a bookmark";
    paragraph.Inlines.Add(bookmark);
    
    section.Blocks.Add(paragraph);
    
    richTextView.Content.Sections.Clear();
    richTextView.Content.Sections.Add(section);
    

    To create a hyperlink that points to the bookmark simply create a hyperlink inline and set its hyperlink property to new NBookmarkHyperlink referencing the name of the bookmark:

    Creating Hyperlink Inline to a Bookmark
    Copy Code
    NHyperlinkInline hyperlink = new NHyperlinkInline();
    hyperlink.Hyperlink = new NBookmarkHyperlink("MyBookmark");
    hyperlink.Text = "Jump to MyBookmark";
    paragraph.Inlines.Add(hyperlink);
    

    To position the rich text view so that the bookmark is visible to the user you can use the Goto method:

    Navigating to a Bookmark
    Copy Code
    richTextView.Content.Goto(ENTextDocumentPart.Bookmark, "MyBookmark", true);
    
    See Also