Aspose::Words::Shading class

Shading class

Contains shading attributes for an object. To learn more, visit the Programming with Documents documentation article.

class Shading : public InternableComplexAttr,
                public IComplexAttr

Methods

MethodDescription
ClearFormatting()Removes shading from the object.
Equals(System::SharedPtr<System::Object>) overrideDetermines whether the specified object is equal in value to the current object.
Equals(const System::SharedPtr<Aspose::Words::Shading> &)Determines whether the specified Shading is equal in value to the current Shading.
GetHashCode() const overrideServes as a hash function for this type.
get_BackgroundPatternColor()Gets or sets the color that’s applied to the background of the Shading object.
get_BackgroundPatternThemeColor()Gets or sets the background pattern theme color in the applied color scheme that is associated with this Shading object.
get_BackgroundTintAndShade()Gets or sets a double value that lightens or darkens a background theme color.
get_ForegroundPatternColor()Gets or sets the color that’s applied to the foreground of the Shading object.
get_ForegroundPatternThemeColor()Gets or sets the foreground pattern theme color in the applied color scheme that is associated with this Shading object.
get_ForegroundTintAndShade()Gets or sets a double value that lightens or darkens a foreground theme color.
get_Texture()Gets or sets the shading texture.
set_BackgroundPatternColor(System::Drawing::Color)Sets the color that’s applied to the background of the Shading object.
set_BackgroundPatternThemeColor(Aspose::Words::Themes::ThemeColor)Sets the background pattern theme color in the applied color scheme that is associated with this Shading object.
set_BackgroundTintAndShade(double)Sets a double value that lightens or darkens a background theme color.
set_ForegroundPatternColor(System::Drawing::Color)Sets the color that’s applied to the foreground of the Shading object.
set_ForegroundPatternThemeColor(Aspose::Words::Themes::ThemeColor)Sets the foreground pattern theme color in the applied color scheme that is associated with this Shading object.
set_ForegroundTintAndShade(double)Sets a double value that lightens or darkens a foreground theme color.
set_Texture(Aspose::Words::TextureIndex)Sets the shading texture.

Examples

Shows how to apply border and shading color while building a table.

auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);

// Start a table and set a default color/thickness for its borders.
System::SharedPtr<Aspose::Words::Tables::Table> table = builder->StartTable();
table->SetBorders(LineStyle::Single, 2.0, System::Drawing::Color::get_Black());

// Create a row with two cells with different background colors.
builder->InsertCell();
builder->get_CellFormat()->get_Shading()->set_BackgroundPatternColor(System::Drawing::Color::get_LightSkyBlue());
builder->Writeln(u"Row 1, Cell 1.");
builder->InsertCell();
builder->get_CellFormat()->get_Shading()->set_BackgroundPatternColor(System::Drawing::Color::get_Orange());
builder->Writeln(u"Row 1, Cell 2.");
builder->EndRow();

// Reset cell formatting to disable the background colors
// set a custom border thickness for all new cells created by the builder,
// then build a second row.
builder->get_CellFormat()->ClearFormatting();
builder->get_CellFormat()->get_Borders()->get_Left()->set_LineWidth(4.0);
builder->get_CellFormat()->get_Borders()->get_Right()->set_LineWidth(4.0);
builder->get_CellFormat()->get_Borders()->get_Top()->set_LineWidth(4.0);
builder->get_CellFormat()->get_Borders()->get_Bottom()->set_LineWidth(4.0);

builder->InsertCell();
builder->Writeln(u"Row 2, Cell 1.");
builder->InsertCell();
builder->Writeln(u"Row 2, Cell 2.");

doc->Save(get_ArtifactsDir() + u"DocumentBuilder.TableBordersAndShading.docx");

Shows how to decorate text with borders and shading.

auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);

System::SharedPtr<Aspose::Words::BorderCollection> borders = builder->get_ParagraphFormat()->get_Borders();
borders->set_DistanceFromText(20);
borders->idx_get(BorderType::Left)->set_LineStyle(LineStyle::Double);
borders->idx_get(BorderType::Right)->set_LineStyle(LineStyle::Double);
borders->idx_get(BorderType::Top)->set_LineStyle(LineStyle::Double);
borders->idx_get(BorderType::Bottom)->set_LineStyle(LineStyle::Double);

System::SharedPtr<Aspose::Words::Shading> shading = builder->get_ParagraphFormat()->get_Shading();
shading->set_Texture(TextureIndex::TextureDiagonalCross);
shading->set_BackgroundPatternColor(System::Drawing::Color::get_LightCoral());
shading->set_ForegroundPatternColor(System::Drawing::Color::get_LightSalmon());

builder->Write(u"This paragraph is formatted with a double border and shading.");
doc->Save(get_ArtifactsDir() + u"DocumentBuilder.ApplyBordersAndShading.docx");

See Also