In This Topic
DsWord 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.
Get Shading
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.
C# |
Copy Code |
//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); |
Back to Top
Set 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.
C# |
Copy Code |
//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; |
Back to Top
For more information on how to implement background shading using DsWord, see DsWord sample browser.