We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Text Background color not set properly

Hi,

I am using Aspose words for Java 10.2 for creating a new document. In that, i have set the background color for the text using the code,

Font font = run.getFont();
java.awt.Color color = new java.awt.Color(195,214,155); //light green color
font.setColor(color);

But my text background color appears to be gray in document.Please help me in fixing this.

Hello
Thanks for your interest in Aspose.Words. I cannot reproduce the problem on my side using the latest version of Aspose.Words for Java and the following code for testing:

Document doc = new Document();
Paragraph paragraph = new Paragraph(doc);
Run run = new Run(doc, "MyContent");
// Set font color
run.getFont().setColor(Color.RED);
// Set Background color
run.getFont().getShading().setBackgroundPatternColor(Color.YELLOW);
paragraph.appendChild(run);
doc.getFirstSection().getBody().appendChild(paragraph);
doc.save("C:\\Temp\\out.docx");

Please let me know in case of any issues. I will be glad to help you.
Please follow this link to find more information about our product and lot of very useful examples:
https://docs.aspose.com/words/java/

Best regards,