Learn how to apply themes in PowerPoint presentations using Java: https://blog.aspose.com/2021/08/16/apply-theme-in-powerpoint-using-java/
Last active
September 17, 2021 05:16
-
-
Save aspose-com-gists/9126e502f254c5aa98b378b14215b804 to your computer and use it in GitHub Desktop.
Apply Theme in PowerPoint Presentations using Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load or create presentation | |
Presentation pres = new Presentation("pres.pptx"); | |
try { | |
// Get available styles | |
int numberOfBackgroundFills = pres.getMasterTheme().getFormatScheme().getBackgroundFillStyles().size(); | |
System.out.println("Number of background fill styles for theme is " + numberOfBackgroundFills); | |
// Set style | |
pres.getMasters().get_Item(0).getBackground().setStyleIndex(2); | |
// Save presentation | |
pres.save("out.pptx", SaveFormat.Pptx); | |
} finally { | |
if (pres != null) pres.dispose(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load or create presentation | |
Presentation pres = new Presentation(); | |
try { | |
// Add a shape | |
IAutoShape shape = pres.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 10, 10, 100, 100); | |
// Set fill type | |
shape.getFillFormat().setFillType(FillType.Solid); | |
// Set scheme color | |
shape.getFillFormat().getSolidFillColor().setSchemeColor(SchemeColor.Accent4); | |
// Save presentation | |
pres.save("out.pptx", SaveFormat.Pptx); | |
} finally { | |
if (pres != null) pres.dispose(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load or create presentation | |
Presentation pres = new Presentation(); | |
try { | |
// Add shape | |
IAutoShape shape = pres.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 10, 10, 100, 100); | |
// Add paragraph and set text | |
Paragraph paragraph = new Paragraph(); | |
Portion portion = new Portion("Theme text format"); | |
paragraph.getPortions().add(portion); | |
shape.getTextFrame().getParagraphs().add(paragraph); | |
// Set font | |
portion.getPortionFormat().setLatinFont(new FontData("+mn-lt")); | |
// Save presentation | |
pres.save("out.pptx", SaveFormat.Pptx); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment