Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Tue Mar 21, 2017 7:27 pm

How can I reference the same Footnote more than once?
Please see attached document.

Thanks!

A99
 
Posts: 2
Joined: Fri Mar 10, 2017 1:50 pm

Wed Mar 22, 2017 8:51 am

Dear A99,

Thanks for your inquiry.
Here is sample code for your kind reference.
Code: Select all
            Document document = new Document();
            document.LoadFromFile(@"F:\testing\doc form\original document\10099.docx");
            Section section = document.Sections[0];
            //add footnote
            Paragraph paragraph = section.Paragraphs[0];
            Footnote footnote = paragraph.AppendFootnote(FootnoteType.Footnote);
            footnote.TextBody.AddParagraph().AppendText("First");

            //insert bookmart includes the footnote
            BookmarkStart start = new BookmarkStart(document, "_FootNote1");           
            BookmarkEnd end = new BookmarkEnd(document, "_FootNote1");
            paragraph.ChildObjects.Insert(paragraph.ChildObjects.IndexOf(footnote), start);
            paragraph.ChildObjects.Insert(paragraph.ChildObjects.IndexOf(footnote)+1, end);

            //add a cross-reference field, and link it to the bookmark
            Field Field = new Field(document);
            Field.Type = FieldType.FieldNoteRef;
            Field.Code = @" NOTEREF _FootNote1 \f \h  \* MERGEFORMAT ";

            //add it into the place where reference the same footnote.
            section.Paragraphs[1].ChildObjects.Add(Field);
            FieldMark fieldmark = new FieldMark(document, FieldMarkType.FieldSeparator);
            section.Paragraphs[1].ChildObjects.Add(fieldmark);
           
            TextRange tr = new TextRange(document);
            tr.Text = "1";
            tr.CharacterFormat.SubSuperScript = SubSuperScript.SuperScript;
            section.Paragraphs[1].ChildObjects.Add(tr);

            FieldMark fieldEnd = new FieldMark(document, FieldMarkType.FieldEnd);
            section.Paragraphs[1].ChildObjects.Add(fieldEnd);
           
            document.SaveToFile("sameFootNote10099.docx", FileFormat.Docx);

Hope this helps, if there is any question, please let me know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Fri Mar 24, 2017 8:13 am

Dear A99,

Did you test the code I provided ? Did it help you solve your issue ?

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Mar 29, 2017 11:59 am

Thanks for the follow-up. Yes it appears to work as expected.
Thanks.

A99
 
Posts: 2
Joined: Fri Mar 10, 2017 1:50 pm

Thu Mar 30, 2017 1:24 am

Dear A99,

Thanks for your feedback.
Please feel free to contact us if you have any issue.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.Doc