Microsoft Word offers easy solution to insert footnote into Word document. However, by using C#, we can insert footnote into Word document even we don't install Microsoft on system.
Spire.Doc for .NET, a professional and powerful .NET Word component, which can easily help us insert footnote into Word document through C# code. Download Spire.Doc for .NET and make sure Spire.Doc for .NET and Visual Studio are correctly installed on system. Follow the simple instructions below to insert footnote into Word document.
Step 1 Create Project
Create a C# project in visual studio add Spire.Doc.dll as reference. The default setting of Spire.Doc.dll is placed under "C:\Program Files\e-iceblue\Spire.Doc\Bin”. Select assembly Spire.Doc.dll and click OK to add it to the project.
Step 2 Load Word Document
Use the following code to load Word document which we need insert footnote.
Document document = new Document();
document.LoadFromFile(@”E:\work\documents\Antarctic.docx”);
Section section = document.Sections[0];
Paragraph paragraph = section.Paragraphs[1];
Step 3 Insert Footnote into Word Document
Spire.Doc for .NET presents easy solution to insert footnote into Word document. Furthermore, it enables users to design font, color and size. The code below can help us insert footnote and design style.
Footnote footnote=paragraph.AppendFootnote(FootnoteType.Footnote);
TextRange text = footnote.TextBody.AddParagraph().AppendText(“If you want to get more information of Antarctic, please check from wiki.”);
text.CharacterFormat.FontName = “Arial Narrow”;
text.CharacterFormat.FontSize = 12;
text.CharacterFormat.TextColor = Color.SlateGray;
Step 4 Save
After finish inserting footnotes, use the code below to save the settings. We can also rename the file here.
document.SaveToFile(“FootNote.docx”, FileFormat.Docx);
System.Diagnostics.Process.Start(“FootNote.docx”);
Effective Screenshots: