Hello,
I am having some problems with aspose.words lib, I believe there are some problems there.
I am running 23.6 java aspose.word version.
Attached screen-capture file, I have worked there with same file that is attached. There is one list item and when navigating in different list item levels and I check font size.
Level 0 - has size 11(did not change manually anything here);
Level 1 - has size 18(I have set this size for this level manually);
Level 2 ant all others has size 11(I did nothing here).
But when checking this document with aspose.words libs I get different results. Here is a code sample:
Document d = new Document("test-word-old.docx");
Paragraph p = d.getFirstSection().getBody().getLastParagraph();
assertTrue(p.isListItem());//To check if this really list item
ListLevelCollection listLevels = p.getListFormat().getList().getListLevels();//getting all 9 list levels..
assertTrue(listLevels.get(0).getFont().getSize() == 10.0);//When navigating doc file I see it is 11 size
assertTrue(listLevels.get(1).getFont().getSize() == 18.0);//I set it manually in doc file and can see it set correctly
assertTrue(listLevels.get(2).getFont().getSize() == 10.0);//Navigating doc file I can see it is 11
// My guess that list level styles had no manual change are wrong here and different from that actually is shown in word.
//Here in am getting actual paragraphs content and can see that list level is 0 and font size is 11 and that is correct.
assertTrue(p.getListFormat().getListLevelNumber() == 0);
assertTrue(p.getListFormat().getListLevel().getFont().getSize() == 11.0);
So I believe when checking all ListLevels for list they are not correct or maybe I am missing something?
list-item.zip (1.2 MB)
@ANDREA.FARRIS You get the expected result. If you inspect numbering.xml
inside your document you will see the following:
....
<w:lvl w:ilvl="0" w:tplc="FFFFFFFF">
<w:start w:val="1"/>
<w:numFmt w:val="decimal"/>
<w:lvlText w:val="%1."/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:ind w:left="720" w:hanging="360"/>
</w:pPr>
</w:lvl>
<w:lvl w:ilvl="1" w:tplc="0962383C">
<w:start w:val="1"/>
<w:numFmt w:val="lowerLetter"/>
<w:lvlText w:val="%2."/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:ind w:left="1440" w:hanging="360"/>
</w:pPr>
<w:rPr>
<w:sz w:val="36"/>
<w:szCs w:val="36"/>
</w:rPr>
</w:lvl>
<w:lvl w:ilvl="2" w:tplc="0409001B">
<w:start w:val="1"/>
<w:numFmt w:val="lowerRoman"/>
<w:lvlText w:val="%3."/>
<w:lvlJc w:val="right"/>
<w:pPr>
<w:ind w:left="2160" w:hanging="180"/>
</w:pPr>
</w:lvl>
....
As you can see font size is explicitly set only for the second level:
<w:rPr>
<w:sz w:val="36"/>
<w:szCs w:val="36"/>
</w:rPr>
In other cases font size for list label is inherited from the paragraph break font:
Document d = new Document("C:\\Temp\\in.docx");
Paragraph p = d.getFirstSection().getBody().getLastParagraph();
System.out.println(p.getParagraphBreakFont().getSize()); // Returns 11.
Thank you for the response. I still have one question.
Like you mentioned font size was set explicitly on second level and we can see it in xml and code:
<w:rPr>
<w:sz w:val="36"/>
<w:szCs w:val="36"/>
</w:rPr>
assertTrue(listLevels.get(1).getFont().getSize() == 18.0)
For other levels nothing was done and I can see that in XML this information just missing, but when checking font size for all other levels in code I get that font size is 10
assertTrue(listLevels.get(0).getFont().getSize() == 10.0)
And in this situation in the code I am not sure if this size was set explicitly to 10 or nothing was done and I should use font size inherited from paragraph. How can I know that?
@ANDREA.FARRIS As you have mentioned in your code you can use the following code to get an actual font size applied to list level:
p.getListFormat().getListLevel().getFont().getSize()
Before using the list level with a concrete paragraph, there is no way to determine whether font size of it is applied explicitly or not.