I am using Aspose.Words for .Net and I am trying to insert a cross-reference to a footnote. (You do this so that you can reference a footnote multiple times, but only insert the footnote text once.) This is possible in MS Word, but I can’t quite figure out how to do it in Aspose.Words.
If it matters, in MS Word, the field looks like this: {NOTEREF _Ref185070032 \f} I just can’t figure out how to determine the magic number: _Ref185970032 from a previously inserted footnote.
Hi
Thanks for your inquiry. This “magic number” is name of auto generated bookmark that is created surround footnote. This looks like the following. BookmarkStart Footnote BookmarkEnd
You can try to achieve this using the following code.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// write some text
builder.Write("Some text is added.");
// insert footnote
Footnote footnote = builder.InsertFootnote(FootnoteType.Footnote, "Footnote text.");
// create name
string name = String.Format("_Ref{0}",footnote.GetHashCode().ToString());
// create bookmark
BookmarkStart start = new BookmarkStart(doc, name);
BookmarkEnd end = new BookmarkEnd(doc, name);
// insert bookmark start before footnote
footnote.ParentParagraph.InsertBefore(start, footnote);
// insert bookmark end after footnote
footnote.ParentParagraph.InsertAfter(end, footnote);
// insert NOTEREF field (YOu should update this field in MS WORD)
builder.InsertField(String.Format(@"NOTEREF {0} \h", name), "1");
// save document
doc.Save(@"407_105812_ategen\out.doc");
But there in one problem. Aspose.Words doesn’t update NOTEREF fields. That’s why you should update an inserted field manually in MS Word.
I hope that this information will help you. Please let me know if you would like to know something else.
Best regards.
Would there be any way for me to hack in some code that would update noteref’s? Maybe if you could point me in the right direction I could see what I can do.