Is it possible to get style by internal name?


For example, as I have noticed in example:

ArrayList paragraphs = paragraphsByStyleName(doc, "Heading 1");

Is it possible to make the same thing if I have Microsoft Word in another language, in danish, for example?

we can get stlye only by name in Aspose, but I have noticed that they colud be different.
( Heading 1 , Overskrift 1, etc… )

Is it possible to get Heading 1, via internal word name, or number, in order not to be language dependent?

Thank you.

Thanks for your request. I think StyleIdentifier is just what you need:
Best regards,

Hi Alexey,

Thank you! This is what I need.

Hi ,

I have used the following code:

Document doc = new Document("C:\\Working\\Features\\Special_Chart\\" + "TestFile.doc ");
NodeCollection runs = doc.getChildNodes(NodeType.RUN, true);
for( Run run : (Iterable) runs )
    System.out.println(run.getFont().getStyleIdentifier() + " " + run.getText());
    if (run.getFont().getStyleIdentifier() == StyleIdentifier.HEADING_1)

It never enters into if-condition.
You can find test file: TestFile.doc in attachements and result program log in another attachment.

P.S. in general only these styles are detected:

public static final int DEFAULT_PARAGRAPH_FONT = 65;
public static final int INTENSE_EMPHASIS = 261;
public static final int SUBTLE_EMPHASIS = 260;
public static final int EMPHASIS = 88;
public static final int STRONG = 87;
public static final int SUBTLE_REFERENCE = 262;
public static final int INTENSE_REFERENCE = 263;
public static final int BOOK_TITLE = 264;

but I would like to find NORMAL, HEADING_1 and HEADING_2.

Hi Alexander,

Thanks for your inquiry. I think, you can achieve what you need by using the following code snippet:

Document doc = new Document("C:\temp\TestFile.doc");

NodeCollection paragraphs = doc.getChildNodes(NodeType.PARAGRAPH, true);
for (Paragraph para: (Iterable<Paragraph>)paragraphs)
    if (para.getParagraphFormat().getStyleIdentifier() == StyleIdentifier.HEADING_1)

Please let us know if you need more information, We are always glad to help you.

Best Regards,

Hi, awais.hafeez,

thank you for your answer.

Seems like it works for predefiend styles.

Can you look at attached file.

I can get only styles from stlye bar , all of them I have not changed, see attached picture:10-01-12 15-42-42.png
But I don’t want to get them.

How it is possible for me to get exaclty these texts with different colors: Heading1, Heading2, Normal??? see: TestFile2007.docx

Thank you in advance.


Normal text without any problems Heading2

Normal text without any problems Normal


Thanks for your inquiry. May be the following article is what you are looking for:

I hope, this will help.

Best Regards,