Footnote is a note at the bottom of a page that gives more detailed information about something on the page. In this section, we will demonstrate how to add footnote in word using Spire.Doc for WPF.
First, create a new project by choosing WPF Application in Visual Studio, adding a button in the Main Window. Add Spire.Doc.Wpf.dll as reference to your project, and then double click the button to start.
Step 1: Initialize a new instance of Document class. Load the word document from the file.
Document doc = new Document();
doc.LoadFromFile("Oscar.docx");
Step 2: Select the section and paragraph which needs adding footnote. In this example, we choose the first section and the fourth paragraph.
Section sec = doc.Sections[0]; Paragraph paragraph = sec.Paragraphs[3];
Step 3: Add footnote by the method of paragraph.AppendFootnote() and then add the footnote contents by using footnote.TextBody.AddParagraph().AppendText(). At last, set the font style, size and color.
Footnote fn = paragraph.AppendFootnote(FootnoteType.Footnote);
TextRange text = fn.TextBody.AddParagraph().AppendText("Oscar Wilde (film), a 1960 biographical film about Oscar Wilde");
text.CharacterFormat.FontName = "Calibri";
text.CharacterFormat.FontSize = 11;
text.CharacterFormat.TextColor = Color.Chocolate;
Step 4: Set format of the marker.
fn.MarkerCharacterFormat.FontName = "Arial"; fn.MarkerCharacterFormat.FontSize = 14; fn.MarkerCharacterFormat.Bold = true; fn.MarkerCharacterFormat.TextColor = Color.Brown;
Step 5: Save the document and launch the file.
document.SaveToFile("FootNote.docx", FileFormat.Docx);
System.Diagnostics.Process.Start("FootNote.docx");
Effective Screenshot:


Full codes:
using System.Drawing;
using System.Windows;
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;
namespace Add_Footnote_to_Word
{
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
Document doc = new Document();
doc.LoadFromFile("Oscar.docx");
Section sec = doc.Sections[0];
Paragraph paragraph = sec.Paragraphs[3];
Footnote fn = paragraph.AppendFootnote(FootnoteType.Footnote);
TextRange text = fn.TextBody.AddParagraph().AppendText("Oscar Wilde (film), a 1960 biographical film about Oscar Wilde");
text.CharacterFormat.FontName = "Calibri";
text.CharacterFormat.FontSize = 11;
text.CharacterFormat.TextColor = Color.Chocolate;
fn.MarkerCharacterFormat.FontName = "Arial";
fn.MarkerCharacterFormat.FontSize = 14;
fn.MarkerCharacterFormat.Bold = true;
fn.MarkerCharacterFormat.TextColor = Color.Brown;
doc.SaveToFile("AddFootNote.docx", FileFormat.Docx);
System.Diagnostics.Process.Start("AddFootNote.docx");
}
}
}
Imports System.Drawing
Imports System.Windows
Imports Spire.Doc
Imports Spire.Doc.Documents
Imports Spire.Doc.Fields
Namespace Add_Footnote_to_Word
'''
''' Interaction logic for MainWindow.xaml
'''
Public Partial Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
End Sub
Private Sub button1_Click(sender As Object, e As RoutedEventArgs)
Dim doc As New Document()
doc.LoadFromFile("Oscar.docx")
Dim sec As Section = doc.Sections(0)
Dim paragraph As Paragraph = sec.Paragraphs(3)
Dim fn As Footnote = paragraph.AppendFootnote(FootnoteType.Footnote)
Dim text As TextRange = fn.TextBody.AddParagraph().AppendText("Oscar Wilde (film), a 1960 biographical film about Oscar Wilde")
text.CharacterFormat.FontName = "Calibri"
text.CharacterFormat.FontSize = 11
text.CharacterFormat.TextColor = Color.Chocolate
fn.MarkerCharacterFormat.FontName = "Arial"
fn.MarkerCharacterFormat.FontSize = 14
fn.MarkerCharacterFormat.Bold = True
fn.MarkerCharacterFormat.TextColor = Color.Brown
doc.SaveToFile("AddFootNote.docx", FileFormat.Docx)
System.Diagnostics.Process.Start("AddFootNote.docx")
End Sub
End Class
End Namespace
