Insert Caption for Figures and Tables

Hello Support,

I want to create Table of figures for images. In Word one of the way is to use caption and other using styles.
Based on search in documentation my understanding is that aspose do not have insert caption functionality.
Is it possible to have basic working example of how to use styles to create table of figures?

Thanks in advance.

Regards
Mandar

@mandar_limaye

Thanks for your inquiry. Yes, Aspose.Words does not provide option to add caption to Figures and Tables. However, you can iterate through images/tables and add captions programmatically. Please check following sample code snippet hopefully it will help you to accomplish the task.

Document doc = new Document("input.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
NodeCollection Shapes = doc.GetChildNodes(NodeType.Shape, true);
foreach (Shape shape in Shapes)
{

    if (shape.HasImage)
    {
        builder.MoveTo(shape.ParentParagraph);
        builder.Write("Figure: ");
        builder.InsertField(@"SEQ Numlist \r", "");
    }
}