Check the style of the paragraph

Dear Team,

I am using java aspose word product. how can we check the current paragraph is bold or not. I want to reject the paragraph which is fully bold and i don’t reject the paragraph which is partially bold.

my code:

       for (Paragraph para : (Iterable<Paragraph>) doc.getChildNodes(NodeType.PARAGRAPH, true))
                             NodeCollection runs = para.getChildNodes(NodeType.RUN, true);
						boolean flagF = false;
						for (Run run : (Iterable<Run>) runs) {
							if (!run.getFont().getBold()) {
								flagF = true;
						} (15.4 KB)

Best regards,


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 Normal style is applied and direct formatting is applied to Run nodes. So, you need to iterate over Run node and check if all nodes are formatted as bold.

If the style applied to text has bold formatting, you can use Paragraph.ParagraphFormat property as shown below.

Document doc = new Document(MyDir + "paramiss.docx");
for (Paragraph para : (Iterable<Paragraph>) doc.getChildNodes(NodeType.PARAGRAPH, true))