Theme Class
Represents document Theme, and provides access to main theme parts including MajorFonts, MinorFonts and Colors
Inheritance Hierarchy
SystemObject
  Aspose.Words.ThemesTheme

Namespace: Aspose.Words.Themes
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.12
Syntax
public class Theme

The Theme type exposes the following members.

Constructors
  NameDescription
Public methodTheme
Initializes a new instance of the Theme class
Properties
  NameDescription
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.
Methods
  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Examples
Shows how to set custom theme colors and fonts.
Document doc = new Document(MyDir + "ThemeColors.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