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

Free Support Forum - aspose.com

BackgroundPatternColor not transparent

I’ve run into a small issue while evaluating Aspose Words 13.7.0


when I set the paragraph BackgroundPatternColor property to transparent it is displayed as white in the document.

here is example code:

Aspose.Words.Document doc;
Aspose.Words.Body body;

doc = new Aspose.Words.Document();
doc.PageColor = System.Drawing.Color.FromArgb(200,200,200);
body = doc.FirstSection.Body;

Aspose.Words.Paragraph p = new Aspose.Words.Paragraph(doc);
p.ParagraphFormat.Shading.BackgroundPatternColor = System.Drawing.Color.FromArgb(0,255,255,255);
p.AppendChild(new Aspose.Words.Run(doc,“test paragraph 1”));
body.AppendChild§;

p = new Aspose.Words.Paragraph(doc);
p.ParagraphFormat.Shading.BackgroundPatternColor = System.Drawing.Color.FromArgb(0,0,0,0);
p.AppendChild(new Aspose.Words.Run(doc,“test paragraph 2”));
body.AppendChild§;

p = new Aspose.Words.Paragraph(doc);
p.ParagraphFormat.Shading.BackgroundPatternColor = System.Drawing.Color.Transparent;
p.AppendChild(new Aspose.Words.Run(doc, “test paragraph 3”));
body.AppendChild§;

doc.Save(“testBackColor.docx”, Aspose.Words.SaveFormat.Docx);

The first paragraph and the third paragraph are displayed with white backgrounds in the document but I believe should be completely transparent as the ‘A’ color property is 0 and in the case of the third paragraph uses the .Net transparent named color. In fact the transparency value seems to be ignored anytime the RGB components are > 0. I’m not trying to use any transparency, it’s only really a problem because the .Net named color for transparency (System.Drawing.Color.Transparent) is not mapping to transparent in the document. So I have to be very careful not to use it and document the code for future reference. I think you should revisit how you determine transparency.

Hi Phillip,


Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word do. In your case, I suggest you please use the Color.Empty instead of Color.Transparent in your code.

If Shading.BackgroundPatternColor is set to Color.Transparent, MS do not show any value for this. Please see the attached image for detail. If you set Shading.BackgroundPatternColor to Color.Empty, MS Word shows it as ‘No Color’.

Hope this answers your query. Please let us know if you have any more queries.