Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active February 9, 2025 19:43
Show Gist options
  • Save aspose-com-gists/6103af2de4c9324ca9df8d094654b5f2 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/6103af2de4c9324ca9df8d094654b5f2 to your computer and use it in GitHub Desktop.
Create 3d Shapes in Powerpoint Files
public class main {
public static void main(String[] args) {
// Set the path for the working directory.
String outPptxFile = "Presentation2.pptx";
// Create an instance of the Presentation class.
Presentation pres = new Presentation();
try
{
// Create a new AutoShape, tune it from default template and add it to the end of the collection.
IAutoShape shape = pres.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 200, 150, 200, 200);
// Call the setText method to set the plain text for a TextFrame.
shape.getTextFrame().setText("3D");
// Set the font height by calling the setFontHeight method.
shape.getTextFrame().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setFontHeight(64);
// Define the camera type by calling the setCameraType function.
shape.getThreeDFormat().getCamera().setCameraType(CameraPresetType.OrthographicFront);
// Set rotation by invoking the setRotation function.
shape.getThreeDFormat().getCamera().setRotation(20, 30, 40);
// The setLightType method represents a preset light right that can be applied to a shape.
shape.getThreeDFormat().getLightRig().setLightType(LightRigPresetType.Flat);
// Define direction, material and height of an extrusion effect.
shape.getThreeDFormat().getLightRig().setDirection(LightingDirection.Top);
shape.getThreeDFormat().setMaterial(MaterialPresetType.Powder);
shape.getThreeDFormat().setExtrusionHeight(100);
// Call the save method to save the file onto the disk.
pres.save(outPptxFile, 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