[]
GcWord allows you to specify the background shading for a paragraph using BackgroundPatternColor property of the Shading class which can be accessed using Shading property of the ParagraphFormat class.
To get the shading:
Access a paragraph from the paragraph collection using Paragraphs property of the RangeBase class.
Access the paragraph formatting properties using Format property of the Paragraph class.
Access the shading formatting for the paragraph using Shading property of the ParagraphFormat class.
Get shading property. For example, get the shading texture using Texture property of the Shading class.
Get the background color using BackgroundPatternColor property of the Shading class.
Display the shading pattern and color on the console.
//Get shading
TexturePattern texture =
doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Shading.Texture;
Color shading=
doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Shading.BackgroundPatternColor.RGB;
Console.WriteLine("Shading Pattern: " + texture + "\n Shading Color: " + shading);
To set the shading:
Access a paragraph from the paragraph collection using Paragraphs property of the RangeBase class.
Access the paragraph formatting properties using Format property of the Paragraph class.
Access the shading formatting for the paragraph using Shading property of the ParagraphFormat class.
Set a shading property. For example, set the shading texture using Texture property of the Shading class.
Set the background color using BackgroundPatternColor property of the Shading class.
//Set shading
doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Shading.Texture =
TexturePattern.Percent15;
doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Shading.BackgroundPatternColor.RGB =
Color.LightPink;
For more information on how to implement background shading using GcWord, see GcWord sample browser.