I\'m trying to get the style information from an MS docx file, I have no problem writing file content with added styles like bold, italic. font size etc, but reading the fil
Okay, so based on the comments from Gagravarr, the solution is below, exactly as I wanted. So basically Gagravarr answered the question but I'm not sure how apart from saying it hear to give him credit.
for (XWPFParagraph paragraph : docx.getParagraphs()) {
int pos = 0;
for (XWPFRun run : paragraph.getRuns()) {
System.out.println("Current run IsBold : " + run.isBold());
System.out.println("Current run IsItalic : " + run.isItalic());
for (char c : run.text().toCharArray()) {
System.out.print(c);
pos++;
}
System.out.println();
}
}
`
Output below
Current run IsBold : false
Current run IsItalic : false
"Hello, this is
Current run IsBold : true
Current run IsItalic : false
bold text
Current run IsBold : false
Current run IsItalic : false
and this is
Current run IsBold : false
Current run IsItalic : true
italic text
Current run IsBold : false
Current run IsItalic : false
a
Current run IsBold : false
Current run IsItalic : false
n
Current run IsBold : false
Current run IsItalic : false
d this is
Current run IsBold : true
Current run IsItalic : true
bold-italic text
Current run IsBold : false
Current run IsItalic : false
"