Shading Class
Contains shading attributes for an object.
Inheritance Hierarchy
SystemObject
  Aspose.WordsInternableComplexAttr
    Aspose.WordsShading

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.11
Syntax
public class Shading : InternableComplexAttr

The Shading type exposes the following members.

Properties
  NameDescription
Public propertyCode exampleBackgroundPatternColor
Gets or sets the color that's applied to the background of the Shading object.
Public propertyCode exampleForegroundPatternColor
Gets or sets the color that's applied to the foreground of the Shading object.
Public propertyCode exampleTexture
Gets or sets the shading texture.
Methods
  NameDescription
Public methodCode exampleClearFormatting
Removes shading from the object.
Public methodEquals(Object)
Determines whether the specified object is equal in value to the current object.
(Overrides ObjectEquals(Object).)
Public methodEquals(Shading)
Determines whether the specified Shading is equal in value to the current Shading.
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for this type.
(Overrides ObjectGetHashCode.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Protected methodNotifyChanging (Inherited from InternableComplexAttr.)
Public methodToString (Inherited from Object.)
Examples
Shows how to apply borders and shading to a paragraph.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Set paragraph borders
BorderCollection borders = builder.ParagraphFormat.Borders;
borders.DistanceFromText = 20;
borders[BorderType.Left].LineStyle = LineStyle.Double;
borders[BorderType.Right].LineStyle = LineStyle.Double;
borders[BorderType.Top].LineStyle = LineStyle.Double;
borders[BorderType.Bottom].LineStyle = LineStyle.Double;

// Set paragraph shading
Shading shading = builder.ParagraphFormat.Shading;
shading.Texture = TextureIndex.TextureDiagonalCross;
shading.BackgroundPatternColor = Color.LightCoral;
shading.ForegroundPatternColor = Color.LightSalmon;

builder.Write("I'm a formatted paragraph with double border and nice shading.");
Examples
Shows how to format table and cell with different borders and shadings
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Table table = builder.StartTable();
builder.InsertCell();

// Set the borders for the entire table.
table.SetBorders(LineStyle.Single, 2.0, Color.Black);
// Set the cell shading for this cell.
builder.CellFormat.Shading.BackgroundPatternColor = Color.Red;
builder.Writeln("Cell #1");

builder.InsertCell();
// Specify a different cell shading for the second cell.
builder.CellFormat.Shading.BackgroundPatternColor = Color.Green;
builder.Writeln("Cell #2");

// End this row.
builder.EndRow();

// Clear the cell formatting from previous operations.
builder.CellFormat.ClearFormatting();

// Create the second row.
builder.InsertCell();

// Create larger borders for the first cell of this row. This will be different
// compared to the borders set for the table.
builder.CellFormat.Borders.Left.LineWidth = 4.0;
builder.CellFormat.Borders.Right.LineWidth = 4.0;
builder.CellFormat.Borders.Top.LineWidth = 4.0;
builder.CellFormat.Borders.Bottom.LineWidth = 4.0;
builder.Writeln("Cell #3");

builder.InsertCell();
// Clear the cell formatting from the previous cell.
builder.CellFormat.ClearFormatting();
builder.Writeln("Cell #4");

doc.Save(ArtifactsDir + "Table.SetBordersAndShading.doc");
See Also