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

Free Support Forum - aspose.com

Create number and bullet list when TXT is imported into DOM using NET

I would like to create a lists automatically similar MS Word behaviour.
When I put in Word:

1. Some text.

and press Enter, then Word automatically creates list item and show as:

 {indent} 1. {tab char} Some text.

(note - {indent} and {tab char} are added by Word automatically)

When I put in Word:

Some text

it shows as paragraph.

My question is - is there feature in Aspose.Words API that allows to create list automatically when I put text by:
builder.writeln(“1. Some text.”);

Or automatically convert paragraph into list in case if paragraphs starts with '- ', '1. ', 'a. ’ etc?

@dyuzhev

We suggest you please read the following article about working with lists.
Working with Lists

Could you please share some more detail why you need to insert text like this and insert line break to create the list? We will then provide you more information about your query.

thank you for the answer.

I have a file with a plain text, like this:

Some text.
Some text.
Some text.
1. Some text.
2. Some text.
3. Some text.
Some text.
Some text.
- Some text.
- Some text.

I read it in Java line by line and put each line into a new Document by builder.writeln(line);.
In resulted Word file I would like to get an indents for lists 1. 2. 3. and - lists and they should be real lists for further adding a new list items in editing by Word. At this moment I need to select each list in Word and set list format manually (or press Enter at the end of line of each list item as I wrote above). I would like to do this automatically at the document creation stage by Aspose API.

@dyuzhev

Instead of reading text line by line, we suggest you please import the .txt file into Aspose.Words’ DOM. Please check the following code example.

Document doc = new Document(MyDir + "in.txt");
doc.Save(MyDir + "out.docx"); 

You will get the list item in output document. Please read the following article to work with text document.
Working with Text Document