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

Free Support Forum - aspose.com

Add Custom Styles (-aw-footnote-startnumber) in HTML to Transform Content into Real Footnotes in Word Document using C#

Hello Aspose Team.

I have a little issue with the footnote’s in Aspose.Words.

When I work with a document where footnote’s are not working properly, when I click on the reference it just redirecting to the current page footer.Its not properly pointing to the exact location where the footnote is defined


Please ZIP and upload your simplified input Word document, Aspose.Words generated DOCX file showing the undesired behavior and piece of source code here for testing. We will then investigate the issue on our end and provide you more information.

Downloads.zip (11.3 KB)

Hi @awais.hafeez
Please find the attached zip file contains source code and word document for the reference


I am afraid, we are unable to run the code you provided. Also, please provide the template “TestTemplate.docx” document here for further testing. Please also provide a standalone simple and runnable Console Application (source code without compilation errors) that helps us to reproduce your current problem on our end. We will then investigate the issue further on our end and provide you more information. Thanks for your cooperation.

1 Like

not sure if this helps anything but out of curiosity i tried to unzip it myself and i wasn’t able to run that code either… hopefully you would find the issue anyway. i also had some issues with my https://delicerecipes.com/


I am afraid, as requested earlier in my this post, we need template document and a console application to be able to reproduce the exact problem on our end. For example, in the code you shared, HandleMergeFieldInsertHtml class definition was missing and there were other compile time errors.

z AsposeWord.zip (17.9 KB)

Hi @awais.hafee,
PFA Working codes and template.
We are copying the data from word document to a kendoeditor, from there it is saved to database and then using aspose we are creating the word document from the db data.
Data for FootNote from database : “[1] Test1”

After converting to the word document by aspose the source code of footnotes is changing to :"

[1] Test1

This not the desired behaviour

In my sample code data is hard coded instead of fetching from database


We are working on your query and will get back to you soon.

@awais.hafeez Hi, Is there any update on this?


Please see these sample HTML and DOCX files:

You will see the following code is able to properly transform such ‘HTML content’ into a proper Footnote in Word document:

Document doc = new Document("E:\\Temp\\HTML with Footnote.html");

Hope, this helps in achieving what you are looking for.

Hi @awais.hafeez

Is there any C# code change required for achieving this?


My previous post mentions the standard way of transforming ‘HTML content’ into a proper Footnote in Word document. However, please also provide your expected DOCX document showing the desired output here for our reference. You can create this document by using MS Word. We will then analyze the required code changes and provide you more information.

Please find attached zip file contains Expected output doc file and OutPut doc file from the aspose console applicationDownloads.zip (43.1 KB)


Please see these sample HTML, Template and resultant DOCX files:

And try running the following simplified C# code:

Document doc = new Document("E:\\Temp\\Downloads\\TestTemplate.docx");

var documentName = "Sample Title";
string BackgroundDiscussion = File.ReadAllText("E:\\Temp\\Downloads\\html with footnotes.html");

doc.MailMerge.FieldMergingCallback = new HandleMergeFieldInsertHtml();
doc.MailMerge.Execute(new string[] { "Title", "BackgroundDiscussion" },
                        new object[] { documentName, BackgroundDiscussion });


public class HandleMergeFieldInsertHtml : IFieldMergingCallback
    void IFieldMergingCallback.FieldMerging(FieldMergingArgs args)
        if (args.FieldName.Equals("BackgroundDiscussion"))
            DocumentBuilder builder = new DocumentBuilder(args.Document);


        if (args.FieldName.Equals("Title"))
            DocumentBuilder builder = new DocumentBuilder(args.Document);

            builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;

        args.Text = "";

    void IFieldMergingCallback.ImageFieldMerging(ImageFieldMergingArgs args)
        // Do nothing.

Hope, this helps.

Hi @awais.hafeez,
Code working as expected ,I need a clarification on the html styles you applied.
Whether this styles automatically be applied when we paste the content from word document into the kendo editor,but its not happening in my case.

Whether these styles(-aw-import:ignore,-aw-footnote-numberstyle,-aw-footnote-isauto) are
in-build property of aspose.
Should I apply these styles in my code?Is there any aspose code required to apply these styles to the html


Yes, the following custom styles are required in HTML so that Aspose.Words can properly read this information from HTML and turn such HTML markup into proper Footnotes in Word document:

  • -aw-import:ignore
  • -aw-footnote-numberstyle
  • -aw-footnote-startnumber
  • -aw-footnote-type
  • -aw-footnote-isauto


When you set HtmlSaveOptions.ExportRoundtripInformation option to ‘true’, Aspose.Words will export such custom “-aw-*” CSS properties in HTML as part of round-trip information.