Free Support Forum - aspose.com

Prblem in creating list levels

Hi Aspose team,

I am creating a list like,

1)Section

1.1) Clause

some text in clause

Follwing code snippet works fine Word 2003 but not in Word 2007

In word 2007 indenting is not proper

builder.getListFormat().applyNumberDefault();

builder.getListFormat().listOutdent();
builder.getListFormat().setList(doc.getLists().get(0));
builder.getListFormat().getList().getListLevels().get(0).setNumberStyle(NumberStyle.ARABIC);
builder.getListFormat().getList().getListLevels().get(0).setNumberFormat("\u0000)");

builder.getListFormat().listIndent();
builder.getListFormat().setList(doc.getLists().get(0));
builder.getListFormat().getList().getListLevels().get(1).setNumberStyle(NumberStyle.ARABIC);
builder.getListFormat().getList().getListLevels().get(1).setNumberFormat("\u0000.\u0001)");

Please reply..

Thanks In Advance

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. I used the following code to create the same list and all works fine on my side:

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

// Create a list.

List list = doc.getLists().add(ListTemplate.NUMBER_ARABIC_DOT);

// Modify list if required.

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

list.getListLevels().get(0).setNumberFormat("\u0000)");

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

list.getListLevels().get(1).setNumberFormat("\u0000.\u0001)");

// Create few items.

builder.getListFormat().setList(list);

builder.writeln("This is the first level");

builder.getListFormat().listIndent();

builder.writeln("This is the second level");

builder.getListFormat().listOutdent();

builder.writeln("This is the first level again");

// Stop buildign the list.

builder.getListFormat().removeNumbers();

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

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

Hope this helps.

Best regards,

Thanks for reply!!!

i tried your code snippet on my side ,still getting same problem.

attaching a word file...

Please suggest

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Maybe you should just configure Tab, Text and Number positions. See the following code:

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

// Create a list.

List list = doc.getLists().add(ListTemplate.NUMBER_ARABIC_DOT);

// Modify list if required.

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

list.getListLevels().get(0).setNumberFormat("\u0000)");

list.getListLevels().get(0).setNumberPosition(0);

list.getListLevels().get(0).setTextPosition(20);

list.getListLevels().get(0).setTabPosition(20);

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

list.getListLevels().get(1).setNumberFormat("\u0000.\u0001)");

list.getListLevels().get(1).setNumberPosition(20);

list.getListLevels().get(1).setTextPosition(50);

list.getListLevels().get(1).setTabPosition(50);

// Create few items.

builder.getListFormat().setList(list);

builder.writeln("This is the first level");

builder.getListFormat().listIndent();

builder.writeln("This is the second level");

builder.getListFormat().listOutdent();

builder.writeln("This is the first level again");

// Stop buildign the list.

builder.getListFormat().removeNumbers();

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

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

Hope this helps.

Best regards.