Learn how to create and access SmartArt in PowerPoint using Java: https://blog.aspose.com/2021/08/22/create-smartart-in-powerpoint-using-java/
Last active
September 23, 2021 10:57
-
-
Save aspose-com-gists/6a054076684197a0d28101bb2e71b30c to your computer and use it in GitHub Desktop.
Create or Access SmartArt in PowerPoint 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 presentation | |
Presentation pres = new Presentation("AccessSmartArtShape.pptx"); | |
try { | |
// Traverse through every shape inside first slide | |
for (IShape shape : pres.getSlides().get_Item(0).getShapes()) | |
{ | |
// Check if shape is of SmartArt type | |
if (shape instanceof ISmartArt) | |
{ | |
// Typecast shape to SmartArtEx | |
ISmartArt smart = (ISmartArt) shape; | |
// Check SmartArt Layout | |
if (smart.getLayout() == SmartArtLayoutType.BasicBlockList) | |
{ | |
System.out.println("Do some thing here...."); | |
} | |
} | |
} | |
} 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 presentation | |
Presentation pres = new Presentation("SimpleSmartArt.pptx"); | |
try { | |
// Get first slide | |
ISlide slide = pres.getSlides().get_Item(0); | |
// Traverse through every shape inside first slide | |
for (IShape shape : slide.getShapes()) | |
{ | |
// Check if shape is of SmartArt type | |
if (shape instanceof ISmartArt) | |
{ | |
// Typecast shape to SmartArtEx | |
ISmartArt smart = (ISmartArt) shape; | |
// Check SmartArt style | |
if (smart.getQuickStyle() == SmartArtQuickStyleType.SimpleFill) { | |
// Change SmartArt Style | |
smart.setQuickStyle(SmartArtQuickStyleType.Cartoon); | |
} | |
// Check SmartArt color type | |
if (smart.getColorStyle() == SmartArtColorType.ColoredFillAccent1) { | |
// Change SmartArt color type | |
smart.setColorStyle(SmartArtColorType.ColorfulAccentColors); | |
} | |
} | |
} | |
// Save presentation | |
pres.save("ChangeSmartArtStyle.pptx", SaveFormat.Pptx); | |
} finally { | |
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
// Create a presentation or load existing one | |
Presentation pres = new Presentation(); | |
try { | |
// Get first slide | |
ISlide slide = pres.getSlides().get_Item(0); | |
// Add SmartArt shape | |
ISmartArt smart = slide.getShapes().addSmartArt(0, 0, 400, 400, SmartArtLayoutType.BasicBlockList); | |
// Save presentation | |
pres.save("SimpleSmartArt.pptx", SaveFormat.Pptx); | |
} finally { | |
if (pres != null) pres.dispose(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment