We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Stop indentation at some specific point in document

Hi,

I want to stop indentation at some specific points. (not to completely remove it.)

Like i want this

ABCD
a. CDEF // Where this and below can have different alignment (this could be centre and below could be justified) 
    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
b. XYZ//// Where this and below can have different alignment (this could be centre and below could be justified) 
    Default text is here

I wrote the code for this use case , but i am not able to get different alignment for "a. CDEF " and line below it. They always have the same alignment. (may be because they are in same paragraph).

Please help.

@saurabh.arora

Thanks for your inquiry. Please check following sample code snippet for your requirement. Hopefully it will help you to accomplish the task.

com.aspose.words.Document doc = new com.aspose.words.Document();
DocumentBuilder builder= new DocumentBuilder(doc);
com.aspose.words.List list=doc.getLists().add(ListTemplate.NUMBER_LOWERCASE_LETTER_DOT);
builder.writeln("ABCD");
builder.getListFormat().setList(list);
builder.getParagraphFormat().setLeftIndent(20);
builder.writeln("CDEF");
builder.getListFormat().removeNumbers();
builder.getParagraphFormat().setLeftIndent(35);
builder.writeln("Test text ");
builder.getParagraphFormat().clearFormatting();
builder.getListFormat().setList(list);
builder.getParagraphFormat().setLeftIndent(20);
builder.writeln("XYZ");
builder.getListFormat().removeNumbers();
doc.save("List_Indent.docx");