public class Theme
Example:
Shows how to set custom theme colors and fonts.Document doc = new Document(getMyDir() + "Theme colors.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()
|
Property Getters/Setters Summary | ||
---|---|---|
ThemeColors | getColors() | |
Allows to specify the set of theme colors for the document.
|
||
ThemeFonts | getMajorFonts() | |
Allows to specify the set of major fonts for different languages.
|
||
ThemeFonts | getMinorFonts() | |
Allows to specify the set of minor fonts for different languages.
|
public ThemeColors getColors()
Example:
Shows how to set custom theme colors and fonts.Document doc = new Document(getMyDir() + "Theme colors.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");
public ThemeFonts getMajorFonts()
Example:
Shows how to set custom theme colors and fonts.Document doc = new Document(getMyDir() + "Theme colors.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");
public ThemeFonts getMinorFonts()
Example:
Shows how to set custom theme colors and fonts.Document doc = new Document(getMyDir() + "Theme colors.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");