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

Free Support Forum - aspose.com

Issue with list format

Hi,



i’m trying to implement a certain list-format:



(1) dobedooo

(a) dobedoo dam dam

____(i) damdam doobeee

(b) damdam





( i added the “_” for showing the indents )



well and that’s my code for that:



[…]



// Create a list based on a template.



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



// Completely customize one list level.

ListLevel level1 = list.getListLevels().get(0);

level1.setStartAt(1);

level1.setNumberFormat("(\u0000)");

level1.setAlignment(0);

level1.setNumberPosition(0);



// Completely customize one list level.

ListLevel level2 = list.getListLevels().get(1);

level2.setNumberStyle(NumberStyle.LOWERCASE_LETTER);

level2.setStartAt(1);

level2.setNumberFormat("(\u0000)");

level2.setAlignment(0);





// Completely customize one list level.

ListLevel level3 = list.getListLevels().get(2);

level3.setNumberStyle(NumberStyle.LOWERCASE_ROMAN);

level3.setStartAt(1);

level3.setNumberFormat("(\u0000)");

level3.setAlignment(0);







builder.getListFormat().setListLevelNumber(0);

builder.getListFormat().setList(list);

builder.writeln(“dobedoo”);

builder.getListFormat().setListLevelNumber(1);

builder.writeln(“dobedoo dam dam”);

builder.getListFormat().setListLevelNumber(2);

builder.writeln(“damdam dobedoo”);

builder.getListFormat().setListLevelNumber(1);

builder.writeln(“damdam”);

builder.getListFormat().setListLevelNumber(0);

builder.write( “…”);

builder.getListFormat().removeNumbers();

[…]





the result is attached!

what am I doing wrong here ?



thanks and best regards.



christian

Hi

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

Thanks for your request. I modified your code. I highlighted places where you made a mistake.

// Create docuemnt and DocumentBuilder.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

// Create a list based on a template.

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

// Completely customize one list level.

ListLevel level1 = list.getListLevels().get(0);

level1.setStartAt(1);

level1.setNumberFormat("(\u0000)");

level1.setAlignment(0);

level1.setNumberPosition(0);

// Completely customize one list level.

ListLevel level2 = list.getListLevels().get(1);

level2.setNumberStyle(NumberStyle.LOWERCASE_LETTER);

level2.setStartAt(1);

level2.setNumberFormat("(\u0001)");

level2.setAlignment(0);

// Completely customize one list level.

ListLevel level3 = list.getListLevels().get(2);

level3.setNumberStyle(NumberStyle.LOWERCASE_ROMAN);

level3.setStartAt(1);

level3.setNumberFormat("(\u0002)");

level3.setAlignment(0);

builder.getListFormat().setListLevelNumber(0);

builder.getListFormat().setList(list);

builder.writeln("dobedoo");

builder.getListFormat().setListLevelNumber(1);

builder.writeln("dobedoo dam dam");

builder.getListFormat().setListLevelNumber(2);

builder.writeln("damdam dobedoo");

builder.getListFormat().setListLevelNumber(1);

builder.writeln("damdam");

builder.getListFormat().setListLevelNumber(0);

builder.write("...");

builder.getListFormat().removeNumbers();

// Save result.

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

Hope this helps.

Best regards.

Hi Alexey,

thanks a lot - that’s it ! I just found that one sample in the documentation with the setNumberFormat() thing and didn’t recognize that this is dependet on the listlevel !



Best regards,

Christian

Hi Christian,

We will look into making that clearer in the documentation in the future. Thank you for bringing that to our attention.

Thanks,