When you convert DOCX to HTML, numbering heading in appendix has broken styling

Hi!

If you convert the following DOCX file to HTML, the styling of the heading in the appendix is broken.

Occurs in Aspose Words (Java) v24.2 but not in v22.9.

Sample file:
appendix.docx (14.4 KB)

Below is the expected and actual HTML produced, including screenshots.

Expected:

Actual:

Expected:

<html>
<body>
<div style="line-height:116%; font-family:Aptos; font-size:12pt">
    <div>
        <p style="margin-top:0pt; margin-bottom:8pt">
            <span>Some text</span>
        </p>
        <p style="margin-top:0pt; margin-bottom:8pt">
            <span> </span>
        </p>
        <p style="margin-top:0pt; margin-bottom:22pt; page-break-before:always; page-break-after:avoid; line-height:normal; widows:0; orphans:0; border-bottom:1.5pt solid #000000; padding-bottom:1pt; font-size:16pt">
            <span style="font-family:Arial; font-weight:bold">Appendix A blah blah</span>
        </p>
        <p style="margin-top:6pt; margin-left:28.8pt; margin-bottom:12pt; text-indent:-28.8pt; page-break-after:avoid; line-height:130%; widows:0; orphans:0">
            <span style="font-family:Arial; font-weight:bold">A.1</span>
            <span style="width:10.79pt; font:7pt 'Times New Roman'; display:inline-block">       </span>
            <span style="font-family:Arial; font-weight:bold">Something</span>
        </p>
        <p style="margin-top:0pt; margin-bottom:8pt">
            <span> </span>
        </p>
    </div>
</div>
</body>
</html>

Actual:

<html>
<body>
<div style="line-height:116%; font-family:Aptos; font-size:12pt">
    <div>
        <p style="margin-top:0pt; margin-bottom:8pt">
            <span>Some text</span>
        </p>
        <p style="margin-top:0pt; margin-bottom:8pt">
            <span> </span>
        </p>
        <p style="margin-top:0pt; margin-bottom:22pt; page-break-before:always; page-break-after:avoid; line-height:normal; widows:0; orphans:0; border-bottom:1.5pt solid #000000; padding-bottom:1pt; font-size:16pt">
            <span style="font-family:Arial; font-weight:bold">Appendix A blah blah</span>
        </p>
        <ol type="1" class="awlist1" style="margin:0pt; padding-left:0pt">
            <li style="margin-top:6pt; margin-left:28.8pt; margin-bottom:12pt; text-indent:-28.8pt; page-break-after:avoid; line-height:130%; widows:0; orphans:0; font-family:Arial; font-weight:bold">
                <span style="width:10.79pt; font:7pt 'Times New Roman'; display:inline-block">       </span>
                <span>Something</span>
            </li>
        </ol>
        <p style="margin-top:0pt; margin-bottom:8pt">
            <span> </span>
        </p>
    </div>
</div>
</body>
</html>

@digi0 I cannot reproduce the problem on my side using 24.3 version of Aspose.Words. but you can explicitly specify ExportListLabels.AS_INLINE_TEXT to get the expected output:

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

Thanks for your reply!

I had a look and it seems we are saving the document differently to the example you shared. We are using this save method: public SaveOutputParameters save(OutputStream stream, SaveOptions saveOptions). Then we convert the stream to a byte array and use that to do a HTML conversion and write that to a file. This flow works as expected in v22.9 but breaks in later versions.

Are you able to confirm that the save method I mentioned above also works correctly on v24.3? :slight_smile:

@digi0 Yes, I can confirm saving to stream works as expected. The following code produced exactly the same output as saving directly to a file:

Document doc = new Document("C:\\Temp\\in.docx");
HtmlSaveOptions opt = new HtmlSaveOptions();
opt.setExportListLabels(ExportListLabels.AS_INLINE_TEXT);
opt.setPrettyFormat(true);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
doc.save(outputStream, opt);
Files.write(Paths.get("C:\\Temp\\out.html"), outputStream.toByteArray());

Will see if we can change something on our end to get around this then. Thank you!

1 Like