How to Add Footer for A Word Document with Silverlight

Footer, often added on the bottom of one Word page, shows additional information about document. The information can be document title, company name, author name, page number etc. Besides text, footer can be image as well, such as company logo, stamp and so on.

In this post, I will share my method about how to add footer in Word document with Silverlight. I will create a new Word document and then add footer for it. The footer is text and will be formatted. Also, the Silverlight Word component, Spire.Doc for Silverlight is used in this example and its dll file has been added as reference in my project.


Step 1. Design User Control

Rename MainPage.xaml as Footer.xaml. Double click Footer.xaml to design UserControl. At the beginning, judge size. Add a label and change its contents as “Draw Footer in Word”. Then, set text font style and color. Next, add a button to run. Finally, set UserControl background as image.

Step 2. Declare saveFileDialog

Declare a saveFileDialog for save Word document. Then, set filter for this saveFileDialog. In this example, I set filter format as .docx.

Step 3. Add Footer

Declare a new word document. Then, add a section in this document. Next, add footer in this section.

Create a footer paragraph, append text for this paragraph. The text is footer content. Then, set format for footer content, including font style, color and alignment.

In order to separate footer from document contents, add top border for footer. Then, set border style and color.

Step 4. Save File

Judge if the saveFileDialog which is declared in step 1 can pop up. If so, save document which image is inserted in through it.

Full Footer.xaml.cs

using System.Windows;

using System.Windows.Controls;

using System.IO;

using System.Drawing;

using Spire.Doc;

using Spire.Doc.Documents;

using Spire.Doc.Fields;



namespace WordFooter


    public partial class MainPage : UserControl


        //Declare SaveFileDialog

        private SaveFileDialog saveFiledialog = new SaveFileDialog();

        public MainPage()



            this.saveFiledialog.Filter = “Word Document (*.docx)|*.docx”;



        private void button1_Click(object sender, RoutedEventArgs e)


            //Create Document

            Document document = new Document();

            Section section = document.AddSection();


            //Draw Footer

            HeaderFooter footer = section.HeadersFooters.Footer;

            Paragraph footerParagraph = footer.AddParagraph();

            TextRange text = footerParagraph.AppendText(“Word Footer”);


            //Set Footer Format

            text.CharacterFormat.FontName = “Calibri”;

            text.CharacterFormat.FontSize = 14;

            text.CharacterFormat.TextColor = Color.DarkOrange;

            text.CharacterFormat.Bold = true;

            text.CharacterFormat.Italic = true;


                = Spire.Doc.Documents.HorizontalAlignment.Right;


            //Set Borders


                = Spire.Doc.Documents.BorderStyle.ThinThinSmallGap;

            footerParagraph.Format.Borders.Top.Space = 0.15f;

            footerParagraph.Format.Borders.Color = Color.CadetBlue;


            //Save Document

            bool? result = this.saveFiledialog.ShowDialog();

            if (result.HasValue && result.Value)


                using (Stream stream = this.saveFiledialog.OpenFile())


                    document.SaveToStream(stream, FileFormat.Docx);







DOWNLOAD Spire.Doc for Silverlight Here


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s