TOF is not working for images of HTML in aspose word

Hi,
We have image with caption in HTML.When it is converted to word document using aspose word 20.6, TOF is not generated.Below is the code snippet used to convert from HTML to aspose word.
try {
String dataDir ="";
HtmlLoadOptions htmloptions = new HtmlLoadOptions(dataDir);
Document doc = new Document(dataDir + “input.html”, htmloptions);
DocumentBuilder builder = new DocumentBuilder(doc);
doc.updateFields();
doc.save(dataDir+“TableOfContents_out.doc”);
} catch (Exception e) {
e.printStackTrace();
}
As workaround we added caption using aspose as below which is working and creating TOF for us, but we are unable to use the caption from HTML, please let us know if any workaround to caption of image in aspose.
try {
String dataDir ="";
HtmlLoadOptions htmloptions = new HtmlLoadOptions(dataDir);
Document doc = new Document(dataDir + “input.html”, htmloptions);

	DocumentBuilder builder = new DocumentBuilder(doc);
	
	builder.insertParagraph();
	builder.write("Table Of Contents ");
	builder.setBold(true);
	builder.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
	builder.insertTableOfContents("\\o \"1-3\" \\h \\z \\u");
	
	builder.insertParagraph();
	builder.write("Table Of Figures ");
	builder.setBold(true);
	builder.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
	builder.insertField("TOC \\a Figure", "");
	
	
	NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);
	for (Shape shape : (Iterable<Shape>) shapes) {
	    if (shape.hasImage()) {
	    	builder.moveTo(shape.getParentNode());
		  	builder.insertParagraph();
	        builder.write("Figure ");
	        builder.insertField("SEQ Figure \\* ARABIC", "");
			
			//Need to add captions from HTML.But not abe to get it in shape object
	        builder.write(" Precautions to corona virus");
	    }
	}	
	doc.updateFields();
	doc.save(dataDir+"TableOfContents_out.doc");
} catch (Exception e) {
	e.printStackTrace();
}

TableOfContents_out.zip (292.5 KB)
input.zip (280.7 KB)

@shripad.hegde

Pease note that Aspose.Words mimics the behavior of MS Word. If you open the HTML in MS Word and insert the table of figure, you will get the same output (no TOF).

You are using the correct workaround to get the desired output.