Issue while extracting content control html from word document

Hi Team,

I am facing issue while extracting content control html text from document. The list numbers are getting overlapped with the text in the generated output. There should be spacing between text and list numbers.

Attaching the code :

public static void main(String[] args) throws Exception {

    com.aspose.words.License license = new com.aspose.words.License();
    license.setLicense("/home/saurabharora/Downloads/Aspose.Total.Product.Family.lic");
    com.aspose.words.Document document = new com.aspose.words.Document("/home/saurabharora/Downloads/Framework Sourcing Agreement (7).docx");

    for (Object st : document.getChildNodes(NodeType.STRUCTURED_DOCUMENT_TAG, true)) {
        StructuredDocumentTag std = (StructuredDocumentTag) st;
        if ((std.getSdtType() == SdtType.RICH_TEXT) && std.getTag().equals("BASIC__1003__75926__138__138")) {
            HtmlSaveOptions opts = new HtmlSaveOptions(SaveFormat.HTML);
            opts.setHtmlVersion(HtmlVersion.HTML_5);
            opts.setExportImagesAsBase64(true);
            opts.setExportPageMargins(true);
            opts.setExportListLabels(ExportListLabels.BY_HTML_TAGS);
            opts.setExportFontsAsBase64(true);
            opts.setExportTocPageNumbers(true);
            opts.setExportShapesAsSvg(true);
            System.out.println(std.toString(opts));
        }
    }
}

Also Attaching the html output received.

<div style="-aw-sdt-tag:'BASIC__1003__75926__138__138'; -aw-sdt-title:'Term of Agreement'"><ol start="3" class="awlist1" style="margin:0pt; padding-left:0pt"><li style="margin-top:12pt; margin-left:28.1pt; margin-bottom:12pt; text-indent:-28.1pt; font-family:Delivery; font-size:11pt; -aw-list-padding-sml:17.6pt"><span style="width:17.6pt; font:7pt 'Times New Roman'; display:inline-block; -aw-import:ignore">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span><span style="font-weight:bold">TERM OF THIS AGREEMENT</span></li></ol><p style="margin-top:0pt; margin-left:28.1pt; margin-bottom:6pt; text-align:justify; font-size:11pt"><span style="font-family:Delivery">This Agreement shall enter into force on </span><span style="-aw-sdt-content:placeholder; -aw-sdt-tag:'BASIC__1003__25835__206__206'; -aw-sdt-title:'Effective Date'"><span style="font-family:Delivery; background-color:#c0c0c0">16.08.2024</span></span><span style="font-family:Delivery"> (the, </span><span style="font-family:Delivery; font-weight:bold">“Effective Date”</span><span style="font-family:Delivery">) and remain in force for an indefinite period. This Agreement may be terminated by either party with a written notice period of three (3) months at the end of a calendar month, and at the earliest on </span><span style="-aw-sdt-content:placeholder; -aw-sdt-tag:'BASIC__1003__66375__206__206'; -aw-sdt-title:'Earliest Termination Date'"><span style="font-family:Delivery; background-color:#c0c0c0">07.09.2024</span></span><span style="font-family:Delivery">.</span></p></div>

Attaching the document :

aspose-issue-22Aug.zip (1.1 MB)

Please check and suggest.

Thanks

@ashu_agrawal_sirionlabs_com Please try outputting list labels as inline text:

opts.setExportListLabels(ExportListLabels.AS_INLINE_TEXT);

In this case layout is closer to the original document.

This option will work in all documents or we need to set this according to some condition?

@ashu_agrawal_sirionlabs_com The option should work in all cases. When ExportListLabels.AS_INLINE_TEXT is used list labels are emulated with simple text. So the output should look correct in all cases.