I have a list of nodes (List<Node> nodes), and I want to convert it to html.
We have below code to create new Document (tempDoc) with these nodes and then we convert (tempDoc) to html.
Document tempDoc = new Document();
foreach (Node node in nodes)
{
NodeImporter importer = new NodeImporter(node.Document, temp,
ImportFormatMode.KeepSourceFormatting);
tempDoc.FirstSection.Body.AppendChild(importer.ImportNode(node, true));
}
With this html is getting created correctly except List.
For List we are facing an issue.
We have Word Document like this -
image.png (10.6 KB)
Document has 2 lists, if we convert this document directly to html, it converts to html correctly, having 2 <ol>.
But when we have list of nodes and we try to convert it to html by creating new Document - it is creating 3 <ol>. and hence numbering is getting messed up as below.
image.png (12.3 KB)
For more info, I have attached Word Document, html_directly_converted, html by creating new document from list of nodes.
While debugging I found, when we append node (isListItem: true) to temporary document, it creates a new List in temp document as I see ListId is different, may be it is causing an issue.
Am I missing something to append nodes into new Document ?
Is there a way to copy complete List to new Document including List Item nodes ?
Is there a way to convert list of nodes directly to html, without creating new temporary document, as it is causing issue ?
We can not convert the source document completely to html, as we have other processing, from there we are getting list of nodes and we just want to convert those nodes.
IR10010707.zip (19.3 KB)