How to remove expand/collapse in Docx using Java

Dear team,

We need to remove expand/collapse option in Docx please provide source code for this

@e503824 please, explain whether you want to hide the expand/collapse mark display to the left of the paragraph beginning?

or you want to enable “Collapse by default” option?

If something else, please, explain in more detail, and attach the screenshot or the expected document created by MS Word.

dear team,

Please refer below attached screenshot and advise how to remove

Screenshot : Capture.JPG (34.9 KB)

@e503824 MS Word has a number of built-in styles (mainly Heading styles) that are displayed in MS Word in a similar way. There is no option responsible for displaying the expand/collapse mark. If you assign the similar style to a paragraph, then MS Word will display the expand/collapse mark on the left.
You can copy this style and disable OutlineLevel option.

Style style = doc.getStyles().addCopy(para.getParagraphFormat().getStyle());
style.getParagraphFormat().setOutlineLevel(OutlineLevel.BODY_TEXT);
para.getParagraphFormat().setStyle(style);

But in this case other issues can appear, for example, with displaying the TOC. This title will not be displayed in the TOC.

Dear team,

I have tried but its not working for me can you please provide code to remove expand/collapse option from source document

@e503824
As I have noted above, there is no option to remove the expand/collapse mark. Please note that Aspose.Words provides functionality limited to a document format, in this case it is Docx. If this feature is not provided by Docx format, Aspose.Words will not be able to implement it.
A paragraph with the outline level other than BODY_TEXT will be displayed in MS Word like this, and the only way to hide this expand/collapse mark is to set the outline level to BODY_TEXT as shown in the code above.
You can also attach a Docx document with the desired formatting here, and we will show you how to implement this using Aspose.Words.