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

Free Support Forum - aspose.com

Creating New List

Hi,

I am using Aspose words for java. I want to create a list with three levels having different NumberingStyle(level0 as bullet, level1 as numbering and level2 as lowercase letter).
how to do that using Aspose API?. The list should look like the list in the document attached.

Hi

Thanks for your request. Please see the following link to learn how to create and customize lists.

http://www.aspose.com/documentation/java-components/aspose.words-for-java/com/aspose/words/listlevel.html#NumberFormat

Also, please see the following code:

// Create new document and Documentbuilder.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

// Create new list and configure the first 3 levels of the list.

com.aspose.words.List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT);

// Configure the first level.

list.getListLevels().get(0).getFont().setName("Symbol");

list.getListLevels().get(0).setNumberStyle(NumberStyle.BULLET);

list.getListLevels().get(0).setNumberFormat("\u00B7"); // This is a bullet.

// Configure the second level.

list.getListLevels().get(1).setNumberStyle(NumberStyle.ARABIC);

list.getListLevels().get(1).setNumberFormat("\u0001."); // This is a number of the second level.

// Configure the third level.

list.getListLevels().get(2).setNumberStyle(NumberStyle.LOWERCASE_LETTER);

list.getListLevels().get(2).setNumberFormat("\u0002."); // This is a number of the third level.

// insert content into the document using DocumentBuilder.

builder.getListFormat().setList(list);

builder.writeln("test");

builder.writeln("test");

// Move to the next level.

builder.getListFormat().listIndent();

builder.writeln("test");

builder.writeln("test");

// Move to the next level.

builder.getListFormat().listIndent();

builder.writeln("test");

builder.writeln("test");

// Move to the previous level.

builder.getListFormat().listOutdent();

builder.writeln("test");

builder.writeln("test");

// Move to the previous level.

builder.getListFormat().listOutdent();

builder.writeln("test");

builder.writeln("test");

// Save output.

doc.save("C:\\Temp\\out.docx");

Hope this helps.

Best regards,