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

Free Support Forum - aspose.com

List indenting and text in the lists but not numbered

1. Title

a. Sub Title

Block of text under 1.a

b. Another title

2. Blaa Blaa

This is a very simple example of what I would like to do with aspose. I am sure aspose can do this, I can't seem to figure out how to insert the green highlighted block of text "Block of text under 1.a" at the correct indent. It either gets a list number ... or isn't indented correctly.. could you give me a simple piece of code that can produce the above example?

Bryan Grossman

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

Thanks for your inquiry. I think that you can use the following code:

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

//Start list

builder.ListFormat.ApplyNumberDefault();

builder.Writeln("this is 1 item");

builder.ListFormat.ListIndent();

builder.Write("this is 1.a item");

//Use linebreak instead paragraph break in the list

//Is you insert paragraph break you will get new list item

builder.InsertBreak(BreakType.LineBreak);

builder.Write("some text under 1.a item");

//Insert Paragraph break

//You can also use Writeln method instead Write in the previouse code line

builder.Writeln();

//Insert 1.b item

builder.Writeln("this is 1.b item");

//Outdent list level

builder.ListFormat.ListOutdent();

//Insert 2item

builder.Writeln("this is 2 item");

//End list

builder.ListFormat.RemoveNumbers();

//Save document

doc.Save(@"Test278\out.doc");

You can also configure your list using ListFormat and ListLevel properties. Please see the following link for more information.

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/aspose.words.listformat.html

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/aspose.words.listformat.listlevel.html

Hope this helps.

Best regards.

Thank you for this code it was exactly what I needed. But now I seem to have run into another problem. I would like to use InsertHtml and have the html insert at the indent level like the “builder.write” command would do for text, but for html. When I insert any html with

tags the html breaks out of the list formatting. But if the html has simple text then it works… Is there any way after I insert the html I can grab that last paragraph and tell it to belong to the list… but not numbered and just indented at the list level….? I hope that made sense…

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

Thanks for your inquiry. Please check the following link

I think that it could be useful for you.

Best regards.