Stop list indentation on particular point

Hi,

I want to stop indentation at some specific points. (not to completely remove it.) Like when i inert through builder.insertHTML , i want to stop indentation. Like for example , i have the following code -

builder.getListFormat().setList(document.getLists().add(ListTemplate.NUMBER_DEFAULT));

builder.writeln(“ABCD”);

builder.getListFormat().listIndent();

builder.writeln(“CDEF”);

builder.insertHtml(“

Always test your software with a “worst-case\n” +
" scenario” amount of sample data, to get an accurate sense of\n" +
" its performance in the real world",true);

builder.getListFormat().removeNumbers();

My output is -

  1. ABCD
    a. CDEF
    b. Always test your software with a “worst-case scenario” amount of sample data, to get an accurate sense of its performance in the real world

but i want output as -

  1. ABCD
    a. CDEF
    Always test your software with a “worst-case scenario” amount of sample data, to get an accurate sense of its performance in the real world

How can i stop indentation on insertHTML , please help.

@saurabh.arora

Thanks for your inquiry. We have tested the scenario with Aspose.Words for Java 17.9 and we are unable to notice your reported issue. However, if you want to add some custom indentation to HTML text, then you can set ParagarphFormat property accordingly. Please try following code snippet with latest version of Aspose.Words for Java, it will resolve the issue.

com.aspose.words.Document doc = new com.aspose.words.Document();
DocumentBuilder builder= new DocumentBuilder(doc);
builder.getListFormat().setList(doc.getLists().add(ListTemplate.NUMBER_DEFAULT));
builder.writeln("ABCD");
builder.getListFormat().listIndent();
builder.writeln("CDEF");
builder.getParagraphFormat().setLeftIndent(20);
builder.insertHtml("Always test your software with a “worst-case\n" +" scenario amount of sample data, to get an accurate sense of\n" +" its performance in the real world",true);
builder.getListFormat().removeNumbers();
doc.save("E:/Data/List_Indent.docx");