Free Support Forum - aspose.com

font.getHighlightColor() return java.awt.Color[r=0-g=0-b=0] for highlighted run

Hi.


Recently i’ve found following issue:
run.getFont().getHighlightColor() return black for highlighted runs.

Reproduced:
- Aspose.Word.Java.11.6.0;
- Aspose.Word.Java.11.8.0;

Code:
public class T2 {
public static void main(String[] args) throws Exception {
Document d = new Document(“highlight.doc”);

Run r = null;
for (Object o : d.getChildNodes(NodeType.RUN, true)) {
r = (Run) o;
if (r.getText().equals(“Text”))
break;
}

if (r == null) throw new IllegalStateException(“Run not found”);
System.out.println(r.getFont().getHighlightColor());
}
}

Output:
java.awt.Color[r=0,g=0,b=0]

Document highlight.doc attached.
Hi Yohan,

Thanks for your inquiry. The text inside shared document has not highlighted text. The text has shading. Please see the attached image file for detail and read following documentation links for your kind reference.

http://www.aspose.com/docs/display/wordsjava/Shading
http://www.aspose.com/docs/display/wordsjava/Font


Document d = new Document(MYDir + "highlight.doc");

Run r = null;

for (Object o : d.getChildNodes(NodeType.RUN, true)) {

r = (Run) o;

if (r.getText().equals("Text"))

break;

}

if (r == null) throw new IllegalStateException("Run not found");

System.out.println(r.getFont().getHighlightColor());

System.out.println(r.getFont().getShading().getBackgroundPatternColor());

System.out.println(r.getFont().getShading().getForegroundPatternColor());

Hi Tahir.


Thank you for the clarification.

-Dima

Hi Yohan,


Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.