How to format OL tags to convert HTML to Docx file to get words default list functionality

We are building content in HTML and looking use Aspose to convert them to word and pdf format. The documentation I’m finding on you site for this process seems pretty scant and all I’ve found have an archived note on it. Really I’m trying to use OL lists and format them in a manner that the numbers are left aligned and the text wraps under the first line not under the number. Using list postion outside on the HTML side lines the text up as desired, while using the inside postion has the numbers left aligned like I want. Doing lists in word the default functionality is numbers lefts aligned and it properly wraps the text to stay inline with the first line of text.

I’m more concerned with getting the output on the word side of things, but ideally I’d like them to visually match as much as possible. So any assistance you can give that would allow for that would be appreciated.

Basically looking to get this in my output.

@AurinBlackstaff to be able to provide a better assistance, can you post the input file, the current output and the expected output and the code that you are using to make the conversion?

@AurinBlackstaff You can use the following HTML syntax:

<ol type="1" style="margin:0pt; padding-left:0pt">
	<li style="margin-left:31.35pt; padding-left:4.65pt">
		<span>Test</span>
	</li>
	<li style="margin-left:31.35pt; padding-left:4.65pt">
		<span>Test</span>
		<ol type="a" style="margin-right:0pt; margin-left:0pt; padding-left:0pt">
			<li style="margin-left:31.05pt; padding-left:4.95pt">
				<span>Test</span>
			</li>
			<li style="margin-left:31.56pt; padding-left:4.44pt">
				<span>Test</span><br /><span>test</span>
				<ol type="i" style="margin-right:0pt; margin-left:0pt; padding-left:0pt">
					<li style="margin-left:32pt; padding-left:4pt">
						<span>Test</span>
					</li>
					<li style="margin-left:32pt; padding-left:4pt">
						<span>Test </span>
					</li>
				</ol>
			</li>
		</ol>
	</li>
	<li style="margin-left:31.35pt; padding-left:4.65pt">
		<span>Test</span>
	</li>
	<li style="margin-left:31.35pt; margin-bottom:8pt; padding-left:4.65pt">
		<span>Test</span><br /><span>test</span>
	</li>
</ol>

Basically, you Aspose.Words supports formatting roundtrip from MS Word document to HTML and vice versa. So you can create a document with required formatting in MS Word, save it as HTML using Aspose.Words to see what HTML is expected by Aspose.Words as input:

Document doc = new Document("C:\\Temp\\in.docx");
HtmlSaveOptions opt = new HtmlSaveOptions();
opt.setPrettyFormat(true);
opt.setExportListLabels(ExportListLabels.BY_HTML_TAGS);
doc.save("C:\\Temp\\out.html", opt);

Thank you. I really appreciate this definitely close to what I’m looking for and hopefully going the save as html route will get me what I need. I’ll let you know if I run into anything weird/not working, but give me a great starting point.

1 Like