How to Add Footnote in Word with C#, VB.NET

Footnote is one kind of annotations to explain one word or sentence in contents. It is often put on the bottom of one page. Because of footnote, users can learn some complicated words more clearly and the completeness can be preserved.

So, this guide will show how to add footnote in a Word document with C#/VB.NET by using Spire.Doc for .NET.

Friendly Reminder: Make Sure Spire.Doc and Visual Studio are correctly installed on system.

Step 1: Declare a new document and use document.LoadFromFile() to get Word document which you want to add footnote. Then, get the second paragraph for which the footnote will be given from the first section.

[C#]
            Document document = new Document();
            document.LoadFromFile(@"E:\work\documents\Antarctic.docx");
            Section section = document.Sections[0];
            Paragraph paragraph = section.Paragraphs[1];
[VB.NET]
            Dim document As New Document()
            document.LoadFromFile("E:\work\documents\Antarctic.docx")
            Dim section As Section = document.Sections(0)
            Dim paragraph As Paragraph = section.Paragraphs(1)

Step 2: Use paragraph.AppendFootnote() method to add footnote. The parameter passed to this method is FootnotType. Then, add footnote contents by using footnote.TextBody.AddParagraph().AppendText() method. Finally, set contents format, including font style, size and color.

[C#]
            Footnote footnote=paragraph.AppendFootnote(FootnoteType.Footnote);
            TextRange text = footnote.TextBody.AddParagraph().AppendText("Check Wiki to get more information");
            text.CharacterFormat.FontName = "Arial Black";
            text.CharacterFormat.FontSize = 12;
            text.CharacterFormat.TextColor = Color.SlateGray;
[VB.NET]
            Dim footnote As Footnote = paragraph.AppendFootnote(FootnoteType.Footnote)
            Dim text As TextRange = footnote.TextBody.AddParagraph().AppendText("Check Wiki to get more information")
            text.CharacterFormat.FontName = "Arial Black"
            text.CharacterFormat.FontSize = 12
            text.CharacterFormat.TextColor = Color.SlateGray

Step 3: As is known, there is a marker to be shown on the location where you want to add footnote. So this step is used to set marker format. Assign values for footnote.MarkerCharacterFormat.FontName/Fontsize/Bold/TextColor.

[C#]
            footnote.MarkerCharacterFormat.FontName = "Calibri";
            footnote.MarkerCharacterFormat.FontSize = 15;
            footnote.MarkerCharacterFormat.Bold = true;
            footnote.MarkerCharacterFormat.TextColor = Color.DarkCyan;
[VB.NET]
            footnote.MarkerCharacterFormat.FontName = "Calibri"
            footnote.MarkerCharacterFormat.FontSize = 15
            footnote.MarkerCharacterFormat.Bold = True
            footnote.MarkerCharacterFormat.TextColor = Color.DarkCyan

Step 4: Save this document by using document.SaveToFile() method. There are two parameters passed: file name string and file format. Then, launch this file for viewing.

[C#]
            document.SaveToFile("FootNote.docx", FileFormat.Docx);
            System.Diagnostics.Process.Start("FootNote.docx");
[VB.NET]
            document.SaveToFile("FootNote.docx", FileFormat.Docx)
            System.Diagnostics.Process.Start("FootNote.docx")

Insert Word Footnote

Insert Word Footnote

Spire.Doc is an MS Word component which enables user to perform a wide range of Word document processing tasks directly, such as generate, read, write and modify Word document for .NET. Click to learn more