Quick Start
Quick Start
This guide shows the fastest path from installation to a saved .pptx file using
Aspose.Slides FOSS for Java. The library is MIT-licensed, requires no Microsoft Office,
and runs on any platform supporting Java 21 or later.
Prerequisites
| Requirement | Detail |
|---|---|
| Java | 21 or later |
| OS | Windows, macOS, Linux, Docker |
| Package | aspose-slides-foss from Maven Central |
Install
Add the Maven dependency to your pom.xml. Always wrap Presentation in a try-with-resources
block to ensure internal resources are released after use:
<dependency>
<groupId>org.aspose.slides.foss</groupId>
<artifactId>aspose-slides-foss</artifactId>
<version>1.0.0</version>
</dependency>Create a Presentation
Construct a Presentation with no arguments to create a blank deck. The library
automatically adds one empty slide. Call save() with the output file path:
import org.aspose.slides.foss.Presentation;
try (Presentation prs = new Presentation()) {
prs.save("empty.pptx");
}Add a Shape with Text
Access the first slide via getSlides().get(0), insert a rectangle using
getShapes().addAutoShape(), then attach text via addTextFrame():
import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.ISlide;
import org.aspose.slides.foss.IAutoShape;
import org.aspose.slides.foss.ITextFrame;
import org.aspose.slides.foss.IPortionFormat;
import org.aspose.slides.foss.ShapeType;
import org.aspose.slides.foss.NullableBool;
try (Presentation prs = new Presentation()) {
ISlide slide = prs.getSlides().get(0);
IAutoShape shape = slide.getShapes().addAutoShape(
ShapeType.RECTANGLE, 50, 50, 400, 150
);
ITextFrame tf = shape.addTextFrame("Hello from Aspose.Slides FOSS!");
IPortionFormat fmt = tf.getParagraphs().get(0).getPortions().get(0).getPortionFormat();
fmt.setFontHeight(24);
fmt.setFontBold(NullableBool.TRUE);
prs.save("with_shape.pptx");
}Apply a Solid Fill
Set setFillType(FillType.SOLID) on the shape’s fill format and provide an RGB color
via setColor(new Color(r, g, b)):
import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.IAutoShape;
import org.aspose.slides.foss.ShapeType;
import org.aspose.slides.foss.FillType;
import org.aspose.slides.foss.drawing.Color;
try (Presentation prs = new Presentation()) {
IAutoShape shape = prs.getSlides().get(0).getShapes().addAutoShape(
ShapeType.RECTANGLE, 100, 100, 400, 200
);
shape.getFillFormat().setFillType(FillType.SOLID);
shape.getFillFormat().getSolidFillColor().setColor(new Color(70, 130, 180));
shape.addTextFrame("Styled shape");
prs.save("styled.pptx");
}Load an Existing File
Pass a file path to the Presentation constructor to open an existing .pptx file.
Read the slide count, modify the deck as needed, then call save() to write the output:
import org.aspose.slides.foss.Presentation;
try (Presentation prs = new Presentation("existing.pptx")) {
System.out.println("Slides: " + prs.getSlides().size());
prs.save("copy.pptx");
}