When creating a new List, we must add a parameter, in order to specify which ListTemplate is used to create a List. I would like to do the reverse operation : from an existing List, to get the ListTemplate it uses.
If such an operation is not possible, how can I do to obtain for each level of the list the bullet used ?
A list in a MS Word document is a set of list formatting properties. The formatting of the lists is stored in the ListCollection separately from the paragraphs of text. You can use DocumentBase.getLists property to access the list formatting used in the document.
Please use the following code snippet to get the existing list in the document and set it for some other paragraphs. I have attached the input and output documents with this post.
Document doc = new Document(MyDir + "Test37.docx");
// Get First Paragraph
Paragraph para = (Paragraph)doc.getChild(NodeType.PARAGRAPH, 0, true);
DocumentBuilder builder = new DocumentBuilder(doc);
builder.moveToDocumentEnd();
builder.writeln("");
builder.writeln("");
if (para.isListItem())
{
builder.getListFormat().setList(para.getListFormat().getList());
for (int i = 0; i < 9; i++)
{
builder.writeln("List Item " + i);
}
}
doc.save(MyDir + "AsposeOut.docx");
Please let us know if you need more information, we are always glad to help you.
Thanks for your answer but I still don’t understand how to get the ListTemplate constant when reading a document.
For example, let’ s say I have a document with ListTemplate.NUMBER_ARABIC_DOT list. When parsing this document with Aspose Word I would like to retrieve this information.
Is there some way to do that for example something like :
ListTemplate listTemplate = doc.getLists().get(0).getListTemplate();
or
ListTemplate listTemplate = doc.getLists().get(0).getListLevels().get(0).getListTemplate();
Thanks for your inquiry. Unfortunately, Aspose.Words does not support the requested feature at the moment. However, I have logged this feature request as WORDSNET-7562 in our issue tracking system. You will be notified via this forum thread once this feature is available.
Thanks for your inquiry. Currently, this feature is pending for analysis and is in the queue. I am afraid, I cannot provide you any reliable estimate at the moment. Once this feature is analyzed, we will then be able to provide you an estimate.