java.lang.Object
com.aspose.words.Theme
- All Implemented Interfaces:
- java.lang.Cloneable
public class Theme
- extends java.lang.Object
Represents document Theme, and provides access to main theme parts including MajorFonts, MinorFonts and ColorsExample:
Shows how to set custom theme colors and fonts.
Document doc = new Document(getMyDir() + "ThemeColors.docx");
// This object gives us access to the document theme, which is a source of default fonts and colors
Theme theme = doc.getTheme();
// These fonts will be inherited by some styles like "Heading 1" and "Subtitle"
theme.getMajorFonts().setLatin("Courier New");
theme.getMinorFonts().setLatin("Agency FB");
Assert.assertEquals(theme.getMajorFonts().getComplexScript(), "");
Assert.assertEquals(theme.getMajorFonts().getEastAsian(), "");
Assert.assertEquals(theme.getMinorFonts().getComplexScript(), "");
Assert.assertEquals(theme.getMinorFonts().getEastAsian(), "");
// This collection of colors corresponds to the color palette from Microsoft Word which appears when changing shading or font color
ThemeColors colors = theme.getColors();
// We will set the color of each color palette column going from left to right like this
colors.setDark1(Color.BLUE);
colors.setLight1(Color.GREEN);
colors.setDark2(Color.MAGENTA);
colors.setLight2(Color.BLACK);
colors.setAccent1(Color.RED);
colors.setAccent2(Color.PINK);
colors.setAccent3(Color.YELLOW);
colors.setAccent4(Color.orange);
colors.setAccent5(Color.cyan);
colors.setAccent6(Color.darkGray);
// We can also set colors for hyperlinks like this
colors.setHyperlink(Color.WHITE);
colors.setFollowedHyperlink(Color.lightGray);
doc.save(getArtifactsDir() + "Themes.CustomColorsAndFonts.docx");
Constructor Summary |
Theme()
|
Theme
public Theme()
-
Property Getters/Setters Detail |
-
Allows to specify the set of theme colors for the document.
Example:
Shows how to set custom theme colors and fonts.
Document doc = new Document(getMyDir() + "ThemeColors.docx");
// This object gives us access to the document theme, which is a source of default fonts and colors
Theme theme = doc.getTheme();
// These fonts will be inherited by some styles like "Heading 1" and "Subtitle"
theme.getMajorFonts().setLatin("Courier New");
theme.getMinorFonts().setLatin("Agency FB");
Assert.assertEquals(theme.getMajorFonts().getComplexScript(), "");
Assert.assertEquals(theme.getMajorFonts().getEastAsian(), "");
Assert.assertEquals(theme.getMinorFonts().getComplexScript(), "");
Assert.assertEquals(theme.getMinorFonts().getEastAsian(), "");
// This collection of colors corresponds to the color palette from Microsoft Word which appears when changing shading or font color
ThemeColors colors = theme.getColors();
// We will set the color of each color palette column going from left to right like this
colors.setDark1(Color.BLUE);
colors.setLight1(Color.GREEN);
colors.setDark2(Color.MAGENTA);
colors.setLight2(Color.BLACK);
colors.setAccent1(Color.RED);
colors.setAccent2(Color.PINK);
colors.setAccent3(Color.YELLOW);
colors.setAccent4(Color.orange);
colors.setAccent5(Color.cyan);
colors.setAccent6(Color.darkGray);
// We can also set colors for hyperlinks like this
colors.setHyperlink(Color.WHITE);
colors.setFollowedHyperlink(Color.lightGray);
doc.save(getArtifactsDir() + "Themes.CustomColorsAndFonts.docx");
-
Allows to specify the set of major fonts for different languages.
Example:
Shows how to set custom theme colors and fonts.
Document doc = new Document(getMyDir() + "ThemeColors.docx");
// This object gives us access to the document theme, which is a source of default fonts and colors
Theme theme = doc.getTheme();
// These fonts will be inherited by some styles like "Heading 1" and "Subtitle"
theme.getMajorFonts().setLatin("Courier New");
theme.getMinorFonts().setLatin("Agency FB");
Assert.assertEquals(theme.getMajorFonts().getComplexScript(), "");
Assert.assertEquals(theme.getMajorFonts().getEastAsian(), "");
Assert.assertEquals(theme.getMinorFonts().getComplexScript(), "");
Assert.assertEquals(theme.getMinorFonts().getEastAsian(), "");
// This collection of colors corresponds to the color palette from Microsoft Word which appears when changing shading or font color
ThemeColors colors = theme.getColors();
// We will set the color of each color palette column going from left to right like this
colors.setDark1(Color.BLUE);
colors.setLight1(Color.GREEN);
colors.setDark2(Color.MAGENTA);
colors.setLight2(Color.BLACK);
colors.setAccent1(Color.RED);
colors.setAccent2(Color.PINK);
colors.setAccent3(Color.YELLOW);
colors.setAccent4(Color.orange);
colors.setAccent5(Color.cyan);
colors.setAccent6(Color.darkGray);
// We can also set colors for hyperlinks like this
colors.setHyperlink(Color.WHITE);
colors.setFollowedHyperlink(Color.lightGray);
doc.save(getArtifactsDir() + "Themes.CustomColorsAndFonts.docx");
-
Allows to specify the set of minor fonts for different languages.
Example:
Shows how to set custom theme colors and fonts.
Document doc = new Document(getMyDir() + "ThemeColors.docx");
// This object gives us access to the document theme, which is a source of default fonts and colors
Theme theme = doc.getTheme();
// These fonts will be inherited by some styles like "Heading 1" and "Subtitle"
theme.getMajorFonts().setLatin("Courier New");
theme.getMinorFonts().setLatin("Agency FB");
Assert.assertEquals(theme.getMajorFonts().getComplexScript(), "");
Assert.assertEquals(theme.getMajorFonts().getEastAsian(), "");
Assert.assertEquals(theme.getMinorFonts().getComplexScript(), "");
Assert.assertEquals(theme.getMinorFonts().getEastAsian(), "");
// This collection of colors corresponds to the color palette from Microsoft Word which appears when changing shading or font color
ThemeColors colors = theme.getColors();
// We will set the color of each color palette column going from left to right like this
colors.setDark1(Color.BLUE);
colors.setLight1(Color.GREEN);
colors.setDark2(Color.MAGENTA);
colors.setLight2(Color.BLACK);
colors.setAccent1(Color.RED);
colors.setAccent2(Color.PINK);
colors.setAccent3(Color.YELLOW);
colors.setAccent4(Color.orange);
colors.setAccent5(Color.cyan);
colors.setAccent6(Color.darkGray);
// We can also set colors for hyperlinks like this
colors.setHyperlink(Color.WHITE);
colors.setFollowedHyperlink(Color.lightGray);
doc.save(getArtifactsDir() + "Themes.CustomColorsAndFonts.docx");
See Also:
Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
Aspose.Words Support Forum - our preferred method of support.