vjlaker
October 25, 2010, 11:02am
1
I’m using Aspose.words version 3.3 and I have word document that has highlighted text and I’m trying to grab the run property. I’m having trouble trying to grab it with this method.
run.getRunPr()
Can someone show me how to use this method or another way to grab the propery the xml of the word document is below.
<w:r w:rsidRPr="006C2375">
<w:rPr>
<w:highlight w:val="red"/>
</w:rPr>
<w:t>which</w:t>
</w:r>
AndreyN
October 25, 2010, 11:19am
2
Hi
Thanks for your inquiry. In your case, you should use Font.HightlightColor:
https://reference.aspose.com/words/java/com.aspose.words/font/#setHighlightColor-java.awt.Color
Hope this helps.
Best regards,
vjlaker
October 25, 2010, 12:54pm
3
AndreyN,
I want to use Font.HighlightColor to grab the color but is there a way to only grab the color if it’s highlighted.
Hi
Thanks for your inquiry. I think in this case you can try using the following code:
if (!run.getFont().getHighlightColor().equals(new Color(0, 0, 0, 0)))
System.out.println(run.getFont().getHighlightColor());
Best regards,
vjlaker
October 26, 2010, 11:12am
5
AndreyN,
if I create a java color object from Font.getColor()
method and that color object contains these values
java.awt.Color[r = 255, g = 0, b = 0]
Can you tell me which Color method I would use to get all those values an can you show me a code example.
thanks
AndreyN
October 26, 2010, 12:23pm
6
Hi
Thanks for your inquiry. In this case, you can try using the following piece of code:
System.out.printf("R=%d \nG=%d \nB=%d \nA=%d \n",
color.getRed(),
color.getGreen(),
color.getBlue(),
color.getAlpha())
Please feel free to ask if you have any further queries.
Best regards,