Introduction

Aspose.Slides FOSS for Java (aspose-slides-foss on Maven Central) is a free, MIT-licensed library for creating and editing PowerPoint .pptx files entirely in Java. It runs on Windows, macOS, Linux, and Docker containers with no dependency on Microsoft Office.

This article walks through the key features available in version 1.0.0.


Key Features

Presentation Loading and Saving

Presentation is the root object. Construct it with no arguments to create a new file or pass a file path to load an existing one. Call save() with a file path to write the output. Use try-with-resources to ensure all internal resources are released:

import org.aspose.slides.foss.Presentation;

// Create new
try (Presentation prs = new Presentation()) {
    prs.save("output.pptx");
}

// Load and save
try (Presentation prs2 = new Presentation("existing.pptx")) {
    prs2.save("copy.pptx");
}

Slide Management

The getSlides() method returns the slide collection. Add slides with addEmptySlide(), remove them with remove(), and access existing slides by index:

import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.ISlide;
import org.aspose.slides.foss.ILayoutSlide;

try (Presentation prs = new Presentation()) {
    ISlide slide = prs.getSlides().get(0);   // First slide (created automatically)

    // Add a second slide using the first master/layout
    ILayoutSlide layout = prs.getMasters().get(0).getLayoutSlides().get(0);
    ISlide newSlide = prs.getSlides().addEmptySlide(layout);
    prs.save("two_slides.pptx");
}

AutoShape Insertion and Text

Add shapes using slide.getShapes().addAutoShape(). Capture the returned ITextFrame from the shape to set text content and apply character formatting:

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, 300, 100
    );
    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("shape_demo.pptx");
}

Solid and Gradient Fills

Apply FillType.SOLID with an RGB color or FillType.GRADIENT for multi-stop fills:

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));
    prs.save("solid_fill.pptx");
}

Visual Effects

Apply outer shadows, glow, and soft-edge effects via shape.getEffectFormat():

import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.IAutoShape;
import org.aspose.slides.foss.IEffectFormat;
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, 300, 150
    );
    IEffectFormat ef = shape.getEffectFormat();
    ef.enableOuterShadowEffect();
    ef.getOuterShadowEffect().setBlurRadius(8);
    ef.getOuterShadowEffect().setDistance(6);
    ef.getOuterShadowEffect().setDirection(45);
    ef.getOuterShadowEffect().getShadowColor().setColor(Color.fromArgb(128, 0, 0, 0));
    prs.save("shadow.pptx");
}

Quick Start

Add the Maven dependency (Java 21 or later required):

<dependency>
    <groupId>org.aspose.slides.foss</groupId>
    <artifactId>aspose-slides-foss</artifactId>
    <version>1.0.0</version>
</dependency>
import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.IAutoShape;
import org.aspose.slides.foss.ShapeType;

try (Presentation prs = new Presentation()) {
    IAutoShape shape = prs.getSlides().get(0).getShapes().addAutoShape(
        ShapeType.RECTANGLE, 50, 50, 400, 150
    );
    shape.addTextFrame("My first slide");
    prs.save("first.pptx");
}

Supported Formats

FormatExtensionReadWrite
PPTX.pptx

Open Source & Licensing

Aspose.Slides FOSS for Java is released under the MIT License. Install from Maven Central as aspose-slides-foss. Commercial use, redistribution, and modification are all permitted.


Getting Started