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

Free Support Forum - aspose.com

Require Some Clarification on Retrieval of Font Size for Some Styles


I need some clarifications on retrieval of font size for following styles: “Heading 1” and “TOC Heading”.

If we load the document and print the font size for styles specified above, we get 14.0 but if we open the document in MS Word UI then font size for these styles come out as 16.0.

I am confused why we are seeing different values for font size with Aspose APIs and MS Word UI.

The code is given below:

public void testHeading1() throws Exception {
Document sample =new Document(“MSBlank.docx”);
if (sample.getStyles().get(“Heading 1”) == null) {
System.out.println(“Heading 1 not present in sample”);
} else {
System.out.println("Style name: "+“Heading 1”);
System.out.println("Font Name: "+sample.getStyles().get(“Heading 1”).getFont().getName());
System.out.println("Font Size: "+sample.getStyles().get(“Heading 1”).getFont().getSize());
if (sample.getStyles().get(“TOC Heading”) == null) {
System.out.println(“TOC Heading not present in sample”);
} else {
System.out.println("Style name: "+“TOC Heading”);
System.out.println("Font Name: "+sample.getStyles().get(“TOC Heading”).getFont().getName());
System.out.println("Font Size: "+sample.getStyles().get(“TOC Heading”).getFont().getSize());


The output is:

Style name: Heading 1
Font Name: Cambria
Font Size: 14.0

Style name: TOC Heading
Font Name: Cambria
Font Size: 14.0

The MS Word UI for both styles is attached as snapshots. If you look into these snapshots, you will observe that font size for both styles is 16.0

The sample document is attached with this post.

Please look into this issue as soon as possible.


Hi Manisha,

Thanks for your inquiry. The problem occurs because there is no text in this document which is formatted with “Heading 1” and “TOC Heading” styles i.e. these two styles are not used in this document. The following code could also not find these styles in document.
for(Style s : doc.getStyles()) {
Moreover, you can verify by unzipping the document and check styles.xml, there is no “Heading 1” or “TOC Heading” style in it. So, Aspose.Words returns default font size which is 14. Hope, this helps.

Best regards,