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

Free Support Forum - aspose.com

Set Starting Number for List Level in Word Document using Java | Set Numbering Value

when I checked by code paragraph with text “Return/Destruction of Confidential Information”
like that paragraph.getListFormat().getListLevel().getStartAt(),
I saw value 1, but in ms word 3 http://joxi.ru/ZrJOOYPcw7xjem
Can I get value 3?
test.zip (12.2 KB)

@vhostt,

You can get Paragraph’s List Label string by using the following Java code:

Document doc = new Document("E:\\Temp\\test (25)\\test.docx");
doc.updateListLabels();

for (Paragraph para : (Iterable<Paragraph>) doc.getChildNodes(NodeType.PARAGRAPH, true)) {
    if (para.isListItem()) {
        System.out.println(para.getListLabel().getLabelString());
    }
} 

Hope, this helps.

@awais.hafeez
No, you misunderstood. I see that in the office the startAt value is 3,but in aspose 1 and I don’t understand why.

@vhostt,

We tested the scenario further and have managed to reproduce the same problem on our end. For the sake of any correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-20557. We will further look into the details of this problem and will keep you updated on the status of the linked issue. We apologize for your inconvenience.

A post was split to a new topic: ListLevel.StartAt product inquiry

@vhostt,

Regarding WORDSNET-20557, please note that the StartAt property does not represent the value of the ‘Set numbering value’ menu. The value from the MS Word UI is not the current value, it is the value for the new style. Please take a look at the following picture and links:

Can you please elaborate a bit further what exactly do you actually want to achieve? Is it about list labels or is it about numbering formats? This will help us to understand your requirement and the goal you want to accomplish.

MS Word just shows the current label value and you can change this numbering value. It is not the current startAt value, it is for the new numbering and you can change it. In this case, ‘3’ would be the default value for the new list, not for the existing list.

Thanks for explaining. so why the numbering is correct if 1 and 3 has listId 1, but 2 has 4 http://joxi.ru/5mdNNYPF3BDx0A

@vhostt,

We will check this list numbering scenario further on our end and share our findings with you as soon as possible.

@vhostt,

Regarding WORDSNET-20557, we have completed the work on this issue and concluded to close this issue with “not a bug” status. Please check the following analysis details:

Please take a look on the simplified document.xml of the test document. You will see that second paragraph has w:numId w:val="4" but 1 and 3 have w:numId w:val="1".

<w:p>
    <w:pPr>
        <w:numPr>
            <w:ilvl w:val="0" />
            <w:numId w:val="1" />
        </w:numPr>
        <w:r>
            <w:t>Definitions</w:t>
        </w:r>
</w:p>
<w:p>
    <w:pPr>
        <w:numPr>
            <w:ilvl w:val="0" />
            <w:numId w:val="4" />
        </w:numPr>
    </w:pPr>
    <w:r>
        <w:t>Non-Disclosure and Obligation to Maintain Confidentiality</w:t>
    </w:r>
</w:p>
<w:p>
    <w:pPr>
        <w:numPr>
            <w:ilvl w:val="0" />
            <w:numId w:val="1" />
        </w:numPr>
    </w:pPr>
    <w:r>
        <w:t>Return/Destruction of Confidential Information</w:t>
    </w:r>
</w:p>

You can try to use doc.UpdateListLabels(); method. This method updates list label properties such as ListLabel.LabelValue and ListLabel.LabelString for each Paragraph.ListLabel object in the document. After update you will be able to get correct ListLabel values. Please see the following code:

Document doc = new Document("C:\\Temp\\test.docx");

// Updates list label properties for each Paragraph.ListLabel object in the document.
doc.UpdateListLabels();

foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
{
    if (para.IsListItem)
    {
        Console.WriteLine("StartAt = " + para.ListFormat.ListLevel.StartAt);
        Console.WriteLine("LabelValue = " + para.ListLabel.LabelValue);
        Console.WriteLine("LabelString = " + para.ListLabel.LabelString);
    }
}

The output looks like this:

StartAt = 1
LabelValue = 1
LabelString = 1.

StartAt = 1
LabelValue = 2
LabelString = 2.

StartAt = 1
LabelValue = 3
LabelString = 3.