ThemeColors class

ThemeColors class

Represents the color scheme of the document theme which contains twelve colors.

ThemeColors object contains six accent colors, two dark colors, two light colors and a color for each of a hyperlink and followed hyperlink.

Properties

NameDescription
accent1Specifies color Accent 1.
accent2Specifies color Accent 2.
accent3Specifies color Accent 3.
accent4Specifies color Accent 4.
accent5Specifies color Accent 5.
accent6Specifies color Accent 6.
dark1Specifies color Dark 1.
dark2Specifies color Dark 2.
followed_hyperlinkSpecifies color for a clicked hyperlink.
hyperlinkSpecifies color for a hyperlink.
light1Specifies color Light 1.
light2Specifies color Light 2.

Examples

Shows how to set custom colors and fonts for themes.

doc = aw.Document(file_name=MY_DIR + 'Theme colors.docx')
# The "Theme" object gives us access to the document theme, a source of default fonts and colors.
theme = doc.theme
# Some styles, such as "Heading 1" and "Subtitle", will inherit these fonts.
theme.major_fonts.latin = 'Courier New'
theme.minor_fonts.latin = 'Agency FB'
# Other languages may also have their custom fonts in this theme.
self.assertEqual('', theme.major_fonts.complex_script)
self.assertEqual('', theme.major_fonts.east_asian)
self.assertEqual('', theme.minor_fonts.complex_script)
self.assertEqual('', theme.minor_fonts.east_asian)
# The "Colors" property contains the color palette from Microsoft Word,
# which appears when changing shading or font color.
# Apply custom colors to the color palette so we have easy access to them in Microsoft Word
# when we, for example, change the font color via "Home" -> "Font" -> "Font Color",
# or insert a shape, and then set a color for it via "Shape Format" -> "Shape Styles".
colors = theme.colors
colors.dark1 = aspose.pydrawing.Color.midnight_blue
colors.light1 = aspose.pydrawing.Color.pale_green
colors.dark2 = aspose.pydrawing.Color.indigo
colors.light2 = aspose.pydrawing.Color.khaki
colors.accent1 = aspose.pydrawing.Color.orange_red
colors.accent2 = aspose.pydrawing.Color.light_salmon
colors.accent3 = aspose.pydrawing.Color.yellow
colors.accent4 = aspose.pydrawing.Color.gold
colors.accent5 = aspose.pydrawing.Color.blue_violet
colors.accent6 = aspose.pydrawing.Color.dark_violet
# Apply custom colors to hyperlinks in their clicked and un-clicked states.
colors.hyperlink = aspose.pydrawing.Color.black
colors.followed_hyperlink = aspose.pydrawing.Color.gray
doc.save(file_name=ARTIFACTS_DIR + 'Themes.CustomColorsAndFonts.docx')

See Also