Theme Class

Represents document Theme, and provides access to main theme parts including MajorFonts, MinorFonts and Colors

Inheritance Hierarchy


Namespace:  Aspose.Words.Themes
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.7.0


public class Theme

The Theme type exposes the following members.


Public methodTheme
Initializes a new instance of the Theme class


Public propertyCode exampleColors
Allows to specify the set of theme colors for the document.
Public propertyCode exampleMajorFonts
Allows to specify the set of major fonts for different languages.
Public propertyCode exampleMinorFonts
Allows to specify the set of minor fonts for different languages.


Public methodEquals (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodToString (Inherited from Object.)


Shows how to set custom theme colors and fonts.
Document doc = new Document(MyDir + "Theme colors.docx");

// This object gives us access to the document theme, which is a source of default fonts and colors
Theme theme = doc.Theme;

// These fonts will be inherited by some styles like "Heading 1" and "Subtitle"
theme.MajorFonts.Latin = "Courier New";
theme.MinorFonts.Latin = "Agency FB";

Assert.AreEqual(string.Empty, theme.MajorFonts.ComplexScript);
Assert.AreEqual(string.Empty, theme.MajorFonts.EastAsian);
Assert.AreEqual(string.Empty, theme.MinorFonts.ComplexScript);
Assert.AreEqual(string.Empty, theme.MinorFonts.EastAsian);

// This collection of colors corresponds to the color palette from Microsoft Word which appears when changing shading or font color 
ThemeColors colors = theme.Colors;

// We will set the color of each color palette column going from left to right like this
colors.Dark1 = Color.MidnightBlue;
colors.Light1 = Color.PaleGreen;
colors.Dark2 = Color.Indigo;
colors.Light2 = Color.Khaki;

colors.Accent1 = Color.OrangeRed;
colors.Accent2 = Color.LightSalmon;
colors.Accent3 = Color.Yellow;
colors.Accent4 = Color.Gold;
colors.Accent5 = Color.BlueViolet;
colors.Accent6 = Color.DarkViolet;

// We can also set colors for hyperlinks like this
colors.Hyperlink = Color.Black;
colors.FollowedHyperlink = Color.Gray;

doc.Save(ArtifactsDir + "Themes.CustomColorsAndFonts.docx");

See Also