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

Free Support Forum - aspose.com

NumberingIndent is wrong for a particular list in this doc

The attached doc has 2 lists in it (1 and 1.1) WrongIndent.zip (12.5 KB)

If you open it it at Word, you will see that the numbering is all aligned at 0.
However if you open it in Aspose and print out LeftIndent, FirstLineIndent, and NumberPosition, we get some interesting results for the 1 list.

     Document doc = new Document("WrongIndent.docx");
     var paras = doc.GetChildNodes(NodeType.Paragraph, true);
     foreach (var para in paras)
     {
        Paragraph p = (Paragraph)para;
        Console.WriteLine(p.GetText());
        Console.WriteLine("Left Indent: {0}", p.ParagraphFormat.LeftIndent);
        Console.WriteLine("First Line Indent: {0}", p.ParagraphFormat.FirstLineIndent);
        if (p.IsListItem)
        {
           Console.WriteLine("Number Position: {0}", p.ListFormat.ListLevel.NumberPosition);
        }
     }

Gives me the results:

Definitions and interpretation
Left Indent: 35.4
First Line Indent: -34
Number Position: 22.7

Definitions
Left Indent: 35.45
First Line Indent: -34
Number Position: 0

Interpretation
Left Indent: 34
First Line Indent: -34
Number Position: 0

Priority of Contract documents
Left Indent: 35.4
First Line Indent: -34
Number Position: 22.7

Given the documentation says:

“The ListLevel.NumberPosition property gets or sets the position(in points) of the number or bullet for the list level. NumberPosition corresponds to LeftIndent plus FirstLineIndent of the paragraph.”

For the L1 numbered items (e.g. 1. Definitions and interpretation) the numbers don’t add up: (Left Indent + First Line Indent) != Number Position

@tkbtadmin

Thanks for your inquiry. We have tested the scenario with your shared document and noticed the reported issue. We have logged a ticket WORDSNET-15698 in our issue tracking system for further investigation. We will keep you updated about the issue resolution progress.

Best Regards,

@tkbtadmin

Thanks for your patience. We have investigated the issue and found it is not a bug but expected behavior.

For the L1 numbered items (e.g. 1. Definitions and interpretation) the numbers don’t add up: (Left Indent + First Line Indent) != Number Position

The resulting paragraph inherits properties of the level in the list instance, so you can not compare paragraph and list level indention properties. For example, paragraph with “Definitions and interpretation” content has the following indent parameters on the list level (in the markup):

<w:ind w:left=“680” w:hanging=“226”/>

It corresponds to “34” points of the left indent and “-11.3”points for first line indent. So, client gets “NumberPosition” equals to “22.7” points according the following description in the Aspose.Words for .NET API Reference:

“NumberPosition corresponds to LeftIndent plus FirstLineIndent of the paragraph.”

However, the problematic paragraph also contains directly set left indent and first line indent values which overrides values from the list level. The following values are extracted from the markup:

<w:ind w:left=“708” w:hanging=“680”/>

These values correspond to results which obtained (after conversion from twips to points):

Definitions and interpretation
Left Indent: 35.4
First Line Indent: -34

OK that makes sense - so lets say as a generally rule that if you have a paragraph object, you should calculate the number position by getting the paragraph.LeftIndent + paragraph.FirstLineIndent because it will be the most correct (regardless of whether the values are coming from the list or the overridden paragraph formatting). Obviously if I don’t have a paragraph you use the NumberPosition.

BTW that is not at all clear from the documentation. I assumed, reading that documentation, that it would be using the paragraphs LeftIndent + FirstLineIndent, not going all the way back to the list. Can understand why now I’m told.

@tkbtadmin

Thanks for your feedback and we are sorry for the confusion. However, it is good to know that above explanation helped you to understand the scenario.