Aspose word save table as svg when converting word to html

ばんのうネギ134号.docx (136.3 KB)

the 2 tables in word is saved as svg or img when save word as html using aspose word

How can I make it a <table> in html output ?

@ygi This is an expected behavior because tables in your source document are in shapes. In such case Aspose.Words renders the shapes and exports them either as an image or as SVG. To export table as <table> to HTML, the table must be in the main document body.

Can I preprocess that doc To make the Table in the docx to be a table in output html?

Because we are putting plain text to the context of large language model, in this case the image/svg output for a table does not fit.

@ygi You can programmatically move the table outside the shape, but this might lead to difference in the output document layout:

Document doc = new Document(@"C:\Temp\in.docx");

foreach (Shape s in doc.GetChildNodes(NodeType.Shape, true))
{
    if (s.GetChildNodes(NodeType.Table, false).Count > 0 && s.IsTopLevel)
    {
        while (s.HasChildNodes)
        {
            s.ParentParagraph.ParentNode.InsertAfter(s.LastChild, s.ParentParagraph);
        }
        s.Remove();
    }
}

doc.Save(@"C:\Temp\out.html");

much thanks, I will try this

1 Like