Footnotes and Endnotes

Footnotes and endnotes are used to add a note about a term in a document. Footnotes are located on the same page as the terms they describe (below page content) while endnotes can be found at the end of the document or at the end of the section, depending on the endnote settings. Footnote and endnote settings (such as location, numbering style, starting number, etc.) can be defined on the document (used for newly added sections) and section level.

The following example shows how to specify footnote and endnote settings on both the document and section level as well as how to insert footnotes and endnotes that contain simple text or more complex content (such as hyperlinks).

Screenshot

Footnotes and Endnotes Screenshot

See the full code below, use RUN EXAMPLE to execute.


1using System;
2using System.IO;
3using System.Linq;
4using GemBox.Document;
5using GemBox.Document.Drawing;
6
7class Sample
8{
9    [STAThread]
10    static void Main(string[] args)
11    {
12        // If using Professional version, put your serial key below.
13        ComponentInfo.SetLicense("FREE-LIMITED-KEY");
14
15        DocumentModel document = new DocumentModel();
16
17        // All sections added to the document will have footnotes
18        // numbered using lower letters.
19        document.Settings.Footnote.NumberStyle = NumberStyle.LowerLetter;
20
21        // All sections added to the document will have endnotes
22        // numbered using lower Roman.
23        document.Settings.Endnote.NumberStyle = NumberStyle.LowerRoman;
24
25        Section section = new Section(document);
26        document.Sections.Add(section);
27
28        // All footnotes in this section will be numbered using digits.
29        // All endnotes in this section will be numbered using lower Roman 
30        // (taken from document settings).
31        section.FootnoteSettings.NumberStyle = NumberStyle.Decimal;
32
33        section.Blocks.Add(new Paragraph(document,
34            new Run(document, "GemBox.Document"),
35            new Note(document, NoteType.Footnote,
36                new Paragraph(document,
37                    new Run(document, "More info at "),
38                    new Hyperlink(document,
39                        "https://www.gemboxsoftware.com/document/overview",
40                        "our website"),
41                    new Run(document, "."))),
42            new Run(document, " is a .NET component that enables developers to read,"),
43            new Run(document, " write, convert and print document files"),
44            new Run(document, " (DOCX, DOC, PDF, HTML, XPS, RTF and TXT)"),
45            new Note(document, NoteType.Endnote,
46                "Image formats like PNG, JPEG, BMP and TIFF are also supported."),
47            new Run(document, " from .NET"),
48            new Note(document, NoteType.Footnote,
49                "Minimum required .NET Framework version is 3.0."),
50            new Run(document, " applications in a simple and efficient way.")));
51
52        section = new Section(document);
53        document.Sections.Add(section);
54
55        // All endnotes in this section will be numbered using upper Roman.
56        // All footnotes in this section will be numbered using lower letters
57        // (taken from document settings).
58        section.EndnoteSettings.NumberStyle = NumberStyle.UpperRoman;
59
60        section.Blocks.Add(new Paragraph(document,
61            new Run(document, "All versions of GemBox.Document come in "),
62            new Run(document, "the Microsoft Windows Installer"),
63            new Note(document, NoteType.Footnote,
64                ".MSI file format."),
65            new Run(document, " format, which ensures you can easily install /"),
66            new Run(document, " uninstall and use multiple GemBox.Document versions"),
67            new Note(document, NoteType.Endnote,
68                new Paragraph(document,
69                    new Run(document, "You can get the latest version "),
70                    new Hyperlink(document,
71                        "https://www.gemboxsoftware.com/document/free-version",
72                        "here"),
73                    new Run(document, "."))),
74            new Run(document, " on the same machine.")));
75
76        document.Sections.Add(
77            new Section(document,
78                new Paragraph(document,
79                    new Run(document, "GemBox.Document Free"),
80                    new Note(document, NoteType.Endnote,
81                        "Limited to 20 paragraphs."),
82                    new Run(document, " is free of charge while GemBox.Document"),
83                    new Run(document, " Professional is a commercial version"),
84                    new Run(document, " licensed per developer."),
85                    new Run(document, " Server deployment is royalty free."))));
86
87        document.Save("Footnotes and Endnotes.docx");
88    }
89}
1Imports System
2Imports System.IO
3Imports System.Linq
4Imports GemBox.Document
5Imports GemBox.Document.Drawing
6
7Module Samples
8
9    Sub Main()
10
11        ' If using Professional version, put your serial key below.
12        ComponentInfo.SetLicense("FREE-LIMITED-KEY")
13
14        Dim document As DocumentModel = New DocumentModel
15
16        ' All sections added to the document will have footnotes
17        ' numbered using lower letters.
18        document.Settings.Footnote.NumberStyle = NumberStyle.LowerLetter
19
20        ' All sections added to the document will have endnotes
21        ' numbered using lower Roman.
22        document.Settings.Endnote.NumberStyle = NumberStyle.LowerRoman
23
24        Dim section As New Section(document)
25        document.Sections.Add(section)
26
27        ' All footnotes in this section will be numbered using digits.
28        ' All endnotes in this section will be numbered using lower Roman 
29        ' (taken from document settings).
30        section.FootnoteSettings.NumberStyle = NumberStyle.Decimal
31
32        section.Blocks.Add(New Paragraph(document,
33            New Run(document, "GemBox.Document"),
34            New Note(document, NoteType.Footnote,
35                New Paragraph(document,
36                    New Run(document, "More info at "),
37                    New Hyperlink(document,
38                        "https://www.gemboxsoftware.com/document/overview",
39                        "our website"),
40                    New Run(document, "."))),
41            New Run(document, " is a .NET component that enables developers to read,"),
42            New Run(document, " write, convert and print document files"),
43            New Run(document, " (DOCX, DOC, PDF, HTML, XPS, RTF and TXT)"),
44            New Note(document, NoteType.Endnote,
45                "Image formats like PNG, JPEG, BMP and TIFF are also supported."),
46            New Run(document, " from .NET"),
47            New Note(document, NoteType.Footnote,
48                "Minimum required .NET Framework version is 3.0."),
49            New Run(document, " applications in a simple and efficient way.")))
50
51        section = New Section(document)
52        document.Sections.Add(section)
53
54        ' All endnotes in this section will be numbered using upper Roman.
55        ' All footnotes in this section will be numbered using lower letters
56        ' (taken from document settings).
57        section.EndnoteSettings.NumberStyle = NumberStyle.UpperRoman
58
59        section.Blocks.Add(New Paragraph(document,
60            New Run(document, "All versions of GemBox.Document come in "),
61            New Run(document, "the Microsoft Windows Installer"),
62            New Note(document, NoteType.Footnote,
63                ".MSI file format."),
64            New Run(document, " format, which ensures you can easily install /"),
65            New Run(document, " uninstall and use multiple GemBox.Document versions"),
66            New Note(document, NoteType.Endnote,
67                New Paragraph(document,
68                    New Run(document, "You can get the latest version "),
69                    New Hyperlink(document,
70                        "https://www.gemboxsoftware.com/document/free-version",
71                        "here"),
72                    New Run(document, "."))),
73            New Run(document, " on the same machine.")))
74
75        document.Sections.Add(
76            New Section(document,
77                New Paragraph(document,
78                    New Run(document, "GemBox.Document Free"),
79                    New Note(document, NoteType.Endnote,
80                        "Limited to 20 paragraphs."),
81                    New Run(document, " is free of charge while GemBox.Document"),
82                    New Run(document, " Professional is a commercial version"),
83                    New Run(document, " licensed per developer."),
84                    New Run(document, " Server deployment is royalty free."))))
85
86        document.Save("Footnotes and Endnotes.docx")
87
88    End Sub
89
90End Module

Check next sample or find out more about GemBox.Document and GemBox Software.