We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Inserting a footnote marker in the middle of a paragraph


I need to insert a footnote in the middle of a paragraph to have something looking like this:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis venenatis1, eros sed ullamcorper varius, odio diam sollicitudin purus, in

Right now, I’m using the following code which adds the footnote marker at the end of the paragraph:

footnote = new Footnote( doc, FootnoteType.Footnote );
footnote.Paragraphs.Add( new Paragraph( doc ) );
footnote.FirstParagraph.Runs.Add( new Run( doc, “some text” );
para.AppendChild( footnote );

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis venenatis, eros sed ullamcorper varius, odio diam sollicitudin purus, in

Is there a way to do this via Aspose.Words?


Thanks for your inquiry. Could you please attach the following Word documents here for reference?

Input document: The document you want to insert Footnote in.
Target document: The document showing the desired behaviour. You can manually create it using Microsoft Word. I just need to learn as to how you want your final document to be generated like.

I will then investigate the problem on my side and provide you code to achieve this.

Best regards,


Here are the documents.

Please note that the “Input document” is constructed on-the-fly based on paragraphs available in a database.

Some paragraphs may contain footnotes (like the 3rd one in the sample) which use the following format “<NOTE:Some text>”. This tag should be replaced by a footnote containing “Some text”.

At the time of posting my question, I created the whole document “manually” but after reading other posts and digging deeper in the help, I switched to the document builder which greatly facilitate the work (first project using Aspose.Words :slight_smile: ). I can now insert the footnote where I need using text splitting / the Write and InsertFootnote functions.

Anyway, is there another way to specify the position of the footnote in a paragraph?


Thanks for the additional information. Please try running the following code to achieve what you’re looking for:

Document doc = new
doc.Range.Replace(new Regex(""), new ReplaceHandler(), false);


private class ReplaceHandler : IReplacingCallback


ReplaceAction IReplacingCallback.Replacing(ReplacingArgs e)


Footnote footnote = new Footnote(e.MatchNode.Document, FootnoteType.Footnote);

e.MatchNode.ParentNode.InsertBefore(footnote, e.MatchNode);

footnote.Paragraphs.Add(new Paragraph(e.MatchNode.Document));

footnote.FirstParagraph.Runs.Add(new Run(e.MatchNode.Document, "This is a test footnote."));

return ReplaceAction.Replace;



I hope, this helps.

Best regards,


Thanks for the code and your help. It helped in another situation I had to handle.

For the footnote I sticked to the DocumentBuilder solution since the its content is variable and the implemented solution is working fine now (although I may review it at a later time).


Sure, in case you have further inquires or need any help, please let us know.

Best regards,

A post was split to a new topic: How can we change the font size of footnote using Aspose.Words