Not able to recognize headings in a word document



How do we recognize the headings in a word document?
We are trying to convert an RTF document to ASCII.
We are trying to use Aspose Words V 17.6 java version and wanted to recognize headings and add some formatting tags like “\H” or “\N” before and after for those headings.
I am attaching a sample RTF document and the code template we are using to convert from RTF to ASCII for your reference.But with my code ., headings are not getting recognized with the getBold() etc options.
The headings are highlighted in yellow.
Can you help me in recognizing those headings?
Aspose heading (14.0 KB)

Thanks in advance.



Thanks for your inquiry. Please note that formatting is applied on a few different levels. For example, let’s consider formatting of simple text. Text in documents is represented by Run element and a Run can only be a child of a Paragraph. You can apply formatting

  1. to Run nodes by using Character Styles e.g. a Glyph Style.
  2. to the parent of those Run nodes i.e. a Paragraph node (possibly via paragraph Styles).
  3. you can also apply direct formatting to Run nodes by using Run attributes (Font). In this case the Run will inherit formatting of Paragraph Style, a Glyph Style and then direct formatting.

In your document, the heading styles are not applied to Paragraphs or Run nodes. Please use the Run.Font property to get the direct font formatting of Run nodes.


Hi Manzoor,
Thanks for your prompt reply.
I think I am confusing with the formatting part.
The main issue here is ,I just want to know how can we identify the headings highlighted in yellow in my RTF document.Once we are able to identify that part.later we can have the formatting changes done…
Can you please share some code snippet for the same to identify/recognize that heading ., I mean highlighted part in my document.?
Awaiting your response.
Thanks in advance.



Thanks for your inquiry. Please use Run.Font.HighlightColor to get the highlight (marker) color as shown in following code example.

Document doc = new Document(MyDir + "Test aspose.rtf");
for (Run run : (Iterable<Run>) doc.getChildNodes(NodeType.RUN, true))
    if(run.getFont().getBold() == true && run.getFont().getHighlightColor().equals(new java.awt.Color(255, 255, 0)) == true)