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

Free Support Forum - aspose.com

Wrong ListLevel startAt value

Hi,

I’m trying to parse a list in word document with aspose words for java 21.9 and there is an issue with listlevels startAt attribute.
All list levels have startAt attribute set as “1”, even though it is set as “2” in word:
image.png (5.9 KB)

Is this an issue with aspose? Thanks!

Code:

Document doc = new Document(dir + “multilevel.docx”);
// Check all list levels
doc.getFirstSection().getBody().getParagraphs().get(2).getListFormat().getList().getListLevels().get(1).getStartAt();

Doc:
multilevel.docx (15.3 KB)

@mrastenis

You are facing the expected behavior of MS Word. Please unzip your document and check document.xml and numbering.xml. The list start at value is ‘1’. For more detail, please check the attached image.
startAt.png (15.4 KB)

@tahir.manzoor Thank you for reply. I’ve investigated word behavior and have a follow up question.

If I set multilevel list properties to “this point forward” without changing the “start at” attribute, then word creates a new list in the numbering.xml file, but that list extends other list (it has abstractNumId property). In this way, word continues numbering of the previous list.
image.png (35.9 KB)

Is there a way to get this data by using aspose?

Doc example:
stat22.docx (13.6 KB)

@mrastenis There is no way to access abstractNumid using Aspose.Words public API. Could you please explain what you are trying to achieve? What is your expected result? We will check and provide you more information.

I am trying to read a word document and convert it into our project structure.
I’m using “startAt” and “listId” properties to calculate list numbering.

The problem in this case is that the listId is different and all startAt attributes are set to “1”, so there is no way for me to know that this list should start with “2.1.2” and not with “1.1.1”.

@mrastenis If it is enough to get list label, you can use the following code to get List labels of all paragraphs:

Document doc = new Document("C:\\Temp\\in2.docx");
doc.updateListLabels();
Iterable<Paragraph> paras = doc.getChildNodes(NodeType.PARAGRAPH, true);
for (Paragraph para : paras)
{
    if (para.isListItem())
    {
        // This will return the current paragraph list label
        System.out.println(para.getListLabel().getLabelString());
    }
}

Also in 21.9.0 version we have introduced new method ListLevel.getEffectiveValue, which, I think, can be handy to achieve what you need.