public class ThemeFonts
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");
Property Getters/Setters Summary | ||
---|---|---|
java.lang.String | getComplexScript() | |
void | setComplexScript(java.lang.Stringvalue) | |
Specifies font name for ComplexScript characters. | ||
java.lang.String | getEastAsian() | |
void | setEastAsian(java.lang.Stringvalue) | |
Specifies font name for EastAsian characters. | ||
java.lang.String | getLatin() | |
void | setLatin(java.lang.Stringvalue) | |
Specifies font name for Latin characters. |
public java.lang.String getComplexScript() / public void setComplexScript(java.lang.String value)
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 java.lang.String getEastAsian() / public void setEastAsian(java.lang.String value)
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 java.lang.String getLatin() / public void setLatin(java.lang.String value)
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");