SDT Not Getting Created Uniformly

I am creating StructuredDocumentTag using below code:

public StructuredDocumentTag createNewStructureDocumentTag(Document document) {
        StructuredDocumentTag structuredDocumentTag;
        try {
            structuredDocumentTag = new StructuredDocumentTag(document, SdtType.RICH_TEXT, MarkupLevel.BLOCK);
            structuredDocumentTag.removeAllChildren();
            var uuId = UUID.randomUUID().toString();
            structuredDocumentTag.setTitle(uuId);
            structuredDocumentTag.setTag(uuId);
            structuredDocumentTag.isShowingPlaceholderText(false);
        } catch (Exception ex) {
            throw new CustomException(TAG_CREATION_ERROR_MESSAGE.formatted(ex.getMessage()), null);
        }
        return structuredDocumentTag;
    }

And making created SDT as parent of paragraph with below code:

public void makeParaChildOfSDT(Paragraph para, StructuredDocumentTag structuredDocumentTag) {
        var parentNode = para.getParentNode();
        if (Objects.nonNull(parentNode)) {
            try {
                parentNode.insertBefore(structuredDocumentTag, para);
                structuredDocumentTag.appendChild(para);
            } catch (Exception ex) {
                throw new CustomException(SDT_INSERTION_ERROR_MESSAGE.formatted(ex.getMessage()), null);
            }
        }
    }

In the attached document created SDT in not uniform in viewer:
In some case SDT covers the list label and in some case it does not.
Attaching the sceenshot for same for both the case. Please let me know the reason behind same.

Test SDT.docx (13.7 KB)
SDT having label:

SDT not having label:

@SATISHSATYAEESH

It sounds like you’re experiencing inconsistent behavior with the Structured Document Tags (SDTs) in your document, particularly regarding their appearance in relation to list labels. This issue can arise from various factors, such as the positioning of the SDT or the specific styles applied to the paragraphs and list items.

Cause: The inconsistency may stem from differences in paragraph styles or the way SDTs are positioned relative to list items.

Solution: Here are several steps you can take to troubleshoot and resolve the issue:

  1. Check Paragraph Styles: Ensure that the paragraph styles applied to the SDT and the list items are consistent. Differences in styles can lead to variations in how the SDT is rendered.

  2. Adjust SDT Positioning: When inserting the SDT, consider its placement relative to the list items. Experiment with different insertion points to see if that affects the overlap.

  3. Use Inline SDTs: If you’re currently using block-level SDTs, switch to inline SDTs. This can help with positioning issues, especially in relation to other inline elements like list labels.

  4. Review SDT Properties: Verify that properties such as isShowingPlaceholderText and style are set appropriately for your use case, as these can affect the SDT’s display.

  5. Test with Simplified Content: Create a simplified version of your document with just a few paragraphs and list items to see if the issue persists. This can help isolate the problem.

Next Steps: If you continue to face issues after trying these steps, please share more details about the specific styles and settings you are using. This information will allow me to provide more targeted assistance.

I hope this helps resolve your issue!

@SATISHSATYAEESH All paragraphs are wrapped to SDT correctly. This is how MS Word shows SDTs. If there is only one line MS Word shows list label outside SDT. If there are more than one line, list label is shown inside SDT.
Aspose.Words cannot control this behavior of MS Word.