Frequently Asked Questions

Frequently Asked Questions

Frequently Asked Questions

How do I install Aspose.Slides FOSS?

Add the Maven dependency to your pom.xml. Java 11 or later is required.

<dependency>
  <groupId>org.aspose.slides.foss</groupId>
  <artifactId>aspose-slides-foss</artifactId>
  <version>1.0.0</version>
</dependency>

Verify the installation:

import org.aspose.slides.foss.Presentation;

Presentation prs = new Presentation();
try {
    System.out.println("Slides: " + prs.getSlides().size());
} finally {
    prs.dispose();
}

No Microsoft Office or other system runtime is required.


Why must I call dispose() on Presentation?

The Presentation class manages internal OPC package resources. Without calling dispose(), those resources are not released, which can cause memory leaks or file locks. Always use try-finally:

Presentation prs = new Presentation("input.pptx");
try {
    // work here
    prs.save("output.pptx", SaveFormat.PPTX);
} finally {
    prs.dispose();
}

Alternatively, use try-with-resources since Presentation implements AutoCloseable:

try (Presentation prs = new Presentation("input.pptx")) {
    prs.save("output.pptx", SaveFormat.PPTX);
}

What file formats can I save to?

Only PPTX is supported:

import org.aspose.slides.foss.SaveFormat;

prs.save("output.pptx", SaveFormat.PPTX);

Export to PDF, HTML, SVG, or image formats (PNG, JPEG) is not available in this edition.


Can I open .ppt (old PowerPoint 97-2003) files?

No. Only .pptx (Office Open XML) files are supported. Legacy .ppt binary format is not handled by this library.


How do I access slides?

Slides are a zero-based collection accessible via prs.getSlides():

ISlide firstSlide = prs.getSlides().get(0);
int slideCount = prs.getSlides().size();

How do I add a second slide?

Use prs.getSlides().addEmptySlide() with a layout:

try (Presentation prs = new Presentation()) {
    ILayoutSlide layout = prs.getLayoutSlides().get(0);
    prs.getSlides().addEmptySlide(layout);
    ISlide slide2 = prs.getSlides().get(1);
    prs.save("two-slides.pptx", SaveFormat.PPTX);
}

How do I set the slide background color?

Access the slide background fill format:

import org.aspose.slides.foss.FillType;
import org.aspose.slides.foss.Color;

ISlide slide = prs.getSlides().get(0);
slide.getBackground().getFillFormat().setFillType(FillType.SOLID);
slide.getBackground().getFillFormat().getSolidFillColor().setColor(
    Color.fromArgb(255, 230, 240, 255)
);

How do I use NullableBool?

NullableBool is a tri-state enum used for formatting properties. Use NullableBool.TRUE (not Java’s true) for bold, italic, and similar properties:

import org.aspose.slides.foss.NullableBool;

fmt.setFontBold(NullableBool.TRUE);
fmt.setFontItalic(NullableBool.FALSE);

Why does setting text color have no effect?

You must also set fillType to FillType.SOLID before assigning the color:

import org.aspose.slides.foss.FillType;
import org.aspose.slides.foss.Color;

fmt.getFillFormat().setFillType(FillType.SOLID);
fmt.getFillFormat().getSolidFillColor().setColor(Color.fromArgb(255, 200, 0, 0));

Can I use charts or SmartArt?

No. Charts, SmartArt, OLE objects, animations, transitions, hyperlinks, VBA macros, and digital signatures are not implemented in this edition and raise UnsupportedOperationException.


Is the library thread-safe?

Each Presentation object is independent. Creating and using separate Presentation instances from separate threads is safe as long as you do not share a single Presentation object across threads without external synchronization.


How do I embed an image?

Read the image bytes and add them to prs.getImages(), then create a PictureFrame:

import org.aspose.slides.foss.ShapeType;

byte[] imageData = java.nio.file.Files.readAllBytes(
    java.nio.file.Paths.get("logo.png")
);
IPPImage image = prs.getImages().addImage(imageData);
slide.getShapes().addPictureFrame(ShapeType.RECTANGLE, 50, 50, 200, 150, image);

See Also