Insert Word Hyperlink in Silverlight

Word hyperlink can guide users to get other related information to contents. It can be Email address, website link or even other documents. When inserting hyperlink, users can add for specified text or enter link address directly.

Spire.Doc for Silverlight, a powerful component on manipulating Word documents with Silverlight, enables users to insert hyperlink in Word with Silverlight. This guide will show the method to realize inserting word hyperlinks in Silverlight. Users can invoke paragraph.AppendHyperlink(link string, text string, hyperlink type) method which is provided by Spire.Doc for Silverlight directly to insert hyperlink in Word.

Download Spire.Doc for Silverlight. Create a Silverlight application. Add a button in MainPage.xaml, and then double it to use the following code to insert hyperlink.

The following screenshot demonstrates the result after inserting hyperlink to Word in Silverlight. The hyperlink is located at the bottom of the picture.

Insert Word Hyperlink

Sample code:

using System;
using System.Windows;
using System.Windows.Controls;
using System.IO;
using System.Reflection;
using Spire.Doc;
using Spire.Doc.Documents;

namespace InsertHyperlink
    public partial class MainPage : UserControl
        public MainPage()

        private void button1_Click(object sender, RoutedEventArgs e)
            //Declare SaveFileDialog
            SaveFileDialog save = new SaveFileDialog();
            save.Filter = "Word Document(*.docx)|*.docx";

            //Load Document
            Document document = new Document();
            Assembly assembly = this.GetType().Assembly;
            foreach (String name in assembly.GetManifestResourceNames())
                if (name.EndsWith("Spire.Doc for Silverlight.docx"))
                    using (Stream docStream = assembly.GetManifestResourceStream(name))
                        document = new Document(docStream, FileFormat.Docx);

            //Add Hyperlink
            Section section = document.Sections[0];
            Paragraph LinkPara = section.AddParagraph();
            LinkPara.AppendHyperlink("", "Learn More about Spire.Doc for Siverlight", HyperlinkType.WebLink);

            //Set Paragrah Style
            ParagraphStyle style = new ParagraphStyle(document);
            style.Name = "LinkStyle";
            style.CharacterFormat.FontName = "Britannic Bold";
            style.CharacterFormat.FontSize = 13;
            style.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple;
            style.ParagraphFormat.LineSpacing = 15F;

            //Save Document
            bool? result = save.ShowDialog();
            if (result.HasValue && result.Value)
                using (Stream stream = save.OpenFile())
                    document.SaveToStream(stream, FileFormat.Docx);
Imports System.IO
Imports System.Reflection
Imports System.Drawing
Imports Spire.Doc
Imports Spire.Doc.Documents

Partial Public Class MainPage
    Inherits UserControl

    Public Sub New()
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
        'Declare SaveFileDialog
        Dim save As New SaveFileDialog()
        save.Filter = "Word Document(*.docx)|*.docx"

        'Load Document
        Dim document As New Document()
        Dim [assembly] As System.Reflection.Assembly = Me.GetType().Assembly
        For Each name As String In [assembly].GetManifestResourceNames()
            If name.EndsWith("Spire.Doc for Silverlight.docx") Then
                Using docStream As Stream = [assembly].GetManifestResourceStream(name)
                    document = New Document(docStream, FileFormat.Docx)
                End Using
            End If
        Next name

        'Add Hyperlink
        Dim section As Section = document.Sections(0)
        Dim LinkPara As Paragraph = section.AddParagraph()
        LinkPara.AppendHyperlink("", "Learn More about Spire.Doc for Siverlight", HyperlinkType.WebLink)

        'Set Paragrah Style
        Dim style As New ParagraphStyle(document)
        style.Name = "LinkStyle"
        style.CharacterFormat.FontName = "Britannic Bold"
        style.CharacterFormat.FontSize = 13
        style.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple
        style.ParagraphFormat.LineSpacing = 15.0F

        'Save Document
        Dim result? As Boolean = save.ShowDialog()
        If result.HasValue AndAlso result.Value Then
            Using stream As Stream = save.OpenFile()
                document.SaveToStream(stream, FileFormat.Docx)
            End Using
        End If
    End Sub
End Class

Spire.Doc is an Microsoft Word component which enables users to perform a wide range of Word document processing tasks directly, such as generate, read, write and modify Word document in WPF.NET and Silverlight.