This project has moved. For the latest updates, please go here.

Background-color

Oct 28, 2011 at 3:49 PM

I'm having a background-color css property in a span element (supported as the documentation says) but no matter which color I use as my background color, it always turns out to be "darkGray" in the "highlight" property of the paragraph.

I'm using the code placed in the documentation too, so am I missing something?

Oct 31, 2011 at 2:47 PM

Ok, I finally modified the source code to make it use a Shading object instead of a Highlight object, it is now working as I expected.

Dec 6, 2011 at 3:24 PM

Hi Wude,

I am seeing highlighted text in word, ie text is highlighted to a different color than the background specified in the style. Is this the same issue and what code did you change? I can see this in the source:

colorValue = en.StyleAttributes.GetAsColor("background-color");
            if (!colorValue.IsEmpty)
            {
                HighlightColorValues color = ConverterUtility.ConvertToHighlightColor(colorValue);
                if (color != HighlightColorValues.None)
                    styleAttributes.Add(new Highlight { Val = color });
            }

but cannot see what to change just yet..

Mark

 

Dec 6, 2011 at 4:34 PM
Edited Dec 6, 2011 at 4:39 PM

I do not remember it right now as I don't have the computer here. But yeah, it was in that part you have wrote, but I think I changed this line:

styleAttributes.Add(new Highlight { Val = color });

instead of "new Highlight" I think I used "new Shading", I don't remember about the property (Val) but you will see it when you change that.
Of course, if you want it to be applied always you will have to comment the if statement


Edit:

http://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing.shading_members.aspx

maybe the property was Fill instead of Val. I'm not sure