This demo uses the DevExpress Word Processing Document API to manage footnotes/endnotes in a predefined document.
Use checkboxes to specify whether the demo should add new footnotes/endnotes to the document. In the Appearance Settings panel, specify layout and numbering parameters.
Use the Modify Notes and Save as… dropdown button to select an output format, process the document, and download the result.
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
using System.Drawing;
void AddNewFootnote(Document document, DocumentPosition footnotePosition, string footnoteText) {
Note footnote = document.Footnotes.Insert(footnotePosition);
SubDocument footnoteDocument = footnote.BeginUpdate();
var footnoteRange = footnoteDocument.AppendText(footnoteText);
CharacterProperties footnoteCharProps = footnoteDocument.BeginUpdateCharacters(footnoteRange);
footnoteCharProps.Bold = true;
footnoteCharProps.ForeColor = Color.Red;
footnoteDocument.EndUpdateCharacters(footnoteCharProps);
footnote.EndUpdate(footnoteDocument);
}
void AddNewEndnote(Document document, DocumentPosition endnotePosition, string endnoteText) {
Note endnote = document.Endnotes.Insert(endnotePosition);
SubDocument endnoteDocument = endnote.BeginUpdate();
var endnoteRange = endnoteDocument.AppendText(endnoteText);
CharacterProperties endnoteCharProps = endnoteDocument.BeginUpdateCharacters(endnoteRange);
endnoteCharProps.Bold = true;
endnoteCharProps.ForeColor = Color.Red;
endnoteDocument.EndUpdateCharacters(endnoteCharProps);
endnote.EndUpdate(endnoteDocument);
}
void ChangeNoteAppearance(Document document, string noteSeparator, NoteRestartType restartType,
NumberingFormat format, int startNumber) {
SubDocument noteSeparatorDoc = document.Footnotes.BeginUpdateSeparator(NoteSeparatorType.Separator);
noteSeparatorDoc.Delete(noteSeparatorDoc.Range);
noteSeparatorDoc.AppendText(noteSeparator);
document.Footnotes.EndUpdateSeparator(noteSeparatorDoc);
foreach (Section section in document.Sections) {
FootnoteOptions footnoteOptions = section.FootnoteOptions;
footnoteOptions.RestartType = restartType;
footnoteOptions.NumberingFormat = format;
footnoteOptions.StartNumber = startNumber;
}
}
void ChangeNotePosition(Document document, EndnotePosition endnotePosition, FootnotePosition footnotePosition) {
document.EndnotePosition = endnotePosition;
foreach (Section section in document.Sections)
section.FootnoteOptions.Position = footnotePosition;
}