Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Word .NET
>
Tutorial
> Create footnote
The following example shows you how to add a footnote.
C# example
using System; using Independentsoft.Office.Word; using Independentsoft.Office.Word.FootnoteEndnote; namespace Sample { class Program { static void Main(string[] args) { WordDocument doc = new WordDocument(); Footnote footnote1 = new Footnote(1); FootnoteReference footnoteReference = new FootnoteReference(1); Run footnoteRun1 = new Run(); footnoteRun1.VerticalAlignment = VerticalAlignment.Superscript; footnoteRun1.AddFootnoteReferenceMark(); Run footnoteRun2 = new Run(); footnoteRun2.AddText("Footnote text."); Paragraph footnoteParagraph = new Paragraph(); footnoteParagraph.Add(footnoteRun1); footnoteParagraph.Add(footnoteRun2); footnote1.Content.Add(footnoteParagraph); Run run1 = new Run(); run1.AddText("Hello Word"); Run footnoteReferenceRun = new Run(); footnoteReferenceRun.VerticalAlignment = VerticalAlignment.Superscript; footnoteReferenceRun.Add(footnoteReference); Paragraph paragraph1 = new Paragraph(); paragraph1.Add(run1); paragraph1.Add(footnoteReferenceRun); doc.Body.Add(paragraph1); doc.Footnotes.Add(footnote1); doc.Save("c:\\test\\output.docx", true); } } }
VB example
Imports System Imports Independentsoft.Office.Word Imports Independentsoft.Office.Word.FootnoteEndnote Module Module1 Sub Main(ByVal args() As String) Dim doc As WordDocument = New WordDocument() Dim footnote1 As Footnote = New Footnote(1) Dim footnoteReference As FootnoteReference = New FootnoteReference(1) Dim footnoteRun1 As Run = New Run footnoteRun1.VerticalAlignment = VerticalAlignment.Superscript footnoteRun1.AddFootnoteReferenceMark() Dim footnoteRun2 As Run = New Run footnoteRun2.AddText("Footnote text.") Dim footnoteParagraph As Paragraph = New Paragraph footnoteParagraph.Add(footnoteRun1) footnoteParagraph.Add(footnoteRun2) footnote1.Content.Add(footnoteParagraph) Dim run1 As Run = New Run run1.AddText("Hello Word") Dim footnoteReferenceRun As Run = New Run footnoteReferenceRun.VerticalAlignment = VerticalAlignment.Superscript footnoteReferenceRun.Add(footnoteReference) Dim paragraph1 As Paragraph = New Paragraph paragraph1.Add(run1) paragraph1.Add(footnoteReferenceRun) doc.Body.Add(paragraph1) doc.Footnotes.Add(footnote1) doc.Save("c:\test\output.docx", True) End Sub End Module
Need help? Ask our developers:
Name*
Email*
Message*