rhegde
July 5, 2021, 12:11pm
1
How do we create multiple footnote/endnote references for a single footnote/endnote text in Aspose.Words?
e.g. Sample sentence1 for a single footnote1
1 . Footnote text.
In Microsoft Word you can do the same by going to the menu References -> Cross-reference. You can then select the option “Reference Type:” as Footnote, option “Insert reference to:” as Footnote number and then select the footnote which is already created.
@rhegde ,
I think, you can build logic on the following C# code of Aspose.Words for .NET API to get the desired results:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
InsertBookmarkWithFootnote(builder, "MyBookmark1", "Contents of MyBookmark1", "Footnote from MyBookmark1");
builder.InsertBreak(BreakType.PageBreak);
InsertFieldNoteRef(builder, "MyBookmark1", true, false, false, "Bookmark1, with footnote number ");
builder.Writeln();
InsertFieldNoteRef(builder, "MyBookmark1", true, false, false, "Bookmark1, with footnote number ");
doc.UpdateFields();
doc.Save("C:\\temp\\21.7.docx");
private static FieldNoteRef InsertFieldNoteRef(DocumentBuilder builder, string bookmarkName, bool insertHyperlink, bool insertRelativePosition, bool insertReferenceMark, string textBefore)
{
builder.Write(textBefore);
FieldNoteRef field = (FieldNoteRef)builder.InsertField(FieldType.FieldNoteRef, true);
field.BookmarkName = bookmarkName;
field.InsertHyperlink = insertHyperlink;
field.InsertRelativePosition = insertRelativePosition;
field.InsertReferenceMark = insertReferenceMark;
builder.Writeln();
return field;
}
private static void InsertBookmarkWithFootnote(DocumentBuilder builder, string bookmarkName, string bookmarkText, string footnoteText)
{
builder.StartBookmark(bookmarkName);
builder.Write(bookmarkText);
builder.InsertFootnote(FootnoteType.Footnote, footnoteText);
builder.EndBookmark(bookmarkName);
builder.Writeln();
}