When converting a DOCX to HTML the document bullets are saved as paragraphs instead of unordered list elements

Hi,

I have a Word document with document bullets in it. When converting the DOCX to HTML the document bullets are saved as paragraphs (<p>) instead of unordered list elements (<ul>).

Here is the document Bullets.zip (10.8 KB)

The failing test:

@Test
public void testBullets() throws Exception {
	File docxFile = new File("src/test/resources/Bullets.docx");
	InputStream in = new FileInputStream(docxFile);
	Document doc = new Document(in);

	NodeCollection paragraphs = doc.getChildNodes(NodeType.PARAGRAPH, true);
	assertThat(paragraphs.get(2).toString(SaveFormat.HTML), Matchers.containsString("<ul>"));
}

The output of paragraphs.get(2).toString(SaveFormat.HTML) is:

<p style="margin-top:0pt; margin-left:54pt; margin-bottom:0pt; text-indent:-36pt; font-size:10pt">
	<span style="font-family:Arial">•</span>
	<span style="font:7pt 'Times New Roman'">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span>
	<span style="font-family:Arial">Option 1</span>
</p>

Could you please help?

Thank you,
Mihail

@mihail.manoli,

Please use ExportListLabels.BY_HTML_TAGS to get the desired output:

Document doc = new Document("C:\\temp\\Bullets\\Bullets.docx");

com.aspose.words.HtmlSaveOptions htmlSaveOptions = new com.aspose.words.HtmlSaveOptions(SaveFormat.HTML);
htmlSaveOptions.setPrettyFormat(true);
htmlSaveOptions.setExportListLabels(ExportListLabels.BY_HTML_TAGS);

doc.save("C:\\temp\\Bullets\\21.3 BY_HTML_TAGS.html", htmlSaveOptions);

Hi @awais.hafeez,

This is exactly what I was searching for!

Cheers,
Mihail