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

Free Support Forum - aspose.com

Check shading

Dear Support Team,


I’m parsing the document:

ParagraphFormat format = paragraph.getParagraphFormat ();
Shading shading = format.getShading ();

If Shading is not set, it always returns to the color RGB (0,0,0). How can I check when the shading is set for the paragraph or not?

Hi Дмитрий,


Thanks for your inquiry. Unfortunately, there is no such property to be able to determine if shading is actually applied or not. However, you can check for the following properties:

ParagraphFormat.Shading.BackgroundPatternColor.IsEmpty
ParagraphFormat.Shading.ForegroundPatternColor.IsEmpty

I hope, this will help.

Best Regards,
Hi' awais.hafeez

I am using version Aspose.Words for Java 11.0.0 (Aspose.Words.jdk16.jar). I did not find the properties you wrote. Please give the code for Java.

Hi,


Thanks for your inquiry. I apologize for providing you the C# properties. I think, for Java, you can check for Paragraph.getParagraphFormat().getShading().hashCode(); if it returns zero then shading is not set.

I hope, this will help.

Best Regards,

Hi,

Thank you, this is what you need.