I have a document containing a list with three levels
I have applied a right indentation for this list.
the word document: Bug.zip (6.5 KB)
Once it is converted to HTML, the right indentation is applied one time for the root level, two times for the second level and three times for the third level and I got a pyramid like structure.
Java code converting the docx file to an HTML:
String dataDir = Utils.getDataDir(ConvertDocumentToHtmlWithRoundtrip.class);
String name = "Bug";
// Load the document.
Document doc = new Document(dataDir + String.format(INPUT, name));
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportListLabels(ExportListLabels.BY_HTML_TAGS);
options.setExportPageMargins(true);
options.setExportPageSetup(true);
doc.save(dataDir + String.format(HTML, name), options);
I have made some analysis, I hope that could help:
The problem is related to differences between OpenXml format and HTML format:
-
For OpenXml: a list is not a nested structure => a sublist is not a child of a list instead they both reference the same list definition.
Each item is a paragraph item <w:p> referencing a list definition and having a level attributes indicating the item level in the list:
A root item is a paragraph referencing a list definition and has 1 as level.
A sub-item is a paragraph referencing the same list definition and has 2 as level, etc.
So there is no inheritance between items from different levels, and if we apply a right indentation for each one it won’t have any cumulative effect -
For HTML it is different, a list is a nested structure, each sub-list is a child of a list and inherits from it. If, for example, we define a right indentation for the root and a right indentation for the child, the final indentation for the child will be the sum of the two indentations.