# Aspose.Slides for Java
> Complete English documentation. Each page retains its canonical source URL.
# Aspose.Slides for Java
> Start here: install Aspose.Slides for Java, create a first presentation, and find the guides for common tasks, deployment and the API reference.
Source: https://docs.aspose.com/slides/java/
Updated: 2026-10-27
Aspose.Slides for Java is a class library for creating, reading, editing and converting PowerPoint and OpenDocument presentations in Java applications, without Microsoft PowerPoint.
It loads and saves PPT, PPTX, PPS, POT and ODP, including macro-enabled and template variants, and exports to PDF, XPS, HTML, SVG, TIFF, Markdown and images.
------
## **Your first presentation**
Aspose.Slides for Java is published in Aspose's own Maven repository, not in Maven Central. Create a folder for a Maven project and save this *pom.xml* in it. It declares the repository, adds the library, and names the class to run:
```xml
4.0.0com.examplehello-slides1.011UTF-8HelloSlidesAsposeJavaAPIAspose Java APIhttps://releases.aspose.com/java/repo/com.asposeaspose-slides26.9jdk16org.apache.maven.pluginsmaven-compiler-plugin3.15.0
```
Save this code as *src/main/java/HelloSlides.java*:
```java
import com.aspose.slides.*;
public class HelloSlides {
public static void main(String[] args) {
// Create a presentation. It already contains one empty slide.
Presentation presentation = new Presentation();
try {
// Get the first slide.
ISlide slide = presentation.getSlides().get_Item(0);
// Add a cloud shape and put text in it.
IAutoShape autoShape = slide.getShapes().addAutoShape(ShapeType.Cloud, 20, 20, 200, 80);
autoShape.getTextFrame().setText("Hello, Aspose!");
// Save the presentation as a PPTX file.
presentation.save("new_presentation.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
}
}
```
Then, with JDK 11 or later and Apache Maven installed, run this command in the project folder:
```bash
mvn compile exec:java
```
The program saves *new_presentation.pptx* in the project folder, with one slide holding a cloud shape with text. On Linux, fontconfig and at least one font must be installed; see [Installation](https://docs.aspose.com/slides/java/installation/#linux). Without a license, the saved file carries an evaluation watermark — see [Licensing](https://docs.aspose.com/slides/java/licensing/). For more ways to create and fill a presentation, see [Create Presentations](https://docs.aspose.com/slides/java/create-presentation/).
# Customize 3D Charts in Presentations Using Java
> Create 3D charts in PowerPoint presentations with Aspose.Slides for Java. Adjust rotation, height proportions, chart depth, and spacing between series with Java examples.
Source: https://docs.aspose.com/slides/java/3d-chart/
Updated: 2026-11-09
## **Overview**
Aspose.Slides for Java lets you customize the view of a 3D chart through the [IChart.getRotation3D](https://reference.aspose.com/slides/java/com.aspose.slides/ichart/#getRotation3D--) method. This article demonstrates how to adjust rotation, height proportions, depth, right-angle axes, and spacing between series, then save the presentation in PPTX format.
## **Set the Rotation and Depth of a 3D Chart**
The example below creates a [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) and uses [IShapeCollection.addChart](https://reference.aspose.com/slides/java/com.aspose.slides/ishapecollection/#addChart-int-float-float-float-float-) to add a stacked 3D column chart to its first slide. It replaces the default series and categories with two series containing three values each. Worksheet index `0` identifies the chart's first data worksheet; row `0` holds series names, and column `0` holds category labels.
The [setRotationX](https://reference.aspose.com/slides/java/com.aspose.slides/irotation3d/#setRotationX-byte-) and [setRotationY](https://reference.aspose.com/slides/java/com.aspose.slides/irotation3d/#setRotationY-int-) methods set the chart's rotation to 40 and 270 degrees, respectively. [setDepthPercents](https://reference.aspose.com/slides/java/com.aspose.slides/irotation3d/#setDepthPercents-int-) sets its depth to 150% of its width, while [setRightAngleAxes](https://reference.aspose.com/slides/java/com.aspose.slides/irotation3d/#setRightAngleAxes-boolean-) enables right-angle axes instead of perspective. The resulting presentation contains the populated chart with these 3D view settings.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.StackedColumn3D, 0, 0, 500, 500);
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
int worksheetIndex = 0;
double[][] values = { { 20, 50, 30 }, { 30, 10, 60 } };
for (int categoryIndex = 0; categoryIndex < 3; categoryIndex++) {
IChartDataCell categoryCell = workbook.getCell(worksheetIndex, categoryIndex + 1, 0, "Category " + (categoryIndex + 1));
chart.getChartData().getCategories().add(categoryCell);
}
for (int seriesIndex = 0; seriesIndex < 2; seriesIndex++) {
IChartDataCell seriesCell = workbook.getCell(worksheetIndex, 0, seriesIndex + 1, "Series " + (seriesIndex + 1));
IChartSeries series = chart.getChartData().getSeries().add(seriesCell, chart.getType());
for (int categoryIndex = 0; categoryIndex < 3; categoryIndex++) {
IChartDataCell valueCell = workbook.getCell(worksheetIndex, categoryIndex + 1, seriesIndex + 1, values[seriesIndex][categoryIndex]);
series.getDataPoints().addDataPointForBarSeries(valueCell);
}
}
chart.getRotation3D().setRightAngleAxes(true);
chart.getRotation3D().setRotationX((byte) 40);
chart.getRotation3D().setRotationY(270);
chart.getRotation3D().setDepthPercents(150);
presentation.save("Rotation3D_out.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Adjust the Height Proportions of a 3D Chart**
Use [IRotation3D.setHeightPercents](https://reference.aspose.com/slides/java/com.aspose.slides/irotation3d/#setHeightPercents-int-) to set the height of a 3D chart as a percentage of its width. This changes the proportions of the 3D scene without resizing the chart object on the slide.
The following example creates a [Column3D](https://reference.aspose.com/slides/java/com.aspose.slides/charttype/) chart with the default data: three series and four categories. It saves three presentations with height proportions of 50%, 100%, and 200%. The chart's position, width, and height remain fixed. The data, rotation, depth, series spacing, and formatting are identical in all three files; only the height percentage changes.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Column3D, 40, 30, 620, 460);
chart.getRotation3D().setRotationX((byte) 20);
chart.getRotation3D().setRotationY(30);
chart.getRotation3D().setRightAngleAxes(true);
chart.getRotation3D().setDepthPercents(100);
chart.getChartData().getSeries().get_Item(0).getParentSeriesGroup().setGapDepth(150);
for (int heightPercent : new int[] { 50, 100, 200 }) {
chart.getRotation3D().setHeightPercents(heightPercent);
presentation.save("chart_height_" + heightPercent + ".pptx", SaveFormat.Pptx);
}
} finally {
presentation.dispose();
}
```
The following images illustrate the same height settings in the equivalent .NET example and were exported using Microsoft PowerPoint. A smaller percentage produces a flatter scene, while a larger percentage produces a taller scene within the same chart object. PowerPoint may also adjust axis tick intervals and label placement to fit the scene.
| Height: 50% | Height: 100% | Height: 200% |
| --- | --- | --- |
|  |  |  |
These methods control different aspects of the chart:
| Method | Effect |
| --- | --- |
| [IRotation3D.setHeightPercents](https://reference.aspose.com/slides/java/com.aspose.slides/irotation3d/#setHeightPercents-int-) | Height of the 3D scene as a percentage of its width. |
| [IChart.setHeight](https://reference.aspose.com/slides/java/com.aspose.slides/ishape/#setHeight-float-) | Height of the chart object on the slide, in points. |
| [IRotation3D.setDepthPercents](https://reference.aspose.com/slides/java/com.aspose.slides/irotation3d/#setDepthPercents-int-) | Depth of the 3D scene as a percentage of its width. |
| [IChartSeriesGroup.setGapDepth](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseriesgroup/#setGapDepth-int-) | Spacing between series along the depth axis, as a percentage of the marker width. |
The height setting affects 3D column and bar charts, including cylinder, cone, and pyramid variants, as well as 3D line, area, pie, and surface charts. The comparison above uses the verified `Column3D` type. The setting does not change the appearance of a 2D `ClusteredColumn` chart or a `BubbleWith3D` chart; these names are members of the [ChartType](https://reference.aspose.com/slides/java/com.aspose.slides/charttype/) class. For other chart appearance settings, see [Chart Formatting](https://docs.aspose.com/slides/java/chart-formatting/).
## **Adjust the Gap Between Series**
Use [IChartSeriesGroup.setGapDepth](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseriesgroup/#setGapDepth-int-) to control the distance between data series along the depth axis of a 3D chart, expressed as a percentage of the marker width. Use values from **0 to 500**, inclusive: `0` removes the gap, while larger values increase the spacing. With a fixed chart depth, increasing the gap makes the markers thinner along the depth axis.
Access the group through [IChartSeries.getParentSeriesGroup](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#getParentSeriesGroup--). The setting applies to every series in that group, not just the series used to access it. [IChartSeries.getGapDepth](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#getGapDepth--) returns the depth gap and reflects the parent group's setting.
This setting affects 3D column and bar charts, including their cylinder, cone, and pyramid variants, as well as 3D line and area charts. The appearance depends on whether the series are arranged in depth, clustered, or stacked. For a clear comparison of gaps between separate series, use `ChartType.Column3D` from the [ChartType](https://reference.aspose.com/slides/java/com.aspose.slides/charttype/) class.
These methods control different aspects of the chart:
| Method | Effect |
| --- | --- |
| [IChartSeriesGroup.setGapDepth](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseriesgroup/#setGapDepth-int-) | Spacing between series along the depth axis, as a percentage of the marker width. |
| [IChartSeriesGroup.setGapWidth](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseriesgroup/#setGapWidth-int-) | Spacing between adjacent bar or column clusters, as a percentage of the bar or column width. |
| [setDepthPercents](https://reference.aspose.com/slides/java/com.aspose.slides/irotation3d/#setDepthPercents-int-) | Overall chart depth, as a percentage of the chart width. |
The following self-contained example uses the default chart data, which contains three series and four categories. It saves two presentations with identical data, rotation, gap width, and chart depth; only the gap depth changes.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Column3D, 40, 30, 620, 230);
chart.getRotation3D().setRotationX((byte) 20);
chart.getRotation3D().setRotationY(30);
chart.getRotation3D().setDepthPercents(100);
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
IChartSeriesGroup group = series.getParentSeriesGroup();
group.setGapWidth(150);
for (int gapDepth : new int[] { 0, 500 }) {
group.setGapDepth(gapDepth);
String fileName = "series_gap_depth_" + gapDepth + ".pptx";
presentation.save(fileName, SaveFormat.Pptx);
}
} finally {
presentation.dispose();
}
```
The following images illustrate the same gap depth settings in the equivalent .NET example and were exported using Microsoft PowerPoint.
| Gap depth: 0% | Gap depth: 500% |
| --- | --- |
|  |  |
## **FAQ**
**Which chart types support 3D mode in Aspose.Slides?**
Aspose.Slides supports 3D variants of column charts, including Column 3D, Clustered Column 3D, Stacked Column 3D, and 100% Stacked Column 3D, along with related 3D types exposed through the [ChartType](https://reference.aspose.com/slides/java/com.aspose.slides/charttype/) class. For an exact, up-to-date list, check the [ChartType](https://reference.aspose.com/slides/java/com.aspose.slides/charttype/) members in the API reference of your installed version.
**Can I get a raster image of a 3D chart for a report or the web?**
Yes. You can export a chart to an image with [Shape.getImage](https://reference.aspose.com/slides/java/com.aspose.slides/shape/#getImage--) or [render the entire slide](https://docs.aspose.com/slides/java/convert-powerpoint-to-png/) to formats like PNG or JPEG. This is useful when you need a raster preview or want to embed the chart into documents, dashboards, or web pages without requiring PowerPoint.
**How performant is building and rendering large 3D charts?**
Performance depends on data volume and visual complexity. For best results, keep 3D effects minimal, avoid heavy textures on walls and plot areas, limit the number of data points per series when possible, and render to an appropriately sized output (resolution and dimensions) to match the target display or print needs.
# Create 3D Effects in Presentations Using Java
> Apply and render 3D effects for PowerPoint shapes and text in Java with Aspose.Slides. Configure camera, lighting, material, extrusion, fills, and 3D text.
Source: https://docs.aspose.com/slides/java/3d-presentation/
Updated: 2026-09-25
## **Overview**
Aspose.Slides for Java can create, edit, preserve, and render PowerPoint-style 3D formatting for shapes and text. This article covers 3D effects such as rotation, extrusion, bevels, lighting, material, gradient or picture fills, and 3D text.
This article is about 3D formatting effects on PowerPoint shapes and text. It is not about inserting or editing standalone 3D model files. When you export a slide to an image, PDF, or HTML, Aspose.Slides renders those 3D effects into the exported 2D output.
## **3D Formatting Concepts**
Use the [IShape.getThreeDFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ishape/#getThreeDFormat--) method to apply 3D formatting to a shape. The method returns [IThreeDFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ithreedformat/), which controls the 3D scene for that shape.
For text, use the [ITextFrameFormat.getThreeDFormat](https://reference.aspose.com/slides/java/com.aspose.slides/itextframeformat/#getThreeDFormat--) method. This applies 3D formatting to the text frame instead of the shape body.
The most important API members are:
| API member | What it controls | When to use it |
|---|---|---|
| [getCamera](https://reference.aspose.com/slides/java/com.aspose.slides/ithreedformat/#getCamera--) | Viewpoint, preset camera type, rotation, zoom, and perspective. | Rotate the object in 3D space or match a PowerPoint 3D rotation preset. |
| [getLightRig](https://reference.aspose.com/slides/java/com.aspose.slides/ithreedformat/#getLightRig--) | Light preset, direction, and light rotation. | Change how highlights and shadows appear on the 3D surface. |
| [getMaterial](https://reference.aspose.com/slides/java/com.aspose.slides/ithreedformat/#getMaterial--) and [setMaterial](https://reference.aspose.com/slides/java/com.aspose.slides/ithreedformat/#setMaterial-int-) | Surface material, such as flat, matte, plastic, or metal. | Make the same geometry look flatter, softer, glossy, or metallic. |
| [getExtrusionHeight](https://reference.aspose.com/slides/java/com.aspose.slides/ithreedformat/#getExtrusionHeight--) and [setExtrusionHeight](https://reference.aspose.com/slides/java/com.aspose.slides/ithreedformat/#setExtrusionHeight-double-) | How far the shape extends backward from its front face. | Turn a flat shape into a visibly thick 3D object. |
| [getExtrusionColor](https://reference.aspose.com/slides/java/com.aspose.slides/ithreedformat/#getExtrusionColor--) | Color of the extruded sides. | Make depth visible or coordinate the side color with the front fill. |
| [getDepth](https://reference.aspose.com/slides/java/com.aspose.slides/ithreedformat/#getDepth--) and [setDepth](https://reference.aspose.com/slides/java/com.aspose.slides/ithreedformat/#setDepth-double-) | Additional 3D depth used by PowerPoint 3D formatting. | Fine-tune depth for shapes or text, especially together with bevel and material settings. |
| [getBevelTop](https://reference.aspose.com/slides/java/com.aspose.slides/ithreedformat/#getBevelTop--) and [getBevelBottom](https://reference.aspose.com/slides/java/com.aspose.slides/ithreedformat/#getBevelBottom--) | Raised or rounded edges on the front and back faces. | Add a softened or molded edge instead of a sharp flat face. |
| [getContourColor](https://reference.aspose.com/slides/java/com.aspose.slides/ithreedformat/#getContourColor--) and [getContourWidth](https://reference.aspose.com/slides/java/com.aspose.slides/ithreedformat/#getContourWidth--) and [setContourWidth](https://reference.aspose.com/slides/java/com.aspose.slides/ithreedformat/#setContourWidth-double-) | Outline around the 3D object. | Emphasize the object boundary in rendered output. |
## **Create a 3D Shape**
A shape usually needs four kinds of settings before it looks convincingly 3D:
- Camera settings, because the default front view may hide the extrusion.
- Light settings, because lighting makes the faces and sides readable.
- Material settings, because the surface affects how light is rendered.
- Extrusion or depth settings, because a flat shape needs thickness.
The following example creates a rectangle, adds text to its front face, and applies 3D formatting. The camera rotation values are in degrees, and the extrusion height is 100 points. The example renders the slide to a PNG image at twice its default dimensions and saves the presentation as PPTX.
```java
import com.aspose.slides.*;
import java.awt.Color;
final float imageScale = 2;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 200, 150, 200, 200);
shape.getTextFrame().setText("3D");
shape.getTextFrame().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setFontHeight(64);
shape.getFillFormat().setFillType(FillType.Solid);
shape.getFillFormat().getSolidFillColor().setColor(new Color(100, 149, 237));
shape.getThreeDFormat().getCamera().setCameraType(CameraPresetType.OrthographicFront);
shape.getThreeDFormat().getCamera().setRotation(20, 30, 40);
shape.getThreeDFormat().getLightRig().setLightType(LightRigPresetType.Flat);
shape.getThreeDFormat().getLightRig().setDirection(LightingDirection.Top);
shape.getThreeDFormat().setMaterial(MaterialPresetType.Flat);
shape.getThreeDFormat().setExtrusionHeight(100);
shape.getThreeDFormat().getExtrusionColor().setColor(Color.BLUE);
IImage thumbnail = slide.getImage(imageScale, imageScale);
try {
thumbnail.save("shape_3d.png", ImageFormat.Png);
} finally {
thumbnail.dispose();
}
presentation.save("shape_3d.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The rendered slide image shows the rectangle as a thick 3D block:

## **Rotate a Shape with the Camera**
In PowerPoint, 3D rotation is configured from the 3-D Rotation pane. The X, Y, and Z rotation values correspond to the rotation you set through the camera API.

In Aspose.Slides, access the camera through [IThreeDFormat.getCamera](https://reference.aspose.com/slides/java/com.aspose.slides/ithreedformat/#getCamera--). This example creates a rectangle, selects an orthographic front view, and sets its X, Y, and Z rotations to 20, 30, and 40 degrees, respectively. It configures the shape in memory without saving a file:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 200, 150, 200, 200);
shape.getThreeDFormat().getCamera().setCameraType(CameraPresetType.OrthographicFront);
shape.getThreeDFormat().getCamera().setRotation(20, 30, 40);
} finally {
presentation.dispose();
}
```
Use the camera when you need to change how the viewer sees the object. It does not change the 2D shape geometry on the slide. It changes the 3D viewpoint used by PowerPoint and by Aspose.Slides when rendering.
## **Add Extrusion and Depth**
Extrusion makes a shape look thick by extending it behind the front face. In PowerPoint, the depth control sets this visible thickness, and the color control sets the color of the side faces.

Use [IThreeDFormat.setExtrusionHeight](https://reference.aspose.com/slides/java/com.aspose.slides/ithreedformat/#setExtrusionHeight-double-) to set the thickness and [IThreeDFormat.getExtrusionColor](https://reference.aspose.com/slides/java/com.aspose.slides/ithreedformat/#getExtrusionColor--) to access the side color. This example gives a rectangle a 100-point extrusion with purple sides and rotates the camera to reveal its thickness. It configures the shape in memory without saving a file:
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 200, 150, 200, 200);
Color extrusionColor = new Color(128, 0, 128);
shape.getThreeDFormat().getCamera().setCameraType(CameraPresetType.OrthographicFront);
shape.getThreeDFormat().getCamera().setRotation(20, 30, 40);
shape.getThreeDFormat().getLightRig().setLightType(LightRigPresetType.Flat);
shape.getThreeDFormat().getLightRig().setDirection(LightingDirection.Top);
shape.getThreeDFormat().setMaterial(MaterialPresetType.Flat);
shape.getThreeDFormat().setExtrusionHeight(100);
shape.getThreeDFormat().getExtrusionColor().setColor(extrusionColor);
} finally {
presentation.dispose();
}
```
The [IThreeDFormat.setDepth](https://reference.aspose.com/slides/java/com.aspose.slides/ithreedformat/#setDepth-double-) method sets the depth of a 3D shape. The [setExtrusionHeight](https://reference.aspose.com/slides/java/com.aspose.slides/ithreedformat/#setExtrusionHeight-double-) method controls the height of the extrusion effect, as shown in this example.
## **Use Gradient or Picture Fills with 3D Effects**
3D formatting is independent of the shape fill. You can apply a solid color, gradient, pattern, or picture fill to the front face and still use the same camera, light, material, and extrusion settings.
This example applies a blue-to-orange gradient to the front face and a dark orange color to the 150-point extrusion. The gradient stops at 0 and 100 mark the start and end of the gradient. The camera rotation values are in degrees. The slide is rendered to a PNG image at twice its default dimensions:
```java
import com.aspose.slides.*;
import java.awt.Color;
final float imageScale = 2;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 200, 150, 250, 250);
shape.getTextFrame().setText("3D Gradient");
shape.getTextFrame().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setFontHeight(64);
shape.getFillFormat().setFillType(FillType.Gradient);
shape.getFillFormat().getGradientFormat().getGradientStops().add(0, Color.BLUE);
shape.getFillFormat().getGradientFormat().getGradientStops().add(100, new Color(255, 165, 0));
shape.getThreeDFormat().getCamera().setCameraType(CameraPresetType.OrthographicFront);
shape.getThreeDFormat().getCamera().setRotation(10, 20, 30);
shape.getThreeDFormat().getLightRig().setLightType(LightRigPresetType.Flat);
shape.getThreeDFormat().getLightRig().setDirection(LightingDirection.Top);
shape.getThreeDFormat().setMaterial(MaterialPresetType.Flat);
Color extrusionColor = new Color(255, 140, 0);
shape.getThreeDFormat().setExtrusionHeight(150);
shape.getThreeDFormat().getExtrusionColor().setColor(extrusionColor);
IImage thumbnail = slide.getImage(imageScale, imageScale);
try {
thumbnail.save("gradient_3d.png", ImageFormat.Png);
} finally {
thumbnail.dispose();
}
} finally {
presentation.dispose();
}
```
The rendered output keeps the gradient on the front face and renders the extrusion separately:

To use a picture fill instead, add the image to the presentation and assign it to the shape fill. This example requires an existing file named "image.jpg" in the working directory. It stretches the picture to fill the rectangle, applies a 150-point extrusion, and sets the camera rotation in degrees. It configures the shape in memory without saving or rendering a file:
```java
import com.aspose.slides.*;
import java.awt.Color;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 200, 150, 250, 250);
Path imagePath = Paths.get("image.jpg");
byte[] imageData = Files.readAllBytes(imagePath);
IPPImage image = presentation.getImages().addImage(imageData);
shape.getFillFormat().setFillType(FillType.Picture);
shape.getFillFormat().getPictureFillFormat().getPicture().setImage(image);
shape.getFillFormat().getPictureFillFormat().setPictureFillMode(PictureFillMode.Stretch);
Color extrusionColor = new Color(255, 140, 0);
shape.getThreeDFormat().getCamera().setCameraType(CameraPresetType.OrthographicFront);
shape.getThreeDFormat().getCamera().setRotation(10, 20, 30);
shape.getThreeDFormat().getLightRig().setLightType(LightRigPresetType.Flat);
shape.getThreeDFormat().getLightRig().setDirection(LightingDirection.Top);
shape.getThreeDFormat().setMaterial(MaterialPresetType.Flat);
shape.getThreeDFormat().setExtrusionHeight(150);
shape.getThreeDFormat().getExtrusionColor().setColor(extrusionColor);
} finally {
presentation.dispose();
}
```
The picture is rendered on the front face, while the extrusion is rendered as the 3D side surface:

## **Apply 3D Formatting to Text**
Shape 3D formatting affects the shape body. Text 3D formatting affects the text frame. This is useful for WordArt-like effects where the letters themselves need extrusion, material, lighting, and camera settings.
The following example creates text with an orange-and-white grid pattern, applies an upward arch, and configures 3D settings through [ITextFrameFormat.getThreeDFormat](https://reference.aspose.com/slides/java/com.aspose.slides/itextframeformat/#getThreeDFormat--). The extrusion height and depth are in points, and the light rotation is in degrees. The shape fill and outline are hidden so that only the text is visible. The example renders a PNG image at twice the default slide dimensions and saves the presentation as PPTX:
```java
import com.aspose.slides.*;
import java.awt.Color;
final float imageScale = 2;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 200, 150, 250, 250);
shape.getFillFormat().setFillType(FillType.NoFill);
shape.getLineFormat().getFillFormat().setFillType(FillType.NoFill);
shape.getTextFrame().setText("3D Text");
IPortion portion = shape.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0);
portion.getPortionFormat().getFillFormat().setFillType(FillType.Pattern);
Color patternColor = new Color(255, 140, 0);
portion.getPortionFormat().getFillFormat().getPatternFormat().getForeColor().setColor(patternColor);
portion.getPortionFormat().getFillFormat().getPatternFormat().getBackColor().setColor(Color.WHITE);
portion.getPortionFormat().getFillFormat().getPatternFormat().setPatternStyle(PatternStyle.LargeGrid);
shape.getTextFrame().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setFontHeight(128);
ITextFrameFormat textFrameFormat = shape.getTextFrame().getTextFrameFormat();
textFrameFormat.setTransform(TextShapeType.ArchUp);
textFrameFormat.getThreeDFormat().setExtrusionHeight(3.5f);
textFrameFormat.getThreeDFormat().setDepth(3);
textFrameFormat.getThreeDFormat().setMaterial(MaterialPresetType.Plastic);
textFrameFormat.getThreeDFormat().getLightRig().setDirection(LightingDirection.Top);
textFrameFormat.getThreeDFormat().getLightRig().setLightType(LightRigPresetType.Balanced);
textFrameFormat.getThreeDFormat().getLightRig().setRotation(0, 0, 40);
textFrameFormat.getThreeDFormat().getCamera().setCameraType(CameraPresetType.PerspectiveContrastingRightFacing);
IImage thumbnail = slide.getImage(imageScale, imageScale);
try {
thumbnail.save("text_3d.png", ImageFormat.Png);
} finally {
thumbnail.dispose();
}
presentation.save("text_3d.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The text is rendered as curved, extruded 3D lettering:

## **Keep Text Flat on a 3D Shape**
To keep text readable while preserving a shape's 3D appearance, call [ITextFrameFormat.setKeepTextFlat](https://reference.aspose.com/slides/java/com.aspose.slides/itextframeformat/#setKeepTextFlat-boolean-) through [ITextFrame.getTextFrameFormat](https://reference.aspose.com/slides/java/com.aspose.slides/itextframe/#getTextFrameFormat--). When the value is `true`, the text stays out of the 3D scene. When it is `false`, the text participates in the scene and follows its 3D orientation.
This setting does not remove the shape's 3D formatting: its camera, lighting, material, and extrusion remain configured through [IShape.getThreeDFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ishape/#getThreeDFormat--). It is also different from ordinary rotation. [IShape.setRotation](https://reference.aspose.com/slides/java/com.aspose.slides/ishape/#setRotation-float-) rotates the shape in the slide plane, while [ITextFrameFormat.setRotationAngle](https://reference.aspose.com/slides/java/com.aspose.slides/itextframeformat/#setRotationAngle-float-) controls the text's custom rotation within its bounding box. Keeping text out of the 3D scene does not reset either of those angles.
The following self-contained example creates a blue rectangle with text and clones it beside the original. Both shapes have the same 3D formatting; only the text setting differs: `false` on the left and `true` on the right. The camera angles are in degrees, and the extrusion height is 40 points. The example saves the presentation as PPTX and renders the comparison slide to PNG at twice its default dimensions.
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 70, 160, 240, 140);
shape.getTextFrame().setText("Readable text");
shape.getTextFrame().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setFontHeight(28);
shape.getTextFrame().getParagraphs().get_Item(0).getParagraphFormat().setAlignment(TextAlignment.Center);
shape.getTextFrame().getTextFrameFormat().setAnchoringType(TextAnchorType.Center);
shape.getFillFormat().setFillType(FillType.Solid);
shape.getFillFormat().getSolidFillColor().setColor(new Color(100, 149, 237));
shape.getThreeDFormat().getCamera().setCameraType(CameraPresetType.OrthographicFront);
shape.getThreeDFormat().getCamera().setRotation(30, 30, 0);
shape.getThreeDFormat().getLightRig().setLightType(LightRigPresetType.Flat);
shape.getThreeDFormat().getLightRig().setDirection(LightingDirection.Top);
shape.getThreeDFormat().setMaterial(MaterialPresetType.Flat);
shape.getThreeDFormat().setExtrusionHeight(40);
shape.getThreeDFormat().getExtrusionColor().setColor(new Color(65, 105, 225));
shape.getTextFrame().getTextFrameFormat().setKeepTextFlat(false);
IAutoShape flatTextShape = (IAutoShape) slide.getShapes().addClone(shape, 400, 160);
flatTextShape.getTextFrame().getTextFrameFormat().setKeepTextFlat(true);
presentation.save("keep_text_flat.pptx", SaveFormat.Pptx);
IImage image = slide.getImage(2, 2);
try {
image.save("keep_text_flat.png", ImageFormat.Png);
} finally {
image.dispose();
}
} finally {
presentation.dispose();
}
```
On the left, the text follows the 3D orientation. On the right, it stays flat and easier to read. Both rectangles retain the same visible extrusion and 3D orientation.

## **Export and Rendering Behavior**
Aspose.Slides preserves 3D formatting when saving to PowerPoint formats such as PPTX. When rendering or exporting to fixed-layout formats, the 3D scene is rasterized or drawn into the output as a 2D result. This applies when you render slides to [PNG](https://docs.aspose.com/slides/java/convert-powerpoint-to-png/), export to [PDF](https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf/), export to [HTML](https://docs.aspose.com/slides/java/convert-powerpoint-to-html/), or generate frames for [video conversion](https://docs.aspose.com/slides/java/convert-powerpoint-to-video/).
Keep these points in mind:
- Exported images and PDFs are not interactive. The object cannot be rotated by the viewer after export.
- The final appearance depends on the combination of camera, light rig, material, extrusion, fill, and slide scaling.
- If you need to inspect inherited or theme-based formatting values, read the [effective shape properties](https://docs.aspose.com/slides/java/shape-effective-properties/).
- Some output formats cannot store editable PowerPoint 3D formatting. In those formats, the visual result is rendered rather than preserved as editable 3D settings.
## **FAQ**
**Can Aspose.Slides create interactive 3D presentations?**
Aspose.Slides creates and renders PowerPoint 3D effects for shapes and text. It does not make exported images, PDFs, or HTML pages interactive 3D scenes that a viewer can rotate. In PPTX, the 3D formatting remains editable in PowerPoint where the format supports it.
**What is the difference between a 3D model and a 3D effect?**
A 3D model is a separate 3D object inserted into a presentation. A 3D effect is formatting applied to a regular PowerPoint shape or text, such as rotation, extrusion, bevel, lighting, and material. This article covers 3D effects.
**Which settings are required for a visible 3D shape?**
At minimum, set a camera rotation and either extrusion or depth. In practice, also set a light rig and material so the rendered faces have clear highlights and shadows.
**Can I apply 3D effects to both shapes and text?**
Yes. Use [IShape.getThreeDFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ishape/#getThreeDFormat--) for the shape body and [ITextFrameFormat.getThreeDFormat](https://reference.aspose.com/slides/java/com.aspose.slides/itextframeformat/#getThreeDFormat--) for text.
**Will 3D effects appear when exporting to images, PDF, HTML, or video frames?**
Yes. Aspose.Slides renders 3D effects when producing slide images, PDF output, HTML output, and frames used for video conversion. The exported output contains the rendered appearance, not an editable 3D object.
**Can I read the final 3D values after inheritance and theme settings are applied?**
Yes. Use the effective formatting APIs described in [Shape Effective Properties](https://docs.aspose.com/slides/java/shape-effective-properties/) to read final camera, light rig, bevel, and related 3D values.
# Access Presentation Slides in Java
> Learn how to access and manage slides in PowerPoint and OpenDocument presentations with Aspose.Slides for Java. Boost productivity with code examples.
Source: https://docs.aspose.com/slides/java/access-slide-in-presentation/
Updated: 2026-08-05
## **Overview**
This article explains how to access and manage slides in a presentation using Aspose.Slides. It shows how to retrieve slides by their zero-based index from the slides collection and how to access a slide by its unique ID using the `getSlideById` method.
You will also learn how to change a slide’s position by using the `setSlideNumber` method and how to define the starting slide number for a presentation with the `setFirstSlideNumber` method. The examples demonstrate loading a presentation, getting slide references, updating slide order or numbering, and saving the modified presentation.
## **Access a Slide by Index**
All slides in a presentation are arranged numerically based on the slide position starting from 0. The first slide is accessible through index 0; the second slide is accessed through index 1; etc.
The Presentation class, representing a presentation file, exposes all slides as an [ISlideCollection](https://reference.aspose.com/slides/java/com.aspose.slides/islidecollection/) collection (collection of [ISlide](https://reference.aspose.com/slides/java/com.aspose.slides/islide/) objects). This Java code shows you how to access a slide through its index:
```java
import com.aspose.slides.*;
// Instantiates a Presentation object that represents a presentation file
Presentation pres = new Presentation("demo.pptx");
try {
// Accesses a slide using its slide index
ISlide slide = pres.getSlides().get_Item(0);
} finally {
pres.dispose();
}
```
## **Access a Slide by ID**
Each slide in a presentation has a unique ID associated with it. You can use the [getSlideById](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#getSlideById-long-) method (exposed by the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class) to target that ID. This Java code shows you how to provide a valid slide ID and access that slide through the [getSlideById](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#getSlideById-long-) method:
```java
import com.aspose.slides.*;
// Instantiates a Presentation object that represents a presentation file
Presentation pres = new Presentation("demo.pptx");
try {
// Gets a slide ID
int id = (int) pres.getSlides().get_Item(0).getSlideId();
// Accesses the slide through its ID
IBaseSlide slide = pres.getSlideById(id);
} finally {
pres.dispose();
}
```
## **Change the Slide Position**
Aspose.Slides allow you to change a slide position. For example, you can specify that the first slide should become the second slide.
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class.
1. Get the slide's reference (whose position you want to change) through its index
1. Set a new position for the slide through the [setSlideNumber](https://reference.aspose.com/slides/java/com.aspose.slides/islide/#setSlideNumber-int-) property.
1. Save the modified presentation.
This Java code demonstrates an operation in which the slide in position 1 is moved to position 2:
```java
import com.aspose.slides.*;
// Instantiates a Presentation object that represents a presentation file
Presentation pres = new Presentation("Presentation.pptx");
try {
// Gets the slide whose position will be changed
ISlide sld = pres.getSlides().get_Item(0);
// Sets the new position for the slide
sld.setSlideNumber(2);
// Saves the modified presentation
pres.save("helloworld_Pos.pptx", SaveFormat.Pptx);
} finally {
pres.dispose();
}
```
The first slide became the second; the second slide became the first. When you change a slide's position, other slides are automatically adjusted.
## **Set the Slide Number**
Using the [setFirstSlideNumber](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#setFirstSlideNumber-int-) property (exposed by the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class), you can specify a new number for the first slide in a presentation. This operation causes other slide numbers to be recalculated.
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class.
1. Get the slide number.
1. Set the slide number.
1. Save the modified presentation.
This Java code demonstrates an operation where the first slide number is set to 10:
```java
import com.aspose.slides.*;
// Instantiates a Presentation object that represents a presentation file
Presentation pres = new Presentation("HelloWorld.pptx");
try {
// Gets the slide number
int firstSlideNumber = pres.getFirstSlideNumber();
// Sets the slide number
pres.setFirstSlideNumber(10);
// Saves the modified presentation
pres.save("Set_Slide_Number_out.pptx", SaveFormat.Pptx);
} finally {
pres.dispose();
}
```
If you prefer to skip the first slide, you can start the numbering from the second slide (and hide the numbering for the first slide) this way:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ILayoutSlide layoutSlide = presentation.getLayoutSlides().getByType(SlideLayoutType.Blank);
presentation.getSlides().addEmptySlide(layoutSlide);
presentation.getSlides().addEmptySlide(layoutSlide);
presentation.getSlides().addEmptySlide(layoutSlide);
// Sets the number for the first presentation slide
presentation.setFirstSlideNumber(0);
// Shows slide numbers for all slides
presentation.getHeaderFooterManager().setAllSlideNumbersVisibility(true);
// Hides the slide number for the first slide
presentation.getSlides().get_Item(0).getHeaderFooterManager().setSlideNumberVisibility(false);
// Saves the modified presentation
presentation.save("output.pptx", SaveFormat.Pptx);
} finally {
if (presentation != null) presentation.dispose();
}
```
## **FAQ**
### Does the slide number a user sees match the collection’s zero-based index?
The number shown on a slide can start from an arbitrary value (e.g., 10) and does not have to match the index; the relationship is controlled by the presentation’s [first slide number](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#setFirstSlideNumber-int-) setting.
### Do hidden slides affect indexing?
Yes. A hidden slide remains in the collection and is counted in indexing; "hidden" refers to display, not its position in the collection.
### Does a slide’s index change when other slides are added or removed?
Yes. Indexes always reflect the current order in slides and are recalculated upon insert, delete, and move operations.
# Manage ActiveX Controls in Presentations Using Java
> Learn how Aspose.Slides for Java leverages ActiveX to automate and enhance PowerPoint presentations, giving developers powerful control over slides.
Source: https://docs.aspose.com/slides/java/activex/
Updated: 2026-08-13
## **Introduction**
ActiveX controls are used in presentations. Aspose.Slides for Java allows you to add and manage ActiveX controls, but they are a bit trickier to manage when compared to normal presentation shapes. We implemented support for adding Media Player Active control in Aspose.Slides. Note that ActiveX controls are not shapes; they are not part of the presentation's [IShapeCollection](https://reference.aspose.com/slides/java/com.aspose.slides/ishapecollection/). They are part of the separate [IControlCollection](https://reference.aspose.com/slides/java/com.aspose.slides/icontrolcollection/) instead. In this topic, we will show you how to work with them.
## **Add a Media Player ActiveX Control to a Slide**
To add an ActiveX Media Player control, do this:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation) class and generate an empty presentation instance.
1. Access the target slide in [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation).
1. Add the Media Player ActiveX control using the [addControl](https://reference.aspose.com/slides/java/com.aspose.slides/IControlCollection#addControl-int-float-float-float-float-) method exposed by [IControlCollection](https://reference.aspose.com/slides/java/com.aspose.slides/icontrolcollection/).
1. Access the Media Player ActiveX control and set the video path by using its properties.
1. Save the presentation as a PPTX file.
This sample code, based on the steps above, shows to how to add Media Player ActiveX Control to a slide:
```java
import com.aspose.slides.*;
// Create empty presentation instance
Presentation pres = new Presentation();
try {
// Adding the Media Player ActiveX control
pres.getSlides().get_Item(0).getControls().addControl(ControlType.WindowsMediaPlayer, 100, 100, 400, 400);
// Access the Media Player ActiveX control and set the video path
pres.getSlides().get_Item(0).getControls().get_Item(0).getProperties().set_Item("URL", "Wildlife.wmv");
// Save the Presentation
pres.save("Output.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
## **Modify an ActiveX Control**
Aspose.Slides for Java 7.1.0 and newer versions are equipped with components for managing ActiveX controls. You can access the already added ActiveX control in your presentation and modify or delete it through its properties.
To manage a simple ActiveX control like a text box and simple command button on a slide, do this:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation) class and load the presentation with ActiveX controls in it.
1. Obtain a slide reference by its index.
1. Access the ActiveX controls in the slide by accessing the [IControlCollection](https://reference.aspose.com/slides/java/com.aspose.slides/icontrolcollection/).
1. Access the TextBox1 ActiveX control using the [IControl](https://reference.aspose.com/slides/java/com.aspose.slides/icontrol/) object.
1. Change the properties of the TextBox1 ActiveX control that include text, font, font height, and frame position.
1. Access the second access control called CommandButton1.
1. Change the button caption, font, and position.
1. Shift the position of the ActiveX controls frames.
1. Write the modified presentation to a PPTX file.
This sample code, based on the steps above, shows how to manage a simple ActiveX control:
```java
import com.aspose.slides.*;
import java.awt.FontMetrics;
import java.awt.SystemColor;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
// Accessing the presentation with ActiveX controls
Presentation pres = new Presentation("ActiveX.pptm");
try {
// Accessing the first slide in presentation
ISlide slide = pres.getSlides().get_Item(0);
// changing TextBox text
IControl control = slide.getControls().get_Item(0);
if (control.getName().equalsIgnoreCase("TextBox1") && control.getProperties() != null) {
String newText = "Changed text";
control.getProperties().set_Item("Value", newText);
// Changing substitute image. PowerPoint will replace this image during activeX activation,
// so sometime it's OK to leave image unchanged.
BufferedImage image = new BufferedImage((int) control.getFrame().getWidth(), (int) control.getFrame().getHeight(),
BufferedImage.TYPE_INT_ARGB);
java.awt.Graphics graphics = image.getGraphics();
graphics.setColor(SystemColor.window);
graphics.fillRect(0, 0, image.getWidth(), image.getHeight());
java.awt.Font font = new java.awt.Font(control.getProperties().get_Item("FontName"), java.awt.Font.PLAIN, 16);
graphics.setColor(SystemColor.windowText);
graphics.setFont(font);
graphics.drawString(newText, 10, 20);
graphics.setColor(SystemColor.controlShadow);
graphics.drawLine(0, image.getHeight() - 1, 0, 0);
graphics.drawLine(0, 0, image.getWidth() - 1, 0);
graphics.setColor(SystemColor.controlDkShadow);
graphics.drawLine(1, image.getHeight() - 2, 1, 1);
graphics.drawLine(1, 1, image.getWidth() - 2, 1);
graphics.setColor(SystemColor.controlHighlight);
graphics.drawLine(1, image.getHeight() - 1, image.getWidth() - 1, image.getHeight() - 1);
graphics.drawLine(image.getWidth() - 1, image.getHeight() - 1, image.getWidth() - 1, 1);
graphics.setColor(SystemColor.controlLtHighlight);
graphics.drawLine(0, image.getHeight(), image.getWidth(), image.getHeight());
graphics.drawLine(image.getWidth(), image.getHeight(), image.getWidth(), 0);
graphics.dispose();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, "PNG", baos);
control.getSubstitutePictureFormat().getPicture().setImage(pres.getImages().addImage(baos.toByteArray()));
}
// Changing Button caption
control = pres.getSlides().get_Item(0).getControls().get_Item(1);
if (control.getName().equalsIgnoreCase("CommandButton1") && control.getProperties() != null) {
String newCaption = "Show MessageBox";
control.getProperties().set_Item("Caption", newCaption);
// Changing substitute
BufferedImage image = new BufferedImage((int) control.getFrame().getWidth(), (int) control.getFrame().getHeight(),
BufferedImage.TYPE_INT_ARGB);
java.awt.Graphics graphics = image.getGraphics();
graphics.setColor(SystemColor.control);
graphics.fillRect(0, 0, image.getWidth(), image.getHeight());
java.awt.Font font = new java.awt.Font(control.getProperties().get_Item("FontName"), java.awt.Font.PLAIN, 16);
graphics.setColor(SystemColor.windowText);
graphics.setFont(font);
FontMetrics metrics = graphics.getFontMetrics(font);
graphics.drawString(newCaption, (image.getWidth() - metrics.stringWidth(newCaption)) / 2, 20);
graphics.setColor(SystemColor.controlLtHighlight);
graphics.drawLine(0, image.getHeight() - 1, 0, 0);
graphics.drawLine(0, 0, image.getWidth() - 1, 0);
graphics.setColor(SystemColor.controlHighlight);
graphics.drawLine(1, image.getHeight() - 2, 1, 1);
graphics.drawLine(1, 1, image.getWidth() - 2, 1);
graphics.setColor(SystemColor.controlShadow);
graphics.drawLine(1, image.getHeight() - 1, image.getWidth() - 1, image.getHeight() - 1);
graphics.drawLine(image.getWidth() - 1, image.getHeight() - 1, image.getWidth() - 1, 1);
graphics.setColor(SystemColor.controlDkShadow);
graphics.drawLine(0, image.getHeight(), image.getWidth(), image.getHeight());
graphics.drawLine(image.getWidth(), image.getHeight(), image.getWidth(), 0);
graphics.dispose();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, "PNG", baos);
control.getSubstitutePictureFormat().getPicture().setImage(pres.getImages().addImage(baos.toByteArray()));
}
// moving 100 points down
for (IControl ctl : pres.getSlides().get_Item(0).getControls()) {
IShapeFrame frame = ctl.getFrame();
ctl.setFrame(new ShapeFrame(frame.getX(), frame.getY() + 100,
frame.getWidth(), frame.getHeight(), frame.getFlipH(), frame.getFlipV(), frame.getRotation()));
}
pres.save("withActiveX-edited_java.pptm", SaveFormat.Pptm);
// removing controls
pres.getSlides().get_Item(0).getControls().clear();
pres.save("withActiveX-cleared_java.pptm", SaveFormat.Pptm);
} catch(IOException e) {
} finally {
if (pres != null) pres.dispose();
}
```
## **FAQ**
### Does Aspose.Slides preserve ActiveX controls when reading and re-saving if they cannot be executed in the Java runtime?
Yes. Aspose.Slides treats them as part of the presentation and can read/modify their properties and frames; executing the controls themselves is not required to preserve them.
### How do ActiveX controls differ from OLE objects in a presentation?
ActiveX controls are interactive managed controls (buttons, text boxes, media player), whereas [OLE](https://docs.aspose.com/slides/java/manage-ole/) refers to embedded application objects (for example, an Excel worksheet). They are stored and handled differently and have different property models.
### Do ActiveX events and VBA macros work if the file has been modified by Aspose.Slides?
Aspose.Slides preserves the existing markup and metadata; however, events and macros run only inside PowerPoint on Windows when security allows it. The library does not execute VBA.
## Related articles
- [ActiveX](https://docs.aspose.com/slides/java/examples/elements/activex/)
# Add Slides to Presentations in Java
> Easily add slides to your PowerPoint and OpenDocument presentations using Aspose.Slides for Java—seamless, efficient slide insertion in seconds.
Source: https://docs.aspose.com/slides/java/add-slide-to-presentation/
Updated: 2026-08-05
## **Overview**
Aspose.Slides allows you to add slides to PowerPoint presentations programmatically. A presentation contains master/layout slides and normal slides, and normal slides are arranged by a zero-based index. Each slide has a unique ID, and presentation files without slides are not supported.
This article explains how to create a `Presentation` object, access its slide collection, add an empty slide, work with the newly added slide, and save the updated presentation. It also covers related points such as inserting slides at a specific position, using layouts, and understanding the blank slide that exists in a newly created presentation.
## **Add a Slide to a Presentation**
Before talking about adding slides to the presentation files, let us discuss some facts about the slides. Each PowerPoint presentation file contains **Master / Layout** slide and other **Normal** slides. It means that a presentation file contains at least one or more slides. It is important to know that presentation files without slides are not supported by Aspose.Slides for Java. Each slide has a unique Id and all the Normal Slides are arranged in an order specified by the zero-based index.
Aspose.Slides for Java allows developers to add empty slides to their presentation. To add an empty slide in the presentation, please follow the steps below:
- Create an instance of [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation) class.
- Instantiate [ISlideCollection](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection) class by setting a reference to the [Slides](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation#getSlides--) (collection of content Slide objects) property exposed by the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation) object.
- Add an empty slide to the presentation at the end of the content slides collection by calling the [**addEmptySlide**](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection#addEmptySlide-com.aspose.slides.ILayoutSlide-) methods exposed by [ISlideCollection](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection) object.
- Do some work with the newly added empty slide.
- Finally, write the presentation file using the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation) object.
```java
import com.aspose.slides.*;
// Instantiate Presentation class that represents the presentation file
Presentation pres = new Presentation();
try {
// Instantiate SlideCollection calss
ISlideCollection slds = pres.getSlides();
for (int i = 0; i < pres.getLayoutSlides().size(); i++) {
// Add an empty slide to the Slides collection
slds.addEmptySlide(pres.getLayoutSlides().get_Item(i));
}
// Do some work on the newly added slide
// Save the PPTX file to the Disk
pres.save("EmptySlide.pptx", SaveFormat.Pptx);
} finally {
pres.dispose();
}
```
## **FAQ**
### Can I insert a new slide at a specific position, not just at the end?
Yes. The library supports slide collections and [insert](https://reference.aspose.com/slides/java/com.aspose.slides/slidecollection/#insertEmptySlide-int-com.aspose.slides.ILayoutSlide-)/[clone](https://reference.aspose.com/slides/java/com.aspose.slides/slidecollection/#insertClone-int-com.aspose.slides.ISlide-com.aspose.slides.ILayoutSlide-) operations, so you can add a slide at the required index rather than only at the end.
### Are the theme/styles preserved when adding a slide based on a layout?
Yes. A layout inherits formatting from its master, and the new slide inherits from the selected layout and its associated master.
### Which slide is present in a new "empty" presentation before adding slides?
A newly created presentation already contains one blank slide with index zero. This is important to consider when calculating insertion indices.
### How do I choose the "right" layout for a new slide if the master has many options?
Generally choose the [LayoutSlide](https://reference.aspose.com/slides/java/com.aspose.slides/layoutslide/) that matches the required structure ([Title and Content, Two Content, etc.](https://reference.aspose.com/slides/java/com.aspose.slides/slidelayouttype/)). If such a layout is missing, you can [add it to the master](https://docs.aspose.com/slides/java/slide-layout/) and then use it.
# Adding Text Dynamically Using VSTO and Aspose.Slides for Java
> See how to migrate from Microsoft Office automation to Aspose.Slides for Java and add dynamic text to PowerPoint (PPT, PPTX) presentations in Java.
Source: https://docs.aspose.com/slides/java/adding-text-dynamically-using-vsto-and-aspose-slides-for-java/
Updated: 2026-08-13
A common task that developers are developers to accomplish is adding text to slides dynamically. This article shows code examples for adding text dynamically using [VSTO](https://docs.aspose.com/slides/java/adding-text-dynamically-using-vsto-and-aspose-slides-for-java/) and [Aspose.Slides for Java](https://docs.aspose.com/slides/java/adding-text-dynamically-using-vsto-and-aspose-slides-for-java/).
## **Adding Text Dynamically**
Both methods follow these steps:
1. Create a presentation.
1. Add a blank slide.
1. Add a text box.
1. Set some text.
1. Write the presentation.
## **VSTO Code Example**
The code snippets below results in a presentation with a plain slide and a string of text on it.
**The presentation as created in VSTO**

```csharp
//Note: PowerPoint is a namespace which has been defined above like this
//using PowerPoint = Microsoft.Office.Interop.PowerPoint;
//Create a presentation
PowerPoint.Presentation pres = Globals.ThisAddIn.Application
.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoFalse);
//Get the blank slide layout
PowerPoint.CustomLayout layout = pres.SlideMaster.
CustomLayouts[7];
//Add a blank slide
PowerPoint.Slide sld = pres.Slides.AddSlide(1, layout);
//Add a text
PowerPoint.Shape shp = sld.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, 150, 100, 400, 100);
//Set a text
PowerPoint.TextRange txtRange = shp.TextFrame.TextRange;
txtRange.Text = "Text added dynamically";
txtRange.Font.Name = "Arial";
txtRange.Font.Bold = Microsoft.Office.Core.MsoTriState.msoTrue;
txtRange.Font.Size = 32;
//Write the output to disk
pres.SaveAs("c:\\outVSTO.ppt",
PowerPoint.PpSaveAsFileType.ppSaveAsPresentation,
Microsoft.Office.Core.MsoTriState.msoFalse);
```
[Source: Examples-CSharp-VSTO-AddTextBoxVSTO-AddTextBoxVSTO.cs](https://gist.githubusercontent.com/aspose-com-gists/a56eda38c01ad33dc653116c7bae4293/raw/60f36b65dcdc5f7368b2d455fe1ae74076eeae08/Examples-CSharp-VSTO-AddTextBoxVSTO-AddTextBoxVSTO.cs)
## **Aspose.Slides for Java Example**
The code snippets below use Aspose.Slides to create a presentation with a plain slide and a string of text on it.
**The presentation as created using Aspose.Slides for Java**

```java
//Create a presentation
Presentation pres = new Presentation();
//Blank slide is added by default, when you create
//presentation from default constructor
//So, we don't need to add any blank slide
ISlide sld = pres.getSlides().get_Item(1);
//Add a textbox
//To add it, we will first add a rectangle
IShape shp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 1200, 800, 3200, 370);
//Hide its line
shp.getLineFormat().setStyle(LineStyle.NotDefined);
//Then add a textframe inside it
ITextFrame tf = ((IAutoShape)shp).getTextFrame();
//Set a text
tf.setText("Text added dynamically");
IPortion port = tf.getParagraphs().get_Item(0).getPortions().get_Item(0);
port.getPortionFormat().setFontBold(NullableBool.True);
port.getPortionFormat().setFontHeight(32);
//Write the output to disk
pres.save("c:\\data\\outAsposeSlides.pptx",SaveFormat.Pptx);
```
[Source: Examples-src-main-java-com-aspose-slides-examples-Text-AddTextBox-AddTextBox.java](https://gist.githubusercontent.com/aspose-com-gists/1f55f0222bc39a382d831900e8de7400/raw/fa5f3d943772a7657d3f0d9cba4b39a80ae73f27/Examples-src-main-java-com-aspose-slides-examples-Text-AddTextBox-AddTextBox.java)
## Related articles
- [Creating Tables Using VSTO and Aspose.Slides for Java](https://docs.aspose.com/slides/java/creating-a-table-on-powerpoint-slide/)
- [Format Text Using VSTO and Aspose.Slides for Java](https://docs.aspose.com/slides/java/format-text-using-vsto-and-aspose-slides-for-java/)
- [Migration from Microsoft Office Automation to Aspose.Slides for Java](https://docs.aspose.com/slides/java/migration-from-microsoft-office-automation-to-aspose/)
# AI Features in Aspose.Slides
> Explore AI features in Aspose.Slides for Java to generate, analyze, and enhance presentations in Java, with guides for PowerPoint and OpenDocument formats.
Source: https://docs.aspose.com/slides/java/ai/
Updated: 2025-09-15
---
lastmod: 2025-09-15T09:30:49+06:00
title: AI Features in Aspose.Slides
linktitle: AI
type: docs
weight: 40
url: /java/ai/
keywords:
- AI features
- AI presentation translator
- AI presentation generator
- AI slide translator
- AI slide generator
- multilingual presentation
- multilingual slide
- PowerPoint
- OpenDocument
- presentation
- Java
- Aspose.Slides
description: "Explore AI features in Aspose.Slides for Java to generate, analyze, and enhance presentations in Java, with guides for PowerPoint and OpenDocument formats."
---
# AI-Powered Multilingual Slide Generator
> Generate multilingual slides from text with Aspose.Slides for Java. Apply your template and export polished decks to PowerPoint and OpenDocument. Learn more.
Source: https://docs.aspose.com/slides/java/ai/generator/
Updated: 2026-08-05
## **Introduction**
Aspose.Slides introduces a new AI-powered feature, the Presentation Generator, which enables developers to automatically create well-structured PowerPoint presentations from simple text inputs such as topic descriptions, summaries, quotations, or bullet points.
Users can adjust the level of content detail and optionally apply a custom presentation template to define the visual design.
Currently, the AI Presentation Generator structures content using text blocks, bullet lists, and tables. Image generation is not yet supported; however, images can be easily added afterward using Aspose.Slides tools or manually.
The output is a complete PowerPoint presentation that can be used as-is or exported to any format supported by the Aspose.Slides API. While the generator produces high-quality results, minor post-editing may be required to meet specific requirements.
## **How It Works**
Aspose.Slides does not include built-in AI models; instead, it integrates with external AI services over the internet. This integration is handled by the [SlidesAIAgent](https://reference.aspose.com/slides/java/com.aspose.slides/slidesaiagent/) class, which uses an implementation of the [IAIWebClient](https://reference.aspose.com/slides/java/com.aspose.slides/iaiwebclient/) interface to communicate with the AI model.
You can use the built-in [OpenAIWebClient](https://reference.aspose.com/slides/java/com.aspose.slides/openaiwebclient/), which connects to OpenAI’s API, or provide a custom implementation of [IAIWebClient](https://reference.aspose.com/slides/java/com.aspose.slides/iaiwebclient/) to work with another AI provider or language model. Aspose.Slides manages all communication with the AI service and processes the AI’s responses to generate slides. Note that the OpenAI API is a paid service, so an account and API key are required when using the built-in [OpenAIWebClient](https://reference.aspose.com/slides/java/com.aspose.slides/openaiwebclient/).
## **Let's Code**
### **Example 1**
This example demonstrates how to generate a presentation on the topic Aspose.Slides using the built-in [OpenAIWebClient](https://reference.aspose.com/slides/java/com.aspose.slides/openaiwebclient/).
```java
import com.aspose.slides.*;
// Create an instance of OpenAIWebClient, the built-in implementation of the OpenAI web client.
OpenAIWebClient aiWebClient = new OpenAIWebClient("gpt-4o-mini", "apiKey", null);
try {
// Create an instance of SlidesAIAgent, which provides access to AI-powered features.
var aiAgent = new SlidesAIAgent(aiWebClient);
// Define the instruction for generating the presentation.
var instruction = "Generate a presentation about Aspose.Slides for Java, highlighting its capabilities and advantages over competitors.";
// Generate a presentation with a medium amount of content based on the instruction.
IPresentation presentation = aiAgent.generatePresentation(instruction, PresentationContentAmountType.Medium);
try {
// Save the generated presentation to the local disk as a PowerPoint (.pptx) file.
presentation.save("Aspose.Slides.Java.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
} finally {
aiWebClient.close();
}
```
### **Example 2**
The following example demonstrates the overloads of the [generatePresentation](https://reference.aspose.com/slides/java/com.aspose.slides/slidesaiagent/#generatePresentation-java.lang.String-int-) method. In this case, an externally managed [HttpURLConnection](https://docs.oracle.com/javase/8/docs/api/java/net/HttpURLConnection.html) instance and the user’s `master presentation` are used.
By default, the built-in [OpenAIWebClient](https://reference.aspose.com/slides/java/com.aspose.slides/openaiwebclient/) creates and manages its own internal [HttpURLConnection](https://docs.oracle.com/javase/8/docs/api/java/net/HttpURLConnection.html) instance, handling its lifecycle automatically. However, if you prefer to manage the [HttpURLConnection](https://docs.oracle.com/javase/8/docs/api/java/net/HttpURLConnection.html) yourself—for example, when using an [URLStreamHandlerFactory](https://docs.oracle.com/javase/8/docs/api/java/net/URLStreamHandlerFactory.html) or [HttpClient](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html) for improved resource management and performance—you can supply your own [HttpURLConnection](https://docs.oracle.com/javase/8/docs/api/java/net/HttpURLConnection.html) instance when constructing the [OpenAIWebClient](https://reference.aspose.com/slides/java/com.aspose.slides/openaiwebclient/).
```java
import com.aspose.slides.*;
import java.net.HttpURLConnection;
import java.net.URL;
// Create and configure the HttpURLConnection yourself.
HttpURLConnection urlConnection = (HttpURLConnection) new URL("https://api.openai.com/v1/chat/completions").openConnection();
// Pass the HttpURLConnection to the OpenAIWebClient constructor.
OpenAIWebClient aiWebClient = new OpenAIWebClient("gpt-4o-mini", "apiKey", "organizationId", urlConnection);
try {
// Create an instance of SlidesAIAgent.
var aiAgent = new SlidesAIAgent(aiWebClient);
// Define the instruction for generating the presentation.
var instruction = "Generate a presentation about Aspose.Slides for Java, highlighting its capabilities and advantages over competitors.";
// Load a master presentation from the local disk to use as the design template.
Presentation masterPresentation = new Presentation("masterPresentation.pptx");
// Generate a detailed presentation using the instruction and master template.
IPresentation presentation = aiAgent.generatePresentation(instruction, PresentationContentAmountType.Detailed, masterPresentation);
try {
// Save the generated presentation as a PDF.
presentation.save("Aspose.Slides.Java.pdf", SaveFormat.Pdf);
} finally {
presentation.dispose();
masterPresentation.dispose();
}
} finally {
aiWebClient.close();
}
```
## **Key Benefits**
The new AI Presentation Generator in Aspose.Slides provides a fast and flexible way to produce structured slide decks from simple text prompts. With support for custom templates and externally managed [HttpURLConnection](https://docs.oracle.com/javase/8/docs/api/java/net/HttpURLConnection.html) instances, it can be seamlessly integrated into a wide range of applications.
Typical use cases include creating marketing presentations, educational materials, client reports, and internal slide decks. Although image generation is not yet supported, the tool already offers a strong foundation for automating presentation creation, with further enhancements expected in the future.
## Related articles
- [AI-Powered Presentation Translator](https://docs.aspose.com/slides/java/ai/translator/)
# AI-Powered Presentation Translator
> Translate PowerPoint slides with AI using Aspose.Slides for Java. Localize PPT, PPTX and ODP while preserving layout—fast and developer-friendly. Try it.
Source: https://docs.aspose.com/slides/java/ai/translator/
Updated: 2026-09-15
## **Introduction**
Aspose.Slides is a powerful API for programmatically managing PowerPoint presentations. In addition to creating, editing, and converting slides, it offers AI-driven features - such as the Presentation Translation API for multilingual slide content.
## **How It Works**
Aspose.Slides does not include built-in AI capabilities but integrates with external AI models over the internet. This functionality is exposed via the [SlidesAIAgent](https://reference.aspose.com/slides/java/com.aspose.slides/slidesaiagent/) class, which uses an implementation of the [IAIWebClient](https://reference.aspose.com/slides/java/com.aspose.slides/iaiwebclient/) interface to communicate with AI services.
You can use the built-in [OpenAIWebClient](https://reference.aspose.com/slides/java/com.aspose.slides/openaiwebclient/) to connect to OpenAI’s API or implement your own [IAIWebClient](https://reference.aspose.com/slides/java/com.aspose.slides/iaiwebclient/) to use a different AI provider or language model.
Aspose.Slides handles the communication, parses the AI responses, and intelligently inserts translated content while preserving the original slide layout and formatting.
Note that the OpenAI API is a paid service, so you will need to create an account and supply your API key when using the built-in [OpenAIWebClient](https://reference.aspose.com/slides/java/com.aspose.slides/openaiwebclient/).
## **Example**
In this example, we translate a PowerPoint presentation into Japanese using the built-in [OpenAIWebClient](https://reference.aspose.com/slides/java/com.aspose.slides/openaiwebclient/) with a specified OpenAI [model](https://platform.openai.com/docs/models).
```java
import com.aspose.slides.*;
// Load a presentation to translate.
Presentation presentation = new Presentation("sample.pptx");
// Create an AI client with OpenAIWebClient, specifying your model and API key.
OpenAIWebClient aiWebClient = new OpenAIWebClient("gpt-4o-mini", "apiKey", null);
try {
// Initialize SlidesAIAgent with the AI client.
SlidesAIAgent aiAgent = new SlidesAIAgent(aiWebClient);
// Translate the presentation to Japanese.
aiAgent.translate(presentation, "japanese");
// Save the translated presentation as a PDF.
presentation.save("sample_jp.pdf", SaveFormat.Pdf);
} finally {
aiWebClient.close();
presentation.dispose();
}
```
By default, the built-in [OpenAIWebClient](https://reference.aspose.com/slides/java/com.aspose.slides/openaiwebclient/) creates and manages its own internal [HttpURLConnection](https://docs.oracle.com/javase/8/docs/api/java/net/HttpURLConnection.html) instance, handling its lifecycle automatically. However, if you prefer to manage the [HttpURLConnection](https://docs.oracle.com/javase/8/docs/api/java/net/HttpURLConnection.html) yourself — primarily to configure essential settings like a proxy, or to use a [URLStreamHandlerFactory](https://docs.oracle.com/javase/8/docs/api/java/net/URLStreamHandlerFactory.html) or a different [HttpClient](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html) for better resource management and performance — you can provide your own `HttpURLConnection` instance when constructing the [OpenAIWebClient](https://reference.aspose.com/slides/java/com.aspose.slides/openaiwebclient/).
```java
import com.aspose.slides.*;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
// Configure an HttpURLConnection instance yourself (custom timeouts, proxy settings, etc.).
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxy.example.com", 8080));
HttpURLConnection urlConnection = (HttpURLConnection)new URL("https://api.openai.com/v1/chat/completions").openConnection(proxy);
urlConnection.setConnectTimeout(30000);
urlConnection.setReadTimeout(60000);
OpenAIWebClient aiWebClient = new OpenAIWebClient("gpt-4o-mini", "apiKey", null, urlConnection);
```
### **Azure OpenAI Example**
You can configure the translator to use your Azure OpenAI deployment with the [OpenAICompatibleWebClient](https://reference.aspose.com/slides/java/com.aspose.slides/openaicompatiblewebclient/).
```java
import com.aspose.slides.*;
String model = "your-azure-deployment-name";
String apiKey = "your-azure-api-key";
String baseUrl = "https://your-resource.openai.azure.com/openai/v1/";
OpenAICompatibleWebClient aiWebClient = new OpenAICompatibleWebClient(model, apiKey, baseUrl);
try {
SlidesAIAgent aiAgent = new SlidesAIAgent(aiWebClient);
Presentation presentation = new Presentation("Presentation.pptx");
try {
aiAgent.translate(presentation, "spanish");
presentation.save("Translated.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
} finally {
aiWebClient.dispose();
}
```
This snippet demonstrates translating a presentation using your Azure OpenAI endpoint. Replace the placeholder values with your deployment name, API key, and endpoint URL.
## **Key Benefits**
The Aspose.Slides Presentation Translation API offers an AI-powered solution for delivering multilingual PowerPoint presentations. By automating translation while preserving layout and design, it saves time and minimizes errors compared to manual workflows. Whether you're a developer, educator, or business professional, this API enables you to create engaging, localized presentations for global audiences - expanding your reach and improving communication.
## Related articles
- [AI-Powered Multilingual Slide Generator](https://docs.aspose.com/slides/java/ai/generator/)
# Animate PowerPoint Charts in Java
> Create stunning animated charts in Java with Aspose.Slides. Boost presentations with dynamic visuals in PPT and PPTX files—get started now.
Source: https://docs.aspose.com/slides/java/animated-charts/
Updated: 2026-11-08
## **Introduction**
Aspose.Slides for Java supports animating the chart elements. **Series**, **Categories**, **Series Elements**, **Categories Elements** can be animated with [ISequence.addEffect](https://reference.aspose.com/slides/java/com.aspose.slides/ISequence#addEffect-com.aspose.slides.IChart-int-int-int-int-int-) method and two enums [EffectChartMajorGroupingType](https://reference.aspose.com/slides/java/com.aspose.slides/EffectChartMajorGroupingType) and [EffectChartMinorGroupingType](https://reference.aspose.com/slides/java/com.aspose.slides/EffectChartMinorGroupingType).
[](https://docs.aspose.com/slides/java/animated-charts/visual-chart-animation-grouping-51704783a7c6.svg)
*Schematic comparison using two series and two categories. Numbers identify illustrative reveal steps, not data values: grouping selects which marks animate together. Actual order and triggers depend on the effects added to the sequence.*
## **Chart Series Animation**
If you want to animate a chart series, write the code according to the steps listed below:
1. Load a presentation.
1. Get reference of the chart object.
1. Animate the series.
1. Write the presentation file to disk.
In the example given below, we animated chart series. The chart in the example file has three series, so one effect is added for each index from 0 to 2. Aspose.Slides does not check the index against the chart data, and an effect added for a series that does not exist is written to the file but animates nothing—keep the index below the number of series in your own chart.
```java
import com.aspose.slides.*;
// Instantiate Presentation class that represents a presentation file
Presentation pres = new Presentation("ExistingChart.pptx");
try {
// Get reference of the chart object
ISlide slide = pres.getSlides().get_Item(0);
IShapeCollection shapes = slide.getShapes();
IChart chart = (IChart) shapes.get_Item(0);
// Animate the series
slide.getTimeline().getMainSequence().addEffect(chart, EffectType.Fade, EffectSubtype.None,
EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart,
EffectChartMajorGroupingType.BySeries, 0,
EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart,
EffectChartMajorGroupingType.BySeries, 1,
EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart,
EffectChartMajorGroupingType.BySeries, 2,
EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
// Write the modified presentation to disk
pres.save("AnimatingSeries_out.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
## **Chart Category Animation**
If you want to animate a chart category, write the code according to the steps listed below:
1. Load a presentation.
1. Get reference of the chart object.
1. Animate the Category.
1. Write the presentation file to disk.
In the example given below, we animated chart category.
```java
import com.aspose.slides.*;
// Instantiate Presentation class that represents a presentation file
Presentation pres = new Presentation("ExistingChart.pptx");
try {
ISlide slide = pres.getSlides().get_Item(0);
IShapeCollection shapes = slide.getShapes();
IChart chart = (IChart) shapes.get_Item(0);
slide.getTimeline().getMainSequence().addEffect(chart, EffectType.Fade, EffectSubtype.None,
EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart,
EffectChartMajorGroupingType.ByCategory, 0,
EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart,
EffectChartMajorGroupingType.ByCategory, 1,
EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart,
EffectChartMajorGroupingType.ByCategory, 2,
EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart,
EffectChartMajorGroupingType.ByCategory, 3,
EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
pres.save("Sample_Animation_C.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
## **Animation in a Series Element**
If you want to animate series elements, write the code according to the steps listed below:
1. Load a presentation.
1. Get reference of the chart object.
1. Animate series elements.
1. Write the presentation file to disk.
In the example given below, we have animated series' elements.
```java
import com.aspose.slides.*;
// Instantiate Presentation class that represents a presentation file
Presentation pres = new Presentation("ExistingChart.pptx");
try {
// Get reference of the chart object
ISlide slide = pres.getSlides().get_Item(0);
IShapeCollection shapes = slide.getShapes();
IChart chart = (IChart) shapes.get_Item(0);
// Animate series elements
slide.getTimeline().getMainSequence().addEffect(chart, EffectType.Fade, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInSeries,
0, 0, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInSeries,
0, 1, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInSeries,
0, 2, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInSeries,
0, 3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInSeries,
1, 0, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInSeries,
1, 1, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInSeries,
1, 2, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInSeries,
1, 3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInSeries,
2, 0, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInSeries,
2, 1, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInSeries,
2, 2, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInSeries,
2, 3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
// Write the presentation file to disk
pres.save("AnimatingSeriesElements_out.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
## **Animation in a Category Element**
If you want to animate categories elements, write the code according to the steps listed below:
1. Load a presentation.
1. Get reference of the chart object.
1. Animate categories elements.
1. Write the presentation file to disk.
In the example given below, we have animated categories elements.
```java
import com.aspose.slides.*;
// Instantiate Presentation class that represents a presentation file
Presentation pres = new Presentation("ExistingChart.pptx");
try {
// Get reference of the chart object
ISlide slide = pres.getSlides().get_Item(0);
IShapeCollection shapes = slide.getShapes();
IChart chart = (IChart) shapes.get_Item(0);
// Animate categories' elements
slide.getTimeline().getMainSequence().addEffect(chart, EffectType.Fade, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInCategory,
0, 0, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInCategory,
0, 1, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInCategory,
0, 2, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInCategory,
0, 3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInCategory,
1, 0, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInCategory,
1, 1, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInCategory,
1, 2, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInCategory,
1, 3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInCategory,
2, 0, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInCategory,
2, 1, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInCategory,
2, 2, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence)slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMinorGroupingType.ByElementInCategory,
2, 3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
// Write the presentation file to disk
pres.save("AnimatingCategoriesElements_out.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
## **FAQ**
### Are different effect types (e.g., entrance, emphasis, exit) supported for charts like for regular shapes?
Yes. A chart is treated as a shape, so it supports the standard animation effect types, including entrance, emphasis, and exit, with full control via the slide's timeline and animation sequences.
### Can I combine chart animation with slide transitions?
Yes. [Transitions](https://docs.aspose.com/slides/java/slide-transition/) apply to the slide, while animation effects apply to objects on the slide. You can use both together in the same presentation and control them independently.
### Are chart animations preserved when saving to PPTX?
Yes. When you [save to PPTX](https://docs.aspose.com/slides/java/save-presentation/), all animation effects and their ordering are preserved because they are part of the presentation's native animation model.
### Can I read existing chart animations from a presentation and modify them?
Yes. The API provides access to the slide timeline, sequences, and effects, allowing you to inspect existing chart animations and adjust them without recreating everything from scratch.
### Can I produce a video that includes chart animations using Aspose.Slides?
Yes. You can [export a presentation to video](https://docs.aspose.com/slides/java/convert-powerpoint-to-video/) while preserving animations, configuring timings and other export settings so the resulting clip reflects the animated playback.
## Related articles
- [Animate PowerPoint Text in Java](https://docs.aspose.com/slides/java/animated-text/)
- [Enhance PowerPoint Presentations with Animations in Java](https://docs.aspose.com/slides/java/powerpoint-animation/)
# Animate PowerPoint Text in Java
> Create dynamic animated text in PowerPoint and OpenDocument presentations using Aspose.Slides for Java, with easy-to-follow, optimized Java code examples.
Source: https://docs.aspose.com/slides/java/animated-text/
Updated: 2026-08-05
## **Overview**
This article explains how to work with animated text in Aspose.Slides by applying animation effects to individual paragraphs and retrieving the effects already assigned to paragraphs in a text frame. It focuses on the API methods used to add paragraph-level animation and inspect existing paragraph animation effects in a presentation.
## **Add Animation Effects to Paragraphs**
We added the [**addEffect()**](https://reference.aspose.com/slides/java/com.aspose.slides/Sequence#addEffect-com.aspose.slides.IParagraph-int-int-int-) method to the [**Sequence**](https://reference.aspose.com/slides/java/com.aspose.slides/Sequence) and [**ISequence**](https://reference.aspose.com/slides/java/com.aspose.slides/ISequence) classes. This method allows you to add animation effects to a single paragraph. This sample code shows you how to add an animation effect to a single paragraph:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("Presentation.pptx");
try {
// select paragraph to add effect
IAutoShape autoShape = (IAutoShape)presentation.getSlides().get_Item(0).getShapes().get_Item(0);
IParagraph paragraph = autoShape.getTextFrame().getParagraphs().get_Item(0);
// add Fly animation effect to selected paragraph
IEffect effect = presentation.getSlides().get_Item(0).getTimeline().getMainSequence().
addEffect(paragraph, EffectType.Fly, EffectSubtype.Left, EffectTriggerType.OnClick);
presentation.save("AnimationEffectinParagraph.pptx", SaveFormat.Pptx);
} finally {
if (presentation != null) presentation.dispose();
}
```
## **Get Animation Effects of Paragraphs**
You may decide to find out the animation effects added to a paragraph—for example, in one scenario, you want to get the animation effects in a paragraph because you plan to apply those effects to another paragraph or shape.
Aspose.Slides for Java allows you to get all the animation effects applied to paragraphs contained in a text frame (shape). This sample code shows you how to get the animation effects in a paragraph:
```java
import com.aspose.slides.*;
Presentation pres = new Presentation("Presentation.pptx");
try {
ISequence sequence = pres.getSlides().get_Item(0).getTimeline().getMainSequence();
IAutoShape autoShape = (IAutoShape)pres.getSlides().get_Item(0).getShapes().get_Item(0);
for (IParagraph paragraph : autoShape.getTextFrame().getParagraphs())
{
IEffect[] effects = sequence.getEffectsByParagraph(paragraph);
if (effects.length > 0)
System.out.println("Paragraph \"" + paragraph.getText() + "\" has " + effects[0].getType() + " effect.");
}
} finally {
pres.dispose();
}
```
## **FAQ**
### How do text animations differ from slide transitions, and can they be combined?
Text animations control object behavior over time on a slide, while [transitions](https://docs.aspose.com/slides/java/slide-transition/) control how slides change. They’re independent and can be used together; playback order is governed by the animation timeline and the transition settings.
### Are text animations preserved when exporting to PDF or images?
No. PDF and raster images are static, so you’ll see a single state of the slide without motion. To keep movement, use [video](https://docs.aspose.com/slides/java/convert-powerpoint-to-video/) or [HTML](https://docs.aspose.com/slides/java/export-to-html5/) export.
### Do text animations work in layouts and the slide master?
Effects applied to layout/master objects are inherited by slides, but their timing and interaction with slide-level animations depend on the final sequence on the slide.
## Related articles
- [Animation](https://docs.aspose.com/slides/java/examples/elements/animation/)
- [Animate PowerPoint Charts in Java](https://docs.aspose.com/slides/java/animated-charts/)
- [Apply Shape Animations in Presentations Using Java](https://docs.aspose.com/slides/java/shape-animation/)
# Output Metadata Limitations
> Aspose.Slides for Java writes fixed application, creator, and producer metadata to saved PPTX, PDF, and ODP files, whatever application name you set.
Source: https://docs.aspose.com/slides/java/api-limitations/
Updated: 2026-09-29
## **Overview**
When presentations are created or exported with Aspose.Slides, certain technical metadata is written to the output file. This article explains the limitations related to the `Application`, `Creator`, `Producer`, and generator metadata fields in PPTX, PDF, and ODP files.
## **Application and Producer**
When you create or export presentations with Aspose.Slides for Java, some technical metadata is written into the file. Two fields often raise questions:
**Application** identifies the program that created or last saved a **PPTX** presentation. In Aspose.Slides for Java, this value is fixed and shows the library name rather than your app name, even if you use [DocumentProperties.setNameOfApplication](https://reference.aspose.com/slides/java/com.aspose.slides/documentproperties/#setNameOfApplication-java.lang.String-).
**Producer** identifies the rendering engine that generated the final file during export. In **PDF** exports, metadata uses **Creator** and **Producer** fields. With Aspose.Slides for Java, both of these are fixed and reflect the library and its version.
**What’s restricted**
You cannot override these fields through the API for the formats above. For **PPTX**, the Application property is written as "Aspose.Slides for Java". For **PDF**, the Creator and Producer properties are written as "Aspose.Slides for Java" followed by the library version. For **ODP**, the generator field is written as "Aspose.Slides for Java" followed by the library version. This behavior is by design and applies regardless of how you load or save the file, and regardless of values assigned using [DocumentProperties.setNameOfApplication](https://reference.aspose.com/slides/java/com.aspose.slides/documentproperties/#setNameOfApplication-java.lang.String-).
This restriction does not apply to **PPT** files: in a PPT file, the application name that you set with [DocumentProperties.setNameOfApplication](https://reference.aspose.com/slides/java/com.aspose.slides/documentproperties/#setNameOfApplication-java.lang.String-) is saved.
# API Reference
> Create, edit, and convert presentations in Java—no PowerPoint needed. Aspose.Slides supports PPT, PPTX, and ODP with fast SVG/PDF export.
Source: https://docs.aspose.com/slides/java/api-reference/
Updated: 2026-08-13
Aspose.Slides for Java is a class library that enables Java applications to read and write presentation
documents without using Microsoft PowerPoint® or others. Aspose.Slides for Java allows to manage text, shapes,
tables & animations, add audio and video to slides, preview slides, export slides to SVG, PDF format and more.
Latest API Reference can be found at [Aspose.Slides for Java API Reference](https://reference.aspose.com/slides/java).
# Restrict Presentation Edits with Shape Locks in Java
> Learn how to lock and unlock shapes in PPTX presentations with Aspose.Slides for Java to restrict selection, movement, resizing, and grouping.
Source: https://docs.aspose.com/slides/java/applying-protection-to-presentation/
Updated: 2026-10-20
## **Background**
A common use for Aspose.Slides for Java is to create, update, and save PowerPoint (PPTX) presentations as part of an automated workflow. When users receive these presentations, restricting changes to shapes can help preserve the intended layout and content.
This article explains how shapes are organized on slides and how to apply and remove shape locks in a PPTX presentation. These locks let you restrict specific editing operations on individual shapes.
## **Composition of a Slide**
A presentation slide is composed of components such as autoshapes, tables, OLE objects, grouped shapes, picture frames, video frames, connectors, and other elements used to build a presentation. In Aspose.Slides for Java, each element on a slide is represented by an object that implements the [IShape](https://reference.aspose.com/slides/java/com.aspose.slides/ishape/) interface or inherits from a class that does.
Different shape types expose different locking options. The [IBaseShapeLock](https://reference.aspose.com/slides/java/com.aspose.slides/ibaseshapelock/) interface is the base interface for shape locks. Aspose.Slides for Java provides the following lock interfaces:
- [IAutoShapeLock](https://reference.aspose.com/slides/java/com.aspose.slides/iautoshapelock/) locks autoshapes.
- [IConnectorLock](https://reference.aspose.com/slides/java/com.aspose.slides/iconnectorlock/) locks connector shapes.
- [IGraphicalObjectLock](https://reference.aspose.com/slides/java/com.aspose.slides/igraphicalobjectlock/) locks graphical objects.
- [IGroupShapeLock](https://reference.aspose.com/slides/java/com.aspose.slides/igroupshapelock/) locks group shapes.
- [IPictureFrameLock](https://reference.aspose.com/slides/java/com.aspose.slides/ipictureframelock/) locks picture frames.
To apply locks across a [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/), iterate through its slides and set the appropriate locks on each supported shape.
## **Apply and Remove Protection**
Shape locks restrict operations such as selecting, moving, and resizing shapes. They do not make the entire presentation uneditable.
### **Apply Protection to PPTX Shapes**
Aspose.Slides for Java provides the [IShape](https://reference.aspose.com/slides/java/com.aspose.slides/ishape/) interface to work with shapes on a slide.
The example calls [setSelectLocked](https://reference.aspose.com/slides/java/com.aspose.slides/iautoshapelock/#setSelectLocked-boolean-), [setPositionLocked](https://reference.aspose.com/slides/java/com.aspose.slides/iautoshapelock/#setPositionLocked-boolean-), and [setSizeLocked](https://reference.aspose.com/slides/java/com.aspose.slides/iautoshapelock/#setSizeLocked-boolean-) with `true` for autoshapes, with equivalent locks for group shapes, connectors, and picture frames. Connectors use [setPositionMove](https://reference.aspose.com/slides/java/com.aspose.slides/iconnectorlock/#setPositionMove-boolean-) for movement; groups also use [setGroupingLocked](https://reference.aspose.com/slides/java/com.aspose.slides/igroupshapelock/#setGroupingLocked-boolean-) to restrict grouping.
The example loads an existing PPTX presentation, checks the shapes in each slide's shape collection, and saves a copy with these restrictions applied. Shapes outside the four handled types are left unchanged. The loop does not traverse the child shapes inside a group.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("Sample.pptx");
try {
for (ISlide slide : presentation.getSlides()) {
for (IShape shape : slide.getShapes()) {
if (shape instanceof IAutoShape) {
IAutoShape autoShape = (IAutoShape) shape;
IAutoShapeLock autoShapeLock = (IAutoShapeLock) autoShape.getShapeLock();
autoShapeLock.setPositionLocked(true);
autoShapeLock.setSelectLocked(true);
autoShapeLock.setSizeLocked(true);
} else if (shape instanceof IGroupShape) {
IGroupShape groupShape = (IGroupShape) shape;
IGroupShapeLock groupShapeLock = (IGroupShapeLock) groupShape.getShapeLock();
groupShapeLock.setGroupingLocked(true);
groupShapeLock.setPositionLocked(true);
groupShapeLock.setSelectLocked(true);
groupShapeLock.setSizeLocked(true);
} else if (shape instanceof IConnector) {
IConnector connectorShape = (IConnector) shape;
IConnectorLock connectorShapeLock = connectorShape.getShapeLock();
connectorShapeLock.setPositionMove(true);
connectorShapeLock.setSelectLocked(true);
connectorShapeLock.setSizeLocked(true);
} else if (shape instanceof IPictureFrame) {
IPictureFrame pictureFrame = (IPictureFrame) shape;
IPictureFrameLock pictureFrameLock = (IPictureFrameLock) pictureFrame.getShapeLock();
pictureFrameLock.setPositionLocked(true);
pictureFrameLock.setSelectLocked(true);
pictureFrameLock.setSizeLocked(true);
}
}
}
presentation.save("ProtectedSample.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
### **Remove Protection**
To remove a shape lock, set its value to `false`. The following example loads a presentation with shape locks and clears the selection, movement, and resizing restrictions through [IAutoShapeLock](https://reference.aspose.com/slides/java/com.aspose.slides/iautoshapelock/), [IGroupShapeLock](https://reference.aspose.com/slides/java/com.aspose.slides/igroupshapelock/), [IConnectorLock](https://reference.aspose.com/slides/java/com.aspose.slides/iconnectorlock/), and [IPictureFrameLock](https://reference.aspose.com/slides/java/com.aspose.slides/ipictureframelock/). It also removes the grouping restriction by passing `false` to [IGroupShapeLock.setGroupingLocked](https://reference.aspose.com/slides/java/com.aspose.slides/igroupshapelock/#setGroupingLocked-boolean-) and saves a copy of the presentation. Other lock settings are left unchanged.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("ProtectedSample.pptx");
try {
for (ISlide slide : presentation.getSlides()) {
for (IShape shape : slide.getShapes()) {
if (shape instanceof IAutoShape) {
IAutoShape autoShape = (IAutoShape) shape;
IAutoShapeLock autoShapeLock = (IAutoShapeLock) autoShape.getShapeLock();
autoShapeLock.setPositionLocked(false);
autoShapeLock.setSelectLocked(false);
autoShapeLock.setSizeLocked(false);
} else if (shape instanceof IGroupShape) {
IGroupShape groupShape = (IGroupShape) shape;
IGroupShapeLock groupShapeLock = (IGroupShapeLock) groupShape.getShapeLock();
groupShapeLock.setGroupingLocked(false);
groupShapeLock.setPositionLocked(false);
groupShapeLock.setSelectLocked(false);
groupShapeLock.setSizeLocked(false);
} else if (shape instanceof IConnector) {
IConnector connectorShape = (IConnector) shape;
IConnectorLock connectorShapeLock = connectorShape.getShapeLock();
connectorShapeLock.setPositionMove(false);
connectorShapeLock.setSelectLocked(false);
connectorShapeLock.setSizeLocked(false);
} else if (shape instanceof IPictureFrame) {
IPictureFrame pictureFrame = (IPictureFrame) shape;
IPictureFrameLock pictureFrameLock = (IPictureFrameLock) pictureFrame.getShapeLock();
pictureFrameLock.setPositionLocked(false);
pictureFrameLock.setSelectLocked(false);
pictureFrameLock.setSizeLocked(false);
}
}
}
presentation.save("RemovedProtectionSample.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
### **Conclusion**
Aspose.Slides for Java lets you restrict specific editing operations on individual shapes or apply the same restrictions across slides. Choose the locks supported by each shape type, and set their values to `false` when you need to remove those restrictions.
## **FAQ**
**Can I combine shape locks and password protection in the same presentation?**
Yes. Shape locks restrict specific editing operations, while [password protection](https://docs.aspose.com/slides/java/password-protected-presentation/) can restrict opening or modifying the presentation. You can use both in the same file.
**Can I restrict editing on specific slides without affecting others?**
Yes. Apply locks only to shapes on the selected slides. This does not change the lock settings on other slides.
**How can I apply locks to individual shapes inside a group?**
Iterate through the collection returned by the group's [getShapes](https://reference.aspose.com/slides/java/com.aspose.slides/igroupshape/#getShapes--) method and apply the appropriate locks to each child shape. Repeat this for any nested groups. The examples above process only the slide's shape collection, so they do not set locks on individual group members.
# Artifact Classifier Change
> Aspose.Slides for Java now uses the jdk8 classifier instead of jdk16. Learn why and how to update your dependencies.
Source: https://docs.aspose.com/slides/java/artifact-classifier-change/
Updated: 2026-10-09
## **Artifact Classifier Change from `jdk16` to `jdk8`**
Starting with version **26.10**, we have changed the classifier used in our published artifacts from **`jdk16`** (Java 6) to **`jdk8`** (Java 8).
### **What changed**
| | Before | After |
|---|---|---|
| Classifier | `jdk16` | `jdk8` |
| Minimum Java version | Java 1.6 | Java 8 |
**Before:**
```
com.aspose:aspose-slides:26.10:jdk16
```
**After:**
```
com.aspose:aspose-slides:26.10:jdk8
```
### **Why we made this change**
After internal review, we decided to **drop support for older Java versions** that were no longer providing value and were actively hindering maintenance. Java 8 was selected as the new, safe baseline for all consumers.
As part of this, the classifier was updated to reflect the actual minimum supported version. We also aligned with the current Oracle naming convention, where the product is officially referred to as **JDK 8** (rather than the legacy `1.8` format).
### **What you need to do**
1. **Update the classifier** in your dependency declarations from `jdk16` to `jdk8`.
**Maven:**
```xml
com.asposeaspose-slides26.10jdk8
```
**Gradle:**
```groovy
implementation 'com.aspose:aspose-slides:26.10:jdk8'
```
2. **Verify your runtime environment** is Java 8 or higher.
3. **Refresh any lock files** or dependency caches that pin the old classifier.
### **Migration Note: jdk16 and jdk8**
Starting version 26.10, both the jdk16 and jdk8 classifiers will provide Java 8–compatible JARs (built with source/target compatibility set to Java 8).
- `jdk16` → continues to be published for backward compatibility (existing integrations).
- `jdk8` → introduced as the new preferred classifier for Java 8 environments.
⚠️ Note: This dual-publishing phase is scheduled to end on March 31, 2027. After this date, the jdk16 classifier will be retired, and only jdk8 will be supported.
### **Compatibility notes**
- The `jdk16` classifier is **no longer published** after **March 31, 2027**.
- If you still require Java 1.6 support, please remain on the previous major version line until you can migrate.
### **Need help?**
If you encounter issues during migration, please contact [Aspose support](https://forum.aspose.com/) for further assistance.
# Manage Audio in Presentations Using Java
> Create and control audio frames in Aspose.Slides for Java—code examples to embed, trim, loop, and configure playback across PPT, PPTX, and ODP presentations.
Source: https://docs.aspose.com/slides/java/audio-frame/
Updated: 2026-08-05
## **Overview**
This article explains how to work with audio frames in Aspose.Slides. It shows how to add embedded audio to slides, customize the audio frame thumbnail, configure playback options such as volume, looping, hiding, trimming, and fade durations, and extract audio used in slide show transitions.
## **Create Audio Frames**
Aspose.Slides for Java allows you to add audio files to slides. The audio files are embedded in slides as audio frames.
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class.
2. Get a slide's reference through its index.
3. Load the audio file stream you want to embed in the slide.
4. Add the embedded audio frame (containing the audio file) to the slide.
5. Set [PlayMode](https://reference.aspose.com/slides/java/com.aspose.slides/AudioPlayModePreset) and `Volume` exposed by the [IAudioFrame](https://reference.aspose.com/slides/java/com.aspose.slides/IAudioFrame) object.
6. Save the modified presentation.
This Java code shows you how to add an embedded audio frame to a slide:
```java
import com.aspose.slides.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
// Instantiates a Presentation class that represents a presentation file
Presentation pres = new Presentation();
try {
// Gets the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Loads the wav sound file to stream
FileInputStream fstr = new FileInputStream(new File("audio.wav"));
// Adds the Audio Frame
IAudioFrame audioFrame = sld.getShapes().addAudioFrameEmbedded(50, 150, 100, 100, fstr);
fstr.close();
// Sets the Play Mode and Volume of the Audio
audioFrame.setPlayMode(AudioPlayModePreset.Auto);
audioFrame.setVolume(AudioVolumeMode.Loud);
// Writes the PowerPoint file to disk
pres.save("AudioFrameEmbed_out.pptx", SaveFormat.Pptx);
} catch(IOException e) {
} finally {
if (pres != null) pres.dispose();
}
```
## **Change the Audio Frame Thumbnail**
When you add an audio file to a presentation, the audio appears as a frame with a standard default image (see the image in the section below). You change the audio frame's preview image (set your preferred image).
This Java code shows you how to change an audio frame's thumbnail or preview image:
```java
import com.aspose.slides.*;
import java.io.FileInputStream;
import java.io.IOException;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
// Adds an audio frame to the slide with a specified position and size.
FileInputStream audioStream = new FileInputStream("sample2.mp3");
IAudioFrame audioFrame = slide.getShapes().addAudioFrameEmbedded(150, 100, 50, 50, audioStream);
audioStream.close();
// Adds an image to presentation resources.
IPPImage picture;
IImage image = Images.fromFile("eagle.jpeg");
try {
picture = presentation.getImages().addImage(image);
} finally {
if (image != null) image.dispose();
}
// Sets the image for the audio frame.
audioFrame.getPictureFormat().getPicture().setImage(picture); // <-----
//Saves the modified presentation to disk
presentation.save("example_out.pptx", SaveFormat.Pptx);
} catch(IOException e) {
} finally {
if (presentation != null) presentation.dispose();
}
```
## **Change Audio Play Options**
Aspose.Slides for Java allows you to change options that control an audio's playback or properties. For example, you can adjust an audio's volume, set the audio to play looped, or even hide the audio icon.
The **Audio Options** pane in Microsoft PowerPoint:

PowerPoint **Audio Options** that correspond to Aspose.Slides [AudioFrame](https://reference.aspose.com/slides/java/com.aspose.slides/AudioFrame) properties:
- **Start** drop-down list matches the [AudioFrame.setPlayMode](https://reference.aspose.com/slides/java/com.aspose.slides/audioframe/#setPlayMode-int-) method
- **Volume** matches the [AudioFrame.setVolume](https://reference.aspose.com/slides/java/com.aspose.slides/audioframe/#setVolume-int-) method
- **Play Across Slides** matches the [AudioFrame.setPlayAcrossSlides](https://reference.aspose.com/slides/java/com.aspose.slides/audioframe/#setPlayAcrossSlides-boolean-) method
- **Loop until Stopped** matches the [AudioFrame.setPlayLoopMode](https://reference.aspose.com/slides/java/com.aspose.slides/audioframe/#setPlayLoopMode-boolean-) method
- **Hide During Show** matches the [AudioFrame.setHideAtShowing](https://reference.aspose.com/slides/java/com.aspose.slides/audioframe/#setHideAtShowing-boolean-) method
- **Rewind after Playing** matches the [AudioFrame.setRewindAudio](https://reference.aspose.com/slides/java/com.aspose.slides/audioframe/#setRewindAudio-boolean-) method
PowerPoint **Editing** options that correspond to Aspose.Slides [AudioFrame](https://reference.aspose.com/slides/java/com.aspose.slides/AudioFrame) properties:
- **Fade In** matches the [AudioFrame.setFadeInDuration](https://reference.aspose.com/slides/java/com.aspose.slides/audioframe/#setFadeInDuration-float-) method
- **Fade Out** matches the [AudioFrame.setFadeOutDuration](https://reference.aspose.com/slides/java/com.aspose.slides/audioframe/#setFadeOutDuration-float-) method
- **Trim Audio Start Time** matches the [AudioFrame.setTrimFromStart](https://reference.aspose.com/slides/java/com.aspose.slides/audioframe/#setTrimFromStart-float-) method
- **Trim Audio End Time** value equals the audio duration minus the value of [AudioFrame.setTrimFromEnd](https://reference.aspose.com/slides/java/com.aspose.slides/audioframe/#setTrimFromEnd-float-) method
The PowerPoint **Volume controll** on the audio control panel corresponds to the [AudioFrame.setVolumeValue](https://reference.aspose.com/slides/java/com.aspose.slides/audioframe/#setVolumeValue-float-) method. It lets you change the audio volume as a percentage.
This is how you change the Audio Play options:
1. [Сreate](https://docs.aspose.com/slides/java/audio-frame/#create-audio-frame) or get the Audio Frame.
2. Set new values for the Audio Frame properties you want to adjust.
3. Save the modified PowerPoint file.
This Java code demonstrates an operation in which an audio's options are adjusted:
```java
import com.aspose.slides.*;
Presentation pres = new Presentation("AudioFrameEmbed_out.pptx");
try {
// Gets the AudioFrame shape
AudioFrame audioFrame = (AudioFrame)pres.getSlides().get_Item(0).getShapes().get_Item(0);
// Sets the Play mode to play on click
audioFrame.setPlayMode(AudioPlayModePreset.OnClick);
// Sets the volume to Low
audioFrame.setVolume(AudioVolumeMode.Low);
// Sets the audio to play across slides
audioFrame.setPlayAcrossSlides(true);
// Disables loop for the audio
audioFrame.setPlayLoopMode(false);
// Hides the AudioFrame during the slide show
audioFrame.setHideAtShowing(true);
// Rewinds the audio to start after playing
audioFrame.setRewindAudio(true);
// Saves the PowerPoint file to disk
pres.save("AudioFrameEmbed_changed.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
This Java example shows how to add a new audio frame with embedded audio, trim it, and set the fade durations:
```java
import com.aspose.slides.*;
import java.nio.file.Files;
import java.nio.file.Paths;
Presentation pres = new Presentation();
try {
ISlide slide = pres.getSlides().get_Item(0);
byte[] audioData = Files.readAllBytes(Paths.get("sampleaudio.mp3"));
IAudio audio = pres.getAudios().addAudio(audioData);
IAudioFrame audioFrame = slide.getShapes().addAudioFrameEmbedded(50, 50, 100, 100, audio);
// Sets the trimming start offset to 1.5 seconds
audioFrame.setTrimFromStart(1500f);
// Sets the trimming end offset to 2 seconds
audioFrame.setTrimFromEnd(2000f);
// Sets the fade-in duration to 200 ms
audioFrame.setFadeInDuration(200f);
// Sets the fade-out duration to 500 ms
audioFrame.setFadeOutDuration(500f);
pres.save("AudioFrameTrimFade_out.pptx", SaveFormat.Pptx);
} finally {
pres.dispose();
}
```
The following code sample shows how to retrieve an audio frame with embedded audio and set its volume to 85%:
```java
import com.aspose.slides.*;
Presentation pres = new Presentation("AudioFrameEmbed_out.pptx");
try {
ISlide slide = pres.getSlides().get_Item(0);
// Gets an audio frame shape
IAudioFrame audioFrame = (IAudioFrame)slide.getShapes().get_Item(0);
// Sets the audio volume to 85%
audioFrame.setVolumeValue(85f);
pres.save("AudioFrameValue_out.pptx", SaveFormat.Pptx);
}
finally {
pres.dispose();
}
```
## **Manage Audio Captions**
Aspose.Slides allows you to add closed captions to an audio frame through the [getCaptionTracks](https://reference.aspose.com/slides/java/com.aspose.slides/iaudioframe/#getCaptionTracks--) method. This method returns an [ICaptionsCollection](https://reference.aspose.com/slides/java/com.aspose.slides/icaptionscollection/), which lets you add WebVTT caption tracks, iterate through existing tracks, and remove them when necessary.
**Add Audio Captions**
Use the [getCaptionTracks](https://reference.aspose.com/slides/java/com.aspose.slides/iaudioframe/#getCaptionTracks--) method to attach one or more caption tracks to an audio frame. In the following example, an audio file is added to a slide, and then a new caption track is loaded from a `.vtt` file.
```java
import com.aspose.slides.*;
import java.nio.file.Files;
import java.nio.file.Paths;
Presentation presentation = new Presentation();
try {
byte[] audioData = Files.readAllBytes(Paths.get("audio.mp3"));
IAudio audio = presentation.getAudios().addAudio(audioData);
ISlide slide = presentation.getSlides().get_Item(0);
IAudioFrame audioFrame = slide.getShapes().addAudioFrameEmbedded(10, 10, 50, 50, audio);
// Add a new caption track from a WebVTT file.
audioFrame.getCaptionTracks().add("New track", "track.vtt");
presentation.save("audio_with_captions.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
**Extract Audio Captions**
You can iterate through the caption tracks associated with an audio frame and save them as `.vtt` files. Each caption track exposes its binary data and unique identifier, which can be used when exporting captions.
```java
import com.aspose.slides.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Presentation presentation = new Presentation("audio_with_captions.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
for (IShape shape : slide.getShapes()) {
if (shape instanceof IAudioFrame ) {
IAudioFrame audioFrame = (IAudioFrame) shape;
for (ICaptions captionTrack : audioFrame.getCaptionTracks()) {
// Save the caption track as a .vtt file.
Path filePath = Paths.get(captionTrack.getCaptionId() + ".vtt");
Files.write(filePath, captionTrack.getBinaryData());
}
}
}
} finally {
presentation.dispose();
}
```
**Remove Audio Captions**
To remove captions from an audio frame, use the methods provided by [ICaptionsCollection](https://reference.aspose.com/slides/java/com.aspose.slides/icaptionscollection/), such as [clear](https://reference.aspose.com/slides/java/com.aspose.slides/icaptionscollection/#clear--), [remove](https://reference.aspose.com/slides/java/com.aspose.slides/icaptionscollection/#remove-com.aspose.slides.ICaptions-), or [removeAt](https://reference.aspose.com/slides/java/com.aspose.slides/icaptionscollection/#removeAt-int-). The following example removes all caption tracks from an audio frame.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("audio_with_captions.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAudioFrame audioFrame = (IAudioFrame) slide.getShapes().get_Item(0);
// Remove all caption tracks from the audio frame.
audioFrame.getCaptionTracks().clear();
presentation.save("audio_without_captions.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Extract Audio**
Aspose.Slides for Java allows you to extract the sound used in slide show transitions. For example, you can extract the sound used in a specific slide.
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class and load the presentation containing the audio.
2. Get the relevant slide's reference through its index.
3. Access the [slideshow transitions](https://reference.aspose.com/slides/java/com.aspose.slides/IBaseSlide#getSlideShowTransition--) for the slide.
4. Extract the sound in byte data.
This code in Java shows you how to extract the audio used in a slide:
```java
import com.aspose.slides.*;
// Instantiates a Presentation class that represents a presentation file
Presentation pres = new Presentation("AudioSlide.pptx");
try {
// Accesses the desired slide
ISlide slide = pres.getSlides().get_Item(0);
// Gets the slideshow transition effects for the slide
ISlideShowTransition transition = slide.getSlideShowTransition();
//Extracts the sound in byte array
byte[] audio = transition.getSound().getBinaryData();
System.out.println("Length: " + audio.length);
} finally {
if (pres != null) pres.dispose();
}
```
## **FAQ**
### Can I reuse the same audio asset across multiple slides without inflating the file size?
Yes. Add the audio once to the presentation’s shared [audio collection](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#getAudios--) and create additional audio frames that reference that existing asset. This avoids duplicating media data and keeps the presentation size under control.
### Can I replace the sound in an existing audio frame without recreating the shape?
Yes. For a linked sound, update the [link path](https://reference.aspose.com/slides/java/com.aspose.slides/iaudioframe/#setLinkPathLong-java.lang.String-) to point to the new file. For an embedded sound, swap the [embedded audio](https://reference.aspose.com/slides/java/com.aspose.slides/iaudioframe/#setEmbeddedAudio-com.aspose.slides.IAudio-) object with another one from the presentation’s [audio collection](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#getAudios--). The frame’s formatting and most playback settings remain intact.
### Does trimming change the underlying audio data stored in the presentation?
No. Trimming adjusts only the playback boundaries. The original audio bytes remain untouched and accessible through the embedded audio or the presentation’s audio collection.
## Related articles
- [Audio](https://docs.aspose.com/slides/java/examples/elements/audio/)
- [Manage Video Frames in Presentations Using Java](https://docs.aspose.com/slides/java/video-frame/)
# Automating PowerPoint Generation in Java: Create Dynamic Presentations Easily
> Automate slide creation on cloud platforms with Aspose.Slides for Java—generate, edit, and convert PowerPoint and OpenDocument files fast and reliably.
Source: https://docs.aspose.com/slides/java/automating-powerpoint-generation-on-cloud-platforms/
Updated: 2026-08-05
## **Introduction**
Creating PowerPoint presentations manually can be a time-consuming and repetitive task—especially when the content is based on dynamic data that frequently changes. Whether it's generating weekly business reports, assembling educational material, or producing client-ready sales decks, automation can save countless hours and ensure consistency across teams.
For Java developers, automating the creation of PowerPoint presentations opens up powerful possibilities. You can integrate slide generation into web portals, deskt op tools, backend services, or cloud platforms to dynamically convert data into professional, branded presentations—on-demand.
In this article, we’ll explore the common use cases for automated PowerPoint generation in Java apps (including deployments on cloud platforms) and why it's becoming an essential feature in modern solutions. From pulling real-time business data to converting text or images into slides, the goal is to transform raw content into structured, visual formats your audience can instantly understand.
## **Common Use Cases for PowerPoint Automation in Java**
Automating PowerPoint generation is especially useful in scenarios where presentation content needs to be dynamically assembled, personalized, or frequently updated. Some of the most common real-world use cases include:
- **Business Reports & Dashboards**
Generate sales summaries, KPIs, or financial performance reports by pulling live data from databases or APIs.
- **Personalized Sales & Marketing Decks**
Automatically create client-specific pitch decks using CRM or form data, ensuring quick turnaround and brand consistency.
- **Educational Content**
Convert learning material, quizzes, or course summaries into structured slide decks for e-learning platforms.
- **Data & AI-Powered Insights**
Use natural language processing or analytics engines to transform raw data or long-form text into summarized presentations.
- **Media-Based Slides**
Assemble presentations from uploaded images, annotated screenshots, or video keyframes with supporting descriptions.
- **Document Conversion**
Automatically convert Word documents, PDFs, or form inputs into visual presentations with minimal manual effort.
- **Developer and Technical Tools**
Create tech demos, documentation overviews, or changelogs in slide format directly from code or markdown content.
By automating these workflows, organizations can scale their content creation, maintain consistency, and free up time for more strategic work.
## **Let's Code**
For this example, we’ve chosen **[Aspose.Slides for Java](https://products.aspose.com/slides/java/)** to demonstrate PowerPoint automation due to its comprehensive feature set and ease of use when working with presentations programmatically.
Unlike lower-level libraries, which require developers to work directly with the Open XML structure (often resulting in verbose and less readable code), Aspose.Slides provides a higher-level API. It abstracts away the complexity, allowing developers to focus on presentation logic—such as layout, formatting, and data binding—without needing to understand the PowerPoint file format in detail.
Although Aspose.Slides is a commercial library, it offers a [free trial](https://releases.aspose.com/slides/java/) version that is fully capable of running the examples provided in this article. For the purpose of demonstrating ideas, testing features, or building a proof of concept like the one we’re covering here, the trial is more than sufficient. This makes it a convenient option for experimenting with automated PowerPoint generation without needing to commit to a license upfront.
Ok, let’s walk through building a sample presentation using real-world content.
### **Create a Title Slide**
We'll begin by creating a new presentation and adding a title slide with a main heading and subtitle.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
ISlide slide0 = presentation.getSlides().get_Item(0);
ILayoutSlide layoutSlide = presentation.getLayoutSlides().getByType(SlideLayoutType.Title);
slide0.setLayoutSlide(layoutSlide);
IAutoShape titleShape = (IAutoShape)slide0.getShapes().get_Item(0);
IAutoShape subtitleShape = (IAutoShape)slide0.getShapes().get_Item(1);
titleShape.getTextFrame().setText("Quarterly Business Review – Q1 2025");
subtitleShape.getTextFrame().setText("Prepared for Executive Team");
```

### **Add a Slide with a Column Chart**
Next, we’ll create a slide showing regional sales performance as a column chart.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
ILayoutSlide layoutSlide1 = presentation.getLayoutSlides().getByType(SlideLayoutType.Blank);
ISlide slide1 = presentation.getSlides().addEmptySlide(layoutSlide1);
IChart chart = slide1.getShapes().addChart(ChartType.ClusteredColumn, 100, 100, 500, 350, false);
chart.getLegend().setPosition(LegendPositionType.Bottom);
chart.setTitle(true);
chart.getChartTitle().addTextFrameForOverriding("Data from January – March 2025");
chart.getChartTitle().setOverlay(false);
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
int worksheetIndex = 0;
chart.getChartData().getCategories().add(workbook.getCell(worksheetIndex, 1, 0, "North America"));
chart.getChartData().getCategories().add(workbook.getCell(worksheetIndex, 2, 0, "Europe"));
chart.getChartData().getCategories().add(workbook.getCell(worksheetIndex, 3, 0, "Asia Pacific"));
chart.getChartData().getCategories().add(workbook.getCell(worksheetIndex, 4, 0, "Latin America"));
chart.getChartData().getCategories().add(workbook.getCell(worksheetIndex, 5, 0, "Middle East"));
IChartSeries series = chart.getChartData().getSeries().add(workbook.getCell(worksheetIndex, 0, 1, "Sales ($K)"), chart.getType());
series.getDataPoints().addDataPointForBarSeries(workbook.getCell(worksheetIndex, 1, 1, 480));
series.getDataPoints().addDataPointForBarSeries(workbook.getCell(worksheetIndex, 2, 1, 365));
series.getDataPoints().addDataPointForBarSeries(workbook.getCell(worksheetIndex, 3, 1, 290));
series.getDataPoints().addDataPointForBarSeries(workbook.getCell(worksheetIndex, 4, 1, 150));
series.getDataPoints().addDataPointForBarSeries(workbook.getCell(worksheetIndex, 5, 1, 120));
```

### **Add a Slide with a Table**
We’ll now add a slide that presents key performance metrics in table format.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
ILayoutSlide layoutSlide2 = presentation.getLayoutSlides().getByType(SlideLayoutType.Blank);
ISlide slide2 = presentation.getSlides().addEmptySlide(layoutSlide2);
double[] columnWidths = {200, 100};
double[] rowHeights = {40, 40, 40, 40, 40};
ITable table = slide2.getShapes().addTable(200, 200, columnWidths, rowHeights);
table.getColumns().get_Item(0).get_Item(0).getTextFrame().setText("Metric");
table.getColumns().get_Item(1).get_Item(0).getTextFrame().setText("Value");
table.getColumns().get_Item(0).get_Item(1).getTextFrame().setText("Total Revenue");
table.getColumns().get_Item(1).get_Item(1).getTextFrame().setText("$1.4M");
table.getColumns().get_Item(0).get_Item(2).getTextFrame().setText("Gross Margin");
table.getColumns().get_Item(1).get_Item(2).getTextFrame().setText("54%");
table.getColumns().get_Item(0).get_Item(3).getTextFrame().setText("New Customers");
table.getColumns().get_Item(1).get_Item(3).getTextFrame().setText("340");
table.getColumns().get_Item(0).get_Item(4).getTextFrame().setText("Customer Retention");
table.getColumns().get_Item(1).get_Item(4).getTextFrame().setText("87%");
```

### **Add a Summary Slide with Bullet Points**
Lastly, we’ll include a summary and action plan using a simple bullet list.
```java
import com.aspose.slides.*;
import java.awt.Color;
static IParagraph createBulletParagraph(String text) {
Paragraph paragraph = new Paragraph();
paragraph.getParagraphFormat().getBullet().setType(BulletType.Symbol);
paragraph.getParagraphFormat().setIndent(15);
paragraph.getParagraphFormat().getDefaultPortionFormat().getFillFormat().setFillType(FillType.Solid);
paragraph.getParagraphFormat().getDefaultPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
paragraph.setText(text);
return paragraph;
}
```
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
ILayoutSlide layoutSlide3 = presentation.getLayoutSlides().getByType(SlideLayoutType.Blank);
ISlide slide3 = presentation.getSlides().addEmptySlide(layoutSlide3);
IAutoShape bulletList = slide3.getShapes().addAutoShape(ShapeType.Rectangle, 100, 50, 600, 200);
bulletList.getFillFormat().setFillType(FillType.NoFill);
bulletList.getLineFormat().getFillFormat().setFillType(FillType.NoFill);
bulletList.getTextFrame().getParagraphs().clear();
bulletList.getTextFrame().getParagraphs().add(createBulletParagraph("Strong performance in North America; growth opportunity in Asia Pacific"));
bulletList.getTextFrame().getParagraphs().add(createBulletParagraph("Improve marketing outreach in underperforming regions"));
bulletList.getTextFrame().getParagraphs().add(createBulletParagraph("Prepare new campaign strategy for Q2"));
bulletList.getTextFrame().getParagraphs().add(createBulletParagraph("Schedule follow-up review in early July"));
```

### **Save the Presentation**
Finally, we save the presentation to disk:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
presentation.save("presentation.pptx", SaveFormat.Pptx);
```
## **Conclusion**
Automating PowerPoint generation in Java applications offers clear benefits in saving time and reducing manual effort. By integrating dynamic content such as charts, tables, and text, developers can quickly produce consistent, professional presentations—ideal for business reports, client meetings, or educational content.
In this article, we've demonstrated how to automate the creation of a presentation from scratch, including adding a title slide, charts, and tables. This approach can be applied across various use cases where automated, data-driven presentations are needed.
By leveraging the right tools, Java developers can efficiently automate PowerPoint creation, enhancing productivity and ensuring consistency across presentations.
# Customize Bubble Charts in Presentations Using Java
> Create and customize powerful bubble charts in PowerPoint with Aspose.Slides for Java to enhance your data visualization easily.
Source: https://docs.aspose.com/slides/java/bubble-chart/
Updated: 2026-11-08
## **Overview**
This article shows how to work with bubble charts in Aspose.Slides. It covers two specific customization options: scaling bubble sizes through the `setBubbleSizeScale` method and controlling how bubble size values are represented through the `setBubbleSizeRepresentation` method.
The examples demonstrate how to create a bubble chart, adjust its size scaling, and switch the bubble size representation to use width. The article also includes a short FAQ section that clarifies support for the “Bubble with 3-D” chart type, notes that practical chart limits depend on performance and the target PowerPoint version, and explains that export preserves the chart’s appearance through the Aspose.Slides rendering engine.
## **Bubble Chart Size Scaling**
Aspose.Slides for Java provides support for Bubble chart size scaling. In Aspose.Slides for Java [**IChartSeries.getBubbleSizeScale**](https://reference.aspose.com/slides/java/com.aspose.slides/IChartSeries#getBubbleSizeScale--), [**IChartSeriesGroup.getBubbleSizeScale**](https://reference.aspose.com/slides/java/com.aspose.slides/IChartSeriesGroup#getBubbleSizeScale--) and [**IChartSeriesGroup.setBubbleSizeScale**](https://reference.aspose.com/slides/java/com.aspose.slides/IChartSeriesGroup#setBubbleSizeScale-int-) methods have been added. Below sample example is given.
```java
import com.aspose.slides.*;
Presentation pres = new Presentation();
try {
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.Bubble, 100, 100, 400, 300);
chart.getChartData().getSeriesGroups().get_Item(0).setBubbleSizeScale(150);
pres.save("Result.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
## **Represent Data as Bubble Chart Sizes**
Methods [**setBubbleSizeRepresentation**](https://reference.aspose.com/slides/java/com.aspose.slides/IChartSeriesGroup#setBubbleSizeRepresentation-int-) and [**getBubbleSizeRepresentation**](https://reference.aspose.com/slides/java/com.aspose.slides/IChartSeriesGroup#getBubbleSizeRepresentation--) have been added to [IChartSeries](https://reference.aspose.com/slides/java/com.aspose.slides/IChartSeries), [IChartSeriesGroup](https://reference.aspose.com/slides/java/com.aspose.slides/IChartSeriesGroup) interfaces, and related classes. **BubbleSizeRepresentation** specifies how the bubble size values are represented in the bubble chart. Possible values are: [**BubbleSizeRepresentationType.Area**](https://reference.aspose.com/slides/java/com.aspose.slides/BubbleSizeRepresentationType#Area) and [**BubbleSizeRepresentationType.Width**](https://reference.aspose.com/slides/java/com.aspose.slides/BubbleSizeRepresentationType#Width). Accordingly, [**BubbleSizeRepresentationType**](https://reference.aspose.com/slides/java/com.aspose.slides/BubbleSizeRepresentationType) enum has been added to specify the possible ways to represent data as bubble chart sizes. Sample code is given below.
```java
import com.aspose.slides.*;
Presentation pres = new Presentation();
try {
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.Bubble, 50, 50, 600, 400, true);
chart.getChartData().getSeriesGroups().get_Item(0).setBubbleSizeRepresentation(BubbleSizeRepresentationType.Width);
pres.save("Presentation_BubbleSizeRepresentation.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
[](https://docs.aspose.com/slides/java/bubble-chart/visual-bubble-chart-bf890435c020.svg)
*Illustrative comparison at the same scale. Area uses the circle’s area, while Width uses its diameter.*
## **FAQ**
### Is a "bubble chart with 3-D effect" supported, and how does it differ from a regular one?
Yes. There is a separate chart type, "Bubble with 3-D." It applies 3-D styling to the bubbles but does not add an additional axis; the data remain X-Y-S (size). The type is available in the [chart type](https://reference.aspose.com/slides/java/com.aspose.slides/charttype/) class.
### Is there a limit on the number of series and points in a bubble chart?
There is no hard limit at the API level; constraints are determined by performance and the target PowerPoint version. It is recommended to keep the number of points reasonable for readability and rendering speed.
### How will export affect the appearance of a bubble chart (PDF, images)?
Export to supported formats preserves the chart’s appearance; rendering is performed by the Aspose.Slides engine. For raster/vector formats, general chart-graphics rendering rules apply (resolution, anti-aliasing), so choose sufficient DPI for printing.
# Manage Callouts in Presentation Charts Using Java
> Create and style callouts in Aspose.Slides for Java with concise code examples, compatible with PPT and PPTX to automate presentation workflows.
Source: https://docs.aspose.com/slides/java/callout/
Updated: 2026-08-05
## **Overview**
This article explains how to work with callouts for chart data labels in Aspose.Slides. It shows how to use the `setShowLabelAsDataCallout` method to display labels as callouts, how to configure callout-related label settings for a doughnut chart, and notes that callouts and their appearance are preserved when presentations are exported to PDF, HTML5, SVG, and raster image formats.
## **Using Callouts**
New methods [**getShowLabelAsDataCallout()**](https://reference.aspose.com/slides/java/com.aspose.slides/IDataLabelFormat#getShowLabelAsDataCallout--) and [**setShowLabelAsDataCallout()**](https://reference.aspose.com/slides/java/com.aspose.slides/IDataLabelFormat#setShowLabelAsDataCallout-boolean-) have been added to [DataLabelFormat](https://reference.aspose.com/slides/java/com.aspose.slides/datalabelformat) class and [IDataLabelFormat](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabelformat) interface. These methods determine either specified chart's data label will be displayed as data callout or as data label.
```java
import com.aspose.slides.*;
Presentation pres = new Presentation();
try {
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.Pie, 50, 50, 500, 400);
chart.getChartData().getSeries().get_Item(0).getLabels().getDefaultDataLabelFormat().setShowValue(true);
chart.getChartData().getSeries().get_Item(0).getLabels().getDefaultDataLabelFormat().setShowLabelAsDataCallout(true);
chart.getChartData().getSeries().get_Item(0).getLabels().get_Item(2).getDataLabelFormat().setShowLabelAsDataCallout(false);
pres.save("DisplayCharts.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
## **Set a Callout for a Doughnut Chart**
Aspose.Slides for Java provides support for setting series data label callout shape for a Doughnut chart. Below sample example is given.
```java
import com.aspose.slides.*;
Presentation pres = new Presentation();
try {
ISlide slide = pres.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Doughnut, 10, 10, 500, 500, false);
IChartDataWorkbook workBook = chart.getChartData().getChartDataWorkbook();
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
chart.setLegend(false);
int seriesIndex = 0;
while (seriesIndex < 15)
{
IChartSeries series = chart.getChartData().getSeries().add(workBook.getCell(0, 0, seriesIndex + 1, "SERIES " + seriesIndex), chart.getType());
series.setExplosion(0);
series.getParentSeriesGroup().setDoughnutHoleSize((byte)20);
series.getParentSeriesGroup().setFirstSliceAngle(351);
seriesIndex++;
}
int categoryIndex = 0;
while (categoryIndex < 15)
{
chart.getChartData().getCategories().add(workBook.getCell(0, categoryIndex + 1, 0, "CATEGORY " + categoryIndex));
int i = 0;
while (i < chart.getChartData().getSeries().size())
{
IChartSeries iCS = chart.getChartData().getSeries().get_Item(i);
IChartDataPoint dataPoint = iCS.getDataPoints().addDataPointForDoughnutSeries(workBook.getCell(0, categoryIndex + 1, i + 1, 1));
dataPoint.getFormat().getFill().setFillType(FillType.Solid);
dataPoint.getFormat().getLine().getFillFormat().setFillType(FillType.Solid);
dataPoint.getFormat().getLine().getFillFormat().getSolidFillColor().setColor(java.awt.Color.WHITE);
dataPoint.getFormat().getLine().setWidth(1);
dataPoint.getFormat().getLine().setStyle(LineStyle.Single);
dataPoint.getFormat().getLine().setDashStyle(LineDashStyle.Solid);
if (i == chart.getChartData().getSeries().size() - 1)
{
IDataLabel lbl = dataPoint.getLabel();
lbl.getTextFormat().getTextBlockFormat().setAutofitType(TextAutofitType.Shape);
lbl.getDataLabelFormat().getTextFormat().getPortionFormat().setFontBold(NullableBool.True);
lbl.getDataLabelFormat().getTextFormat().getPortionFormat().setLatinFont(new FontData("DINPro-Bold"));
lbl.getDataLabelFormat().getTextFormat().getPortionFormat().setFontHeight(12);
lbl.getDataLabelFormat().getTextFormat().getPortionFormat().getFillFormat().setFillType(FillType.Solid);
lbl.getDataLabelFormat().getTextFormat().getPortionFormat().getFillFormat().getSolidFillColor().setColor(java.awt.Color.LIGHT_GRAY);
lbl.getDataLabelFormat().getFormat().getLine().getFillFormat().getSolidFillColor().setColor(java.awt.Color.WHITE);
lbl.getDataLabelFormat().setShowValue(false);
lbl.getDataLabelFormat().setShowCategoryName(true);
lbl.getDataLabelFormat().setShowSeriesName(false);
lbl.getDataLabelFormat().setShowLeaderLines(true);
lbl.getDataLabelFormat().setShowLabelAsDataCallout(false);
chart.validateChartLayout();
lbl.setX((float) lbl.getX()+ (float)0.5);
lbl.setY((float)lbl.getY()+ (float)0.5);
}
i++;
}
categoryIndex++;
}
pres.save("chart.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
## **FAQ**
### Are callouts preserved when converting a presentation to PDF, HTML5, SVG, or images?
Yes. Callouts are part of the chart rendering, so when you export to [PDF](https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf/), [HTML5](https://docs.aspose.com/slides/java/export-to-html5/), [SVG](https://docs.aspose.com/slides/java/render-a-slide-as-an-svg-image/), or [raster images](https://docs.aspose.com/slides/java/convert-powerpoint-to-png/), they are preserved together with the slide’s formatting.
### Do custom fonts work in callouts, and can their appearance be preserved on export?
Yes. Aspose.Slides supports [embedding fonts](https://docs.aspose.com/slides/java/embedded-font/) into the presentation and controls font embedding during exports such as [PDF](https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf/), ensuring the callouts look the same across different systems.
# Customize Chart Axes in Presentations Using Java
> Discover how to use Aspose.Slides for Java to customize chart axes in PowerPoint presentations for reports and visualizations.
Source: https://docs.aspose.com/slides/java/chart-axis/
Updated: 2026-10-30
## **Overview**
This article explains how to customize chart axes with Aspose.Slides for Java. It covers calculated axis values, switching chart rows and columns, axis visibility, category label and tick-mark intervals, date categories and formatting, title rotation, axis positioning, display units, and logarithmic scaling.
## **Get the Max Values on the Vertical Axis on Charts**
Create a [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) and add an area chart with default data. Call [validateChartLayout](https://reference.aspose.com/slides/java/com.aspose.slides/chart/#validateChartLayout--) before reading calculated axis values so that the chart layout is up to date.
Read [getActualMaxValue](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#getActualMaxValue--) and [getActualMinValue](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#getActualMinValue--) for the axis limits, and [getActualMajorUnit](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#getActualMajorUnit--) and [getActualMinorUnit](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#getActualMinorUnit--) for the tick intervals. [getActualMajorUnitScale](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#getActualMajorUnitScale--) and [getActualMinorUnitScale](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#getActualMinorUnitScale--) provide time-unit scales, which are relevant to date axes. The example stores these values in local variables and saves the chart.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Area, 100, 100, 500, 350);
chart.validateChartLayout();
double maxValue = chart.getAxes().getVerticalAxis().getActualMaxValue();
double minValue = chart.getAxes().getVerticalAxis().getActualMinValue();
double majorUnit = chart.getAxes().getVerticalAxis().getActualMajorUnit();
double minorUnit = chart.getAxes().getVerticalAxis().getActualMinorUnit();
int majorUnitScale = chart.getAxes().getVerticalAxis().getActualMajorUnitScale();
int minorUnitScale = chart.getAxes().getVerticalAxis().getActualMinorUnitScale();
presentation.save("AxisValues_out.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Swap the Data between Axes**
Use [switchRowColumn](https://reference.aspose.com/slides/java/com.aspose.slides/chartdata/#switchRowColumn--) to exchange the roles of series and categories in chart data. Each former category becomes a series, and each former series becomes a category. This changes how the data is grouped; it does not exchange the horizontal and vertical axes. The example uses [setRange](https://reference.aspose.com/slides/java/com.aspose.slides/chartdata/#setRange-java.lang.String-) to bind the default data to `Sheet1!A1:D5`, including the header row and category column, before switching rows and columns. It saves a chart with four series and three categories.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 100, 100, 400, 300);
chart.getChartData().setRange("Sheet1!A1:D5");
chart.getChartData().switchRowColumn();
presentation.save("SwitchChartRowColumns_out.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Reverse the Plotting Order of an Axis**
Use [setPlotOrderReversed](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setPlotOrderReversed-boolean-) to reverse a category or value axis. For example, a horizontal bar chart can show project stages from top to bottom in the same order as the worksheet: Planning, Development, Testing. Reversing an axis changes the plotting direction; it does not sort or rearrange the workbook data. By comparison, [switchRowColumn](https://reference.aspose.com/slides/java/com.aspose.slides/chartdata/#switchRowColumn--) exchanges the roles of series and categories.
The following example creates a horizontal bar chart with three stages and one series. It saves a presentation with three slides: normal order, reversed categories, and reversed values. Each copy uses the same dataset, and only one axis is reversed on each copy.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredBar, 50, 40, 620, 320);
chart.setLegend(false);
chart.getChartData().getCategories().clear();
chart.getChartData().getSeries().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
workbook.clear(0);
IChartSeries series = chart.getChartData().getSeries().add(ChartType.ClusteredBar);
String[] stages = { "Planning", "Development", "Testing" };
int[] values = { 10, 30, 20 };
for (int i = 0; i < stages.length; i++) {
IChartDataCell categoryCell = workbook.getCell(0, i + 1, 0, stages[i]);
chart.getChartData().getCategories().add(categoryCell);
IChartDataCell valueCell = workbook.getCell(0, i + 1, 1, values[i]);
series.getDataPoints().addDataPointForBarSeries(valueCell);
}
// Slide 2: display the first category at the top.
ISlide categorySlide = presentation.getSlides().addClone(slide);
IChart categoryChart = (IChart)categorySlide.getShapes().get_Item(0);
categoryChart.getAxes().getVerticalAxis().setPlotOrderReversed(true);
// Keep the horizontal value axis at the bottom.
categoryChart.getAxes().getVerticalAxis().setCrossType(CrossesType.Maximum);
// Slide 3: reverse only the horizontal numeric scale.
ISlide valueSlide = presentation.getSlides().addClone(slide);
IChart valueChart = (IChart)valueSlide.getShapes().get_Item(0);
valueChart.getAxes().getHorizontalAxis().setPlotOrderReversed(true);
presentation.save("ReversedAxes.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
Reversing an axis can also move the perpendicular axis to the opposite side of the plot. [setCrossType](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setCrossType-int-) controls where the other axis crosses the axis being configured. In slide 2, calling it with `CrossesType.Maximum` on the reversed category axis keeps the horizontal value axis at the bottom. For a specific crossing point, use [setCrossAt](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setCrossAt-float-). Check the crossing settings when changing direction, especially if the chart already has a custom crossing point. Call `setPlotOrderReversed` with `false` to restore the normal plotting direction; crossing settings are separate.
| Normal order (slide 1) | Reversed categories (slide 2) | Reversed values (slide 3) |
| --- | --- | --- |
|  |  |  |
| Categories run from bottom to top; values increase from left to right. | Planning, Development, and Testing run from top to bottom. Values and workbook row order are unchanged. | Categories retain their normal order; values increase from right to left. The category axis crosses at zero on the right. |
## **Disable the Vertical Axis for Line Charts**
Call [setVisible](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setVisible-boolean-) with `false` on the vertical axis to hide it. The example creates a line chart with default data and saves it with the vertical axis hidden.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Line, 100, 100, 400, 300);
chart.getAxes().getVerticalAxis().setVisible(false);
presentation.save("HiddenVerticalAxis.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Disable the Horizontal Axis for Line Charts**
Call [setVisible](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setVisible-boolean-) with `false` on the horizontal axis to hide it. The example creates a line chart with default data and saves it with the horizontal axis hidden.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Line, 100, 100, 400, 300);
chart.getAxes().getHorizontalAxis().setVisible(false);
presentation.save("HiddenHorizontalAxis.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Change a Category Axis**
Use [setCategoryAxisType](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setCategoryAxisType-int-) to choose a date or text category axis. This example requires `ExistingChart.pptx`, with a chart as the first shape on the first slide and category cells containing numeric Excel date values. It changes the horizontal axis to a date axis. Calling [setAutomaticMajorUnit](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setAutomaticMajorUnit-boolean-) with `false`, [setMajorUnit](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setMajorUnit-double-) with `1`, and [setMajorUnitScale](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setMajorUnitScale-int-) with `TimeUnitType.Months` places major ticks at one-month intervals.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("ExistingChart.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = (IChart) slide.getShapes().get_Item(0);
chart.getAxes().getHorizontalAxis().setCategoryAxisType(CategoryAxisType.Date);
chart.getAxes().getHorizontalAxis().setAutomaticMajorUnit(false);
chart.getAxes().getHorizontalAxis().setMajorUnit(1);
chart.getAxes().getHorizontalAxis().setMajorUnitScale(TimeUnitType.Months);
presentation.save("ChangeChartCategoryAxis_out.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
### **Determine the Category Axis Type from Data**
Call [setCategoryAxisTypeAutomatically](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setCategoryAxisTypeAutomatically--) after populating the categories, then read [getCategoryAxisType](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#getCategoryAxisType--) to inspect the selection. This is useful when the same chart receives either text labels or numeric date values. The method determines the type when called; it does not enable a persistent mode that reevaluates later data changes. Call it again after replacing the categories.
The following example creates a chart with text categories and prints `true` when the selected type is `CategoryAxisType.Text`. It then replaces the category cell values with dates and calls the method again, printing `true` when the selected type is `CategoryAxisType.Date`. Dates are stored as numeric OLE Automation values, calculated for these dates as the number of days since December 30, 1899, rather than date strings. [setCustomNumberFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatacell/#setCustomNumberFormat-java.lang.String-) controls how those values are displayed; it does not convert text into numeric dates. For more on category cells, see [Chart Workbook](https://docs.aspose.com/slides/java/chart-workbook/).
Use automatic determination when the input is known to contain text categories or numeric dates, as in this example. For ordinary numeric labels, mixed categories, or empty data, explicitly call [setCategoryAxisType](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setCategoryAxisType-int-) to match the intended meaning. Numeric values alone do not establish that the categories represent dates.
```java
import com.aspose.slides.*;
import java.time.LocalDate;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 30, 40, 660, 320);
chart.getChartData().getCategories().clear();
chart.getChartData().getSeries().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
workbook.clear(0);
IChartDataCell seriesName = workbook.getCell(0, 0, 1, "Sales");
IChartSeries series = chart.getChartData().getSeries().add(seriesName, chart.getType());
String[] labels = { "First", "Second", "Third" };
for (int i = 0; i < labels.length; i++) {
IChartDataCell categoryCell = workbook.getCell(0, i + 1, 0, labels[i]);
chart.getChartData().getCategories().add(categoryCell);
IChartDataCell valueCell = workbook.getCell(0, i + 1, 1, (i + 1) * 10);
series.getDataPoints().addDataPointForBarSeries(valueCell);
}
IAxis axis = chart.getAxes().getHorizontalAxis();
axis.setCategoryAxisTypeAutomatically();
System.out.println(axis.getCategoryAxisType() == CategoryAxisType.Text); // true
LocalDate baseDate = LocalDate.of(1899, 12, 30);
LocalDate[] dates = { LocalDate.of(2026, 1, 1), LocalDate.of(2026, 1, 2), LocalDate.of(2026, 2, 1) };
for (int i = 0; i < dates.length; i++) {
IChartDataCell categoryCell = workbook.getCell(0, i + 1, 0);
categoryCell.setValue((double)(dates[i].toEpochDay() - baseDate.toEpochDay()));
categoryCell.setCustomNumberFormat("yyyy-mm-dd");
}
axis.setCategoryAxisTypeAutomatically();
System.out.println(axis.getCategoryAxisType() == CategoryAxisType.Date); // true
presentation.save("AutomaticCategoryAxis.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Control Category Axis Label Intervals**
When a chart has many categories, reduce the number of visible axis labels without removing categories or data points. Call [setAutomaticTickLabelSpacing](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setAutomaticTickLabelSpacing-boolean-) with `false`, then pass the desired category interval to [setTickLabelSpacing](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setTickLabelSpacing-long-). For text categories in their normal order, counting starts at the first category:
| Interval | Labels displayed in the example |
| --- | --- |
| `1` | Category 1, Category 2, Category 3, ... Category 24 |
| `2` | Category 1, Category 3, Category 5, ... Category 23 |
| `3` | Category 1, Category 4, Category 7, ... Category 22 |
An interval of `3` displays every third label, leaving two labels hidden between displayed labels. It does not remove the corresponding columns. Automatic spacing chooses an interval based on the available space; it does not necessarily display every label.
Tick marks have separate controls. Call [setAutomaticTickMarksSpacing](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setAutomaticTickMarksSpacing-boolean-) with `false` and use [setTickMarksSpacing](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setTickMarksSpacing-long-) to set their interval. For example, `1` keeps a tick mark at every category interval while labels appear only every third category. Use [setMajorTickMark](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setMajorTickMark-int-) with a visible style so you can see the result. Calling either automatic-spacing setter with `true` again lets the chart choose that interval again.
The following self-contained example creates 24 categories and one series, then saves three slides in `CategoryAxisIntervals.pptx`: automatic spacing, manual label spacing with independent tick marks, and restored automatic spacing. The two copies retain the original chart data. No input presentation is required. Horizontal label text makes the difference in density easy to see.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 30, 40, 660, 320);
chart.setLegend(false);
chart.getChartData().getCategories().clear();
chart.getChartData().getSeries().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
workbook.clear(0);
IChartSeries series = chart.getChartData().getSeries().add(ChartType.ClusteredColumn);
for (int i = 0; i < 24; i++) {
IChartDataCell categoryCell = workbook.getCell(0, i + 1, 0, "Category " + (i + 1));
chart.getChartData().getCategories().add(categoryCell);
IChartDataCell valueCell = workbook.getCell(0, i + 1, 1, 10 + i % 6 * 5);
series.getDataPoints().addDataPointForBarSeries(valueCell);
}
IAxis axis = chart.getAxes().getHorizontalAxis();
axis.setCategoryAxisType(CategoryAxisType.Text);
axis.getTextFormat().getTextBlockFormat().setRotationAngle(0);
axis.getTextFormat().getPortionFormat().setFontHeight(12);
axis.setMajorTickMark(TickMarkType.Outside);
axis.setAutomaticTickLabelSpacing(true);
axis.setAutomaticTickMarksSpacing(true);
// Slide 2: show every third label, but keep a tick mark for every category.
ISlide manualSlide = presentation.getSlides().addClone(slide);
IChart manualChart = (IChart)manualSlide.getShapes().get_Item(0);
IAxis manualAxis = manualChart.getAxes().getHorizontalAxis();
manualAxis.setAutomaticTickLabelSpacing(false);
manualAxis.setTickLabelSpacing(3);
manualAxis.setAutomaticTickMarksSpacing(false);
manualAxis.setTickMarksSpacing(1);
// Slide 3: let the chart choose both intervals again.
ISlide restoredSlide = presentation.getSlides().addClone(manualSlide);
IChart restoredChart = (IChart)restoredSlide.getShapes().get_Item(0);
restoredChart.getAxes().getHorizontalAxis().setAutomaticTickLabelSpacing(true);
restoredChart.getAxes().getHorizontalAxis().setAutomaticTickMarksSpacing(true);
presentation.save("CategoryAxisIntervals.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
**Automatic spacing (slide 1):** In this rendering, every second category label is displayed and wraps onto two lines. The automatic result can vary with chart size, fonts, and the renderer.

**Manual spacing (slide 2):** Every third label is displayed on one line, while tick marks remain at every category interval. All 24 columns, including those without labels, remain visible with the same values. Slide 3 restores the automatic appearance shown above.

### **Choose the Correct Axis and Interval**
Use this category-count interval for a text category axis, such as the category axis of a column, line, area, or bar chart. In a column chart, it is the horizontal axis. In a horizontal bar chart, the category axis is vertical, so apply these settings to the axis returned by [getVerticalAxis](https://reference.aspose.com/slides/java/com.aspose.slides/iaxesmanager/#getVerticalAxis--). Tick-mark spacing also applies to a series axis in charts that have one.
Do not use category label spacing to set the numeric scale of a value axis. On a value axis, [setMajorUnit](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setMajorUnit-double-) specifies a difference in values: for example, a major unit of `10` produces ticks at 0, 10, 20, and so on when the axis starts at zero. A category label interval of `3` instead counts category positions, regardless of their data values. Scatter and bubble charts use value axes rather than a text category axis. For a date axis, use time-based major units and scales as described in [Change a Category Axis](https://docs.aspose.com/slides/java/chart-axis/#change-a-category-axis).
## **Set the Date Format for Category Axis Values**
The example replaces the default chart data with four annual values. Dates are stored as OLE Automation serial numbers in the first worksheet (index `0`), calculated as the number of days since December 30, 1899, for these dates. Use [setCategoryAxisType](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setCategoryAxisType-int-) with `CategoryAxisType.Date`, call [setNumberFormatLinkedToSource](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setNumberFormatLinkedToSource-boolean-) with `false`, and pass `yyyy` to [setNumberFormat](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setNumberFormat-java.lang.String-) so the category labels display four-digit years independently of the cell formatting.
```java
import com.aspose.slides.*;
import java.time.LocalDate;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Line, 50, 50, 450, 300);
chart.getChartData().getCategories().clear();
chart.getChartData().getSeries().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
workbook.clear(0);
LocalDate baseDate = LocalDate.of(1899, 12, 30);
IChartSeries series = chart.getChartData().getSeries().add(ChartType.Line);
for (int i = 0; i < 4; i++) {
LocalDate date = LocalDate.of(2015 + i, 1, 1);
IChartDataCell categoryCell = workbook.getCell(0, i + 1, 0, date.toEpochDay() - baseDate.toEpochDay());
chart.getChartData().getCategories().add(categoryCell);
IChartDataCell valueCell = workbook.getCell(0, i + 1, 1, i + 1);
series.getDataPoints().addDataPointForLineSeries(valueCell);
}
chart.getAxes().getHorizontalAxis().setCategoryAxisType(CategoryAxisType.Date);
chart.getAxes().getHorizontalAxis().setNumberFormatLinkedToSource(false);
chart.getAxes().getHorizontalAxis().setNumberFormat("yyyy");
presentation.save("DateAxisFormat.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Set a Rotation Angle for a Chart Axis Title**
Call [setTitle](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setTitle-boolean-) with `true` on the vertical axis, provide title text, and use [setRotationAngle](https://reference.aspose.com/slides/java/com.aspose.slides/icharttextblockformat/#setRotationAngle-float-) to rotate the title. The angle is measured in degrees; this example saves a column chart with its value-axis title rotated by 90 degrees.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 450, 300);
chart.getAxes().getVerticalAxis().setTitle(true);
chart.getAxes().getVerticalAxis().getTitle().addTextFrameForOverriding("Value");
chart.getAxes().getVerticalAxis().getTitle().getTextFormat().getTextBlockFormat().setRotationAngle(90);
presentation.save("RotatedAxisTitle.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Set the Axis Position on a Category or Value Axis**
Use [setAxisBetweenCategories](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setAxisBetweenCategories-boolean-) to control whether the value axis crosses the category axis between categories or at category tick marks. This setting applies to category axes. The example sets it to `true` on the horizontal category axis of a column chart and saves the result.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 450, 300);
chart.getAxes().getHorizontalAxis().setAxisBetweenCategories(true);
presentation.save("AxisBetweenCategories.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Set the Display Unit on a Chart Value Axis**
Use [setDisplayUnit](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setDisplayUnit-int-) to scale the labels on a value axis without changing the underlying data. With [DisplayUnitType](https://reference.aspose.com/slides/java/com.aspose.slides/displayunittype/) set to `Millions`, a value of 60,000,000 is displayed as 60. The example creates a column chart and applies the millions display unit to its vertical axis.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 450, 300);
chart.getAxes().getVerticalAxis().setDisplayUnit(DisplayUnitType.Millions);
presentation.save("Result.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Configure a Logarithmic Value Axis**
A logarithmic value axis is useful when positive values span several orders of magnitude. For example, a service might receive 10, 100, 1,000, 10,000, and 100,000 requests over five periods. On a linear scale, the smaller values appear close together near zero. A logarithmic scale makes their relative growth easier to compare: equal distances represent equal ratios rather than equal differences.
Call [setLogarithmic](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setLogarithmic-boolean-) with `true` on the value axis and use [setLogBase](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setLogBase-double-) to choose the base. This changes how the existing values are displayed; it does not change the data or add a logarithmic trend line. A trend line represents a fitted relationship in the data and is a separate feature.
### **Choose the Value Axis and Base**
For a line or column chart, the value axis is returned by [getVerticalAxis](https://reference.aspose.com/slides/java/com.aspose.slides/iaxesmanager/#getVerticalAxis--). For a horizontal bar chart, it is returned by [getHorizontalAxis](https://reference.aspose.com/slides/java/com.aspose.slides/iaxesmanager/#getHorizontalAxis--). Scatter and bubble charts have two value axes, so choose the horizontal axis for X values, the vertical axis for Y values, or both. Do not apply logarithmic scaling to a category axis.
The default logarithmic base is `10`. For PPTX charts, use a base from `2` through `1000`, inclusive; fractional bases such as `2.5` are also supported. With base `10`, successive powers such as 10, 100, 1,000, and 10,000 are equally spaced.
### **Compare Linear and Logarithmic Scaling**
The following self-contained example creates a line chart with the five request counts on the first slide, then clones that slide and enables a base-10 logarithmic value axis on the second. Both slides retain the same data.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Line, 30, 40, 660, 200);
chart.setLegend(false);
chart.getChartData().getCategories().clear();
chart.getChartData().getSeries().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
workbook.clear(0);
IChartSeries series = chart.getChartData().getSeries().add(ChartType.Line);
double[] values = { 10, 100, 1000, 10000, 100000 };
for (int i = 0; i < values.length; i++) {
IChartDataCell categoryCell = workbook.getCell(0, i + 1, 0, "Period " + (i + 1));
chart.getChartData().getCategories().add(categoryCell);
IChartDataCell valueCell = workbook.getCell(0, i + 1, 1, values[i]);
series.getDataPoints().addDataPointForLineSeries(valueCell);
}
// Keep the first slide linear and change only the copy's value-axis scale.
ISlide logarithmicSlide = presentation.getSlides().addClone(slide);
IChart logarithmicChart = (IChart)logarithmicSlide.getShapes().get_Item(0);
IAxis valueAxis = logarithmicChart.getAxes().getVerticalAxis();
valueAxis.setLogarithmic(true);
valueAxis.setLogBase(10);
presentation.save("LogarithmicAxis.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
**Linear scale (slide 1):** Equal vertical distances represent equal differences in request counts. The largest value dominates the chart, making the smaller values difficult to distinguish.

**Logarithmic scale (slide 2):** Equal vertical distances represent equal ratios. Each period has ten times as many requests as the previous one, so the points form a straight rising line on the base-10 scale. The axis labels still show the original request counts.

### **Handle Zero and Negative Values**
A logarithmic scale can display only strictly positive values. Check the data before enabling it. If zero or negative values are meaningful, keep a linear scale or show them separately. If excluding those values is appropriate for the analysis, explain the omission. Do not silently replace them with small positive numbers, as this changes the meaning of the data. Any manually configured minimum or maximum for a logarithmic axis must also be positive.
## **FAQ**
**How do I set the value at which one axis crosses the other (axis crossing)?**
Use [setCrossType](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setCrossType-int-) to select the crossing behavior. To specify a numeric crossing value, use [setCrossAt](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setCrossAt-float-). These settings let you move the axis crossing to a suitable baseline.
**How can I position tick labels relative to the axis?**
Call [setTickLabelPosition](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setTickLabelPosition-int-) using [TickLabelPositionType](https://reference.aspose.com/slides/java/com.aspose.slides/ticklabelpositiontype/): `Low`, `High`, `NextTo`, or `None`. To control the tick marks themselves, use [setMajorTickMark](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setMajorTickMark-int-) or [setMinorTickMark](https://reference.aspose.com/slides/java/com.aspose.slides/axis/#setMinorTickMark-int-); these are separate from label positioning.
## Related articles
- [Format Presentation Charts in Java](https://docs.aspose.com/slides/java/chart-formatting/)
# Optimize Chart Calculations for Presentations in Java
> Understand chart calculations, data updates, and precision control in Aspose.Slides for Java for PPT and PPTX, with practical Java code examples.
Source: https://docs.aspose.com/slides/java/chart-calculations/
Updated: 2026-08-05
## **Overview**
Aspose.Slides provides APIs for working with chart calculations and layout data in presentations. This article shows how to retrieve the actual values of chart elements, including the real position and size of elements that implement `IActualLayout` and the actual values of chart axes. It also explains that these values are populated after chart layout validation.
In addition, the article demonstrates how to get the actual position of parent chart elements and how to hide chart components such as the title, axes, legend, and grid lines. Together, these examples help you inspect chart layout information and control the visibility of chart elements in PowerPoint presentations programmatically.
## **Calculate Actual Values of Chart Elements**
Aspose.Slides for Java provides a simple API for getting these properties. Properties of [IAxis](https://reference.aspose.com/slides/java/com.aspose.slides/IAxis) interface provide information about actual position of axis chart element ([IAxis.getActualMaxValue](https://reference.aspose.com/slides/java/com.aspose.slides/IAxis#getActualMaxValue--), [IAxis.getActualMinValue](https://reference.aspose.com/slides/java/com.aspose.slides/IAxis#getActualMinValue--), [IAxis.getActualMajorUnit](https://reference.aspose.com/slides/java/com.aspose.slides/IAxis#getActualMajorUnit--), [IAxis.getActualMinorUnit](https://reference.aspose.com/slides/java/com.aspose.slides/IAxis#getActualMinorUnit--), [IAxis.getActualMajorUnitScale](https://reference.aspose.com/slides/java/com.aspose.slides/IAxis#getActualMajorUnitScale--), [IAxis.getActualMinorUnitScale](https://reference.aspose.com/slides/java/com.aspose.slides/IAxis#getActualMinorUnitScale--)). It is necessary to call method [IChart.validateChartLayout()](https://reference.aspose.com/slides/java/com.aspose.slides/IChart#validateChartLayout--) previously to fill properties with actual values.
```java
import com.aspose.slides.*;
Presentation pres = new Presentation();
try {
Chart chart = (Chart)pres.getSlides().get_Item(0).getShapes().addChart(ChartType.Area, 100, 100, 500, 350);
chart.validateChartLayout();
double maxValue = chart.getAxes().getVerticalAxis().getActualMaxValue();
double minValue = chart.getAxes().getVerticalAxis().getActualMinValue();
double majorUnit = chart.getAxes().getHorizontalAxis().getActualMajorUnit();
double minorUnit = chart.getAxes().getHorizontalAxis().getActualMinorUnit();
} finally {
if (pres != null) pres.dispose();
}
```
## **Calculate Actual Position of Parent Chart Elements**
Aspose.Slides for Java provides a simple API for getting these properties. Properties of [IActualLayout](https://reference.aspose.com/slides/java/com.aspose.slides/IActualLayout) interface provide information about actual position of parent chart element ([IActualLayout.getActualX](https://reference.aspose.com/slides/java/com.aspose.slides/IActualLayout#getActualX--), [IActualLayout.getActualY](https://reference.aspose.com/slides/java/com.aspose.slides/IActualLayout#getActualY--), [IActualLayout.getActualWidth](https://reference.aspose.com/slides/java/com.aspose.slides/IActualLayout#getActualWidth--), [IActualLayout.getActualHeight](https://reference.aspose.com/slides/java/com.aspose.slides/IActualLayout#getActualHeight--)). It is necessary to call method [IChart.validateChartLayout()](https://reference.aspose.com/slides/java/com.aspose.slides/IChart#validateChartLayout--) previously to fill properties with actual values.
```java
import com.aspose.slides.*;
Presentation pres = new Presentation();
try {
Chart chart = (Chart) pres.getSlides().get_Item(0).getShapes().addChart(ChartType.ClusteredColumn, 100, 100, 500, 350);
chart.validateChartLayout();
double x = chart.getPlotArea().getActualX();
double y = chart.getPlotArea().getActualY();
double w = chart.getPlotArea().getActualWidth();
double h = chart.getPlotArea().getActualHeight();
} finally {
if (pres != null) pres.dispose();
}
```
## **Hide Chart Elements**
This topic helps you to understand how to hide information from chart. Using Aspose.Slides for Java you can hide **Title, Vertical Axis, Horizontal Axis** and **Grid Lines** from chart. Below code example shows how to use these properties.
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation pres = new Presentation();
try {
ISlide slide = pres.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.LineWithMarkers, 140, 118, 320, 370);
//Hiding chart Title
chart.setTitle(false);
///Hiding Values axis
chart.getAxes().getVerticalAxis().setVisible(false);
//Category Axis visibility
chart.getAxes().getHorizontalAxis().setVisible(false);
//Hiding Legend
chart.setLegend(false);
//Hiding MajorGridLines
chart.getAxes().getHorizontalAxis().getMajorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
// Keep only the first series. Removing from the end keeps the remaining indexes valid.
IChartSeriesCollection seriesCollection = chart.getChartData().getSeries();
while (seriesCollection.size() > 1)
{
seriesCollection.removeAt(seriesCollection.size() - 1);
}
IChartSeries series = seriesCollection.get_Item(0);
series.getMarker().setSymbol(MarkerStyleType.Circle);
series.getLabels().getDefaultDataLabelFormat().setShowValue(true);
series.getLabels().getDefaultDataLabelFormat().setPosition(LegendDataLabelPosition.Top);
series.getMarker().setSize(15);
//Setting series line color
series.getFormat().getLine().getFillFormat().setFillType(FillType.Solid);
series.getFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.MAGENTA);
series.getFormat().getLine().setDashStyle(LineDashStyle.Solid);
pres.save("HideInformationFromChart.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
## **FAQ**
### Do external Excel workbooks work as a data source, and how does that affect recalculation?
Yes. A chart can reference an external workbook: when you connect or refresh the external source, formulas and values are taken from that workbook, and the chart reflects the updates during open/edit operations. The API lets you [specify the external workbook](https://reference.aspose.com/slides/java/com.aspose.slides/chartdata/#setExternalWorkbook-java.lang.String-boolean-) path and manage the linked data.
### Can I compute and display trendlines without implementing regression myself?
Yes. [Trendlines](https://docs.aspose.com/slides/java/trend-line/) (linear, exponential, and others) are added and updated by Aspose.Slides; their parameters are recalculated from the series data automatically, so you don’t need to implement your own calculations.
### If a presentation has multiple charts with external links, can I control which workbook each chart uses for computed values?
Yes. Each chart can point to its own [external workbook](https://reference.aspose.com/slides/java/com.aspose.slides/chartdata/#setExternalWorkbook-java.lang.String-boolean-), or you can create/replace an external workbook per chart independently of the others.
# Manage Chart Data Labels in Presentations Using Java
> Learn to add and format chart data labels in PowerPoint presentations using Aspose.Slides for Java for more engaging slides.
Source: https://docs.aspose.com/slides/java/chart-data-label/
Updated: 2026-11-06
## **Introduction**
Data labels display information about chart series and individual data points, helping readers identify values and understand the chart. This article explains how to format values, display percentages, read label text, control labels beyond the axis maximum, adjust category axis label spacing, and position pie chart labels.
## **Count Visible Data Labels**
Use [getCountOfVisibleDataLabels](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabelcollection/#getCountOfVisibleDataLabels--) to check how many data labels are enabled for display before publishing a presentation. Unlike [getCount](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabelcollection/#getCount--), which returns the total number of labels in the collection, it takes the series defaults and individual label settings into account.
This example creates a column chart with one series and three data points. It accesses the series' label collection through [getLabels](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#getLabels--) and prints the visible count as the settings change: **0, 3, 2, 3**. The total count remains **3**.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 500, 300);
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
IChartDataCell seriesCell = workbook.getCell(0, 0, 1, "Values");
IChartSeries series = chart.getChartData().getSeries().add(seriesCell, chart.getType());
for (int i = 0; i < 3; i++) {
IChartDataCell categoryCell = workbook.getCell(0, i + 1, 0, "Category " + (i + 1));
chart.getChartData().getCategories().add(categoryCell);
IChartDataCell valueCell = workbook.getCell(0, i + 1, 1, (i + 1) * 10);
series.getDataPoints().addDataPointForBarSeries(valueCell);
}
IDataLabelCollection labels = series.getLabels();
System.out.println("Total: " + labels.getCount() + "; visible: " + labels.getCountOfVisibleDataLabels()); // Total: 3; visible: 0
labels.getDefaultDataLabelFormat().setShowValue(true);
System.out.println("Visible: " + labels.getCountOfVisibleDataLabels()); // Visible: 3
labels.get_Item(1).getDataLabelFormat().setShowValue(false);
System.out.println("Visible: " + labels.getCountOfVisibleDataLabels()); // Visible: 2
labels.get_Item(1).getDataLabelFormat().setShowLegendKey(true);
System.out.println("Visible: " + labels.getCountOfVisibleDataLabels()); // Visible: 3
} finally {
presentation.dispose();
}
```
The series' [getDefaultDataLabelFormat](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabelcollection/#getDefaultDataLabelFormat--) supplies the default settings. Passing `true` to [setShowValue](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabelformat/#setShowValue-boolean-) there displays values for all three labels. Passing `false` through one label's [getDataLabelFormat](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabel/#getDataLabelFormat--) overrides that setting for the selected label. Passing `true` to [setShowLegendKey](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabelformat/#setShowLegendKey-boolean-) makes that label count as visible again, even though its value remains hidden.
The visible count reflects visibility settings. It does not measure whether labels overlap, are clipped, or are readable in the rendered chart.
## **Set Data Precision in Chart Data Labels**
Use [setNumberFormatOfValues](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#setNumberFormatOfValues-java.lang.String-) to format series values. This example creates a line chart with default data, displays its data table, and enables value labels for the first series. The format `#,##0.00` displays a thousands separator and two decimal places without changing the underlying values.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Line, 50, 50, 450, 300);
chart.setDataTable(true);
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
series.setNumberFormatOfValues("#,##0.00");
series.getLabels().getDefaultDataLabelFormat().setShowValue(true);
presentation.save("PrecisionOfDatalabels_out.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
To format the numeric cells in a chart's embedded workbook, see [Set Custom Number Formats for Workbook Cells](https://docs.aspose.com/slides/java/chart-workbook/#set-custom-number-formats-for-workbook-cells). That example also shows value labels following their source cell formats while preserving the stored numeric values.
## **Display Percentage as Labels**
For a stacked column chart, calculate each value as a percentage of its category total and assign the text to the text frame returned by [getTextFrameForOverriding](https://reference.aspose.com/slides/java/com.aspose.slides/ioverridabletext/#getTextFrameForOverriding--). This example uses the default chart data and displays percentages with two decimal places in an 8-point font. Categories with a total of zero are skipped to avoid division by zero. Recalculate the custom label text if the chart data changes.
```java
import com.aspose.slides.*;
import java.util.Locale;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.StackedColumn, 20, 20, 400, 400);
double[] categoryTotals = new double[chart.getChartData().getCategories().size()];
for (int k = 0; k < chart.getChartData().getCategories().size(); k++) {
for (int i = 0; i < chart.getChartData().getSeries().size(); i++) {
IChartSeries series = chart.getChartData().getSeries().get_Item(i);
Number pointValue = (Number) series.getDataPoints().get_Item(k).getValue().getData();
categoryTotals[k] += pointValue.doubleValue();
}
}
for (int x = 0; x < chart.getChartData().getSeries().size(); x++) {
IChartSeries series = chart.getChartData().getSeries().get_Item(x);
series.getLabels().getDefaultDataLabelFormat().setShowLegendKey(false);
for (int j = 0; j < series.getDataPoints().size(); j++) {
IDataLabel label = series.getDataPoints().get_Item(j).getLabel();
if (categoryTotals[j] == 0) {
continue;
}
Number pointValue = (Number) series.getDataPoints().get_Item(j).getValue().getData();
double dataPointPercent = (pointValue.doubleValue() / categoryTotals[j]) * 100;
IPortion portion = new Portion();
portion.setText(String.format(Locale.US, "%.2f %%", dataPointPercent));
portion.getPortionFormat().setFontHeight(8f);
label.getTextFrameForOverriding().setText("");
IParagraph paragraph = label.getTextFrameForOverriding().getParagraphs().get_Item(0);
paragraph.getPortions().add(portion);
label.getDataLabelFormat().setShowValue(true);
label.getDataLabelFormat().setShowSeriesName(false);
label.getDataLabelFormat().setShowPercentage(false);
label.getDataLabelFormat().setShowLegendKey(false);
label.getDataLabelFormat().setShowCategoryName(false);
label.getDataLabelFormat().setShowBubbleSize(false);
}
}
presentation.save("DisplayPercentageAsLabels_out.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Set Percentage Sign with Chart Data Labels**
When values are stored as fractions, use [setNumberFormat](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabelformat/#setNumberFormat-java.lang.String-) to display percentages. Pass `false` to [setNumberFormatLinkedToSource](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabelformat/#setNumberFormatLinkedToSource-boolean-) to apply the label format independently of the source cells.
This example creates a 100% stacked column chart with red and blue series across four categories. Each pair of values adds up to 1. The label format `0.0%` displays 0.30 as 30.0%, while the vertical axis uses two decimal places. Both series use white, 10-point label text.
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.PercentsStackedColumn, 20, 20, 500, 400);
chart.getAxes().getVerticalAxis().setNumberFormatLinkedToSource(false);
chart.getAxes().getVerticalAxis().setNumberFormat("0.00%");
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
int worksheetIndex = 0;
for (int i = 0; i < 4; i++) {
IChartDataCell categoryCell = workbook.getCell(worksheetIndex, i + 1, 0, "Category " + (i + 1));
chart.getChartData().getCategories().add(categoryCell);
}
String[] seriesNames = { "Reds", "Blues" };
Color[] seriesColors = { Color.RED, Color.BLUE };
double[][] values = { { 0.30, 0.50, 0.80, 0.65 }, { 0.70, 0.50, 0.20, 0.35 } };
for (int i = 0; i < seriesNames.length; i++) {
IChartDataCell seriesCell = workbook.getCell(worksheetIndex, 0, i + 1, seriesNames[i]);
IChartSeries series = chart.getChartData().getSeries().add(seriesCell, chart.getType());
for (int j = 0; j < 4; j++) {
IChartDataCell valueCell = workbook.getCell(worksheetIndex, j + 1, i + 1, values[i][j]);
series.getDataPoints().addDataPointForBarSeries(valueCell);
}
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(seriesColors[i]);
IDataLabelFormat labelFormat = series.getLabels().getDefaultDataLabelFormat();
labelFormat.setShowValue(true);
labelFormat.setNumberFormatLinkedToSource(false);
labelFormat.setNumberFormat("0.0%");
labelFormat.getTextFormat().getPortionFormat().setFontHeight(10);
labelFormat.getTextFormat().getPortionFormat().getFillFormat().setFillType(FillType.Solid);
labelFormat.getTextFormat().getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.WHITE);
}
presentation.save("SetDataLabelsPercentageSign_out.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Read the Actual Text of Data Labels**
Use [getActualLabelText](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabel/#getActualLabelText--) to retrieve the text produced by a data label's settings. This is useful when extracting labels for reports, searching presentation content, or validating generated charts. In the example below, the default [data label format](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabelformat/) combines each category name, series name, and value. One point formats its value as a percentage, and another uses custom text from [getTextFrameForOverriding](https://reference.aspose.com/slides/java/com.aspose.slides/ioverridabletext/#getTextFrameForOverriding--).
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 20, 20, 500, 300);
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
IChartDataCell firstCategoryCell = workbook.getCell(0, 1, 0, "Q1");
chart.getChartData().getCategories().add(firstCategoryCell);
IChartDataCell secondCategoryCell = workbook.getCell(0, 2, 0, "Q2");
chart.getChartData().getCategories().add(secondCategoryCell);
IChartDataCell northSeriesCell = workbook.getCell(0, 0, 1, "North");
IChartSeries north = chart.getChartData().getSeries().add(northSeriesCell, chart.getType());
IChartDataCell northFirstValueCell = workbook.getCell(0, 1, 1, 0.25);
north.getDataPoints().addDataPointForBarSeries(northFirstValueCell);
IChartDataCell northSecondValueCell = workbook.getCell(0, 2, 1, 0.75);
north.getDataPoints().addDataPointForBarSeries(northSecondValueCell);
IChartDataCell southSeriesCell = workbook.getCell(0, 0, 2, "South");
IChartSeries south = chart.getChartData().getSeries().add(southSeriesCell, chart.getType());
IChartDataCell southFirstValueCell = workbook.getCell(0, 1, 2, 0.40);
south.getDataPoints().addDataPointForBarSeries(southFirstValueCell);
IChartDataCell southSecondValueCell = workbook.getCell(0, 2, 2, 0.60);
south.getDataPoints().addDataPointForBarSeries(southSecondValueCell);
for (IChartSeries series : chart.getChartData().getSeries()) {
IDataLabelFormat format = series.getLabels().getDefaultDataLabelFormat();
format.setShowCategoryName(true);
format.setShowSeriesName(true);
format.setShowValue(true);
}
north.getLabels().get_Item(1).getDataLabelFormat().setNumberFormatLinkedToSource(false);
north.getLabels().get_Item(1).getDataLabelFormat().setNumberFormat("0%");
south.getLabels().get_Item(0).getTextFrameForOverriding().setText("Reviewed");
for (IChartSeries series : chart.getChartData().getSeries()) {
for (IChartDataPoint point : series.getDataPoints()) {
IDataLabel label = point.getLabel();
if (!label.isVisible()) {
continue;
}
System.out.println("Value: " + point.getValue().getData() + "; label: " + label.getActualLabelText());
}
}
} finally {
presentation.dispose();
}
```
The number stored in a data point remains `0.75`, even when its label shows `75%` along with the category and series names. Custom text replaces the generated label text. [getActualLabelText](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabel/#getActualLabelText--) returns the resulting label string in either case. Check [isVisible](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabel/#isVisible--) separately, as shown above, when you want to extract only visible labels.
## **Control Data Labels Beyond the Axis Maximum**
When you limit an axis range manually, some data points may exceed its maximum. Use [setShowDataLabelsOverMaximum](https://reference.aspose.com/slides/java/com.aspose.slides/ichart/#setShowDataLabelsOverMaximum-boolean-) to control whether their data labels are shown. This setting changes label visibility; it does not change the axis range or the underlying data values.
The example below creates a 2D clustered column chart with values of 60 and 120. It passes `false` to [setAutomaticMaxValue](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setAutomaticMaxValue-boolean-) and sets the maximum to 100 with [setMaxValue](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setMaxValue-double-) on the vertical axis. The first slide allows labels beyond the maximum; a copy of that slide disables them. Both slides are saved in `DataLabelsOverMaximum.pptx`.
Enable value labels with [setShowValue](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabelformat/#setShowValue-boolean-). The chart-level setting does not enable value display by itself or override an individual label's disabled value display. This example enables values for the entire series and uses [setPosition](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabelformat/#setPosition-int-) to place labels at the outside end of each column.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 600, 400);
chart.setLegend(false);
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
IChartDataCell firstCategory = workbook.getCell(0, 1, 0, "Within range");
IChartDataCell secondCategory = workbook.getCell(0, 2, 0, "Above maximum");
chart.getChartData().getCategories().add(firstCategory);
chart.getChartData().getCategories().add(secondCategory);
IChartDataCell seriesName = workbook.getCell(0, 0, 1, "Values");
IChartSeries series = chart.getChartData().getSeries().add(seriesName, chart.getType());
IChartDataCell firstValue = workbook.getCell(0, 1, 1, 60);
IChartDataCell secondValue = workbook.getCell(0, 2, 1, 120);
series.getDataPoints().addDataPointForBarSeries(firstValue);
series.getDataPoints().addDataPointForBarSeries(secondValue);
series.getLabels().getDefaultDataLabelFormat().setShowValue(true);
series.getLabels().getDefaultDataLabelFormat().setPosition(LegendDataLabelPosition.OutsideEnd);
chart.getAxes().getVerticalAxis().setAutomaticMaxValue(false);
chart.getAxes().getVerticalAxis().setMaxValue(100);
chart.setShowDataLabelsOverMaximum(true);
ISlide secondSlide = presentation.getSlides().addClone(slide);
IChart secondChart = (IChart) secondSlide.getShapes().get_Item(0);
secondChart.setShowDataLabelsOverMaximum(false);
presentation.save("DataLabelsOverMaximum.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The following images show the saved slides rendered by Microsoft PowerPoint. With `true`, the label **120** is visible at the upper boundary; with `false`, it is hidden. The label **60** remains visible, the axis maximum stays at **100**, and the second data point remains **120** in both cases.
| setShowDataLabelsOverMaximum(true) | setShowDataLabelsOverMaximum(false) |
| --- | --- |
|  |  |
This example uses a 2D column chart with a value axis. Charts without a value axis, such as pie and doughnut charts, do not have an axis maximum to limit in this way.
## **Set Label Distance from an Axis**
Use [setLabelOffset](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setLabelOffset-int-) to control the distance between category axis labels and the axis. The value is a percentage of the maximum font size of the axis labels. This example creates a clustered column chart and sets the horizontal axis label offset to 500. This setting affects category axis labels rather than labels attached to individual data points.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 20, 20, 500, 300);
chart.getAxes().getHorizontalAxis().setLabelOffset(500);
presentation.save("SetCategoryAxisLabelDistance_out.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Adjust Label Location**
On a pie chart, adjust data label positions to improve spacing and make room for leader lines.
This example displays the value of the first data point, places its label outside the slice, and adjusts its horizontal and vertical offsets using [setX](https://reference.aspose.com/slides/java/com.aspose.slides/ilayoutable/#setX-float-) and [setY](https://reference.aspose.com/slides/java/com.aspose.slides/ilayoutable/#setY-float-). These offsets are relative to the chart width and height, respectively.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Pie, 50, 50, 200, 200);
IChartSeriesCollection series = chart.getChartData().getSeries();
IDataLabel label = series.get_Item(0).getLabels().get_Item(0);
label.getDataLabelFormat().setShowValue(true);
label.getDataLabelFormat().setPosition(LegendDataLabelPosition.OutsideEnd);
label.setX(0.71f);
label.setY(0.04f);
presentation.save("presentation.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```

## **Format Leader Lines**
When pie chart labels sit outside their slices, leader lines help readers match each value to the correct slice. A contrasting color and a slightly thicker line can make these connections easier to follow, while transparency and a dashed style keep the lines visually unobtrusive.
Use [getLeaderLinesFormat](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabelcollection/#getLeaderLinesFormat--) to format leader lines at the series' data label collection level. The settings in `series.getLabels().getLeaderLinesFormat().getLine()` apply to the collection, rather than to an individual label.
This example creates a pie chart with default data, displays values outside the slices, and enables [setShowLeaderLines](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabelformat/#setShowLeaderLines-boolean-). It moves two labels farther from their slices using [setX](https://reference.aspose.com/slides/java/com.aspose.slides/ilayoutable/#setX-float-) and [setY](https://reference.aspose.com/slides/java/com.aspose.slides/ilayoutable/#setY-float-) offsets, expressed as fractions of the chart width and height. No input presentation is required.
The line's [getFillFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ilineformat/#getFillFormat--) sets a solid blue color with an alpha value of 191 out of 255, giving approximately 25% transparency. [setWidth](https://reference.aspose.com/slides/java/com.aspose.slides/ilineformat/#setWidth-double-) sets the thickness to 2 points, and [setDashStyle](https://reference.aspose.com/slides/java/com.aspose.slides/ilineformat/#setDashStyle-byte-) makes the line dashed.
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Pie, 80, 50, 560, 400);
chart.setLegend(false);
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
IDataLabelFormat labelFormat = series.getLabels().getDefaultDataLabelFormat();
labelFormat.setShowValue(true);
labelFormat.setPosition(LegendDataLabelPosition.OutsideEnd);
labelFormat.setShowLeaderLines(true);
// Move two labels farther away from their slices.
series.getLabels().get_Item(0).setX(0.10f);
series.getLabels().get_Item(0).setY(-0.05f);
series.getLabels().get_Item(1).setX(-0.10f);
series.getLabels().get_Item(1).setY(0.05f);
ILineFormat line = series.getLabels().getLeaderLinesFormat().getLine();
line.getFillFormat().setFillType(FillType.Solid);
line.getFillFormat().getSolidFillColor().setColor(new Color(30, 90, 160, 191));
line.setWidth(2);
line.setDashStyle(LineDashStyle.Dash);
presentation.save("FormattedLeaderLines.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
Enabling leader lines does not guarantee that a line will appear for every label. Visibility depends on label placement and the chart's layout behavior. In this example, the two displaced labels have visible leader lines; the labels that remain close to their slices do not need them.
The following image shows the saved `FormattedLeaderLines.pptx` rendered with Aspose.Slides:

## **Add Multiple Rows of Data Labels Above a Column Chart**
This example creates a column chart with two rows of data labels above the plot area. Series A displays the visible columns, while Series B and Series C provide the additional labels. Their columns are hidden by removing the fill and outline. The [ChartSeriesGroup.setOverlap](https://reference.aspose.com/slides/java/com.aspose.slides/chartseriesgroup/) method aligns all three series with the same category centers.
The [ChartPlotArea](https://reference.aspose.com/slides/java/com.aspose.slides/chartplotarea/) settings reserve space for the label rows. After [Chart.validateChartLayout](https://reference.aspose.com/slides/java/com.aspose.slides/chart/) calculates the default positions, [DataLabel.setX and DataLabel.setY](https://reference.aspose.com/slides/java/com.aspose.slides/datalabel/) preserve the horizontal alignment and apply vertical offsets to arrange the labels in two rows. The numbers remain data labels linked to the series values; only the row headings are separate text shapes.
```java
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 40, 40, 640, 200);
chart.setTitle(false);
chart.setLegend(false);
chart.getTextFormat().getPortionFormat().setFontHeight(12);
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
workbook.clear(0);
String[] categories = {"North", "South", "East", "West"};
String[] seriesNames = {"Series A", "Series B", "Series C"};
double[][] seriesValues = {
{35, 42, 28, 47},
{22, 31, 19, 26},
{12, 16, 14, 18}
};
for (int categoryIndex = 0; categoryIndex < categories.length; categoryIndex++) {
chart.getChartData().getCategories().add(
workbook.getCell(0, categoryIndex + 1, 0, categories[categoryIndex]));
}
for (int seriesIndex = 0; seriesIndex < seriesNames.length; seriesIndex++) {
IChartSeries series = chart.getChartData().getSeries().add(
workbook.getCell(0, 0, seriesIndex + 1, seriesNames[seriesIndex]),
ChartType.ClusteredColumn);
for (int categoryIndex = 0; categoryIndex < categories.length; categoryIndex++) {
series.getDataPoints().addDataPointForBarSeries(workbook.getCell(
0, categoryIndex + 1, seriesIndex + 1,
seriesValues[seriesIndex][categoryIndex]));
}
if (seriesIndex > 0) {
// Hide the columns of B and C, but keep their data labels.
series.getFormat().getFill().setFillType(FillType.NoFill);
series.getFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
series.getLabels().getDefaultDataLabelFormat().setShowValue(true);
series.getLabels().getDefaultDataLabelFormat()
.getTextFormat().getPortionFormat().setFontHeight(12);
IFillFormat labelFill = series.getLabels().getDefaultDataLabelFormat()
.getTextFormat().getPortionFormat().getFillFormat();
labelFill.setFillType(FillType.Solid);
labelFill.getSolidFillColor().setColor(java.awt.Color.BLACK);
series.getLabels().getDefaultDataLabelFormat().setPosition(
LegendDataLabelPosition.InsideBase);
}
}
// Align all three series with the same category centers.
chart.getChartData().getSeries().get_Item(0)
.getParentSeriesGroup().setOverlap((byte) 100);
// Use fewer gridlines for this compact example.
chart.getAxes().getVerticalAxis().setAutomaticMajorUnit(false);
chart.getAxes().getVerticalAxis().setMajorUnit(10);
// Reserve space above the plot for two rows of data labels.
chart.getPlotArea().setLayoutTargetType(LayoutTargetType.Inner);
chart.getPlotArea().setX(0.15f);
chart.getPlotArea().setY(0.32f);
chart.getPlotArea().setWidth(0.80f);
chart.getPlotArea().setHeight(0.48f);
chart.validateChartLayout();
for (int seriesIndex = 1; seriesIndex < seriesNames.length; seriesIndex++) {
IChartSeries series = chart.getChartData().getSeries().get_Item(seriesIndex);
float rowTop = seriesIndex == 1 ? 0.15f : 0.03f;
for (int categoryIndex = 0; categoryIndex < categories.length; categoryIndex++) {
IDataLabel dataLabel = series.getDataPoints().get_Item(categoryIndex).getLabel();
// Keep the default horizontal position. Y is an offset from
// the default label position, expressed as a chart-height fraction.
dataLabel.setX(0);
dataLabel.setY(rowTop - dataLabel.getActualY() / chart.getHeight());
}
// Only the row heading is a separate text shape.
IAutoShape rowHeading = slide.getShapes().addAutoShape(
ShapeType.Rectangle, chart.getX(),
chart.getY() + rowTop * chart.getHeight(), 85, 18);
rowHeading.getFillFormat().setFillType(FillType.NoFill);
rowHeading.getLineFormat().getFillFormat().setFillType(FillType.NoFill);
rowHeading.addTextFrame(seriesNames[seriesIndex]);
rowHeading.getTextFrame().getTextFrameFormat().setMarginTop(0);
rowHeading.getTextFrame().getTextFrameFormat().setMarginBottom(0);
IPortionFormat headingFormat = rowHeading.getTextFrame().getParagraphs()
.get_Item(0).getPortions().get_Item(0).getPortionFormat();
headingFormat.setFontHeight(12);
headingFormat.getFillFormat().setFillType(FillType.Solid);
headingFormat.getFillFormat().getSolidFillColor().setColor(java.awt.Color.BLACK);
}
presentation.save("multiple-rows-of-labels.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```

## **FAQ**
**How can I prevent data labels from overlapping on dense charts?**
Combine automatic label placement, leader lines, and reduced font size; if necessary, hide some fields (for example, the category) or show labels only for extreme values or key points.
**How can I disable labels only for zero, negative, or empty values?**
Filter data points before enabling labels and turn off display for values of 0, negative values, or missing values according to a defined rule.
**How can I ensure a consistent label style when exporting to PDF/images?**
Explicitly set the font family and size and verify that the font is available in the rendering environment to avoid fallback.
# Manage Chart Data Markers in Presentations Using Java
> Learn how to customize chart data markers in Aspose.Slides for Java, boosting presentation impact across PPT and PPTX formats with clear Java code examples.
Source: https://docs.aspose.com/slides/java/chart-data-marker/
Updated: 2026-08-05
## **Overview**
This article explains how to work with chart data markers in Aspose.Slides. It shows how to create a chart, access a series and its data points, apply picture fills to markers at the data-point level, adjust marker size, and save the updated presentation. It also notes that standard marker shapes are available through the `MarkerStyleType` enumeration and that marker appearance is preserved when exporting charts to raster formats or SVG.
## **Set Chart Marker Options**
The markers can be set on chart data points inside particular series. In order to set chart marker options. Please follow the steps below:
- Instantiate [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class.
- Creating the default chart.
- Set the picture.
- Take first chart series.
- Add new data point.
- Write presentation to disk.
In the example given below, we have set the chart marker options on data points level.
```java
import com.aspose.slides.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
// Creating empty presentation
Presentation pres = new Presentation();
try {
// Access first slide
ISlide slide = pres.getSlides().get_Item(0);
// Creating the default chart
IChart chart = slide.getShapes().addChart(ChartType.LineWithMarkers, 0, 0, 400, 400);
// Getting the default chart data WorkSheet index
int defaultWorksheetIndex = 0;
// Getting the chart data WorkSheet
IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();
// Delete demo series
chart.getChartData().getSeries().clear();
// Add new series
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 1, 1, "Series 1"), chart.getType());
// Load the picture 1
IPPImage imgx1 = pres.getImages().addImage(new FileInputStream(new File("Desert.jpg")));
// Load the picture 2
IPPImage imgx2 = pres.getImages().addImage(new FileInputStream(new File("Tulips.jpg")));
// Take first chart series
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
// Add new point (1:3) there.
IChartDataPoint point = series.getDataPoints().addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 1, 1, (double) 4.5));
point.getMarker().getFormat().getFill().setFillType(FillType.Picture);
point.getMarker().getFormat().getFill().getPictureFillFormat().getPicture().setImage(imgx1);
point = series.getDataPoints().addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 2, 1, (double) 2.5));
point.getMarker().getFormat().getFill().setFillType(FillType.Picture);
point.getMarker().getFormat().getFill().getPictureFillFormat().getPicture().setImage(imgx2);
point = series.getDataPoints().addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 3, 1, (double) 3.5));
point.getMarker().getFormat().getFill().setFillType(FillType.Picture);
point.getMarker().getFormat().getFill().getPictureFillFormat().getPicture().setImage(imgx1);
point = series.getDataPoints().addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 4, 1, (double) 4.5));
point.getMarker().getFormat().getFill().setFillType(FillType.Picture);
point.getMarker().getFormat().getFill().getPictureFillFormat().getPicture().setImage(imgx2);
// Changing the chart series marker
series.getMarker().setSize(15);
// Save presentation with chart
pres.save("MarkOptions_out.pptx", SaveFormat.Pptx);
} catch (IOException e) {
} finally {
if (pres != null) pres.dispose();
}
```
## **FAQ**
### Which marker shapes are available out of the box?
Standard shapes are available (circle, square, diamond, triangle, etc.); the list is defined by the [MarkerStyleType](https://reference.aspose.com/slides/java/com.aspose.slides/markerstyletype/) class. If you need a non-standard shape, use a marker with a picture fill to emulate custom visuals.
### Are markers preserved when exporting a chart to an image or SVG?
Yes. When rendering charts to [raster formats](https://docs.aspose.com/slides/java/convert-powerpoint-to-png/) or saving [shapes as SVG](https://docs.aspose.com/slides/java/render-a-slide-as-an-svg-image/), markers retain their appearance and settings, including size, fill, and outline.
# Customize Chart Data Tables in Presentations Using Java
> Customize chart data table fonts, borders, and legend keys in PowerPoint presentations using Aspose.Slides for Java.
Source: https://docs.aspose.com/slides/java/chart-data-table/
Updated: 2026-09-24
## **Overview**
Aspose.Slides for Java lets you display a chart's data table and customize its text formatting, borders, and legend keys. This article explains how to enable the table, format its text, control each type of border, and show or hide legend keys. The examples save the configured charts in PPTX files.
## **Set Font Properties**
To display a chart's data table, pass `true` to [setDataTable](https://reference.aspose.com/slides/java/com.aspose.slides/chart/#setDataTable-boolean-). Use [getChartDataTable](https://reference.aspose.com/slides/java/com.aspose.slides/chart/#getChartDataTable--) to access the table and configure its text formatting.
1. Load the presentation using the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class.
1. Add a clustered column chart to the first slide.
1. Enable the chart's data table.
1. Enable bold text with [setFontBold](https://reference.aspose.com/slides/java/com.aspose.slides/baseportionformat/#setFontBold-byte-) and pass `20` to [setFontHeight](https://reference.aspose.com/slides/java/com.aspose.slides/baseportionformat/#setFontHeight-float-) for 20-point text.
1. Save the modified presentation.
The following example requires `test.pptx` in the working directory with at least one slide. It adds a chart with default data at position (50, 50), with a width of 600 points and a height of 400 points. The saved `output.pptx` contains the chart with its data table enabled and the specified font settings applied.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("test.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 600, 400);
chart.setDataTable(true);
IChartPortionFormat portionFormat = chart.getChartDataTable().getTextFormat().getPortionFormat();
portionFormat.setFontBold(NullableBool.True);
portionFormat.setFontHeight(20);
presentation.save("output.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Customize Data Table Borders**
Enable the table with [IChart.setDataTable](https://reference.aspose.com/slides/java/com.aspose.slides/ichart/#setDataTable-boolean-) and access it through [IChart.getChartDataTable](https://reference.aspose.com/slides/java/com.aspose.slides/ichart/#getChartDataTable--). You can control three types of borders independently:
- [setBorderHorizontal](https://reference.aspose.com/slides/java/com.aspose.slides/idatatable/#setBorderHorizontal-boolean-) controls horizontal cell borders.
- [setBorderVertical](https://reference.aspose.com/slides/java/com.aspose.slides/idatatable/#setBorderVertical-boolean-) controls vertical cell borders.
- [setBorderOutline](https://reference.aspose.com/slides/java/com.aspose.slides/idatatable/#setBorderOutline-boolean-) controls the outer border of the table.
Pass `true` to each method to display its borders or `false` to hide them. The following example creates a clustered column chart with default data, displays horizontal borders and the outer border, and hides vertical borders. It requires no input file. The chart's position and size are specified in points.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 600, 400);
chart.setDataTable(true);
IDataTable dataTable = chart.getChartDataTable();
dataTable.setBorderHorizontal(true);
dataTable.setBorderVertical(false);
dataTable.setBorderOutline(true);
presentation.save("data-table-borders.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The comparison below uses the same chart data and legend key setting in all four cases. Starting with all borders enabled, each remaining variant disables just one border setting. The lower-left variant matches the border settings in the example.

## **Show or Hide Legend Keys**
Legend keys are small colored markers beside the series names in the data table. They help readers match each table row to a chart series. Pass `true` to [setShowLegendKey](https://reference.aspose.com/slides/java/com.aspose.slides/idatatable/#setShowLegendKey-boolean-) to show these markers or `false` to hide them.
The chart's separate legend is controlled by [IChart.setLegend](https://reference.aspose.com/slides/java/com.aspose.slides/ichart/#setLegend-boolean-). These settings are independent: hiding the separate legend does not hide the keys inside the data table, and hiding the table's keys does not hide the separate legend.
The following example creates a chart with default data, enables its data table, and shows legend keys inside it while hiding the separate legend. All table borders are explicitly enabled. No input presentation is required. To hide only the table's keys, pass `false` to [setShowLegendKey](https://reference.aspose.com/slides/java/com.aspose.slides/idatatable/#setShowLegendKey-boolean-).
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 600, 400);
chart.setDataTable(true);
chart.setLegend(false);
IDataTable dataTable = chart.getChartDataTable();
dataTable.setBorderHorizontal(true);
dataTable.setBorderVertical(true);
dataTable.setBorderOutline(true);
dataTable.setShowLegendKey(true);
presentation.save("data-table-legend-keys.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The comparison below shows the same table with legend keys enabled and disabled. All borders remain enabled, and the separate chart legend is hidden in both cases.

## **FAQ**
**Can I show legend keys in a chart's data table?**
Yes. Pass `true` to [setShowLegendKey](https://reference.aspose.com/slides/java/com.aspose.slides/datatable/#setShowLegendKey-boolean-) to display legend keys or `false` to hide them.
**Will the data table be preserved when exporting the presentation to PDF, HTML, or images?**
Yes. Aspose.Slides renders the chart and its displayed data table as part of the slide when exporting to [PDF](https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf/), [HTML](https://docs.aspose.com/slides/java/convert-powerpoint-to-html/), or [images](https://docs.aspose.com/slides/java/convert-powerpoint-to-png/).
**Can I work with data tables in charts loaded from a template?**
Yes. For a chart loaded from an existing presentation or template, use [hasDataTable](https://reference.aspose.com/slides/java/com.aspose.slides/chart/#hasDataTable--) and [setDataTable](https://reference.aspose.com/slides/java/com.aspose.slides/chart/#setDataTable-boolean-) to check or change whether its data table is displayed.
**How can I find charts that have a data table enabled?**
Iterate through the shapes on each slide, identify the charts, and call their [hasDataTable](https://reference.aspose.com/slides/java/com.aspose.slides/chart/#hasDataTable--) method. A value of `true` indicates that the data table is enabled.
# Customize Presentation Chart Entities in Java
> Understand chart entities in Aspose.Slides for Java and learn to manage series, categories, data points and axes in PowerPoint PPT and PPTX using Java.
Source: https://docs.aspose.com/slides/java/chart-entities/
Updated: 2025-11-17
---
lastmod: 2025-11-17T20:34:00+04:00
title: Customize Presentation Chart Entities in Java
linktitle: Chart Entities
type: docs
weight: 30
url: /java/chart-entities/
keywords:
- callout
- axis
- data label
- data marker
- data table
- legend
- plot area
- data series
- error bar
- trend line
- PowerPoint
- presentation
- Java
- Aspose.Slides
description: "Understand chart entities in Aspose.Slides for Java and learn to manage series, categories, data points and axes in PowerPoint PPT and PPTX using Java."
---
## Related articles
- [Create and Customize PowerPoint Charts in Java](https://docs.aspose.com/slides/java/powerpoint-charts/)
- [Format Presentation Charts in Java](https://docs.aspose.com/slides/java/chart-formatting/)
# Format Presentation Charts in Java
> Learn chart formatting in Aspose.Slides for Java and elevate your PowerPoint presentation with custom axes, fonts, number formats, and rounded chart borders.
Source: https://docs.aspose.com/slides/java/chart-formatting/
Updated: 2026-11-09
## **Overview**
This article explains how to format charts in PowerPoint presentations by using Aspose.Slides. It shows how to customize key chart elements such as axes, grid lines, titles, legends, the plot area, and wall fills to improve the appearance and readability of chart data.
It also demonstrates how to set font properties for chart text, apply preset numeric formats to chart data, and enable rounded corners for the chart area. Together, these examples show how to control both the visual style and data presentation of charts in a presentation.
For separate fills and outlines on rising and falling intervals, see the [stock chart example](https://docs.aspose.com/slides/java/create-chart/#create-stock-charts).
## **Format Chart Entities**
Use [IChart](https://reference.aspose.com/slides/java/com.aspose.slides/ichart/) to format chart titles, axes, grid lines, legends, and the plot area. This example creates a line chart with markers and default data, then applies separate text and line styles to its value and category axes. Font sizes and line widths are specified in points; category labels are rotated by 45 degrees.
The value axis uses [setNumberFormat](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setNumberFormat-java.lang.String-) independently of the source cells. Its scale runs from -2 to 15, with major intervals of 2 and minor intervals of 0.5. The example also combines percentage formatting with [setDisplayUnit](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setDisplayUnit-int-) set to thousands, so adapt these settings to the meaning and magnitude of your data. The legend stays outside the plot area because [setOverlay](https://reference.aspose.com/slides/java/com.aspose.slides/ilegend/#setOverlay-boolean-) is called with `false`. Back-wall and floor fills are configured through [getBackWall](https://reference.aspose.com/slides/java/com.aspose.slides/ichart/#getBackWall--) and [getFloor](https://reference.aspose.com/slides/java/com.aspose.slides/ichart/#getFloor--), but these surfaces are only visible in 3D charts.
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.LineWithMarkers, 50, 50, 500, 400);
chart.setTitle(true);
chart.getChartTitle().addTextFrameForOverriding("");
IPortion chartTitle = chart.getChartTitle().getTextFrameForOverriding().getParagraphs().get_Item(0).getPortions().get_Item(0);
chartTitle.setText("Sample Chart");
chartTitle.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
chartTitle.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.GRAY);
chartTitle.getPortionFormat().setFontHeight(20);
chartTitle.getPortionFormat().setFontBold(NullableBool.True);
chartTitle.getPortionFormat().setFontItalic(NullableBool.True);
chart.getAxes().getVerticalAxis().getMajorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.Solid);
chart.getAxes().getVerticalAxis().getMajorGridLinesFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.BLUE);
chart.getAxes().getVerticalAxis().getMajorGridLinesFormat().getLine().setWidth(5);
chart.getAxes().getVerticalAxis().getMajorGridLinesFormat().getLine().setDashStyle(LineDashStyle.DashDot);
chart.getAxes().getVerticalAxis().getMinorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.Solid);
chart.getAxes().getVerticalAxis().getMinorGridLinesFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.RED);
chart.getAxes().getVerticalAxis().getMinorGridLinesFormat().getLine().setWidth(3);
chart.getAxes().getVerticalAxis().setNumberFormatLinkedToSource(false);
chart.getAxes().getVerticalAxis().setDisplayUnit(DisplayUnitType.Thousands);
chart.getAxes().getVerticalAxis().setNumberFormat("0.0%");
chart.getAxes().getVerticalAxis().setAutomaticMajorUnit(false);
chart.getAxes().getVerticalAxis().setAutomaticMaxValue(false);
chart.getAxes().getVerticalAxis().setAutomaticMinorUnit(false);
chart.getAxes().getVerticalAxis().setAutomaticMinValue(false);
chart.getAxes().getVerticalAxis().setMaxValue(15f);
chart.getAxes().getVerticalAxis().setMinValue(-2f);
chart.getAxes().getVerticalAxis().setMinorUnit(0.5f);
chart.getAxes().getVerticalAxis().setMajorUnit(2.0f);
IChartPortionFormat valueAxisText = chart.getAxes().getVerticalAxis().getTextFormat().getPortionFormat();
valueAxisText.setFontBold(NullableBool.True);
valueAxisText.setFontHeight(16);
valueAxisText.setFontItalic(NullableBool.True);
valueAxisText.getFillFormat().setFillType(FillType.Solid);
valueAxisText.getFillFormat().getSolidFillColor().setPresetColor(PresetColor.DarkGreen);
valueAxisText.setLatinFont(new FontData("Times New Roman"));
chart.getAxes().getVerticalAxis().setTitle(true);
chart.getAxes().getVerticalAxis().getTitle().addTextFrameForOverriding("");
IPortion valueAxisTitle = chart.getAxes().getVerticalAxis().getTitle().getTextFrameForOverriding().getParagraphs().get_Item(0).getPortions().get_Item(0);
valueAxisTitle.setText("Primary Axis");
valueAxisTitle.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
valueAxisTitle.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.GRAY);
valueAxisTitle.getPortionFormat().setFontHeight(20);
valueAxisTitle.getPortionFormat().setFontBold(NullableBool.True);
valueAxisTitle.getPortionFormat().setFontItalic(NullableBool.True);
chart.getAxes().getHorizontalAxis().getMajorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.Solid);
chart.getAxes().getHorizontalAxis().getMajorGridLinesFormat().getLine().getFillFormat().getSolidFillColor().setColor(new Color(0, 128, 0));
chart.getAxes().getHorizontalAxis().getMajorGridLinesFormat().getLine().setWidth(5);
chart.getAxes().getHorizontalAxis().getMinorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.Solid);
chart.getAxes().getHorizontalAxis().getMinorGridLinesFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.YELLOW);
chart.getAxes().getHorizontalAxis().getMinorGridLinesFormat().getLine().setWidth(3);
IChartPortionFormat categoryAxisText = chart.getAxes().getHorizontalAxis().getTextFormat().getPortionFormat();
categoryAxisText.setFontBold(NullableBool.True);
categoryAxisText.setFontHeight(16);
categoryAxisText.setFontItalic(NullableBool.True);
categoryAxisText.getFillFormat().setFillType(FillType.Solid);
categoryAxisText.getFillFormat().getSolidFillColor().setColor(Color.BLUE);
categoryAxisText.setLatinFont(new FontData("Arial"));
chart.getAxes().getHorizontalAxis().setTitle(true);
chart.getAxes().getHorizontalAxis().getTitle().addTextFrameForOverriding("");
IPortion categoryAxisTitle = chart.getAxes().getHorizontalAxis().getTitle().getTextFrameForOverriding().getParagraphs().get_Item(0).getPortions().get_Item(0);
categoryAxisTitle.setText("Sample Category");
categoryAxisTitle.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
categoryAxisTitle.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.GRAY);
categoryAxisTitle.getPortionFormat().setFontHeight(20);
categoryAxisTitle.getPortionFormat().setFontBold(NullableBool.True);
categoryAxisTitle.getPortionFormat().setFontItalic(NullableBool.True);
chart.getAxes().getHorizontalAxis().setTickLabelPosition(TickLabelPositionType.Low);
chart.getAxes().getHorizontalAxis().setTickLabelRotationAngle(45);
IChartPortionFormat legendText = chart.getLegend().getTextFormat().getPortionFormat();
legendText.setFontBold(NullableBool.True);
legendText.setFontHeight(16);
legendText.setFontItalic(NullableBool.True);
legendText.getFillFormat().setFillType(FillType.Solid);
legendText.getFillFormat().getSolidFillColor().setPresetColor(PresetColor.DarkRed);
chart.getLegend().setOverlay(false);
chart.getBackWall().setThickness(1);
chart.getBackWall().getFormat().getFill().setFillType(FillType.Solid);
chart.getBackWall().getFormat().getFill().getSolidFillColor().setColor(new Color(255, 165, 0));
chart.getFloor().getFormat().getFill().setFillType(FillType.Solid);
chart.getFloor().getFormat().getFill().getSolidFillColor().setColor(Color.RED);
chart.getPlotArea().getFormat().getFill().setFillType(FillType.Solid);
chart.getPlotArea().getFormat().getFill().getSolidFillColor().setPresetColor(PresetColor.LightCyan);
presentation.save("FormattedChart_out.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Set Font Properties for a Chart**
Set the default font size for chart text through [Chart.getTextFormat](https://reference.aspose.com/slides/java/com.aspose.slides/chart/#getTextFormat--). The example creates a clustered column chart with a 20-point font and enables value labels for the first series through [setShowValue](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabelformat/#setShowValue-boolean-). Text elements with their own explicit font settings can override the chart default.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 100, 100, 500, 400);
chart.getTextFormat().getPortionFormat().setFontHeight(20);
chart.getChartData().getSeries().get_Item(0).getLabels().getDefaultDataLabelFormat().setShowValue(true);
presentation.save("FontPropertiesForChart.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Set the Numeric Format**
Use [IChartDataCell.setPresetNumberFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatacell/#setPresetNumberFormat-byte-) to apply a built-in number format to chart workbook cells. This example creates a clustered column chart with default, cell-backed data and applies format index 10 (`0.00%`) to each series value cell. This changes how the values are displayed in the workbook without changing the underlying numbers; for example, 0.25 is displayed as 25.00%. Axis and data-label formats can be configured separately.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 500, 400);
IChartSeriesCollection series = chart.getChartData().getSeries();
for (IChartSeries chartSeries : series)
{
for (IChartDataPoint dataPoint : chartSeries.getDataPoints())
{
dataPoint.getValue().getAsCell().setPresetNumberFormat((byte) 10); // 0.00%
}
}
presentation.save("PresetNumberFormat_out.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The following table lists built-in number format indices with representative Excel formats for the English (United States) locale. The exact format strings and their display can vary by application and locale, particularly for currency and dates. Some Excel formats also differ from the defaults in the OOXML standard, as described in [Microsoft's number format implementation notes](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oi29500/17d11129-219b-4e2c-88db-45844d21e528).
| Index | Format |
| --- | --- |
| 0 | `General` |
| 1 | `0` |
| 2 | `0.00` |
| 3 | `#,##0` |
| 4 | `#,##0.00` |
| 5 | `"$"#,##0_);("$"#,##0)` |
| 6 | `"$"#,##0_);[Red]("$"#,##0)` |
| 7 | `"$"#,##0.00_);("$"#,##0.00)` |
| 8 | `"$"#,##0.00_);[Red]("$"#,##0.00)` |
| 9 | `0%` |
| 10 | `0.00%` |
| 11 | `0.00E+00` |
| 12 | `# ?/?` |
| 13 | `# ??/??` |
| 14 | `m/d/yyyy` |
| 15 | `d-mmm-yy` |
| 16 | `d-mmm` |
| 17 | `mmm-yy` |
| 18 | `h:mm AM/PM` |
| 19 | `h:mm:ss AM/PM` |
| 20 | `h:mm` |
| 21 | `h:mm:ss` |
| 22 | `m/d/yyyy h:mm` |
| 37 | `#,##0_);(#,##0)` |
| 38 | `#,##0_);[Red](#,##0)` |
| 39 | `#,##0.00_);(#,##0.00)` |
| 40 | `#,##0.00_);[Red](#,##0.00)` |
| 41 | `_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)` |
| 42 | `_("$"* #,##0_);_("$"* (#,##0);_("$"* "-"_);_(@_)` |
| 43 | `_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)` |
| 44 | `_("$"* #,##0.00_);_("$"* (#,##0.00);_("$"* "-"??_);_(@_)` |
| 45 | `mm:ss` |
| 46 | `[h]:mm:ss` |
| 47 | `mm:ss.0` |
| 48 | `##0.0E+0` |
| 49 | `@` |
## **Set Chart Area Rounded Borders**
Call [IChart.setRoundedCorners](https://reference.aspose.com/slides/java/com.aspose.slides/ichart/#setRoundedCorners-boolean-) with `true` to round the corners of the chart area. The example creates a clustered column chart and uses [getLineFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ishape/#getLineFormat--) to give its outline a solid gray color and a single-line style before saving the presentation.
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 20, 100, 600, 400);
chart.getLineFormat().getFillFormat().setFillType(FillType.Solid);
chart.getLineFormat().getFillFormat().getSolidFillColor().setColor(Color.GRAY);
chart.getLineFormat().setStyle(LineStyle.Single);
chart.setRoundedCorners(true);
presentation.save("out.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Edit Existing Chart Annotations**
A chart can contain custom shapes, such as a text annotation explaining the status of a report. Access these shapes through [IChart.getUserShapes](https://reference.aspose.com/slides/java/com.aspose.slides/ichart/#getUserShapes--), also listed under [Chart.getUserShapes](https://reference.aspose.com/slides/java/com.aspose.slides/chart/#getUserShapes--) in the Chart API Reference. The collection returned by [getShapes](https://reference.aspose.com/slides/java/com.aspose.slides/igroupshape/#getShapes--) contains the chart-owned shapes.
An ordinary text box placed over a chart belongs to the slide, even if it looks like part of the chart. Iterating through [Slide.getShapes](https://reference.aspose.com/slides/java/com.aspose.slides/baseslide/#getShapes--) finds the chart and ordinary slide shapes, but does not enumerate the individual shapes inside the chart. Chart titles and data labels are separate chart elements, not custom annotations in this collection.
Download [chart-annotations.pptx](https://docs.aspose.com/slides/java/chart-formatting/chart-annotations.pptx) and place it in the application's working directory. Its first slide contains a chart with an ungrouped annotation reading "Preliminary results", a chart-owned line, and an ordinary slide text box reading "Slide overlay". The example finds the first chart on that slide and changes the annotation to "Final results" when the report is ready to publish. It checks for an empty collection and only edits an [IAutoShape](https://reference.aspose.com/slides/java/com.aspose.slides/iautoshape/) with a non-null text frame returned by [getTextFrame](https://reference.aspose.com/slides/java/com.aspose.slides/iautoshape/#getTextFrame--) and the expected text.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("chart-annotations.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = null;
for (IShape shape : slide.getShapes()) {
if (shape instanceof IChart) {
chart = (IChart) shape;
break;
}
}
if (chart == null || chart.getUserShapes().getShapes().size() == 0) {
System.out.println("No chart or chart-owned shapes found.");
return;
}
boolean updated = false;
for (IShape shape : chart.getUserShapes().getShapes()) {
if (shape instanceof IAutoShape) {
IAutoShape annotation = (IAutoShape) shape;
if (annotation.getTextFrame() != null && "Preliminary results".equals(annotation.getTextFrame().getText())) {
annotation.getTextFrame().setText("Final results");
updated = true;
break;
}
}
}
if (updated) {
presentation.save("chart-annotations-updated.pptx", SaveFormat.Pptx);
} else {
System.out.println("No matching text annotation found.");
}
} finally {
presentation.dispose();
}
```
The line and the slide text box remain unchanged. The following images show the input and the saved, reopened result:
| Before editing | After editing |
| --- | --- |
|  |  |
The example inspects only the top-level chart-owned shapes. If an annotation is inside an [IGroupShape](https://reference.aspose.com/slides/java/com.aspose.slides/igroupshape/), inspect that group's [getShapes](https://reference.aspose.com/slides/java/com.aspose.slides/igroupshape/#getShapes--) collection as well. Repeat this recursively for nested groups, applying the same text checks to their child shapes. A group itself is a container; do not treat it as a text box.
## **FAQ**
**Can I set semi-transparent fills for columns/areas while keeping the border opaque?**
Yes. Fill transparency and the outline are configured separately. This is useful for improving the readability of the grid and data in dense visualizations.
**How can I deal with data labels when they overlap?**
Reduce the font size, disable nonessential label components (for example, categories), adjust the label position, show labels only for selected points if necessary, or switch the format to "value + legend".
**Can I apply gradient or pattern fills to series?**
Yes. Series support solid, gradient, and pattern fills. In practice, use gradients sparingly and avoid combinations that reduce contrast with the grid and text.
## Related articles
- [Customize Chart Axes in Presentations Using Java](https://docs.aspose.com/slides/java/chart-axis/)
- [Customize Presentation Chart Entities in Java](https://docs.aspose.com/slides/java/chart-entities/)
# Customize Chart Legends in Presentations Using Java
> Customize chart legends with Aspose.Slides for Java to optimize PowerPoint presentations with tailored legend formatting.
Source: https://docs.aspose.com/slides/java/chart-legend/
Updated: 2026-09-30
## **Overview**
Aspose.Slides for Java provides options for customizing chart legends in PowerPoint presentations. This article shows how to position and size a legend, set the font size for the whole legend, format an individual legend entry, and hide or restore selected entries.
The FAQ covers related behaviors, including reserving space for the legend, displaying multiline labels, and inheriting formatting from the presentation theme.
## **Legend Positioning**
Use the legend's [setX](https://reference.aspose.com/slides/java/com.aspose.slides/legend/#setX-float-), [setY](https://reference.aspose.com/slides/java/com.aspose.slides/legend/#setY-float-), [setWidth](https://reference.aspose.com/slides/java/com.aspose.slides/legend/#setWidth-float-), and [setHeight](https://reference.aspose.com/slides/java/com.aspose.slides/legend/#setHeight-float-) methods to specify its position and size as fractions of the chart's dimensions.
This example creates a presentation and adds a clustered column chart with default data to the first slide. Dividing the desired legend offsets and dimensions by the chart's width and height converts them to relative values: the legend is offset by 50 points from the chart's top-left corner and sized to 100 by 100 points.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 500, 500);
// Express the legend's position and size relative to the chart.
chart.getLegend().setX(50 / chart.getWidth());
chart.getLegend().setY(50 / chart.getHeight());
chart.getLegend().setWidth(100 / chart.getWidth());
chart.getLegend().setHeight(100 / chart.getHeight());
presentation.save("legend_position.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Set the Font Size of a Legend**
Use the legend's [getTextFormat](https://reference.aspose.com/slides/java/com.aspose.slides/legend/#getTextFormat--) to access its text formatting and use [setFontHeight](https://reference.aspose.com/slides/java/com.aspose.slides/baseportionformat/#setFontHeight-float-) to set the font size in points.
This example creates a chart with default data and sets the legend text to 20 points. It also disables automatic bounds for the vertical axis and sets its range to -5 through 10.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 600, 400);
chart.getLegend().getTextFormat().getPortionFormat().setFontHeight(20);
chart.getAxes().getVerticalAxis().setAutomaticMinValue(false);
chart.getAxes().getVerticalAxis().setMinValue(-5);
chart.getAxes().getVerticalAxis().setAutomaticMaxValue(false);
chart.getAxes().getVerticalAxis().setMaxValue(10);
presentation.save("legend_font_size.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Set the Font Size of an Individual Legend Entry**
Use the collection returned by the legend's [getEntries](https://reference.aspose.com/slides/java/com.aspose.slides/legend/#getEntries--) method to access formatting for a specific entry. Entry indices are zero-based, so index `1` refers to the second entry.
This example creates a clustered column chart whose default data includes at least two series. It formats the second legend entry with bold, italic, and 20-point blue text.
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 600, 400);
IChartTextFormat textFormat = chart.getLegend().getEntries().get_Item(1).getTextFormat();
textFormat.getPortionFormat().setFontBold(NullableBool.True);
textFormat.getPortionFormat().setFontHeight(20);
textFormat.getPortionFormat().setFontItalic(NullableBool.True);
textFormat.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
textFormat.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.BLUE);
presentation.save("legend_entry_format.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Hide Individual Legend Entries**
To exclude an auxiliary series from the legend while keeping its data visible, call [ILegendEntryProperties.setHide](https://reference.aspose.com/slides/java/com.aspose.slides/ilegendentryproperties/#setHide-boolean-) with `true` through [IChartSeries.getRelatedLegendEntry](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#getRelatedLegendEntry--). This hides only the selected legend entry; it does not remove the series or its data points. Calling [IChart.setLegend](https://reference.aspose.com/slides/java/com.aspose.slides/ichart/#setLegend-boolean-) with `false`, in contrast, hides the entire legend.
The example below creates a clustered column chart with multiple series using default data. It hides the second series' legend entry (index `1`) and saves the presentation. It then restores the entry by calling [setHide](https://reference.aspose.com/slides/java/com.aspose.slides/ilegendentryproperties/#setHide-boolean-) with `false` and saves a second copy. The columns remain visible in both files.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 600, 400);
chart.setLegend(true);
ILegendEntryProperties legendEntry = chart.getChartData().getSeries().get_Item(1).getRelatedLegendEntry();
legendEntry.setHide(true);
presentation.save("hidden_legend_entry.pptx", SaveFormat.Pptx);
// Restore the same entry without changing the chart data.
legendEntry.setHide(false);
presentation.save("restored_legend_entry.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The comparison below shows the same chart with all entries visible and with the second entry hidden. The second series' columns remain unchanged.

In column, bar, and line charts, legend entries identify series. For pie charts, they identify individual data points (slices), so use [IChartDataPoint.getRelatedLegendEntry](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapoint/#getRelatedLegendEntry--) on the selected slice instead. The API documents this data-point method for the `Pie`, `Pie3D`, `ExplodedPie`, `ExplodedPie3D`, `PieOfPie`, and `BarOfPie` chart types. Do not assume it applies to doughnut charts, which are not included in that list.
## **FAQ**
**Can I make the chart allocate space for the legend instead of overlaying it?**
Yes. Call [setOverlay](https://reference.aspose.com/slides/java/com.aspose.slides/legend/#setOverlay-boolean-) with `false` to reserve space for the legend instead of allowing it to overlap the plot area.
**Can I make multiline legend labels?**
Yes. Long labels can wrap when the available width is insufficient. You can also use newline characters in series names to request line breaks.
**How do I make the legend follow the presentation theme's color scheme?**
Leave the legend's colors, fills, and fonts unset so that it can inherit theme formatting. Explicit formatting overrides the corresponding theme settings.
# Customize Plot Areas of Presentation Charts in Java
> Discover how to customize chart plot areas in PowerPoint presentations with Aspose.Slides for Java. Improve your slide visuals effortlessly.
Source: https://docs.aspose.com/slides/java/chart-plot-area/
Updated: 2026-11-08
## **Overview**
This article shows how to work with a chart’s plot area in Aspose.Slides. It explains how to get the actual position and size of the plot area by validating the chart layout and then reading its X, Y, width, and height values.
It also demonstrates how to configure the plot area’s layout mode when the layout is set manually, using `LayoutTargetType` to define whether the plot area is calculated by its inner region or by its outer region together with axes and axis labels.
## **Get Width and Height of a Chart Plot Area**
Aspose.Slides for Java provides a simple API for reading the actual position and size of a chart's plot area.
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class.
1. Access first slide.
1. Add chart with default data.
1. Call method [IChart.validateChartLayout()](https://reference.aspose.com/slides/java/com.aspose.slides/IChart#validateChartLayout--) before to get actual values.
1. Gets actual X location (left) of the chart element relative to the left top corner of the chart.
1. Gets actual top of the chart element relative to the left top corner of the chart.
1. Gets actual width of the chart element.
1. Gets actual height of the chart element.
```java
import com.aspose.slides.*;
// Create an instance of Presentation class
Presentation pres = new Presentation();
try {
Chart chart = (Chart)pres.getSlides().get_Item(0).getShapes().addChart(ChartType.ClusteredColumn, 100, 100, 500, 350);
chart.validateChartLayout();
double x = chart.getPlotArea().getActualX();
double y = chart.getPlotArea().getActualY();
double w = chart.getPlotArea().getActualWidth();
double h = chart.getPlotArea().getActualHeight();
} finally {
if (pres != null) pres.dispose();
}
```
## **Set the Layout Mode of a Chart Plot Area**
Aspose.Slides for Java provides a simple API to set the layout mode of the chart plot area. Methods [**setLayoutTargetType**](https://reference.aspose.com/slides/java/com.aspose.slides/ChartPlotArea#setLayoutTargetType-int-) and [**getLayoutTargetType**](https://reference.aspose.com/slides/java/com.aspose.slides/ChartPlotArea#getLayoutTargetType--) have been added to [**ChartPlotArea**](https://reference.aspose.com/slides/java/com.aspose.slides/ChartPlotArea) class and [**IChartPlotArea**](https://reference.aspose.com/slides/java/com.aspose.slides/IChartPlotArea) interface. If the layout of the plot area defined manually this property specifies whether to layout the plot area by its inside (not including axis and axis labels) or outside (including axis and axis labels). There are two possible values which are defined in [**LayoutTargetType**](https://reference.aspose.com/slides/java/com.aspose.slides/LayoutTargetType) enum.
- [**LayoutTargetType.Inner**](https://reference.aspose.com/slides/java/com.aspose.slides/LayoutTargetType#Inner) - specifies that the plot area size shall determine the size of the plot area, not including the tick marks and axis labels.
- [**LayoutTargetType.Outer**](https://reference.aspose.com/slides/java/com.aspose.slides/LayoutTargetType#Outer) - specifies that the plot area size shall determine the size of the plot area, the tick marks, and the axis labels.
[](https://docs.aspose.com/slides/java/chart-plot-area/visual-chart-plot-area-2345b90e2bdf.svg)
*The dashed outline marks the same manual rectangle in both renders. Inner leaves room for ticks and labels outside it. Outer fits them inside it.*
Sample code is given below.
```java
import com.aspose.slides.*;
// Create an instance of Presentation class
Presentation pres = new Presentation();
try {
ISlide slide = pres.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 20, 100, 600, 400);
chart.getPlotArea().setX(0.2f);
chart.getPlotArea().setY(0.2f);
chart.getPlotArea().setWidth(0.7f);
chart.getPlotArea().setHeight(0.7f);
chart.getPlotArea().setLayoutTargetType(LayoutTargetType.Inner);
pres.save("SetLayoutMode_inner.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
## **FAQ**
### In what units are actual x, actual y, actual width, and actual height returned?
In points; 1 inch = 72 points. These are Aspose.Slides coordinate units.
### How does the Plot Area differ from the Chart Area in terms of content?
The Plot Area is the data drawing region (series, gridlines, trendlines, etc.); the Chart Area includes the surrounding elements (title, legend, etc.). In 3D charts, the Plot Area also includes the walls/floor and the axes.
### How are the Plot Area’s x, y, width, and height interpreted when layout is manual?
They are fractions (0–1) of the chart’s overall size; in this mode, auto-positioning is disabled and the fractions you set are used.
### Why did the Plot Area position change after adding/moving the legend?
The legend sits in the chart area outside the Plot Area but affects layout and available space, so the Plot Area may shift when auto-positioning is in effect. (This is standard behavior for PowerPoint charts.)
# Manage Chart Data Series in Presentations in Java
> Learn how to manage chart series, data points, workbook cells, formatting, overlap, gap width, and negative values in presentations with Java.
Source: https://docs.aspose.com/slides/java/chart-series/
Updated: 2026-10-26
## **Overview**
A chart can store its plotted values in workbook cells or directly as numeric literals. An [IChartSeries](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/) represents one set of related values, and each [IChartDataPoint](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapoint/) represents a point in that series. [IChartCategory](https://reference.aspose.com/slides/java/com.aspose.slides/ichartcategory/) objects provide the labels or grouping values shared by the series. In charts created with default data, series names, categories, and point values use [IChartDataCell](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatacell/) objects from the chart workbook.
For a typical category chart, the default workbook uses row 0 for series names, column 0 for category names, and the remaining cells for series values. Worksheet, row, and column indexes passed to [IChartDataWorkbook.getCell](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdataworkbook/#getCell-int-int-int-) are zero-based. This layout is useful when you create a chart with default data, but do not assume that every existing chart uses it. For a loaded presentation, inspect the cells referenced by the series, categories, and data points before changing workbook values.
Chart settings have three different scopes:
- Series-level settings, such as [IChartSeries.getFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#getFormat--), provide the default appearance for all points in one series.
- Data-point settings, such as [IChartDataPoint.getFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapoint/#getFormat--), override the series appearance for one point.
- Group settings apply to compatible series that belong to the same [IChartSeriesGroup](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseriesgroup/). Access the group through [IChartSeries.getParentSeriesGroup](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#getParentSeriesGroup--) when you need to set options such as overlap or gap width.
When no explicit point or series fill is set, the chart style and theme determine the automatic appearance. When both series and point formatting are present, the point formatting takes precedence for that point.

## **Set Series Values Using Numeric Literals**
Use numeric literals when series values come from application data or calculations and do not need worksheet cell references. Call [setDataSourceTypeForValues](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapointcollection/#setDataSourceTypeForValues-int-) with [DataSourceType.DoubleLiterals](https://reference.aspose.com/slides/java/com.aspose.slides/datasourcetype/#DoubleLiterals) before assigning each point's [getValue](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapoint/#getValue--) result through [setAsLiteralDouble](https://reference.aspose.com/slides/java/com.aspose.slides/idoublechartvalue/#setAsLiteralDouble-double-).
The collection setting controls the source type of all point values in that series. Each point value's [getDataSourceType](https://reference.aspose.com/slides/java/com.aspose.slides/ibasechartvalue/#getDataSourceType--) method reports the selected type; change it through the collection setting. With `Worksheet`, use [getAsCell](https://reference.aspose.com/slides/java/com.aspose.slides/isinglecellchartvalue/#getAsCell--) to access the referenced cell. With `DoubleLiterals`, use [getAsLiteralDouble](https://reference.aspose.com/slides/java/com.aspose.slides/idoublechartvalue/#getAsLiteralDouble--) or `setAsLiteralDouble` to read or write the number directly.
The following example creates a column chart with default series and categories, then assigns calculated values of 10, 20, and so on to the existing points of its first series. It saves the presentation, reopens it, and prints the stored values.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 20, 20, 500, 300);
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
series.getDataPoints().setDataSourceTypeForValues(DataSourceType.DoubleLiterals);
for (int i = 0; i < series.getDataPoints().size(); i++) {
series.getDataPoints().get_Item(i).getValue().setAsLiteralDouble((i + 1) * 10);
}
presentation.save("numeric_literals.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
Presentation reopenedPresentation = new Presentation("numeric_literals.pptx");
try {
ISlide reopenedSlide = reopenedPresentation.getSlides().get_Item(0);
IChart reopenedChart = (IChart) reopenedSlide.getShapes().get_Item(0);
IChartSeries reopenedSeries = reopenedChart.getChartData().getSeries().get_Item(0);
for (IChartDataPoint point : reopenedSeries.getDataPoints()) {
System.out.println(point.getValue().getAsLiteralDouble());
}
} finally {
reopenedPresentation.dispose();
}
```
The point value source type is separate from [IChartData.getDataSourceType](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/#getDataSourceType--), which identifies the chart's internal or external workbook configuration. Using numeric literals does not, by itself, remove the embedded workbook. In this example, the workbook remains available for category labels, series names, and the other series. See [Chart Workbook](https://docs.aspose.com/slides/java/chart-workbook/) for workbook management.
For scatter and bubble charts, use [setDataSourceTypeForXValues](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapointcollection/#setDataSourceTypeForXValues-int-) and [setDataSourceTypeForYValues](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapointcollection/#setDataSourceTypeForYValues-int-) to choose the sources for [getXValue](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapoint/#getXValue--) and [getYValue](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapoint/#getYValue--). Bubble charts also use [setDataSourceTypeForBubbleSizes](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapointcollection/#setDataSourceTypeForBubbleSizes-int-) for [getBubbleSize](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapoint/#getBubbleSize--). Set each applicable source to `DoubleLiterals` before assigning numbers through that value's `setAsLiteralDouble` method.
## **Set the Chart Series Overlap**
[IChartSeries.getOverlap](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#getOverlap--) reports how much bars or columns overlap in a 2D chart, from -100 through 100 percent. It is a read-only projection of the setting on the parent series group. Use [IChartSeriesGroup.setOverlap](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseriesgroup/#setOverlap-byte-) to update every compatible series in that group. This option applies to chart types that display grouped bars or columns; it does not affect unrelated series groups in a combination chart.
The following example sets the overlap for the group that contains the first series:
```java
import com.aspose.slides.*;
final int firstSlideIndex = 0;
final int firstSeriesIndex = 0;
final byte overlapPercent = 30;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(firstSlideIndex);
// The new chart contains sample series, categories, and values.
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 20, 20, 500, 200);
IChartSeries series = chart.getChartData().getSeries().get_Item(firstSeriesIndex);
series.getParentSeriesGroup().setOverlap(overlapPercent);
presentation.save("series_overlap.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The result:

## **Change the Series Fill Color**
Use [IChartSeries.getFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#getFormat--) to set the default fill for an entire series. If a point already has an explicit fill, its [IChartDataPoint.getFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapoint/#getFormat--) setting overrides the series fill for that point.
The following example applies a solid blue fill to the first series:
```java
import com.aspose.slides.*;
import java.awt.Color;
final int firstSlideIndex = 0;
final int firstSeriesIndex = 0;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(firstSlideIndex);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 20, 20, 500, 200);
IChartSeries series = chart.getChartData().getSeries().get_Item(firstSeriesIndex);
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(Color.BLUE);
presentation.save("series_color.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The result:

## **Change the Series Name**
A series name is stored in the chart data workbook and is normally displayed in the legend. In the default workbook created for a clustered column chart, cell B1 is at row 0, column 1 and contains the name of the first series. The named constants in the following example make that structure explicit:
```java
import com.aspose.slides.*;
final int firstSlideIndex = 0;
final int worksheetIndex = 0;
final int seriesNameRowIndex = 0;
final int firstSeriesColumnIndex = 1;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(firstSlideIndex);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 20, 20, 500, 200);
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
IChartDataCell seriesNameCell = workbook.getCell(worksheetIndex, seriesNameRowIndex, firstSeriesColumnIndex);
seriesNameCell.setValue("Revenue");
presentation.save("series_name.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
You can also update the cell already referenced by [IChartSeries.getName](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#getName--). This approach avoids assuming a particular row and column in an existing chart:
```java
import com.aspose.slides.*;
final int firstSlideIndex = 0;
final int firstSeriesIndex = 0;
final int firstNameCellIndex = 0;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(firstSlideIndex);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 20, 20, 500, 200);
IChartSeries series = chart.getChartData().getSeries().get_Item(firstSeriesIndex);
IChartDataCell seriesNameCell = series.getName().getAsCells().get_Item(firstNameCellIndex);
seriesNameCell.setValue("Revenue");
presentation.save("series_name.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The result:

### **Create a Series with a Name from Multiple Cells**
A composite series name is useful when a product name and a reporting period are stored in separate workbook cells. For example, you can combine `Product A` in B1 and `2026` in C1 into a single series name while keeping both parts linked to their source cells.
Use [IChartDataWorkbook.getCellCollection](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdataworkbook/#getCellCollection-java.lang.String-boolean-) to retrieve the name range, then pass that collection to [IChartSeriesCollection.add](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseriescollection/#add-com.aspose.slides.IChartCellCollection-int-). The `skipHiddenCells` argument controls whether hidden cells are included: `true` excludes them, while `false` includes them. This example uses `false` to include every cell in the name range.
The following example creates a presentation with one series and two data points. Cells B1:C1 supply only the series name; A2:A3 supply the category labels, and B2:B3 supply the numeric values.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 620, 180);
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
chart.setLegend(true);
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
workbook.clear(0);
// These two cells supply the series name.
workbook.getCell(0, 0, 1, "Product A");
workbook.getCell(0, 0, 2, "2026");
IChartCellCollection nameCells = workbook.getCellCollection("Sheet1!$B$1:$C$1", false);
IChartSeries series = chart.getChartData().getSeries().add(nameCells, ChartType.ClusteredColumn);
// Separate cells supply the categories and numeric data points.
IChartDataCell northCategory = workbook.getCell(0, 1, 0, "North");
IChartDataCell southCategory = workbook.getCell(0, 2, 0, "South");
chart.getChartData().getCategories().add(northCategory);
chart.getChartData().getCategories().add(southCategory);
IChartDataCell northValue = workbook.getCell(0, 1, 1, 120);
IChartDataCell southValue = workbook.getCell(0, 2, 1, 150);
series.getDataPoints().addDataPointForBarSeries(northValue);
series.getDataPoints().addDataPointForBarSeries(southValue);
presentation.save("composite_series_name.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The resulting series name is `Product A 2026`, with a space between the two cell values. The legend displays this as one entry for both columns. The image below illustrates the result:

## **Get the Automatic Series Fill Color**
[IChartSeries.getAutomaticSeriesColor](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#getAutomaticSeriesColor--) returns the color calculated from the series index and the chart style. This is the color used when the series fill has not been explicitly defined. Calling the method reads the calculated color; it does not assign a new fill.
The following example prints the automatic color of each default series:
```java
import com.aspose.slides.*;
import java.awt.Color;
final int firstSlideIndex = 0;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(firstSlideIndex);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 20, 20, 500, 200);
int seriesCount = chart.getChartData().getSeries().size();
for (int seriesIndex = 0; seriesIndex < seriesCount; seriesIndex++) {
IChartSeries series = chart.getChartData().getSeries().get_Item(seriesIndex);
Color automaticColor = series.getAutomaticSeriesColor();
System.out.println("Series " + seriesIndex + ": " + automaticColor);
}
} finally {
presentation.dispose();
}
```
Example output for the default chart style:
```text
Series 0: java.awt.Color[r=79,g=129,b=189]
Series 1: java.awt.Color[r=192,g=80,b=77]
Series 2: java.awt.Color[r=155,g=187,b=89]
```
The exact colors depend on the chart style and theme.
## **Set Invert Fill Color for a Chart Series**
For bar, column, and bubble series, [IChartSeries.setInvertIfNegative](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#setInvertIfNegative-boolean-) can display negative values with a different fill. Set the regular series fill to solid, enable inversion, and assign the negative-value color through [IChartSeries.getInvertedSolidFillColor](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#getInvertedSolidFillColor--). Negative numbers remain unchanged in the workbook; only their display color changes.
The following example replaces the default chart data with one series. Worksheet row 0 contains the series name, column 0 contains category names, and column 1 contains the values:
```java
import com.aspose.slides.*;
import java.awt.Color;
final int firstSlideIndex = 0;
final int worksheetIndex = 0;
final int headerRowIndex = 0;
final int categoryColumnIndex = 0;
final int firstSeriesColumnIndex = 1;
final int firstDataRowIndex = 1;
String[] categoryNames = { "Category 1", "Category 2", "Category 3" };
int[] seriesValues = { -20, 50, -30 };
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(firstSlideIndex);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 20, 20, 500, 200);
IChartData chartData = chart.getChartData();
IChartDataWorkbook workbook = chartData.getChartDataWorkbook();
chartData.getSeries().clear();
chartData.getCategories().clear();
IChartDataCell seriesNameCell = workbook.getCell(worksheetIndex, headerRowIndex, firstSeriesColumnIndex, "Series 1");
int chartType = chart.getType();
IChartSeries series = chartData.getSeries().add(seriesNameCell, chartType);
for (int categoryIndex = 0; categoryIndex < categoryNames.length; categoryIndex++) {
int dataRowIndex = firstDataRowIndex + categoryIndex;
String categoryName = categoryNames[categoryIndex];
int seriesValue = seriesValues[categoryIndex];
IChartDataCell categoryCell = workbook.getCell(worksheetIndex, dataRowIndex, categoryColumnIndex, categoryName);
chartData.getCategories().add(categoryCell);
IChartDataCell valueCell = workbook.getCell(worksheetIndex, dataRowIndex, firstSeriesColumnIndex, seriesValue);
series.getDataPoints().addDataPointForBarSeries(valueCell);
}
Color automaticSeriesColor = series.getAutomaticSeriesColor();
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(automaticSeriesColor);
series.setInvertIfNegative(true);
series.getInvertedSolidFillColor().setColor(Color.RED);
presentation.save("inverted_solid_fill_color.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The result:

You can enable inversion for one point through [IChartDataPoint.setInvertIfNegative](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapoint/#setInvertIfNegative-boolean-). In the following example, inversion is disabled for the series and enabled only for the selected point. The point is also assigned a negative value so that the effect is visible:
```java
import com.aspose.slides.*;
import java.awt.Color;
final int firstSlideIndex = 0;
final int firstSeriesIndex = 0;
final int targetDataPointIndex = 2;
final int negativeValue = -30;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(firstSlideIndex);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 20, 20, 500, 200);
IChartSeries series = chart.getChartData().getSeries().get_Item(firstSeriesIndex);
Color automaticSeriesColor = series.getAutomaticSeriesColor();
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(automaticSeriesColor);
series.getInvertedSolidFillColor().setColor(Color.RED);
series.setInvertIfNegative(false);
IChartDataPoint dataPoint = series.getDataPoints().get_Item(targetDataPointIndex);
dataPoint.getValue().getAsCell().setValue(negativeValue);
dataPoint.setInvertIfNegative(true);
presentation.save("data_point_invert_color_if_negative.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Clear a Specific Data Point Value**
To make one point empty without removing the other points, set its backing workbook cell to `null`. For a column chart, the plotted value is available through [IChartDataPoint.getValue](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapoint/#getValue--). The data point stays at the same category position, but the chart treats its value as blank according to the chart's blank-value settings.
The following example clears only the second point in the first series:
```java
import com.aspose.slides.*;
final int firstSlideIndex = 0;
final int firstSeriesIndex = 0;
final int targetDataPointIndex = 1;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(firstSlideIndex);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 20, 20, 500, 200);
IChartSeries series = chart.getChartData().getSeries().get_Item(firstSeriesIndex);
IChartDataPoint dataPoint = series.getDataPoints().get_Item(targetDataPointIndex);
dataPoint.getValue().getAsCell().setValue(null);
presentation.save("clear_data_point_value.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
Scatter charts use separate X and Y cells, and bubble charts also use a size cell. Clear only the cell that represents the value you intend to remove. Do not call [IChartDataPointCollection.clear](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapointcollection/#clear--) when you want to keep the other points, because that method removes every data point from the collection.
## **Control the Display of Empty Cells**
Hidden cells that contain values are a separate case from empty cells. To include or exclude data from hidden worksheet rows and columns, see [Include Data from Hidden Rows and Columns](https://docs.aspose.com/slides/java/chart-workbook/#include-data-from-hidden-rows-and-columns).
An empty workbook cell represents missing data; a cell containing `0` represents a known numeric value. Call [IChartDataCell.setValue](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatacell/#setValue-java.lang.Object-) with `null` to make a cell empty. A numeric zero remains a zero regardless of the blank-cell setting.
Use [IChart.setDisplayBlanksAs](https://reference.aspose.com/slides/java/com.aspose.slides/ichart/#setDisplayBlanksAs-int-) to choose how the chart displays empty cells. This setting applies to the whole chart. It changes how blanks are plotted, without filling the empty workbook cell with zero or an interpolated value.
The following self-contained example creates a line chart with one series, clears the value for Day 3, and saves the same chart with each mode. No input file is required. The [IChartDataWorkbook](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdataworkbook/) uses worksheet 0, column 0 for category labels, and column 1 for values; row 0 holds the series name. The final data is `10, 20, empty, 30, 40`.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.LineWithMarkers, 40, 40, 640, 400);
IChartData chartData = chart.getChartData();
IChartDataWorkbook workbook = chartData.getChartDataWorkbook();
chartData.getSeries().clear();
chartData.getCategories().clear();
IChartDataCell seriesNameCell = workbook.getCell(0, 0, 1, "Measurements");
IChartSeries series = chartData.getSeries().add(seriesNameCell, chart.getType());
int[] values = { 10, 20, 25, 30, 40 };
for (int i = 0; i < values.length; i++) {
IChartDataCell categoryCell = workbook.getCell(0, i + 1, 0, "Day " + (i + 1));
chartData.getCategories().add(categoryCell);
IChartDataCell valueCell = workbook.getCell(0, i + 1, 1, values[i]);
series.getDataPoints().addDataPointForLineSeries(valueCell);
}
// Leave Day 3 genuinely empty, while retaining its category and data point.
workbook.getCell(0, 3, 1).setValue(null);
int[] modes = { DisplayBlanksAsType.Gap, DisplayBlanksAsType.Zero, DisplayBlanksAsType.Span };
String[] modeNames = { "Gap", "Zero", "Span" };
for (int i = 0; i < modes.length; i++) {
chart.setDisplayBlanksAs(modes[i]);
presentation.save("empty_cells_" + modeNames[i] + ".pptx", SaveFormat.Pptx);
}
} finally {
presentation.dispose();
}
```
Each output file stores the mode assigned before saving: `empty_cells_Gap.pptx`, `empty_cells_Zero.pptx`, and `empty_cells_Span.pptx`. To save only one version, assign the desired mode and save the presentation once instead of iterating over the modes.
The comparison below shows the same data in all three files. Day 3 is empty in the workbook in every case:

The visible effect depends on the chart type. A line chart makes all three modes easy to compare. Bar and column charts have no line to connect across a missing category, so `Span` cannot produce the connecting segment shown above; a missing column and a zero-height column can also look alike. Similarly, a scatter chart with markers only has no connecting line. Do not expect three distinct results for every chart type; check the output for the type you use.
## **Set the Series Gap Width**
Gap width is the space between adjacent bar or column clusters, expressed as a percentage of the bar or column width. Like overlap, it belongs to the parent series group rather than to one series. Call [IChartSeriesGroup.setGapWidth](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseriesgroup/#setGapWidth-int-) once for the group. A larger value creates more space between clusters; a smaller value makes them denser.
The following example changes the gap width and saves only the final presentation:
```java
import com.aspose.slides.*;
final int firstSlideIndex = 0;
final int firstSeriesIndex = 0;
final int gapWidthPercent = 30;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(firstSlideIndex);
IChart chart = slide.getShapes().addChart(ChartType.StackedColumn, 20, 20, 500, 200);
IChartSeries series = chart.getChartData().getSeries().get_Item(firstSeriesIndex);
series.getParentSeriesGroup().setGapWidth(gapWidthPercent);
presentation.save("gap_width_30.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The result:

## **Show or Hide Series Lines**
Series lines visually connect related parts of a chart. Use [IChartSeriesGroup.setSeriesLines](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseriesgroup/#setSeriesLines-boolean-) to show or hide them in supported stacked bar and OfPie charts. In two-dimensional stacked bar and column charts, they connect corresponding stack boundaries across categories. In Pie of Pie and Bar of Pie charts, they connect the main plot to the secondary plot. This setting is not a general-purpose connector for other chart types.
Access the group through [IChartSeries.getParentSeriesGroup](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#getParentSeriesGroup--). The setting applies to every series in that group. [IChartSeries.hasSeriesLines](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#hasSeriesLines--) is read-only and reflects the parent group's setting; call the group's setter to update it.
The following example creates one [PieOfPie](https://reference.aspose.com/slides/java/com.aspose.slides/charttype/#PieOfPie) chart with default data. It saves the same chart with series lines enabled and then disabled, producing two presentations for comparison.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.PieOfPie, 50, 50, 600, 400);
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
IChartSeriesGroup seriesGroup = series.getParentSeriesGroup();
seriesGroup.setSeriesLines(true);
presentation.save("series_lines_enabled.pptx", SaveFormat.Pptx);
seriesGroup.setSeriesLines(false);
presentation.save("series_lines_disabled.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
| Series lines enabled | Series lines disabled |
| --- | --- |
|  |  |
| The two lines connect the main pie to the secondary pie. | Both pies remain visible, but the connecting lines are hidden. |
Series lines differ from data label leader lines, which connect labels to their data points; gridlines, which mark intervals along chart axes; and the lines in a line chart, which represent data values. This setting does not control those elements.
## **FAQ**
**Which chart types support data series?**
All chart types represented by the [ChartType](https://reference.aspose.com/slides/java/com.aspose.slides/charttype/) enumeration use chart data, but their series do not all have the same value structure or settings. For example, category charts use categories and values, scatter charts use X and Y values, and bubble charts add bubble sizes. Use the data-point creation method that matches the series type. Options such as overlap and gap width apply only to compatible bar or column groups.
**What is a chart series group?**
An [IChartSeriesGroup](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseriesgroup/) contains compatible series that share group-level plotting settings. A combination chart can contain more than one group, so changing the group reached through one series does not necessarily change every series in the chart.
**Does a newly created chart contain default data?**
Yes. By default, [IShapeCollection.addChart](https://reference.aspose.com/slides/java/com.aspose.slides/ishapecollection/#addChart-int-float-float-float-float-) creates sample series, categories, and values. You can edit those cells or clear both the series and category collections before adding a completely custom data set. An overload can also create a chart without default data.
**How are chart objects connected to workbook cells?**
Series names, category labels, and data-point values reference cells in an [IChartDataWorkbook](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdataworkbook/). Changing a referenced cell updates the corresponding chart element. When you build custom data, keep category rows and series-value rows aligned so that each point is plotted under the intended category.
**How do I clear one point instead of the whole series?**
Set the relevant value cell to `null` to retain the point's category position as an empty point. Use [IChartDataPointCollection.clear](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapointcollection/#clear--) only when you intend to remove all points from that series. If you also remove categories, update every series so their values remain aligned with the category collection.
**How are empty points displayed?**
The result depends on the chart type and the value configured through [IChart.setDisplayBlanksAs](https://reference.aspose.com/slides/java/com.aspose.slides/ichart/#setDisplayBlanksAs-int-). Supported charts can display blanks as gaps, as zero values, or by connecting neighboring points. Choose the setting that matches the meaning of missing data in your presentation. See [Control the Display of Empty Cells](https://docs.aspose.com/slides/java/chart-series/#control-the-display-of-empty-cells) for a complete example and visual comparison.
**How are negative values formatted?**
For supported bar, column, and bubble series, call [IChartSeries.setInvertIfNegative](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#setInvertIfNegative-boolean-) and set the color returned by [IChartSeries.getInvertedSolidFillColor](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#getInvertedSolidFillColor--). You can override the behavior for an individual point with [IChartDataPoint.setInvertIfNegative](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapoint/#setInvertIfNegative-boolean-). These methods affect formatting, not the stored numeric values.
**Which formatting wins when both a series and a point are formatted?**
Explicit data-point formatting takes precedence for that point. Other points continue to use the explicit series format or, when the series format is not defined, the automatic chart style and theme. Group settings such as overlap and gap width control layout and are not point-level formatting overrides.
**Is there a limit to how many series a chart can contain?**
Aspose.Slides does not impose a separate fixed series-count limit. In practice, presentation file constraints, available memory, rendering time, and chart readability determine a useful limit.
**What should I change when columns are too close together or too far apart?**
Call [IChartSeriesGroup.setGapWidth](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseriesgroup/#setGapWidth-int-) on the appropriate parent series group. Increase the value to widen the space between clusters, or decrease it to bring the clusters closer together.
# Customize Presentation Charts in Java
> Explore every chart type you can create or edit with Aspose.Slides for Java – fast, code-first guides for PowerPoint presentations.
Source: https://docs.aspose.com/slides/java/chart-types/
Updated: 2025-11-17
---
lastmod: 2025-11-17T20:34:00+04:00
title: Customize Presentation Charts in Java
linktitle: Chart Types
type: docs
weight: 20
url: /java/chart-types/
keywords:
- customize chart
- manage chart
- chart type
- PowerPoint chart
- presentation chart
- PPT chart
- PPTX chart
- PowerPoint
- presentation
- Java
- Aspose.Slides
description: "Explore every chart type you can create or edit with Aspose.Slides for Java – fast, code-first guides for PowerPoint presentations."
---
## Related articles
- [Create and Customize PowerPoint Charts in Java](https://docs.aspose.com/slides/java/powerpoint-charts/)
# Manage Chart Workbooks in Presentations Using Java
> Discover Aspose.Slides for Java: effortlessly manage chart workbooks in PowerPoint and OpenDocument formats to streamline your presentation data.
Source: https://docs.aspose.com/slides/java/chart-workbook/
Updated: 2026-10-22
## **Overview**
This article explains how to work with chart workbooks in Aspose.Slides. It shows how to read and write chart data through workbook streams, use workbook cells as chart data labels, access worksheet collections, and specify the data source type for chart values.
It also covers working with external workbooks as chart data sources. The examples demonstrate how to create and assign an external workbook, retrieve the path of an external workbook linked to a chart, and edit chart data when the workbook is available.
For workbook cells that represent missing data, see [Control the Display of Empty Cells](https://docs.aspose.com/slides/java/chart-series/) for the difference between an empty cell and zero, and a line-chart comparison of the available display modes.
## **Include Data from Hidden Rows and Columns**
Use [IChart.setPlotVisibleCellsOnly](https://reference.aspose.com/slides/java/com.aspose.slides/ichart/#setPlotVisibleCellsOnly-boolean-) to control whether a chart plots data from hidden worksheet rows and columns. Set it to `true` to plot only visible cells, or `false` to include both visible and hidden cells. This setting controls chart plotting; it does not hide or unhide worksheet rows or columns.
The [sample presentation](https://docs.aspose.com/slides/java/chart-workbook/hidden-source-data.pptx) contains a column chart as the first shape on its first slide. The embedded worksheet, `Sheet1`, contains the following source range, `A1:C4`. Row 3 and column C are hidden, but their cells still contain values.
| Worksheet row | A: Month | B: Retail | C: Wholesale (hidden column) |
| --- | --- | --- | --- |
| 2 | January | 10 | 30 |
| 3 (hidden row) | February | 40 | 60 |
| 4 | March | 20 | 50 |
Access source cells through [IChartData.getChartDataWorkbook](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/#getChartDataWorkbook--) and read [IChartDataCell.isHidden](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatacell/#isHidden--) to inspect their hidden status. This method reports the hidden status without changing it. In this file, B2 is visible, B3 belongs to the hidden row, and C2 belongs to the hidden column; the example prints `false`, `true`, and `true`, respectively.
For this example, refresh the chart data after changing the plotting setting: retain the embedded workbook with [readWorkbookStream](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/#readWorkbookStream--) and reload it with [writeWorkbookStream](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/#writeWorkbookStream-byte---). When including all cells, also use [setRange](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/#setRange-java.lang.String-) to restore the complete range, including the hidden February category. Simply changing the flag is insufficient to refresh this sample's cached chart data and category labels.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("hidden-source-data.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
int shapeCount = slide.getShapes().size();
if (shapeCount > 0 && slide.getShapes().get_Item(0) instanceof IChart) {
IChart chart = (IChart) slide.getShapes().get_Item(0);
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
System.out.println("B2 hidden: " + workbook.getCell(0, "B2").isHidden());
System.out.println("B3 hidden: " + workbook.getCell(0, "B3").isHidden());
System.out.println("C2 hidden: " + workbook.getCell(0, "C2").isHidden());
byte[] workbookData = chart.getChartData().readWorkbookStream();
for (boolean visibleOnly : new boolean[] { true, false }) {
chart.setPlotVisibleCellsOnly(visibleOnly);
// Refresh the chart data from the embedded workbook.
chart.getChartData().writeWorkbookStream(workbookData);
if (!visibleOnly) {
// Restore the complete source range, including hidden categories.
chart.getChartData().setRange("Sheet1!$A$1:$C$4");
}
presentation.save("hidden_cells_" + visibleOnly + ".pptx", SaveFormat.Pptx);
}
} else {
System.out.println("The first shape is not a chart.");
}
} finally {
presentation.dispose();
}
```
The example saves two versions of the presentation: one with only the visible Retail values (10 and 20), and another with all six values. The images below illustrate the two plotting modes. Row 3 and column C remain hidden in both embedded workbooks.
| Only visible cells (`true`) | All cells (`false`) |
| --- | --- |
|  |  |
A hidden cell containing a value is different from an empty cell. [IChart.setDisplayBlanksAs](https://reference.aspose.com/slides/java/com.aspose.slides/ichart/#setDisplayBlanksAs-int-) controls how missing values are displayed; it does not include or exclude hidden source data. See [Control the Display of Empty Cells](https://docs.aspose.com/slides/java/chart-series/#control-the-display-of-empty-cells) for an example.
## **Retrieve a Chart's Data Range**
Before updating workbook data in an existing presentation, inspect the source ranges to identify which worksheet cells each chart uses. The [IChartData.getRange](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/#getRange--) method returns the current data range as a worksheet-qualified formula, such as `Sheet1!$A$1:$D$5`. Here, `Sheet1` is the worksheet name, `!` separates it from the cell range, and `$A$1:$D$5` identifies cells A1 through D5, inclusive. The dollar signs indicate absolute row and column references.
The method reads the current range without changing the chart or its workbook. If the chart does not use a workbook as its data source, it throws `InvalidOperationException`. For more information, see the [ChartData API Reference](https://reference.aspose.com/slides/java/com.aspose.slides/chartdata/).
This example opens a presentation and checks the shapes directly on each slide for charts. It prints each chart's name and source range. If a chart does not use a workbook, it prints a message and continues to the next chart.
```java
import com.aspose.slides.*;
import com.aspose.slides.exceptions.InvalidOperationException;
Presentation presentation = new Presentation("presentation.pptx");
try {
for (ISlide slide : presentation.getSlides()) {
for (IShape shape : slide.getShapes()) {
if (shape instanceof IChart) {
IChart chart = (IChart) shape;
try {
String range = chart.getChartData().getRange();
System.out.println(chart.getName() + ": " + range);
} catch (InvalidOperationException exception) {
System.out.println(chart.getName() + ": The chart does not use a workbook as its data source.");
}
}
}
}
} finally {
presentation.dispose();
}
```
## **Read and Write Chart Data from a Workbook**
Aspose.Slides for Java provides the [readWorkbookStream](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/#readWorkbookStream--) and [writeWorkbookStream](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/#writeWorkbookStream-byte---) methods that allow you to read and write chart data workbooks (containing chart data edited with Aspose.Cells). **Note** that the chart data has to be organized in the same manner or must have a structure similar to the source.
This example uses a presentation with a chart as the first shape on its first slide. It reads the embedded workbook into a byte array, clears the existing series and categories, and writes the same workbook back. The changes remain in memory; the example does not save the presentation.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("chart.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
int shapeCount = slide.getShapes().size();
if (shapeCount > 0 && slide.getShapes().get_Item(0) instanceof IChart) {
IChart chart = (IChart) slide.getShapes().get_Item(0);
IChartData chartData = chart.getChartData();
byte[] workbookData = chartData.readWorkbookStream();
chartData.getSeries().clear();
chartData.getCategories().clear();
chartData.writeWorkbookStream(workbookData);
} else {
System.out.println("The first shape is not a chart.");
}
} finally {
presentation.dispose();
}
```
### **Validate Chart Layout After Workbook Modification**
When you replace an embedded workbook with a modified one, the chart retains its original series and category collections. This mismatch can cause [IChart.validateChartLayout](https://reference.aspose.com/slides/java/com.aspose.slides/ichart/#validateChartLayout--) to fail with an index-out-of-range error. Clear the existing series and categories before writing the updated workbook back to the chart. This example uses a chart that is the first shape on the first slide. The comment marks where workbook editing would occur; the runnable example writes the original workbook back and validates the layout in memory.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("chart.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
int shapeCount = slide.getShapes().size();
if (shapeCount > 0 && slide.getShapes().get_Item(0) instanceof IChart) {
IChart chart = (IChart) slide.getShapes().get_Item(0);
IChartData chartData = chart.getChartData();
byte[] workbookData = chartData.readWorkbookStream();
// Modify the workbook bytes here, for example, using Aspose.Cells.
chartData.getSeries().clear();
chartData.getCategories().clear();
chartData.writeWorkbookStream(workbookData);
chart.validateChartLayout();
} else {
System.out.println("The first shape is not a chart.");
}
} finally {
presentation.dispose();
}
```
Clearing the collections removes stale data references before the workbook is written back. Rebuild any required series and category mappings for the updated workbook before using the chart.
## **Set Custom Number Formats for Workbook Cells**
Use [IChartDataCell.setCustomNumberFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatacell/#setCustomNumberFormat-java.lang.String-) to control how numeric values appear in a chart's embedded workbook. For example, a report may need a conversion rate displayed as a percentage with four decimal places and a coefficient displayed with five decimal places. Keep both values numeric so they remain available for calculations and chart plotting.
A number format changes the display, not the stored value. The format `0.0000%` displays `0.125` as `12.5000%`; it does not replace the stored number with `12.5`. Similarly, `0.00000` displays `0.1234567` as `0.12346` without rounding the stored value. If the custom format is an empty string (`""`), the format returned by [getPresetNumberFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatacell/#getPresetNumberFormat--) is used instead.
The following example creates a column chart and accesses its cells through [getChartDataWorkbook](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/#getChartDataWorkbook--). On worksheet 0, B2 contains the conversion rate and C2 contains the coefficient. Both cells supply chart values. The example also enables value labels linked to the source formats.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
presentation.getSlideSize().setSize(720, 270, SlideSizeScaleType.DoNotScale);
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 20, 620, 210);
chart.setTitle(false);
chart.getAxes().getVerticalAxis().setNumberFormatLinkedToSource(false);
chart.getAxes().getVerticalAxis().setNumberFormat("0.00");
chart.getAxes().getVerticalAxis().setAutomaticMinValue(false);
chart.getAxes().getVerticalAxis().setMinValue(0);
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
workbook.clear(0);
IChartDataCell categoryCell = workbook.getCell(0, "A2", "Sample");
chart.getChartData().getCategories().add(categoryCell);
IChartDataCell percentageCell = workbook.getCell(0, "B2", 0.125);
percentageCell.setCustomNumberFormat("0.0000%");
IChartDataCell percentageName = workbook.getCell(0, "B1", "Conversion rate");
IChartSeries percentageSeries = chart.getChartData().getSeries().add(percentageName, chart.getType());
percentageSeries.getDataPoints().addDataPointForBarSeries(percentageCell);
IChartDataCell precisionCell = workbook.getCell(0, "C2", 0.1234567);
precisionCell.setCustomNumberFormat("0.00000");
IChartDataCell precisionName = workbook.getCell(0, "C1", "Coefficient");
IChartSeries precisionSeries = chart.getChartData().getSeries().add(precisionName, chart.getType());
precisionSeries.getDataPoints().addDataPointForBarSeries(precisionCell);
for (IChartSeries series : chart.getChartData().getSeries()) {
IDataLabelFormat labelFormat = series.getDataPoints().get_Item(0).getLabel().getDataLabelFormat();
labelFormat.setShowValue(true);
labelFormat.setNumberFormatLinkedToSource(true);
}
presentation.save("CustomCellFormats.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
Workbook cell formats are separate from formats set directly on chart axes or data labels. In this example, each label displays its source cell's value because [setShowValue](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabelformat/#setShowValue-boolean-) is set to `true`, and follows the source number format because [setNumberFormatLinkedToSource](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabelformat/#setNumberFormatLinkedToSource-boolean-) is set to `true`. After saving and reopening the presentation, the labels display `12.5000%` and `0.12346`, as shown below. The vertical axis uses its own number format, assigned with [setNumberFormat](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setNumberFormat-java.lang.String-) as `0.00`, with [setNumberFormatLinkedToSource](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setNumberFormatLinkedToSource-boolean-) set to `false`.
To format a data label independently, set its source-link flag to `false` and assign a format with [setNumberFormat](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabelformat/#setNumberFormat-java.lang.String-). This does not change the workbook cell's format. For example, an independent label format of `0.00` displays the first value as `0.13`, while B2 still displays `12.5000%`. See [Chart Data Labels](https://docs.aspose.com/slides/java/chart-data-label/#set-percentage-sign-with-chart-data-labels) for direct label formatting.
The image below was rendered from the saved presentation after reopening it:

## **Set a Workbook Cell as a Chart Data Label**
You can use text from workbook cells as chart data labels.
This example adds a bubble chart with default data to the first slide of an existing presentation. It uses cells A10:A12 on worksheet 0 for the first three labels in the first series, enables labels from cells, and saves the updated presentation.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("chart2.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Bubble, 50, 50, 600, 400, true);
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
series.getLabels().getDefaultDataLabelFormat().setShowLabelValueFromCell(true);
series.getLabels().get_Item(0).setValueFromCell(workbook.getCell(0, "A10", "Label 0 cell value"));
series.getLabels().get_Item(1).setValueFromCell(workbook.getCell(0, "A11", "Label 1 cell value"));
series.getLabels().get_Item(2).setValueFromCell(workbook.getCell(0, "A12", "Label 2 cell value"));
presentation.save("resultchart.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Manage Worksheets**
The [IChartDataWorkbook.getWorksheets](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdataworkbook/#getWorksheets--) method provides access to the worksheets in a chart workbook. This example creates a pie chart with default data and prints each worksheet name to the console.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Pie, 50, 50, 400, 500);
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
for (int i = 0; i < workbook.getWorksheets().size(); i++) {
System.out.println(workbook.getWorksheets().get_Item(i).getName());
}
} finally {
presentation.dispose();
}
```
## **Specify the Data Source Type**
Series point values can also be stored directly as numeric literals. See [Set Series Values Using Numeric Literals](https://docs.aspose.com/slides/java/chart-series/#set-series-values-using-numeric-literals) for a complete example that saves and reads them. The source type of point values is separate from the chart's internal or external workbook configuration; using numeric literals does not, by itself, remove the embedded workbook.
This example creates a 3D column chart with default data and sets two series names using different data sources. The first name uses a string literal; the second uses cell C1 on worksheet 0. The [DataSourceType](https://reference.aspose.com/slides/java/com.aspose.slides/datasourcetype/) enumeration selects the source for each name. The example saves the presentation with the updated series names.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Column3D, 50, 50, 600, 400, true);
IStringChartValue literalName = chart.getChartData().getSeries().get_Item(0).getName();
literalName.setDataSourceType(DataSourceType.StringLiterals);
literalName.setData("LiteralString");
IStringChartValue cellName = chart.getChartData().getSeries().get_Item(1).getName();
IChartDataCell nameCell = chart.getChartData().getChartDataWorkbook().getCell(0, "C1", "NewCell");
cellName.setDataSourceType(DataSourceType.Worksheet);
cellName.setData(nameCell);
presentation.save("pres.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Detect Unsupported Embedded Workbook Formats**
Aspose.Slides does not support the Excel binary workbook (.xlsb) format that can be embedded in some charts. You can use the [getEmbeddedWorkbookType](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/#getEmbeddedWorkbookType--) method on [IChartData](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/) together with the [WorkbookType](https://reference.aspose.com/slides/java/com.aspose.slides/workbooktype/) enumeration to detect unsupported formats and skip those charts. This example inspects the shapes on the first slide of an existing presentation, skips non-chart shapes, and prints a diagnostic message for each chart with an embedded .xlsb workbook.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("sample.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
for (IShape shape : slide.getShapes()) {
if (!(shape instanceof IChart)) {
continue;
}
IChart chart = (IChart) shape;
IChartData chartData = chart.getChartData();
boolean isInternalWorkbook = chartData.getDataSourceType() == ChartDataSourceType.InternalWorkbook;
boolean isBinaryMacro = chartData.getEmbeddedWorkbookType() == WorkbookType.WorkbookBinaryMacro;
if (isInternalWorkbook && isBinaryMacro) {
System.out.println("Skipping a chart with an unsupported .xlsb workbook.");
continue;
}
// Read or modify supported chart workbook data here.
}
} finally {
presentation.dispose();
}
```
## **External Workbook**
Aspose.Slides supports using external workbooks as a data source for charts.
### **Create an External Workbook**
Use [readWorkbookStream](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/#readWorkbookStream--) and [setExternalWorkbook](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/#setExternalWorkbook-java.lang.String-) to export an embedded chart workbook to a file and link the chart to that external workbook.
This example creates a pie chart with default data and exports its workbook. It completes the file write before assigning the external workbook as the chart data source, then saves the linked presentation.
```java
import com.aspose.slides.*;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Pie, 50, 50, 400, 600);
Path workbookPath = Paths.get("externalWorkbook1.xlsx").toAbsolutePath();
byte[] workbookData = chart.getChartData().readWorkbookStream();
try {
Files.write(workbookPath, workbookData);
chart.getChartData().setExternalWorkbook(workbookPath.toString());
presentation.save("externalWorkbook.pptx", SaveFormat.Pptx);
} catch (IOException exception) {
System.out.println("Could not write the external workbook: " + exception.getMessage());
}
} finally {
presentation.dispose();
}
```
### **Set an External Workbook**
Using the [setExternalWorkbook](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/#setExternalWorkbook-java.lang.String-) method, you can assign an external workbook to a chart as its data source. This method can also be used to update a path to the external workbook (if the latter has been moved).
While you cannot edit the data in workbooks stored in remote locations or resources, you can still use such workbooks as an external data source. If the relative path for an external workbook is provided, it gets converted to a full path automatically.
This example uses an external workbook whose worksheet named `Sheet1` contains a series name in B1, category names in A2:A4, and numeric values in B2:B4. The example creates a pie chart, links the workbook, and uses [setRange](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/#setRange-java.lang.String-) to map A1:B4 to one series and three categories. It saves the presentation with the linked chart.
```java
import com.aspose.slides.*;
import java.nio.file.Paths;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Pie, 50, 50, 400, 600, true);
IChartData chartData = chart.getChartData();
String workbookPath = Paths.get("externalWorkbook.xlsx").toAbsolutePath().toString();
chartData.setExternalWorkbook(workbookPath);
chartData.setRange("Sheet1!$A$1:$B$4");
presentation.save("Presentation_with_externalWorkbook.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The `updateChartData` parameter of [setExternalWorkbook](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/#setExternalWorkbook-java.lang.String-boolean-) controls whether the workbook is loaded.
* When `updateChartData` is `false`, only the workbook path is updated. The chart data is not loaded or updated from the target workbook, so the workbook can be unavailable.
* When `updateChartData` is `true`, the chart data is updated from the target workbook.
The following example assigns a placeholder URL with `updateChartData` set to `false`. It retains the pie chart's default data and saves the presentation without loading the unavailable workbook.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Pie, 50, 50, 400, 600, true);
chart.getChartData().setExternalWorkbook("https://example.com/unavailable-workbook.xlsx", false);
presentation.save("SetExternalWorkbookWithUpdateChartData.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
### **Get the External Data Source Workbook Path of a Chart**
To identify the workbook linked to a chart, check whether the chart uses an external data source and retrieve its workbook path.
This example inspects the first shape on the first slide of a presentation with a linked external workbook. If it is a chart linked to an external workbook, the example prints [getExternalWorkbookPath](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/#getExternalWorkbookPath--) to the console. It then saves a copy of the presentation.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("externalWorkbook.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
if (slide.getShapes().size() > 0 && slide.getShapes().get_Item(0) instanceof IChart) {
IChart chart = (IChart) slide.getShapes().get_Item(0);
IChartData chartData = chart.getChartData();
if (chartData.getDataSourceType() == ChartDataSourceType.ExternalWorkbook) {
System.out.println(chartData.getExternalWorkbookPath());
} else {
System.out.println("The chart does not use an external workbook.");
}
} else {
System.out.println("The first shape is not a chart.");
}
presentation.save("Result.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
### **Edit Chart Data**
You can edit the data in external workbooks the same way you make changes to the contents of internal workbooks. When an external workbook cannot be loaded, an exception is thrown.
This example uses a chart that is the first shape on the first slide and is linked to an accessible external workbook. It sets the cell-backed value of the first data point in the first series to 100 and saves the updated presentation. Editing cell values can update the linked external XLSX file, so use a copy if you need to preserve the original workbook.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("presentation.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
int shapeCount = slide.getShapes().size();
if (shapeCount > 0 && slide.getShapes().get_Item(0) instanceof IChart) {
IChart chart = (IChart) slide.getShapes().get_Item(0);
IChartSeriesCollection series = chart.getChartData().getSeries();
if (series.size() > 0 && series.get_Item(0).getDataPoints().size() > 0) {
IChartDataCell valueCell = series.get_Item(0).getDataPoints().get_Item(0).getValue().getAsCell();
if (valueCell != null) {
valueCell.setValue(100);
presentation.save("presentation_out.pptx", SaveFormat.Pptx);
} else {
System.out.println("The first data point is not linked to a workbook cell.");
}
} else {
System.out.println("The chart has no data points to edit.");
}
} else {
System.out.println("The first shape is not a chart.");
}
} finally {
presentation.dispose();
}
```
### **Recover a Workbook from the Chart Cache**
If a chart uses an external workbook that is missing or unavailable, Aspose.Slides can reconstruct the chart workbook from the data cached in the presentation. Create [LoadOptions](https://reference.aspose.com/slides/java/com.aspose.slides/loadoptions/), call [LoadOptions.setSpreadsheetOptions](https://reference.aspose.com/slides/java/com.aspose.slides/loadoptions/#setSpreadsheetOptions-com.aspose.slides.ISpreadsheetOptions-), and set [ISpreadsheetOptions.setRecoverWorkbookFromChartCache](https://reference.aspose.com/slides/java/com.aspose.slides/ispreadsheetoptions/#setRecoverWorkbookFromChartCache-boolean-) to `true` before opening the presentation.
The following Java example recovers workbook data for a chart that is the first shape on the first slide and references an unavailable external workbook. It accesses the recovered data through [IChart.getChartData](https://reference.aspose.com/slides/java/com.aspose.slides/ichart/#getChartData--) and [IChartData.getChartDataWorkbook](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/#getChartDataWorkbook--):
```java
import com.aspose.slides.*;
SpreadsheetOptions spreadsheetOptions = new SpreadsheetOptions();
spreadsheetOptions.setRecoverWorkbookFromChartCache(true);
LoadOptions loadOptions = new LoadOptions();
loadOptions.setSpreadsheetOptions(spreadsheetOptions);
Presentation presentation = new Presentation("presentation.pptx", loadOptions);
try {
ISlide slide = presentation.getSlides().get_Item(0);
int shapeCount = slide.getShapes().size();
if (shapeCount > 0 && slide.getShapes().get_Item(0) instanceof IChart) {
IChart chart = (IChart) slide.getShapes().get_Item(0);
IChartDataWorkbook recoveredWorkbook = chart.getChartData().getChartDataWorkbook();
// Read or modify the recovered workbook data here.
} else {
System.out.println("The first shape is not a chart.");
}
} finally {
presentation.dispose();
}
```
If the external workbook is unavailable and recovery is disabled, Aspose.Slides throws an exception. Enable recovery only when using the cached chart data is an acceptable fallback, because the cache may not contain changes made to the external workbook after the presentation was last updated.
## **FAQ**
**Can I determine whether a specific chart is linked to an external or an embedded workbook?**
Yes. A chart has a [data source type](https://reference.aspose.com/slides/java/com.aspose.slides/chartdata/#getDataSourceType--) and a [path to an external workbook](https://reference.aspose.com/slides/java/com.aspose.slides/chartdata/#getExternalWorkbookPath--); if the source is an external workbook, you can read the full path to make sure an external file is being used.
**Are relative paths to external workbooks supported, and how are they stored?**
Yes. If you specify a relative path, it is automatically converted to an absolute path. The presentation stores the absolute path in the PPTX file, so moving the workbook may require updating the link.
**Can I use workbooks located on network resources/shares?**
Yes, such workbooks can be used as an external data source. However, editing remote workbooks directly from Aspose.Slides is not supported—they can only be used as a source.
**Does Aspose.Slides overwrite the external XLSX when saving the presentation?**
The presentation stores a [link to the external file](https://reference.aspose.com/slides/java/com.aspose.slides/chartdata/#getExternalWorkbookPath--). Editing cell-backed chart data can also update the linked local XLSX file. Use a copy of the workbook if the original must remain unchanged.
**What should I do if the external file is password-protected?**
Aspose.Slides does not accept a password when linking. A common approach is to remove protection in advance or prepare a decrypted copy (for example, using [Aspose.Cells](https://reference.aspose.com/cells/java/)) and link to that copy.
**Can multiple charts reference the same external workbook?**
Yes. Each chart stores its own link. If they all point to the same file, updating that file will be reflected in each chart the next time the data is loaded.
# Apply Chart Worksheet Formulas in Presentations in Java
> Apply Excel-style formulas in Aspose.Slides for Java chart worksheets, recalculate values, and use the results in PowerPoint charts.
Source: https://docs.aspose.com/slides/java/chart-worksheet-formulas/
Updated: 2026-08-21
## **Overview**
PowerPoint charts usually store their source data in an embedded worksheet. In Aspose.Slides for Java, you can access that worksheet through the chart data workbook, write input values, assign formulas to cells, calculate supported formulas, and use the calculated cells as chart data.
This article explains the complete formula workflow: create a chart, populate its worksheet, assign A1-style or R1C1-style formulas, recalculate them, read the calculated values, connect those cells to a chart series, and save the presentation. It also describes the supported formula syntax, the built-in function subset, cached values, unsupported formulas, and spreadsheet-specific errors.
## **Chart Worksheets and Formulas**
A chart worksheet contains the categories, series names, and values used by a chart. In PowerPoint, you can inspect the worksheet by opening the chart data editor:

In Aspose.Slides, the worksheet is exposed through the [IChartDataWorkbook](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdataworkbook/) interface. Use [IChartDataCell.setFormula](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatacell/#setFormula-java.lang.String-) for A1-style formulas and [IChartDataCell.setR1C1Formula](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatacell/#setR1C1Formula-java.lang.String-) for R1C1-style formulas. After changing input cells or formulas, call [IChartDataWorkbook.calculateFormulas](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdataworkbook/#calculateFormulas--) to recalculate supported formulas and update the corresponding cell values.
A calculated cell still exposes its result through [IChartDataCell.getValue](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatacell/#getValue--). This is important when you need to inspect a formula result in code or use the cell as a chart data point.
## **Create a Chart and Calculate Worksheet Formulas**
The following example demonstrates an end-to-end workflow. It creates a clustered column chart, clears the sample data, writes quarterly revenue and expense values, calculates profit with formulas, reads the results, uses the calculated cells as chart values, and saves the presentation.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 600, 350);
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
int worksheetIndex = 0;
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
workbook.clear(worksheetIndex);
IChartDataCell category1 = workbook.getCell(worksheetIndex, "A2", "Q1");
IChartDataCell category2 = workbook.getCell(worksheetIndex, "A3", "Q2");
IChartDataCell category3 = workbook.getCell(worksheetIndex, "A4", "Q3");
workbook.getCell(worksheetIndex, "B1", "Revenue");
workbook.getCell(worksheetIndex, "C1", "Expenses");
workbook.getCell(worksheetIndex, "D1", "Profit");
workbook.getCell(worksheetIndex, "B2").setValue(120.0);
workbook.getCell(worksheetIndex, "C2").setValue(80.0);
workbook.getCell(worksheetIndex, "B3").setValue(150.0);
workbook.getCell(worksheetIndex, "C3").setValue(95.0);
workbook.getCell(worksheetIndex, "B4").setValue(135.0);
workbook.getCell(worksheetIndex, "C4").setValue(110.0);
IChartDataCell profit1 = workbook.getCell(worksheetIndex, "D2");
IChartDataCell profit2 = workbook.getCell(worksheetIndex, "D3");
IChartDataCell profit3 = workbook.getCell(worksheetIndex, "D4");
profit1.setFormula("B2-C2");
profit2.setFormula("B3-C3");
profit3.setFormula("B4-C4");
workbook.calculateFormulas();
double q1Profit = ((Number) profit1.getValue()).doubleValue(); // 40
double q2Profit = ((Number) profit2.getValue()).doubleValue(); // 55
double q3Profit = ((Number) profit3.getValue()).doubleValue(); // 25
System.out.println("Q1 profit: " + q1Profit);
System.out.println("Q2 profit: " + q2Profit);
System.out.println("Q3 profit: " + q3Profit);
chart.getChartData().getCategories().add(category1);
chart.getChartData().getCategories().add(category2);
chart.getChartData().getCategories().add(category3);
IChartSeries profitSeries = chart.getChartData().getSeries().add(workbook.getCell(worksheetIndex, "D1"), chart.getType());
profitSeries.getDataPoints().addDataPointForBarSeries(profit1);
profitSeries.getDataPoints().addDataPointForBarSeries(profit2);
profitSeries.getDataPoints().addDataPointForBarSeries(profit3);
profitSeries.getLabels().getDefaultDataLabelFormat().setShowValue(true);
presentation.save("chart-formulas.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The chart data points reference `D2:D4`, so the chart uses the calculated profit values. There is no separate chart-refresh call in this workflow: recalculate the workbook first, then use or save the chart data that points to the calculated cells.
## **Use A1-Style Formulas**
A1 notation identifies columns with letters and rows with numbers. Assign A1-style expressions through [IChartDataCell.setFormula](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatacell/#setFormula-java.lang.String-).
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 500, 300);
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
workbook.getCell(0, "C3").setValue(10);
workbook.getCell(0, "F2").setValue(2);
workbook.getCell(0, "G2").setValue(3);
workbook.getCell(0, "H2").setValue(4);
IChartDataCell cell = workbook.getCell(0, "A2");
cell.setFormula("C3+SUM(F2:H2)");
workbook.calculateFormulas();
Object value = cell.getValue(); // 19
} finally {
presentation.dispose();
}
```
Common A1 reference forms are:
| Reference | Relative | Absolute | Mixed |
|---|---|---|---|
| Cell | `A2` | `$A$2` | `A$2`, `$A2` |
| Row | `2:2` | `$2:$2` | — |
| Column | `A:A` | `$A:$A` | — |
| Range | `A2:C4` | `$A$2:$C$4` | `A$2:$C4`, `$A2:C$4` |
Relative references can change when a formula is moved or copied by a spreadsheet application. Absolute references keep both coordinates fixed, while mixed references fix only a row or a column.
## **Use R1C1-Style Formulas**
R1C1 notation identifies both rows and columns numerically. Relative references use offsets in square brackets. Assign this syntax through [IChartDataCell.setR1C1Formula](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatacell/#setR1C1Formula-java.lang.String-).
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 500, 300);
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
workbook.getCell(0, "B2").setValue(12);
workbook.getCell(0, "C2").setValue(5);
IChartDataCell cell = workbook.getCell(0, "D2");
cell.setR1C1Formula("RC[-2]-RC[-1]");
workbook.calculateFormulas();
Object value = cell.getValue(); // 7
} finally {
presentation.dispose();
}
```
Common R1C1 reference forms are:
| Reference | Relative | Absolute | Mixed |
|---|---|---|---|
| Cell | `R[2]C[3]` | `R2C3` | `R2C[3]`, `R[2]C3` |
| Row | `R[2]` | `R2` | — |
| Column | `C[3]` | `C3` | — |
| Range | `R[2]C[3]:R[5]C[7]` | `R2C3:R5C7` | `R2C3:R[5]C[7]`, `R[2]C3:R5C[7]` |
For example, in cell `D2`, `RC[-2]` means the cell in the same row two columns to the left (`B2`).
## **Formula Constants and Operators**
The built-in formula evaluator supports logical values, numeric literals, strings, spreadsheet error values, arithmetic operators, and comparison operators.
### **Constants and Literals**
| Type | Examples | Notes |
|---|---|---|
| Logical | `TRUE`, `FALSE` | Can be used directly in logical expressions such as `A2=TRUE`. |
| Numeric | `1`, `0.5`, `.3`, `1E-2` | Common and scientific notation are supported. |
| String | `"abc"`, `"2/3/2020 12:00"` | Text literals are enclosed in double quotation marks inside the formula. |
| Error result | `#DIV/0!`, `#N/A`, `#REF!` | A valid formula can evaluate to a spreadsheet error value instead of a normal result. |
This example uses several constant types:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 500, 300);
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
workbook.getCell(0, "A2").setValue(false);
workbook.getCell(0, "B2").setFormula("A2=TRUE");
workbook.getCell(0, "C2").setFormula("1+0.5");
workbook.getCell(0, "D2").setFormula(".3*1E-2");
workbook.getCell(0, "E2").setFormula("\"abc\"");
workbook.getCell(0, "F2").setFormula("2/0");
workbook.calculateFormulas();
Object logicalValue = workbook.getCell(0, "B2").getValue(); // false
Object numericValue = workbook.getCell(0, "C2").getValue(); // 1.5
Object scientificValue = workbook.getCell(0, "D2").getValue(); // 0.003
Object stringValue = workbook.getCell(0, "E2").getValue(); // abc
Object errorValue = workbook.getCell(0, "F2").getValue(); // #DIV/0!
} finally {
presentation.dispose();
}
```
### **Arithmetic Operators**
| Operator | Meaning | Example |
|---|---|---|
| `+` | Addition or unary plus | `2+3` |
| `-` | Subtraction or negation | `2-3`, `-3` |
| `*` | Multiplication | `2*3` |
| `/` | Division | `2/3` |
| `%` | Percent | `30%` |
| `^` | Exponentiation | `2^3` |
Use parentheses to make evaluation order explicit, for example `(A2+B2)*C2`.
### **Comparison Operators**
Comparison expressions return logical values.
| Operator | Meaning | Example |
|---|---|---|
| `=` | Equal to | `A2=3` |
| `<>` | Not equal to | `A2<>3` |
| `>` | Greater than | `A2>3` |
| `>=` | Greater than or equal to | `A2>=3` |
| `<` | Less than | `A2<3` |
| `<=` | Less than or equal to | `A2<=3` |
## **Supported Predefined Functions**
Aspose.Slides includes a built-in formula evaluator for chart worksheets, but it is not a complete Excel calculation engine. The documented function set is limited to the functions below. Do not assume that an arbitrary Excel function can be recalculated by [IChartDataWorkbook.calculateFormulas](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdataworkbook/#calculateFormulas--).
| Function | Purpose or supported form | Example |
|---|---|---|
| `ABS` | Absolute value | `ABS(A2)` |
| `AVERAGE` | Arithmetic mean | `AVERAGE(B2:B5)` |
| `CEILING` | Round a number upward to a multiple | `CEILING(A2,5)` |
| `CHOOSE` | Select a value by index | `CHOOSE(A2,"Low","High")` |
| `CONCAT` | Join text values | `CONCAT(A2,B2)` |
| `CONCATENATE` | Join text values | `CONCATENATE(A2," ",B2)` |
| `DATE` | Create a date value using the 1900 date system | `DATE(2026,8,19)` |
| `DAYS` | Return the number of days between dates | `DAYS(B2,A2)` |
| `FIND` | Find one text value inside another | `FIND("-",A2)` |
| `FINDB` | Byte-oriented text search | `FINDB("a",A2)` |
| `IF` | Conditional result | `IF(A2>0,A2,0)` |
| `INDEX` | Reference form | `INDEX(A2:C4,2,3)` |
| `LOOKUP` | Vector form | `LOOKUP(A2,B2:B5,C2:C5)` |
| `MATCH` | Vector form | `MATCH(A2,B2:B5,0)` |
| `MAX` | Maximum value | `MAX(B2:B5)` |
| `SUM` | Sum values | `SUM(B2:B5)` |
| `VLOOKUP` | Vertical lookup | `VLOOKUP(A2,B2:D10,3,FALSE)` |
The restrictions shown in the table are significant: `INDEX` is documented in reference form, while `LOOKUP` and `MATCH` are documented in their vector forms. `DATE` uses the 1900 date system. Features and functions not listed here should be treated as unsupported by the Aspose.Slides formula evaluator unless they are documented separately.
## **Calculate Formulas with a Preferred Culture**
Some chart workbook functions interpret text according to culture-specific rules. This is especially important for functions intended for languages that use double-byte character sets (DBCS). To calculate such formulas correctly, create [LoadOptions](https://reference.aspose.com/slides/java/com.aspose.slides/loadoptions/), set the preferred culture with [SpreadsheetOptions.setPreferredCulture](https://reference.aspose.com/slides/java/com.aspose.slides/spreadsheetoptions/#setPreferredCulture-java.util.Locale-), assign the spreadsheet options through [LoadOptions.setSpreadsheetOptions](https://reference.aspose.com/slides/java/com.aspose.slides/loadoptions/#setSpreadsheetOptions-com.aspose.slides.ISpreadsheetOptions-), and then load the presentation.
The following example selects the Japanese culture, opens a presentation with the configured load options, and calls [IChartDataWorkbook.calculateFormulas](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdataworkbook/#calculateFormulas--) for every chart workbook:
```java
import com.aspose.slides.*;
import java.util.Locale;
Locale japaneseCulture = Locale.forLanguageTag("ja-JP");
ISpreadsheetOptions spreadsheetOptions = new SpreadsheetOptions();
spreadsheetOptions.setPreferredCulture(japaneseCulture);
LoadOptions loadOptions = new LoadOptions();
loadOptions.setSpreadsheetOptions(spreadsheetOptions);
Presentation presentation = new Presentation("presentation.pptx", loadOptions);
try {
for (ISlide slide : presentation.getSlides()) {
for (IShape shape : slide.getShapes()) {
if (shape instanceof IChart) {
IChart chart = (IChart) shape;
chart.getChartData().getChartDataWorkbook().calculateFormulas();
}
}
}
} finally {
presentation.dispose();
}
```
The preferred culture is part of the presentation loading configuration, so specify it before creating the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) instance. Use the culture expected by the workbook formulas; for example, use `ja-JP` for formulas that should follow Japanese DBCS calculation rules.
## **Recalculation and Cached Values**
Spreadsheet files commonly store both a formula and its last calculated value. Aspose.Slides can therefore read a cached value from [IChartDataCell.getValue](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatacell/#getValue--) when a presentation is loaded and the relevant chart data has not been changed.
After changing input cells or formulas, do not rely on an old cached result. Call [IChartDataWorkbook.calculateFormulas](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdataworkbook/#calculateFormulas--) before reading calculated values or saving chart data that depends on them.
For formulas outside the supported subset, Aspose.Slides may be unable to parse the formula or establish its dependencies. If the workbook has been modified, the previous cached value can no longer be considered reliable. In that situation, reading the value of a cell with unsupported data can raise [CellUnsupportedDataException](https://reference.aspose.com/slides/java/com.aspose.slides/cellunsupporteddataexception/).
If your chart depends on Excel functions that Aspose.Slides does not evaluate, calculate those formulas with a spreadsheet engine that supports them and write the resulting values back to the chart workbook. Do not replace unsupported formulas with guessed values.
## **Handle Formula Errors**
There are two different kinds of problems to distinguish.
A formula can be valid but produce a spreadsheet error result such as `#DIV/0!`, `#N/A`, `#NAME?`, `#NULL!`, `#NUM!`, `#REF!`, or `#VALUE!`. In this case, the error token is a cell result and can be returned through [IChartDataCell.getValue](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatacell/#getValue--).
A formula can also fail at the parsing, reference, dependency, or supported-data level. Aspose.Slides provides spreadsheet-specific exceptions for these cases: [CellInvalidFormulaException](https://reference.aspose.com/slides/java/com.aspose.slides/cellinvalidformulaexception/), [CellInvalidReferenceException](https://reference.aspose.com/slides/java/com.aspose.slides/cellinvalidreferenceexception/), [CellCircularReferenceException](https://reference.aspose.com/slides/java/com.aspose.slides/cellcircularreferenceexception/), and [CellUnsupportedDataException](https://reference.aspose.com/slides/java/com.aspose.slides/cellunsupporteddataexception/).
When formulas come from templates or user input, handle these exceptions around recalculation and value access:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 500, 300);
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
IChartDataCell cell = workbook.getCell(0, "A2");
cell.setFormula("SUM(B2:B5)");
try {
workbook.calculateFormulas();
System.out.println(cell.getValue());
} catch (CellInvalidFormulaException ex) {
System.err.println("Invalid formula: " + ex.getMessage());
} catch (CellInvalidReferenceException ex) {
System.err.println("Invalid cell reference: " + ex.getMessage());
} catch (CellCircularReferenceException ex) {
System.err.println("Circular reference: " + ex.getMessage());
} catch (CellUnsupportedDataException ex) {
System.err.println("Unsupported spreadsheet data: " + ex.getMessage());
}
} finally {
presentation.dispose();
}
```
## **Practical Limitations**
The formula support in chart worksheets is intended for a defined subset of spreadsheet calculations, not for full Excel compatibility. Keep these constraints in mind when designing a reporting workflow:
- Use only the documented constants, operators, references, and functions when you need Aspose.Slides to recalculate formulas.
- Recalculate after changing cells that formula results depend on.
- Treat cached values from loaded presentations as snapshots, not as a replacement for recalculation after edits.
- Test formulas from existing templates before relying on their calculated values, especially when they use functions outside the documented list.
- For formulas that require a full spreadsheet calculation engine, calculate them externally and then update the chart workbook with the resulting values.
## **FAQ**
**What is the difference between [IChartDataCell.setFormula](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatacell/#setFormula-java.lang.String-) and [IChartDataCell.setR1C1Formula](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatacell/#setR1C1Formula-java.lang.String-)?**
[IChartDataCell.setFormula](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatacell/#setFormula-java.lang.String-) stores an A1-style expression such as `B2-C2`. [IChartDataCell.setR1C1Formula](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatacell/#setR1C1Formula-java.lang.String-) stores an R1C1-style expression such as `RC[-2]-RC[-1]`. Use the notation that best matches how you generate or copy formulas.
**Do I need to read the cell itself or its value after calculation?**
[IChartDataWorkbook.getCell](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdataworkbook/#getCell-int-java.lang.String-) returns an [IChartDataCell](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatacell/). To obtain the calculated result, call that cell's [IChartDataCell.getValue](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatacell/#getValue--) method after recalculation.
**When should I call [IChartDataWorkbook.calculateFormulas](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdataworkbook/#calculateFormulas--)?**
Call [IChartDataWorkbook.calculateFormulas](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdataworkbook/#calculateFormulas--) after changing input values or formulas and before you depend on the calculated results. This updates the values of formulas that the built-in evaluator supports.
**Does Aspose.Slides support every Excel function?**
No. The built-in evaluator supports a documented subset of functions. Functions outside that subset should not be assumed to recalculate correctly. If full Excel formula compatibility is required, perform the calculation with an appropriate spreadsheet engine and write the final values to the chart workbook.
**What happens if a loaded presentation contains an unsupported formula?**
If the chart data has not changed, the workbook may still contain a previously calculated cached value. After related data is modified, that cached value may no longer be valid. Accessing a cell whose formula cannot be handled can raise [CellUnsupportedDataException](https://reference.aspose.com/slides/java/com.aspose.slides/cellunsupporteddataexception/).
**Are formula error values the same as Java exceptions?**
No. A result such as `#DIV/0!` is a spreadsheet value produced by a valid calculation. Exceptions such as [CellInvalidFormulaException](https://reference.aspose.com/slides/java/com.aspose.slides/cellinvalidformulaexception/) or [CellCircularReferenceException](https://reference.aspose.com/slides/java/com.aspose.slides/cellcircularreferenceexception/) indicate that the formula cannot be processed normally.
**Does a chart update automatically when a formula cell changes?**
A chart series can reference workbook cells. Recalculate the workbook first, then save or render the presentation. If the chart data points reference the calculated cells, the chart uses those updated cell values; no separate chart-refresh method is required for this workflow.
**Can charts use an external Excel workbook?**
Yes, chart data can be configured to use an external workbook through the chart data API. However, the formula calculation workflow described in this article concerns the chart data workbook and the formula subset evaluated by Aspose.Slides. Do not assume that [IChartDataWorkbook.calculateFormulas](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdataworkbook/#calculateFormulas--) provides full recalculation of arbitrary formulas in an external XLSX file.
**Can I use formulas that reference another worksheet or workbook?**
Excel-style references may exist in chart workbooks, but formula evaluation is limited by the supported parser and function set. If a cross-sheet or external reference is essential, validate that exact formula with your target Aspose.Slides version. For workflows that require broad Excel reference compatibility, calculate the workbook externally and write the resolved values back to the chart data.
**Should formula strings start with `=`?**
The Aspose.Slides API examples assign expressions such as `B2-C2` or `SUM(B2:B5)` without a leading `=`. Using that form keeps generated formulas consistent with the documented API examples.
# Clone Presentation Slides in Java
> Quickly duplicate PowerPoint slides with Aspose.Slides for Java. Follow our clear code examples to automate PPT creation in seconds and eliminate manual work.
Source: https://docs.aspose.com/slides/java/clone-slides/
Updated: 2026-11-08
## **Introduction**
Cloning is the process of making an exact copy or replica of something. Aspose.Slides for Java also makes it possible to make a copy or clone of any slide and then insert that cloned slide to the current or any other opened presentation. The process of slide cloning creates a new slide that can be modified by developers without changing the original slide. There are several possible ways to clone a slide:
- Clone at End within a Presentation.
- Clone at Another Position within Presentation.
- Clone at End in another Presentation.
- Clone at Another Position in another Presentation.
- Clone together with its master slide into another Presentation.
In Aspose.Slides for Java, (a collection of [ISlide](https://reference.aspose.com/slides/java/com.aspose.slides/ISlide) objects) exposed by the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) object provides the [addClone](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection#addClone-com.aspose.slides.ISlide-) and [insertClone](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection#insertClone-int-com.aspose.slides.ISlide-) methods to perform the above types of slide cloning
## **Clone a Slide at the End of a Presentation**
If you want to clone a slide and then use it within the same presentation file at the end of the existing slides, use the [addClone](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection#addClone-com.aspose.slides.ISlide-) method according to the steps listed below:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class.
1. Instantiate the [ISlideCollection](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation#getSlides--) class by referencing the Slides collection exposed by the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) object.
1. Call the [addClone](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection#addClone-com.aspose.slides.ISlide-) method exposed by the [ISlideCollection](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation#getSlides--) object and pass the slide to be cloned as a parameter to the [addClone](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection#addClone-com.aspose.slides.ISlide-) method.
1. Write the modified presentation file.
In the example given below, we have cloned a slide (lying at the first position – zero index – of the presentation) to the end of the presentation.
```java
import com.aspose.slides.*;
// Instantiate Presentation class that represents a presentation file
Presentation pres = new Presentation("CloneWithinSamePresentationToEnd.pptx");
try {
// Clone the desired slide to the end of the collection of slides in the same presentation
ISlideCollection slds = pres.getSlides();
slds.addClone(pres.getSlides().get_Item(0));
// Write the modified presentation to disk
pres.save("Aspose_CloneWithinSamePresentationToEnd_out.pptx", SaveFormat.Pptx);
} finally {
pres.dispose();
}
```
## **Clone a Slide to Another Position within a Presentation**
If you want to clone a slide and then use it within the same presentation file but at a different position, use the [insertClone](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection#insertClone-int-com.aspose.slides.ISlide-) method:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class.
1. Instantiate the class by referencing the [**Slides**](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation#getSlides--) collection exposed by the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) object.
1. Call the [insertClone](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection#insertClone-int-com.aspose.slides.ISlide-) method exposed by the [ISlideCollection](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation#getSlides--) object and pass the slide to be cloned along with the index for the new position as a parameter to the [insertClone](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection#insertClone-int-com.aspose.slides.ISlide-) method.
1. Write the modified presentation as a PPTX file.
In the example given below, we have cloned a slide (lying at index 1 – position 2 – of the presentation) to index 2 – position 3 – of the presentation.
```java
import com.aspose.slides.*;
// Instantiate Presentation class that represents a presentation file
Presentation pres = new Presentation("CloneWithInSamePresentation.pptx");
try {
// Get the collection of slides in the presentation
ISlideCollection slds = pres.getSlides();
// Clone the desired slide to the specified index in the same presentation
slds.insertClone(2, pres.getSlides().get_Item(1));
// Write the modified presentation to disk
pres.save("Aspose_CloneWithInSamePresentation_out.pptx", SaveFormat.Pptx);
} finally {
pres.dispose();
}
```
## **Clone a Slide at the End of Another Presentation**
If you need to clone a slide from one presentation and use it in another presentation file, at the end of the existing slides:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class containing the presentation the slide will be cloned from.
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class containing the destination presentation that the slide will be added to.
1. Instantiate the [ISlideCollection](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection) class by referencing the [**Slides**](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation#getSlides--) collection exposed by the Presentation object of the destination presentation.
1. Call the [addClone](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection#addClone-com.aspose.slides.ISlide-) method exposed by the [ISlideCollection](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation#getSlides--) object and pass the slide from the source presentation as a parameter to the [addClone](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection#addClone-com.aspose.slides.ISlide-) method.
1. Write the modified destination presentation file.
In the example given below, we have cloned a slide (from the first index of the source presentation) to the end of the destination presentation.
```java
import com.aspose.slides.*;
// Instantiate Presentation class to load the source presentation file
Presentation srcPres = new Presentation("CloneAtEndOfAnother.pptx");
try {
// Instantiate Presentation class for destination PPTX (where slide is to be cloned)
Presentation destPres = new Presentation();
try {
// Clone the desired slide from the source presentation to the end of the collection of slides in destination presentation
ISlideCollection slds = destPres.getSlides();
slds.addClone(srcPres.getSlides().get_Item(0));
// Write the destination presentation to disk
destPres.save("Aspose2_out.pptx", SaveFormat.Pptx);
} finally {
destPres.dispose();
}
} finally {
srcPres.dispose();
}
```
## **Clone a Slide to Another Position in Another Presentation**
If you need to clone a slide from one presentation and use it in another presentation file, at a specific position:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class containing the source presentation the slide will be cloned from.
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class containing the presentation the slide will be added to.
1. Instantiate the [ISlideCollection](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation#getSlides--) class by referencing the Slides collection exposed by the Presentation object of the destination presentation.
1. Call the [insertClone](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection#insertClone-int-com.aspose.slides.ISlide-) method exposed by the [ISlideCollection](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation#getSlides--) object and pass the slide from the source presentation along with the desired position as a parameter to the [insertClone](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection#insertClone-int-com.aspose.slides.ISlide-) method.
1. Write the modified destination presentation file.
In the example given below, we have cloned a slide (from the zero index of the source presentation) to index 1 (position 2) of the destination presentation.
```java
import com.aspose.slides.*;
// Instantiate Presentation class to load the source presentation file
Presentation srcPres = new Presentation("CloneAtEndOfAnother.pptx");
try {
// Instantiate Presentation class for destination PPTX (where slide is to be cloned)
Presentation destPres = new Presentation();
try {
// Clone the desired slide from the source presentation to the specified index in the destination presentation
ISlideCollection slds = destPres.getSlides();
slds.insertClone(1, srcPres.getSlides().get_Item(0));
// Write the destination presentation to disk
destPres.save("Aspose2_out.pptx", SaveFormat.Pptx);
} finally {
destPres.dispose();
}
} finally {
srcPres.dispose();
}
```
## **Clone a Slide with Its Master Slide to Another Presentation**
If you need to clone a slide with a master slide from one presentation from and use it in another presentation, you need to clone the desired master slide from source presentation to destination presentation first. Then you need to use that master slide for cloning slide with master slide. The [**addClone(ISlide, IMasterSlide, boolean)**](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection#addClone-com.aspose.slides.ISlide-com.aspose.slides.IMasterSlide-boolean-) expects a master slide from destination presentation rather than from source presentation. In order to clone the slide with a master, please follow the steps below:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class containing the source presentation the slide will be cloned from.
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class containing the destination presentation the slide will be cloned to.
1. Access the slide to be cloned along with the master slide.
1. Instantiate the [IMasterSlideCollection](https://reference.aspose.com/slides/java/com.aspose.slides/IMasterSlideCollection) class by referencing the Masters collection exposed by the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) object of the destination presentation.
1. Call the [addClone](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection#addClone-com.aspose.slides.ISlide-) method exposed by the [IMasterSlideCollection](https://reference.aspose.com/slides/java/com.aspose.slides/IMasterSlideCollection) object and pass the master from the source PPTX to be cloned as a parameter to the [addClone](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection#addClone-com.aspose.slides.ISlide-) method.
1. Instantiate the [ISlideCollection](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation#getSlides--) class by setting the reference to the Slides collection exposed by the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) object of the destination presentation.
1. Call the [addClone](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection#addClone-com.aspose.slides.ISlide-) method exposed by the [ISlideCollection](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation#getSlides--) object and pass the slide from the source presentation to be cloned and master slide as a parameter to the [addClone](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection#addClone-com.aspose.slides.ISlide-) method.
1. Write the modified destination presentation file.
In the example given below, we have cloned a slide with a master (lying at the zero index of the source presentation) to the end of the destination presentation using a master from source slide.
```java
import com.aspose.slides.*;
// Instantiate Presentation class to load the source presentation file
Presentation srcPres = new Presentation("CloneToAnotherPresentationWithMaster.pptx");
try {
// Instantiate Presentation class for destination presentation (where slide is to be cloned)
Presentation destPres = new Presentation();
try {
// Instantiate ISlide from the collection of slides in source presentation along with
// Master slide
ISlide SourceSlide = srcPres.getSlides().get_Item(0);
IMasterSlide SourceMaster = SourceSlide.getLayoutSlide().getMasterSlide();
// Clone the desired master slide from the source presentation to the collection of masters in the
// Destination presentation
IMasterSlideCollection masters = destPres.getMasters();
IMasterSlide DestMaster = masters.addClone(SourceMaster);
// Clone the desired slide from the source presentation with the desired master to the end of the
// Collection of slides in the destination presentation
ISlideCollection slds = destPres.getSlides();
slds.addClone(SourceSlide, DestMaster, true);
// Save the destination presentation to disk
destPres.save("CloneToAnotherPresentationWithMaster_out.pptx", SaveFormat.Pptx);
} finally {
destPres.dispose();
}
} finally {
srcPres.dispose();
}
```
## **Clone a Slide at the End of a Specified Section**
If you want to clone a slide and then use it within the same presentation file but at a different section, then use the [**addClone**](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection#addClone-com.aspose.slides.ISlide-com.aspose.slides.ISection-) method exposed by the [**ISlideCollection**](https://reference.aspose.com/slides/java/com.aspose.slides/ISlideCollection) interface. Aspose.Slides for Java makes it possible to clone a slide from the first section and then insert that cloned slide to the second section of the same presentation.
The following code snippet shows you how to clone a slide and insert the cloned slide into a specified section.
```java
import com.aspose.slides.*;
IPresentation presentation = new Presentation();
try {
presentation.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 200, 50, 300, 100);
presentation.getSections().addSection("Section 1", presentation.getSlides().get_Item(0));
ISection section2 = presentation.getSections().appendEmptySection("Section 2");
presentation.getSlides().addClone(presentation.getSlides().get_Item(0), section2);
// Save the destination presentation to disk
presentation.save("CloneSlideIntoSpecifiedSection.pptx", SaveFormat.Pptx);
} finally {
if (presentation != null) presentation.dispose();
}
```
## **Ensure Matching Slide Size**
When cloning slides into another presentation, make sure the destination presentation has the same slide size as the source. If the slide sizes differ, Aspose.Slides does not automatically rescale the cloned shapes—their original coordinates and dimensions are preserved, which may cause the content to appear misaligned or extend beyond the slide boundaries.
You can set the destination presentation's slide size to match the source before cloning the master and slide:
```java
Dimension2D sourceSize = sourcePresentation.getSlideSize().getSize();
targetPresentation.getSlideSize().setSize(
sourceSize.getWidth(), sourceSize.getHeight(), SlideSizeScaleType.DoNotScale);
```
Do this before cloning the master and the slide.
[](https://docs.aspose.com/slides/java/clone-slides/visual-clone-slides-1f4700a4b669.svg)
*Illustrative .NET 26.11 output at the same scale. The cloned frame stays at (500, 200), sized 160 × 100 points; the smaller canvas clips it. In the guide’s workflow, match the destination size first, copy the master, then clone against that destination master. The dashed outline marks off-canvas geometry, not exported pixels.*
## **FAQ**
**Do speaker notes and reviewer comments get cloned?**
Yes. The notes page and review comments are included in the clone. If you don’t want them, [remove them](https://docs.aspose.com/slides/java/presentation-notes/) after insertion.
**How are charts and their data sources handled?**
The chart object, formatting, and embedded data are copied. If the chart was linked to an external source (e.g., an OLE-embedded workbook), that linkage is preserved as an [OLE object](https://docs.aspose.com/slides/java/manage-ole/). After moving between files, verify data availability and refresh behavior.
**Can I control the insertion position and sections for the clone?**
Yes. You can insert the clone at a specific slide index and place it into a chosen [section](https://docs.aspose.com/slides/java/slide-section/). If the target section doesn’t exist, create it first and then move the slide into it.
Related feature: [Clone slides between presentations](https://docs.aspose.com/slides/features/clone-slides/).
# Common Exceptions and Errors Involving Fonts on Linux
> Font exceptions and errors on Linux
Source: https://docs.aspose.com/slides/java/common-errors-involving-fonts/
Updated: 2026-08-25
## **Overview**
When Aspose.Slides is used on Linux, font-related issues may occur if the Java process cannot access the required font folders or temporary directory, if no fonts are installed on the system, or if required system libraries such as fontconfig or libfreetype are missing.
This article describes common errors and exceptions related to fonts on Linux and provides solutions for resolving them. It explains how to check access to font and TEMP directories, install the required fonts and libraries, and use `FontsLoader` to load fonts without installing them system-wide.
## **Missing Text or Images (EMF or WMF) When Code Is Executed on Linux**
This problem occurs in systems with restrictions in these cases:
1. When there are no fonts installed or when the font folder for the java process cannot be accessed
2. When the TEMP directory cannot be accessed.
### **Solution**
Check and confirm that access to the TEMP directory and the fonts folder has been granted.
In some cases, you may be unable to grant access to folders due to restrictions imposed by the environment or a security policy. Try these workarounds:
**Workaround**
Use [FontsLoader](https://reference.aspose.com/slides/java/com.aspose.slides/FontsLoader) to load the required fonts without installing them:
```
FontsLoader.loadExternalFonts(pathToFontsFolders);
```
If the TEMP directory cannot be accessed, use this code to specify another directory as the TEMP for Java:
```
String newTempFolder = "pathToTmpFolder";
String oldValue = System.getProperty("java.io.tmpdir");
java.io.File file = new java.io.File(newTempFolder);
if (!file.exists())
file.mkdir();
System.setProperty("java.io.tmpdir", newTempFolder);
try {
FontsLoader.loadExternalFonts(pathToFontsFolders);
Presentation pres = ...
// ....
} finally {
System.setProperty("java.io.tmpdir", oldValue);
}
```
## **Exception: InvalidOperationException: Cannot Find Any Fonts Installed on the System**
This exception occurs when
1) the Java process cannot access the fonts folder
2) no fonts have been installed.
### **Solution**
1. Check and confirm that access to the font folder for the Java process has been granted.
2. Install some fonts or use [FontsLoader](https://reference.aspose.com/slides/java/com.aspose.slides/FontsLoader).
3. Install fonts.
* Ubuntu:
```
sudo apt-get update
sudo apt-get install -y fonts-dejavu-core
fc-cache -fv
```
* CentOS:
```
sudo yum makecache
sudo yum -y install dejavu-sans-fonts
fc-cache -fv
```
* Using [FontsLoader](https://reference.aspose.com/slides/java/com.aspose.slides/FontsLoader):
```
FontsLoader.loadExternalFonts(pathToFontsFolders);
```
## **Exception: InternalError: InvocationTargetException**
When converting a PPTX file to PDF on Linux, the conversion may fail with `java.lang.InternalError: java.lang.reflect.InvocationTargetException`. If the underlying error states `Cannot load from short array because "sun.awt.FontConfiguration.head" is null`, the Linux font configuration is unavailable or its cache has not been initialized.
### **Solution**
Install fontconfig and rebuild the font cache:
```bash
sudo yum install -y fontconfig
sudo fc-cache --force
```
## **Exception: NoClassDefFoundError: Could Not Initialize Class com.aspose.slides.internal.ey.this**
This exception occurs on a Linux system that lacks fontconfig and fonts.
### **Solution**
Install fontconfig:
* Ubuntu:
```
sudo apt-get update
sudo apt-get -y install fontconfig
```
* CentOS:
```
sudo yum makecache
sudo yum -y install fontconfig
```
Additionally, some open-jdk versions (for example, **alpine JDK**) also **require installed fonts**.
* Ubuntu:
```
sudo apt-get install -y fonts-dejavu-core
fc-cache -fv
```
* CentOS:
```
sudo yum -y install dejavu-sans-fonts
fc-cache -fv
```
## **Exception: UnsatisfiedLinkError: libfreetype.so.6: Cannot Open Shared Object File: No Such File or Directory**
This exception occurs on a Linux system that lacks the libfreetype library.
### **Solution**
Install libfreetype and fontconfig:
* Ubuntu:
```
sudo apt-get update
sudo apt-get install libfreetype6
sudo apt-get -y install fontconfig
```
* CentOS:
```
sudo yum makecache
sudo yum install libfreetype6
sudo yum -y install fontconfig
```
Don't forget to install fonts or use FontsLoader.
# Compare Presentation Slides in Java
> Compare PowerPoint and OpenDocument presentations programmatically with Aspose.Slides for Java. Identify slide differences in code quickly.
Source: https://docs.aspose.com/slides/java/compare-slides/
Updated: 2026-08-05
## **Overview**
Aspose.Slides allows you to compare slides, layout slides, and master slides using the `equals` method provided by the `IBaseSlide` interface and the `BaseSlide` class. This method returns `true` when the compared slides are identical in their structure and static content.
## **Compare Two Slides**
Equals method has been added to [IBaseSlide](https://reference.aspose.com/slides/java/com.aspose.slides/IBaseSlide) interface and [BaseSlide](https://reference.aspose.com/slides/java/com.aspose.slides/BaseSlide) class. It returns true for the slides/layout and slides/master slides which identical by its structure and static content.
Two slides are equal if all shapes, styles, texts, animation and other settings. etc. are equal. The comparison doesn't take into account unique identifier values, e.g. SlideId and dynamic content, e.g. current date value in Date Placeholder.
```java
import com.aspose.slides.*;
Presentation presentation1 = new Presentation("AccessSlides.pptx");
try {
Presentation presentation2 = new Presentation("HelloWorld.pptx");
try {
for (int i = 0; i < presentation1.getMasters().size(); i++)
{
for (int j = 0; j < presentation2.getMasters().size(); j++)
{
if (presentation1.getMasters().get_Item(i).equals(presentation2.getMasters().get_Item(j)))
System.out.println(String.format("SomePresentation1 MasterSlide#%d is equal to SomePresentation2 MasterSlide#%d", i, j));
}
}
} finally {
presentation2.dispose();
}
} finally {
presentation1.dispose();
}
```
## **FAQ**
### Does the fact that a slide is hidden affect the comparison of the slides themselves?
[Hidden status](https://reference.aspose.com/slides/java/com.aspose.slides/slide/#getHidden--) is a presentation/playback-level property, not visual content. The equality of two specific slides is determined by their structure and static content; the mere fact that a slide is hidden does not make the slides different.
### Are hyperlinks and their parameters taken into account?
Yes. Links are part of a slide’s static content. If the URL or the hyperlink action differs, this is usually treated as a difference in static content.
### If a chart refers to an external Excel file, will the contents of that file be taken into account?
No. The comparison is performed based on the slides themselves. External data sources are generally not read at comparison time; only what is present in the slide’s structure and static state is considered.
# Manage Connectors in Presentations in Java
> Learn how to add, attach, reroute, adjust, and inspect straight, bent, and curved PowerPoint connectors with Aspose.Slides for Java.
Source: https://docs.aspose.com/slides/java/connector/
Updated: 2026-08-27
## **Overview**
A connector is a line that can remain attached to two shapes when either shape moves. Its ends attach to connection sites, represented by green dots in PowerPoint. Some bent and curved connectors also expose adjustment points, represented by orange dots, that control the position of individual connector segments.
Aspose.Slides represents connectors through the [IConnector](https://reference.aspose.com/slides/java/com.aspose.slides/iconnector/) interface. You can create them, attach their ends to shapes, choose connection sites, reroute them, and modify the geometry of connectors that have adjustment points.
## **Connector Types**
The [ShapeType](https://reference.aspose.com/slides/java/com.aspose.slides/shapetype/) class includes straight, bent, and curved connector presets. The following table shows the available connector geometries and the number of adjustment points defined by each preset.
| Connector | Image | Number of adjustment points |
|---|---|---|
| `ShapeType.Line` |  | 0 |
| `ShapeType.StraightConnector1` |  | 0 |
| `ShapeType.BentConnector2` |  | 0 |
| `ShapeType.BentConnector3` |  | 1 |
| `ShapeType.BentConnector4` |  | 2 |
| `ShapeType.BentConnector5` |  | 3 |
| `ShapeType.CurvedConnector2` |  | 0 |
| `ShapeType.CurvedConnector3` |  | 1 |
| `ShapeType.CurvedConnector4` |  | 2 |
| `ShapeType.CurvedConnector5` |  | 3 |
The number and meaning of adjustment points are part of the selected connector preset. Do not assume that two different connector types expose the same collection layout.
## **Connect Two Shapes**
Use [IShapeCollection.addConnector](https://reference.aspose.com/slides/java/com.aspose.slides/ishapecollection/#addConnector-int-float-float-float-float-) to add a connector, and use [IConnector.setStartShapeConnectedTo](https://reference.aspose.com/slides/java/com.aspose.slides/iconnector/#setStartShapeConnectedTo-com.aspose.slides.IShape-) and [IConnector.setEndShapeConnectedTo](https://reference.aspose.com/slides/java/com.aspose.slides/iconnector/#setEndShapeConnectedTo-com.aspose.slides.IShape-) to attach its ends. After both ends are attached, [IConnector.reroute](https://reference.aspose.com/slides/java/com.aspose.slides/iconnector/#reroute--) selects a short route between the shapes.
The following example connects an ellipse and a rectangle with a bent connector:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape ellipse = slide.getShapes().addAutoShape(ShapeType.Ellipse, 40, 80, 120, 80);
IAutoShape rectangle = slide.getShapes().addAutoShape(ShapeType.Rectangle, 320, 240, 140, 80);
IConnector connector = slide.getShapes().addConnector(ShapeType.BentConnector2, 0, 0, 10, 10);
connector.setStartShapeConnectedTo(ellipse);
connector.setEndShapeConnectedTo(rectangle);
connector.reroute();
presentation.save("connected-shapes.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
Calling `reroute` can change the [setStartShapeConnectionSiteIndex](https://reference.aspose.com/slides/java/com.aspose.slides/iconnector/#setStartShapeConnectionSiteIndex-long-) and [setEndShapeConnectionSiteIndex](https://reference.aspose.com/slides/java/com.aspose.slides/iconnector/#setEndShapeConnectionSiteIndex-long-) values. Assign specific connection sites after rerouting if those sites must remain fixed.
## **Choose a Connection Site**
Each connectable shape reports its number of sites through [IShape.getConnectionSiteCount](https://reference.aspose.com/slides/java/com.aspose.slides/ishape/#getConnectionSiteCount--). Validate a preferred zero-based site index before assigning it to a connector end; site counts vary by shape geometry.
This example attaches the connector to a particular site on the ellipse when that site exists:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape ellipse = slide.getShapes().addAutoShape(ShapeType.Ellipse, 40, 80, 120, 80);
IAutoShape rectangle = slide.getShapes().addAutoShape(ShapeType.Rectangle, 320, 240, 140, 80);
IConnector connector = slide.getShapes().addConnector(ShapeType.BentConnector3, 0, 0, 10, 10);
connector.setStartShapeConnectedTo(ellipse);
connector.setEndShapeConnectedTo(rectangle);
long preferredSiteIndex = 2;
if (preferredSiteIndex < ellipse.getConnectionSiteCount()) {
connector.setStartShapeConnectionSiteIndex(preferredSiteIndex);
} else {
System.out.println("The ellipse has only " + ellipse.getConnectionSiteCount() + " connection sites.");
}
presentation.save("specific-connection-site.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Adjust a Connector Point**
Connectors with adjustment points expose them through [IGeometryShape.getAdjustments](https://reference.aspose.com/slides/java/com.aspose.slides/igeometryshape/#getAdjustments--). Inspect every [IAdjustValue](https://reference.aspose.com/slides/java/com.aspose.slides/iadjustvalue/) and check its [getType](https://reference.aspose.com/slides/java/com.aspose.slides/iadjustvalue/#getType--) value before changing it with [setRawValue](https://reference.aspose.com/slides/java/com.aspose.slides/iadjustvalue/#setRawValue-long-). The general rules for identifying preset shape adjustments are described in [Shape Manipulation](https://docs.aspose.com/slides/java/shape-manipulations/).
The number, order, meaning, and valid value range of connector adjustments depend on the connector preset. The adjustment type is read-only, while the adjustment value is writable. The read-only [getName](https://reference.aspose.com/slides/java/com.aspose.slides/iadjustvalue/#getName--) method provides additional identification when a connector contains more than one adjustment of the same semantic type.
### **Route Around an Obstacle**
In the following layout, a `BentConnector5` connector between two shapes passes through a third shape:

This code creates the obstructed connector:
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
slide.getShapes().addAutoShape(ShapeType.Rectangle, 300, 150, 150, 75);
IAutoShape sourceShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 500, 400, 100, 50);
IAutoShape targetShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 70, 30);
IConnector connector = slide.getShapes().addConnector(ShapeType.BentConnector5, 20, 20, 400, 300);
connector.getLineFormat().setEndArrowheadStyle(LineArrowheadStyle.Triangle);
connector.getLineFormat().getFillFormat().setFillType(FillType.Solid);
connector.getLineFormat().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
connector.setStartShapeConnectedTo(sourceShape);
connector.setEndShapeConnectedTo(targetShape);
connector.setStartShapeConnectionSiteIndex(2);
presentation.save("connector-obstruction.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
Moving the vertical bend changes the route so that the connector bypasses the obstacle:

Instead of assuming that collection index `1` always represents the vertical bend, this example searches for `ConnectorBendPositionY` and changes it only when the expected semantic type is present:
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
slide.getShapes().addAutoShape(ShapeType.Rectangle, 300, 150, 150, 75);
IAutoShape sourceShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 500, 400, 100, 50);
IAutoShape targetShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 70, 30);
IConnector connector = slide.getShapes().addConnector(ShapeType.BentConnector5, 20, 20, 400, 300);
connector.getLineFormat().setEndArrowheadStyle(LineArrowheadStyle.Triangle);
connector.getLineFormat().getFillFormat().setFillType(FillType.Solid);
connector.getLineFormat().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
connector.setStartShapeConnectedTo(sourceShape);
connector.setEndShapeConnectedTo(targetShape);
connector.setStartShapeConnectionSiteIndex(2);
IAdjustValue verticalBend = null;
for (int adjustmentIndex = 0; adjustmentIndex < connector.getAdjustments().size(); adjustmentIndex++) {
IAdjustValue adjustment = connector.getAdjustments().get_Item(adjustmentIndex);
System.out.println(adjustment.getName() + ": " + adjustment.getType() + ", raw value = " + adjustment.getRawValue());
if (adjustment.getType() == ShapeAdjustmentType.ConnectorBendPositionY) {
verticalBend = adjustment;
break;
}
}
if (verticalBend == null) {
System.out.println("The connector does not expose a vertical bend adjustment.");
} else {
verticalBend.setRawValue(60000);
presentation.save("connector-obstruction-fixed.pptx", SaveFormat.Pptx);
}
} finally {
presentation.dispose();
}
```
A `BentConnector5` has two `ConnectorBendPositionX` adjustments and one `ConnectorBendPositionY` adjustment. If the type you need occurs more than once, inspect `getName` and the known geometry of that preset before selecting one. If an adjustment reports `ShapeAdjustmentType.Custom`, treat its meaning and range as preset-specific and do not change it until that contract is known.
## **Relate Adjustment Values to Connector Geometry**
For bent connectors, adjustment values can be used to estimate the positions of individual segments. These calculations are specific to the connector preset:
- `BentConnector4` normally exposes one `ConnectorBendPositionX` and one `ConnectorBendPositionY` adjustment.
- For these bend positions, dividing the value returned by `getRawValue` by `100000f` produces the fraction of the connector frame width or height used by the examples below.
- A connector frame can be rotated or flipped, so frame coordinates must be transformed before they are compared with slide coordinates.
The following examples use `getType` to identify the adjustments first. They do not treat collection indexes as portable identifiers.
### **Unrotated Connector**
The initial layout contains two text shapes connected by a `BentConnector4`:

This example inspects the connector and obtains its horizontal and vertical bend adjustments:
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape sourceShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 60, 25);
sourceShape.getTextFrame().setText("From");
IAutoShape targetShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 500, 100, 60, 25);
targetShape.getTextFrame().setText("To");
IConnector connector = slide.getShapes().addConnector(ShapeType.BentConnector4, 20, 20, 400, 300);
connector.getLineFormat().setEndArrowheadStyle(LineArrowheadStyle.Triangle);
connector.getLineFormat().getFillFormat().setFillType(FillType.Solid);
connector.getLineFormat().getFillFormat().getSolidFillColor().setColor(Color.RED);
connector.getLineFormat().setWidth(3);
connector.setStartShapeConnectedTo(sourceShape);
connector.setStartShapeConnectionSiteIndex(3);
connector.setEndShapeConnectedTo(targetShape);
connector.setEndShapeConnectionSiteIndex(2);
for (int adjustmentIndex = 0; adjustmentIndex < connector.getAdjustments().size(); adjustmentIndex++) {
IAdjustValue adjustment = connector.getAdjustments().get_Item(adjustmentIndex);
System.out.println(adjustment.getName() + ": " + adjustment.getType() + ", raw value = " + adjustment.getRawValue());
}
} finally {
presentation.dispose();
}
```
To change both bends, locate each expected type and modify the values only after both have been found:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape sourceShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 60, 25);
IAutoShape targetShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 500, 100, 60, 25);
IConnector connector = slide.getShapes().addConnector(ShapeType.BentConnector4, 20, 20, 400, 300);
connector.setStartShapeConnectedTo(sourceShape);
connector.setStartShapeConnectionSiteIndex(3);
connector.setEndShapeConnectedTo(targetShape);
connector.setEndShapeConnectionSiteIndex(2);
IAdjustValue horizontalBend = null;
IAdjustValue verticalBend = null;
for (int adjustmentIndex = 0; adjustmentIndex < connector.getAdjustments().size(); adjustmentIndex++) {
IAdjustValue adjustment = connector.getAdjustments().get_Item(adjustmentIndex);
if (adjustment.getType() == ShapeAdjustmentType.ConnectorBendPositionX) {
horizontalBend = adjustment;
} else if (adjustment.getType() == ShapeAdjustmentType.ConnectorBendPositionY) {
verticalBend = adjustment;
}
}
if (horizontalBend == null || verticalBend == null) {
System.out.println("The connector does not expose the expected bend adjustments.");
} else {
horizontalBend.setRawValue(horizontalBend.getRawValue() + 20000);
verticalBend.setRawValue(verticalBend.getRawValue() + 200000);
presentation.save("connector-adjusted.pptx", SaveFormat.Pptx);
}
} finally {
presentation.dispose();
}
```
The result is a connector whose horizontal and vertical segments have moved:

Once the semantic types are known, their values can be converted into connector-frame coordinates. This example draws a thin rectangle over the vertical segment controlled by the two bend adjustments:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape sourceShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 60, 25);
IAutoShape targetShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 500, 100, 60, 25);
IConnector connector = slide.getShapes().addConnector(ShapeType.BentConnector4, 20, 20, 400, 300);
connector.setStartShapeConnectedTo(sourceShape);
connector.setStartShapeConnectionSiteIndex(3);
connector.setEndShapeConnectedTo(targetShape);
connector.setEndShapeConnectionSiteIndex(2);
IAdjustValue horizontalBend = null;
IAdjustValue verticalBend = null;
for (int adjustmentIndex = 0; adjustmentIndex < connector.getAdjustments().size(); adjustmentIndex++) {
IAdjustValue adjustment = connector.getAdjustments().get_Item(adjustmentIndex);
if (adjustment.getType() == ShapeAdjustmentType.ConnectorBendPositionX) {
horizontalBend = adjustment;
} else if (adjustment.getType() == ShapeAdjustmentType.ConnectorBendPositionY) {
verticalBend = adjustment;
}
}
if (horizontalBend == null || verticalBend == null) {
System.out.println("The connector does not expose the expected bend adjustments.");
} else {
float x = connector.getX() + connector.getWidth() * horizontalBend.getRawValue() / 100000f;
float y = connector.getY();
float height = connector.getHeight() * verticalBend.getRawValue() / 100000f;
slide.getShapes().addAutoShape(ShapeType.Rectangle, x, y, 1, height);
presentation.save("connector-segment-guide.pptx", SaveFormat.Pptx);
}
} finally {
presentation.dispose();
}
```
The guide shape marks the calculated segment:

### **Rotated or Flipped Connector**
When the same connector geometry is oriented vertically, its [IShape.getFrame](https://reference.aspose.com/slides/java/com.aspose.slides/ishape/#getFrame--), [ShapeFrame.getFlipH](https://reference.aspose.com/slides/java/com.aspose.slides/shapeframe/#getFlipH--), and [ShapeFrame.getFlipV](https://reference.aspose.com/slides/java/com.aspose.slides/shapeframe/#getFlipV--) values affect the conversion from connector-frame coordinates to slide coordinates.
This example creates and adjusts the vertically oriented connector:
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape sourceShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 60, 25);
sourceShape.getTextFrame().setText("From");
IAutoShape targetShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 400, 60, 25);
targetShape.getTextFrame().setText("To 1");
IConnector connector = slide.getShapes().addConnector(ShapeType.BentConnector4, 20, 20, 400, 300);
connector.getLineFormat().setEndArrowheadStyle(LineArrowheadStyle.Triangle);
connector.getLineFormat().getFillFormat().setFillType(FillType.Solid);
connector.getLineFormat().getFillFormat().getSolidFillColor().setColor(new Color(102, 205, 170));
connector.getLineFormat().setWidth(3);
connector.setStartShapeConnectedTo(sourceShape);
connector.setStartShapeConnectionSiteIndex(2);
connector.setEndShapeConnectedTo(targetShape);
connector.setEndShapeConnectionSiteIndex(3);
for (int adjustmentIndex = 0; adjustmentIndex < connector.getAdjustments().size(); adjustmentIndex++) {
IAdjustValue adjustment = connector.getAdjustments().get_Item(adjustmentIndex);
if (adjustment.getType() == ShapeAdjustmentType.ConnectorBendPositionX) {
adjustment.setRawValue(adjustment.getRawValue() + 20000);
} else if (adjustment.getType() == ShapeAdjustmentType.ConnectorBendPositionY) {
adjustment.setRawValue(adjustment.getRawValue() + 200000);
}
}
presentation.save("vertical-connector-adjusted.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The adjusted connector appears vertically between the shapes:

For an arbitrary rotation angle `alpha`, rotate a connector-frame point `(x, y)` around the frame center `(x0, y0)`:
`X = (x - x0) * cos(alpha) - (y - y0) * sin(alpha) + x0`
`Y = (x - x0) * sin(alpha) + (y - y0) * cos(alpha) + y0`
The following code handles the 90-degree orientation used in this example and draws a red guide over the corresponding connector segment:
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape sourceShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 60, 25);
IAutoShape targetShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 400, 60, 25);
IConnector connector = slide.getShapes().addConnector(ShapeType.BentConnector4, 20, 20, 400, 300);
connector.setStartShapeConnectedTo(sourceShape);
connector.setStartShapeConnectionSiteIndex(2);
connector.setEndShapeConnectedTo(targetShape);
connector.setEndShapeConnectionSiteIndex(3);
IAdjustValue horizontalBend = null;
IAdjustValue verticalBend = null;
for (int adjustmentIndex = 0; adjustmentIndex < connector.getAdjustments().size(); adjustmentIndex++) {
IAdjustValue adjustment = connector.getAdjustments().get_Item(adjustmentIndex);
if (adjustment.getType() == ShapeAdjustmentType.ConnectorBendPositionX) {
horizontalBend = adjustment;
} else if (adjustment.getType() == ShapeAdjustmentType.ConnectorBendPositionY) {
verticalBend = adjustment;
}
}
if (horizontalBend == null || verticalBend == null) {
System.out.println("The connector does not expose the expected bend adjustments.");
} else {
horizontalBend.setRawValue(horizontalBend.getRawValue() + 20000);
verticalBend.setRawValue(verticalBend.getRawValue() + 200000);
float x = connector.getX();
float y = connector.getY();
if (connector.getFrame().getFlipH() == NullableBool.True) {
x += connector.getWidth();
}
if (connector.getFrame().getFlipV() == NullableBool.True) {
y += connector.getHeight();
}
x += connector.getWidth() * horizontalBend.getRawValue() / 100000f;
float rotatedX = connector.getFrame().getCenterX() - y + connector.getFrame().getCenterY();
float rotatedY = x - connector.getFrame().getCenterX() + connector.getFrame().getCenterY();
float segmentWidth = connector.getHeight() * verticalBend.getRawValue() / 100000f;
IAutoShape guide = slide.getShapes().addAutoShape(ShapeType.Rectangle, rotatedX, rotatedY, segmentWidth, 1);
guide.getLineFormat().getFillFormat().setFillType(FillType.Solid);
guide.getLineFormat().getFillFormat().getSolidFillColor().setColor(Color.RED);
presentation.save("rotated-connector-segment-guide.pptx", SaveFormat.Pptx);
}
} finally {
presentation.dispose();
}
```
The red guide marks the calculated segment after the coordinate transformation:

These formulas describe the presets used in the examples, not a universal connector model. Validate the adjustment types, frame orientation, and value ranges before applying the same calculation to a different preset.
## **Find a Connector Direction Angle**
The direction of a straight connector can be calculated from its width and height, with horizontal and vertical flips applied. The following example reports the clockwise angle from the positive horizontal axis in slide coordinates:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IConnector connector = slide.getShapes().addConnector(ShapeType.StraightConnector1, 100, 100, 200, 100);
boolean flipH = connector.getFrame().getFlipH() == NullableBool.True;
boolean flipV = connector.getFrame().getFlipV() == NullableBool.True;
float deltaX = connector.getWidth() * (flipH ? -1 : 1);
float deltaY = connector.getHeight() * (flipV ? -1 : 1);
double angle = Math.atan2(deltaY, deltaX) * 180.0 / Math.PI;
if (angle < 0) {
angle += 360;
}
System.out.printf("Connector direction: %.2f degrees%n", angle);
} finally {
presentation.dispose();
}
```
## **FAQ**
**How can I tell whether a connector can attach to a shape?**
Check the shape's [getConnectionSiteCount](https://reference.aspose.com/slides/java/com.aspose.slides/ishape/#getConnectionSiteCount--) value. A positive count means the shape exposes connection sites. Validate the selected site index before assigning it to either connector end.
**Can I identify a connector adjustment by its collection index?**
An index is meaningful only for a known connector preset and collection layout. Check [IAdjustValue.getType](https://reference.aspose.com/slides/java/com.aspose.slides/iadjustvalue/#getType--) before modifying a value, and use [IAdjustValue.getName](https://reference.aspose.com/slides/java/com.aspose.slides/iadjustvalue/#getName--) as additional information when the same semantic type occurs more than once.
**What happens when a connected shape is deleted?**
The corresponding connector end becomes detached. The connector remains on the slide and can be deleted, positioned as a free line, or attached to another shape.
**Are connector bindings preserved when a slide is copied?**
Bindings are generally preserved when the connected shapes are copied with the slide. If a connector is copied without one of its target shapes, the affected end must be attached again.
# Convert ODP to PPTX in Java
> Convert ODP to PPTX with Aspose.Slides for Java. Clean Java code examples, batch tips, and high-quality results—no PowerPoint needed.
Source: https://docs.aspose.com/slides/java/convert-odp-to-pptx/
Updated: 2026-08-05
## **Overview**
This article explains how to convert an ODP presentation to PPTX format using Aspose.Slides.
## **Convert ODP to PPTX/PPT Presentation**
Aspose.Slides for Java offers [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class that represents a presentation file. [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class can now also access ODP through [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation#Presentation-java.lang.String-) constructor when the object is instantiated. The following example shows how to convert a ODP Presentation into PPTX Presentation.
```java
import com.aspose.slides.*;
// Open the ODP file
Presentation pres = new Presentation("AccessOpenDoc.odp");
try {
// Saving the ODP presentation to PPTX format
pres.save("AccessOpenDoc_out.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
## **Live Example**
You can visit [**Aspose.Slides Conversion**](https://products.aspose.app/slides/conversion/) web app, which is built with **Aspose.Slides API.** The app demonstrates how ODP to PPTX conversion can be implemented with Aspose.Slides API.
## **FAQ**
### Do I need to install Microsoft PowerPoint or LibreOffice to convert ODP to PPTX?
No. Aspose.Slides works standalone and does not require third-party applications to read or write ODP/PPTX.
### Are master slides, layouts, and themes preserved during conversion?
Yes. The library uses a full presentation object model and retains structure, including master slides and layouts, so the design remains correct after conversion.
### Can I convert password-protected ODP files?
Yes. Aspose.Slides supports detecting protection, opening and working with [protected presentations](https://docs.aspose.com/slides/java/password-protected-presentation/) (including ODP) when you provide the password, as well as configuring encryption and access to document properties.
### Is Aspose.Slides suitable for cloud or REST-based conversion services?
Yes. You can use the local library in your own backend or [Aspose.Slides Cloud](https://products.aspose.cloud/slides/family/) (REST API); both options support ODP → PPTX conversion.
# Convert OpenDocument Presentations in Java
> Aspose.Slides for Java lets you convert ODP to PDF, HTML, and image formats with ease. Boost your Java apps with fast and accurate presentation conversion.
Source: https://docs.aspose.com/slides/java/convert-openoffice-odp/
Updated: 2026-08-05
## **Introduction**
[**Aspose.Slides API**](https://products.aspose.com/slides/java/) allows you to convert OpenDocument (ODP) presentations to many formats (HTML, PDF, TIFF, SWF, XPS, etc.). The API used to convert ODP files to other document formats is the same as the one used for PowerPoint (PPT and PPTX) conversion operations.
For example, if you need to convert an ODP presentation to PDF, you can do it as follows:
```java
import com.aspose.slides.*;
Presentation presentation = null;
try {
presentation = new Presentation("pres.odp");
presentation.save("pres.pdf", SaveFormat.Pdf);
} finally {
if (presentation != null) {
presentation.dispose();
}
}
```
## **OpenDocument Presentation in Different Applications**
When an OpenDocument presentation (ODP) file is opened in PowerPoint, it may not retain the original formatting from the application in which it was created. This happens because the OpenDocument presentation app and the PowerPoint app offer different features and rendering behaviors.
Here are some of the differences:
- In PowerPoint, tables are typically rendered last and may overlay other shapes, regardless of their order on the ODP slide.
- Picture fill for ODP tables is not supported in PowerPoint.
- Text vertical rotation (270°, stacked) and distributed alignment are not supported in LibreOffice/OpenOffice Impress.
- Picture fill, gradient fill, and pattern fill for text are not supported in LibreOffice/OpenOffice Impress.
MS PowerPoint and LibreOffice/OpenOffice Impress also handle lists differently. An ODP file created in PowerPoint may not display correctly in LibreOffice/OpenOffice Impress, and vice versa.
The image below shows how a list appears when created in LibreOffice Impress:

Aspose.Slides saves ODP lists in a way that ensures they are displayed correctly in LibreOffice/OpenOffice Impress.
[Learn more about the OpenDocument format and PowerPoint](https://support.microsoft.com/en-us/office/use-powerpoint-to-save-or-open-a-presentation-in-the-opendocument-presentation-odp-format-94805e84-1b09-4c98-a8b5-0da2a52242a0).
## **FAQ**
### What if the formatting of my ODP file changes after conversion?
ODP and PowerPoint use different presentation models, and some elements—like tables, custom fonts, or fill styles—may not render exactly the same. It is recommended to review the output and adjust layout or formatting in code if needed.
### Do I need OpenOffice or LibreOffice installed to use ODP conversion?
No, Aspose.Slides is a standalone library and does not require OpenOffice or LibreOffice to be installed on your system.
### Can I customize the output format during ODP conversion (e.g., set PDF options)?
Yes, Aspose.Slides provides rich options for customizing the output. For example, when saving to PDF, you can control compression, image quality, text rendering, and more through the [PdfOptions](https://reference.aspose.com/slides/java/com.aspose.slides/pdfoptions/) class.
### Is Aspose.Slides suitable for server-side or cloud-based ODP processing?
Absolutely. Aspose.Slides is designed to work in both desktop and server environments, including cloud-based platforms like Azure, AWS, and Docker containers, without any UI dependencies.
## Related articles
- [Convert PowerPoint Presentations in Java | HTML, PNG, PDF, Word, TIFF](https://docs.aspose.com/slides/java/convert-powerpoint/)
- [Convert Presentations to Multiple Formats in Java](https://docs.aspose.com/slides/java/convert-presentation/)
# Convert PowerPoint Presentations in Handout Mode Using Java
> Convert presentations to handouts in Java. Set slides per page, keep notes, export to PDF or images with Aspose.Slides, with sample Java code. Try it free.
Source: https://docs.aspose.com/slides/java/convert-powerpoint-in-handout-mode/
Updated: 2026-11-08
## **Introduction**
Aspose.Slides allows you to convert presentations to output formats that support Handout mode. In this mode, multiple slides are arranged on a single page, which is useful for printing presentation materials for conferences, seminars, and similar events.
Handout mode is configured through the `setSlidesLayoutOptions` method, which is available in [IPdfOptions](https://reference.aspose.com/slides/java/com.aspose.slides/ipdfoptions/), [IRenderingOptions](https://reference.aspose.com/slides/java/com.aspose.slides/irenderingoptions/), [IHtmlOptions](https://reference.aspose.com/slides/java/com.aspose.slides/ihtmloptions/), and [ITiffOptions](https://reference.aspose.com/slides/java/com.aspose.slides/itiffoptions/). To define the handout layout, use the [HandoutLayoutingOptions](https://reference.aspose.com/slides/java/com.aspose.slides/handoutlayoutingoptions/) object.
To set the handout page dimensions and orientation before export, see [Notes Page Size](https://docs.aspose.com/slides/java/notes-size/).
## **Handout Mode Export**
To export a presentation in Handout mode, set the `setSlidesLayoutOptions` method for the target export options and assign a [HandoutLayoutingOptions](https://reference.aspose.com/slides/java/com.aspose.slides/handoutlayoutingoptions/) instance that defines the number of slides per page and related display parameters.
Below is a code example showing how to convert a presentation to PDF in Handout mode.
```java
import com.aspose.slides.*;
// Load a presentation.
Presentation presentation = new Presentation("sample.pptx");
try {
// Set the export options.
HandoutLayoutingOptions slidesLayoutOptions = new HandoutLayoutingOptions();
slidesLayoutOptions.setHandout(HandoutType.Handouts4Horizontal); // 4 slides on one page horizontally
slidesLayoutOptions.setPrintSlideNumbers(true); // print slide numbers
slidesLayoutOptions.setPrintFrameSlide(true); // print a frame around slides
slidesLayoutOptions.setPrintComments(false); // no comments
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setSlidesLayoutOptions(slidesLayoutOptions);
// Export the presentation to PDF with the chosen layout.
presentation.save("output.pdf", SaveFormat.Pdf, pdfOptions);
} finally {
if (presentation != null) presentation.dispose();
}
```
Keep in mind that the `setSlidesLayoutOptions` method is available only for certain output formats, such as PDF, HTML, TIFF, and when rendering as images.
[](https://docs.aspose.com/slides/java/convert-powerpoint-in-handout-mode/visual-convert-powerpoint-in-handout-mode-2d311e39d758.svg)
*The same four numbered slides exported as one slide per PDF page and as a horizontal handout. The handout includes printed slide numbers and frames.*
## **FAQ**
**What is the maximum number of slide thumbnails per page in Handout mode?**
Aspose.Slides supports [presets](https://reference.aspose.com/slides/java/com.aspose.slides/handouttype/) up to 9 thumbnails per page with horizontal or vertical ordering: 1, 2, 3, 4 (horizontal/vertical), 6 (horizontal/vertical), and 9 (horizontal/vertical).
**Can I define a custom grid, such as 5 or 8 slides per page?**
No. The number and ordering of thumbnails are controlled strictly by the [HandoutType](https://reference.aspose.com/slides/java/com.aspose.slides/handouttype/) class; arbitrary layouts are not supported.
**Can I include hidden slides in the Handout output?**
Yes. Enable the hidden slides using the `setShowHiddenSlides` method in the export settings for the target format, such as [PdfOptions](https://reference.aspose.com/slides/java/com.aspose.slides/pdfoptions/), [HtmlOptions](https://reference.aspose.com/slides/java/com.aspose.slides/htmloptions/), or [TiffOptions](https://reference.aspose.com/slides/java/com.aspose.slides/tiffoptions/).
# Convert PowerPoint Presentations to Animated GIFs in Java
> Easily convert PowerPoint presentations (PPT, PPTX) to animated GIFs with Aspose.Slides for Java. Fast, high-quality results.
Source: https://docs.aspose.com/slides/java/convert-powerpoint-to-animated-gif/
Updated: 2026-08-13
## **Overview**
Aspose.Slides allows you to convert PowerPoint presentations to animated GIF files with just a few lines of code. This is useful when you need to share slide content in a lightweight, widely supported animated format that can be embedded in web pages, messengers, or documentation. This article explains how to export a presentation to GIF using default settings and how to customize the output by configuring options such as frame size, slide delay, and transition frame rate through [GifOptions](https://reference.aspose.com/slides/java/com.aspose.slides/gifoptions/).
## **Convert Presentations to Animated GIF Using Default Settings**
This sample code in Java shows you how to convert a presentation to animated GIF using standard settings:
```java
import com.aspose.slides.*;
Presentation pres = new Presentation("pres.pptx");
try {
pres.save("pres.gif", SaveFormat.Gif);
} finally {
if (pres != null) pres.dispose();
}
```
The animated GIF will be created with default parameters.
If you prefer to customize the parameters for the GIF, you can use the [GifOptions](https://reference.aspose.com/slides/java/com.aspose.slides/GifOptions) class. See the sample code below.
## **Convert Presentations to Animated GIF Using Custom Settings**
This sample code shows you how to convert a presentation to animated GIF using custom settings in Java:
```java
import com.aspose.slides.*;
import java.awt.Dimension;
Presentation pres = new Presentation("pres.pptx");
try {
GifOptions gifOptions = new GifOptions();
gifOptions.setFrameSize(new Dimension(960, 720)); // the size of the resulted GIF
gifOptions.setDefaultDelay(2000); // how long each slide will be showed until it will be changed to the next one
gifOptions.setTransitionFps(35); // increase FPS to better transition animation quality
pres.save("pres.gif", SaveFormat.Gif, gifOptions);
} finally {
if (pres != null) pres.dispose();
}
```
You may want to check out a FREE [Text to GIF](https://products.aspose.app/slides/text-to-gif) converter developed by Aspose.
## **FAQ**
### What if the fonts used in the presentation aren’t installed on the system?
Install the missing fonts or [configure fallback fonts](https://docs.aspose.com/slides/java/powerpoint-fonts/). Aspose.Slides will substitute, but the appearance may differ. For branding, always ensure the required typefaces are explicitly available.
### Can I overlay a watermark on the GIF frames?
Yes. [Add a semi-transparent object/logo](https://docs.aspose.com/slides/java/watermark/) to the master slide or to individual slides before export — the watermark will appear on every frame.
# Convert PowerPoint Presentations to HTML in Java
> Convert PowerPoint presentations to HTML in Java. Use Aspose.Slides to export PPT and PPTX files, selected slides, notes, fonts, images, SVG, and media.
Source: https://docs.aspose.com/slides/java/convert-powerpoint-to-html/
Updated: 2026-08-05
## **Overview**
Aspose.Slides for Java can save PowerPoint presentations as HTML without Microsoft PowerPoint. The basic conversion is a single [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) load and a `save` call with [SaveFormat](https://reference.aspose.com/slides/java/com.aspose.slides/saveformat/). Use [HtmlOptions](https://reference.aspose.com/slides/java/com.aspose.slides/htmloptions/) when you need to control the exported layout, fonts, images, notes, comments, SVG output, or linked resources.
This guide focuses on practical HTML export scenarios:
- Export a whole presentation or selected slides.
- Generate fixed-layout, responsive, or SVG-based HTML.
- Include speaker notes and comments.
- Control image quality and cropped image data.
- Embed fonts or save font files separately.
- Choose how external resources and media files are written and referenced.
By default, HTML export produces a self-contained HTML document where most resources are embedded. This is convenient for sharing one file, but it can increase output size. For web publishing, consider external resources, lower image DPI, and only embedding fonts that are not reliably available in the target environment.
## **Convert a Presentation to HTML**
To export a presentation to HTML, load it with [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) and save it with [SaveFormat.Html](https://reference.aspose.com/slides/java/com.aspose.slides/saveformat/).
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("presentation.pptx");
try {
presentation.save("presentation.html", SaveFormat.Html);
} finally {
presentation.dispose();
}
```
This example writes one HTML file. The presentation object is disposed in the `finally` block, which releases file handles and rendering resources after export.
## **Use HtmlOptions**
[HtmlOptions](https://reference.aspose.com/slides/java/com.aspose.slides/htmloptions/) is the main configuration class for HTML export. Common settings include:
- `SlidesLayoutOptions`: adds notes, comments, handouts, or other layout information.
- `HtmlFormatter`: changes the HTML document structure or delegates formatting to a controller.
- `SlideImageFormat`: changes how slides are represented, for example as SVG.
- `PicturesCompression`: controls image DPI and output size.
- `DeletePicturesCroppedAreas`: keeps or removes cropped image data.
- `SvgResponsiveLayout`: makes exported SVG content adapt to its container.
- `ShowHiddenSlides`: includes hidden slides when required.
The following sections show the most common options separately so you can combine only the ones your workflow needs.
## **Convert Selected Slides to HTML**
The `Presentation.save` overload that accepts slide numbers uses 1-based slide positions. The loop below saves every slide to a separate HTML file.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("presentation.pptx");
try {
int slideCount = presentation.getSlides().size();
for (int slideIndex = 0; slideIndex < slideCount; slideIndex++) {
int slideNumber = slideIndex + 1;
int[] slideNumbers = { slideNumber };
String htmlFileName = "slide-" + slideNumber + ".html";
presentation.save(htmlFileName, slideNumbers, SaveFormat.Html);
}
} finally {
presentation.dispose();
}
```
Use this pattern when a website or application needs one HTML page per slide. If each slide should have the same layout, create one [HtmlOptions](https://reference.aspose.com/slides/java/com.aspose.slides/htmloptions/) instance and pass it to each `save` call.
## **Create Responsive HTML**
[ResponsiveHtmlController](https://reference.aspose.com/slides/java/com.aspose.slides/responsivehtmlcontroller/) provides responsive HTML output through [HtmlFormatter](https://reference.aspose.com/slides/java/com.aspose.slides/htmlformatter/). Use it when the exported page should adapt better to browser width.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("presentation.pptx");
try {
ResponsiveHtmlController controller = new ResponsiveHtmlController();
HtmlFormatter formatter = HtmlFormatter.createCustomFormatter(controller);
HtmlOptions htmlOptions = new HtmlOptions();
htmlOptions.setHtmlFormatter(formatter);
presentation.save("presentation-responsive.html", SaveFormat.Html, htmlOptions);
} finally {
presentation.dispose();
}
```
For SVG-based responsive layout, set `SvgResponsiveLayout` on [HtmlOptions](https://reference.aspose.com/slides/java/com.aspose.slides/htmloptions/). This is useful when the slide content is exported as scalable SVG markup.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("presentation.pptx");
try {
HtmlOptions htmlOptions = new HtmlOptions();
htmlOptions.setSvgResponsiveLayout(true);
presentation.save("presentation-svg-responsive.html", SaveFormat.Html, htmlOptions);
} finally {
presentation.dispose();
}
```
## **Include Speaker Notes and Comments**
Use [NotesCommentsLayoutingOptions](https://reference.aspose.com/slides/java/com.aspose.slides/notescommentslayoutingoptions/) through `HtmlOptions.setSlidesLayoutOptions` to include speaker notes or comments. Notes and comments are hidden by default unless you choose their positions.
Suppose the source presentation contains speaker notes:

The following code exports the slide content with speaker notes below the slide.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("presentation.pptx");
try {
NotesCommentsLayoutingOptions layoutOptions = new NotesCommentsLayoutingOptions();
layoutOptions.setNotesPosition(NotesPositions.BottomFull);
HtmlOptions htmlOptions = new HtmlOptions();
htmlOptions.setSlidesLayoutOptions(layoutOptions);
presentation.save("presentation-with-notes.html", SaveFormat.Html, htmlOptions);
} finally {
presentation.dispose();
}
```
The exported HTML includes the notes area:

To export comments, set `CommentsPosition`, for example to `CommentsPositions.Right` or `CommentsPositions.Bottom`. If you need only comments, omit `NotesPosition`. If you need both notes and comments, set both properties.
## **Control Image Quality and Cropped Areas**
HTML export can compress slide images to reduce output size. Set `PicturesCompression` to a value from [PicturesCompression](https://reference.aspose.com/slides/java/com.aspose.slides/picturescompression/) when you need higher image quality.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("presentation.pptx");
try {
HtmlOptions htmlOptions = new HtmlOptions();
htmlOptions.setPicturesCompression(PicturesCompression.Dpi150);
presentation.save("presentation-dpi-150.html", SaveFormat.Html, htmlOptions);
} finally {
presentation.dispose();
}
```
By default, cropped areas of images may be removed from the exported output. Keep cropped data only when users must be able to recover or inspect those hidden image parts. Keeping it can increase the HTML size.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("presentation.pptx");
try {
HtmlOptions htmlOptions = new HtmlOptions();
htmlOptions.setDeletePicturesCroppedAreas(false);
presentation.save("presentation-with-cropped-areas.html", SaveFormat.Html, htmlOptions);
} finally {
presentation.dispose();
}
```
## **Add CSS**
For simple styling, pass a CSS string to `HtmlFormatter.createDocumentFormatter`. This changes the surrounding HTML document while Aspose.Slides continues to render the slide content.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("presentation.pptx");
try {
String cssRules = "body { margin: 0; background: #f7f7f7; } .slide { margin: 24px auto; }";
HtmlFormatter formatter = HtmlFormatter.createDocumentFormatter(cssRules, true);
HtmlOptions htmlOptions = new HtmlOptions();
htmlOptions.setHtmlFormatter(formatter);
presentation.save("presentation-styled.html", SaveFormat.Html, htmlOptions);
} finally {
presentation.dispose();
}
```
For a custom document header, a linked CSS file, or custom markup around slides and shapes, implement [IHtmlFormattingController](https://reference.aspose.com/slides/java/com.aspose.slides/ihtmlformattingcontroller/) and pass it to [HtmlFormatter](https://reference.aspose.com/slides/java/com.aspose.slides/htmlformatter/) with `createCustomFormatter`.
## **Embed Fonts**
If the target environment may not have the presentation fonts installed, embed fonts in the HTML with [EmbedAllFontsHtmlController](https://reference.aspose.com/slides/java/com.aspose.slides/embedallfontshtmlcontroller/). Embedding improves visual fidelity but increases output size.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("presentation.pptx");
try {
String[] fontNamesToExclude = { "Arial" };
EmbedAllFontsHtmlController fontController = new EmbedAllFontsHtmlController(fontNamesToExclude);
HtmlFormatter formatter = HtmlFormatter.createCustomFormatter(fontController);
HtmlOptions htmlOptions = new HtmlOptions();
htmlOptions.setHtmlFormatter(formatter);
presentation.save("presentation-embedded-fonts.html", SaveFormat.Html, htmlOptions);
} finally {
presentation.dispose();
}
```
Exclude fonts only when you are confident that the target browsers or systems already provide them. For brand fonts or less common fonts, embedding is usually safer.
## **Link Font Files Instead of Embedding Them**
To reduce the HTML file size, you can write font data to separate WOFF files and add `@font-face` rules to the HTML. The helper below extends [EmbedAllFontsHtmlController](https://reference.aspose.com/slides/java/com.aspose.slides/embedallfontshtmlcontroller/) and overrides `writeFont`.
```java
import com.aspose.slides.*;
class LinkedFontsHtmlController extends EmbedAllFontsHtmlController {
private final java.nio.file.Path fontOutputDirectory;
private final String fontUrlPrefix;
LinkedFontsHtmlController(
java.nio.file.Path fontOutputDirectory,
String fontUrlPrefix) throws java.io.IOException {
super(new String[0]);
this.fontOutputDirectory = fontOutputDirectory;
this.fontUrlPrefix = fontUrlPrefix.endsWith("/") ? fontUrlPrefix : fontUrlPrefix + "/";
java.nio.file.Files.createDirectories(fontOutputDirectory);
}
@Override
public void writeFont(
IHtmlGenerator generator,
IFontData originalFont,
IFontData substitutedFont,
String fontStyle,
String fontWeight,
byte[] fontData) {
try {
IFontData font = substitutedFont == null ? originalFont : substitutedFont;
String safeFontName = makeSafeFileName(font.getFontName());
String safeFontStyle = fontStyle == null || fontStyle.trim().isEmpty() ? "normal" : fontStyle;
String safeFontWeight = fontWeight == null || fontWeight.trim().isEmpty() ? "normal" : fontWeight;
String fontFileName = safeFontName + "-" + safeFontStyle + "-" + safeFontWeight + ".woff";
java.nio.file.Path fontFilePath = fontOutputDirectory.resolve(fontFileName);
java.nio.file.Files.write(fontFilePath, fontData);
String encodedFontFileName = java.net.URLEncoder.encode(fontFileName, "UTF-8");
String fontUrl = fontUrlPrefix + encodedFontFileName.replace("+", "%20");
String escapedBackslashes = font.getFontName().replace("\\", "\\\\");
String fontFamily = escapedBackslashes.replace("'", "\\'");
generator.addHtml("");
} catch (java.io.IOException exception) {
throw new RuntimeException("Unable to write an exported font.", exception);
}
}
private String makeSafeFileName(String fileName) {
String invalidCharacters = "\\/:*?\"<>|";
char[] safeCharacters = fileName.toCharArray();
for (int characterIndex = 0; characterIndex < safeCharacters.length; characterIndex++) {
if (invalidCharacters.indexOf(safeCharacters[characterIndex]) >= 0) {
safeCharacters[characterIndex] = '_';
}
}
return new String(safeCharacters);
}
}
java.nio.file.Path outputDirectory = java.nio.file.Paths.get(System.getProperty("user.dir"), "html-output");
java.nio.file.Path fontsDirectory = outputDirectory.resolve("fonts");
java.nio.file.Files.createDirectories(outputDirectory);
Presentation presentation = new Presentation("presentation.pptx");
try {
LinkedFontsHtmlController fontController = new LinkedFontsHtmlController(fontsDirectory, "fonts");
HtmlFormatter formatter = HtmlFormatter.createCustomFormatter(fontController);
HtmlOptions htmlOptions = new HtmlOptions();
htmlOptions.setHtmlFormatter(formatter);
java.nio.file.Path htmlFilePath = outputDirectory.resolve("presentation.html");
presentation.save(htmlFilePath.toString(), SaveFormat.Html, htmlOptions);
} finally {
presentation.dispose();
}
```
In this example, font files are saved to `html-output/fonts`, and the HTML references them with URLs such as `fonts/BrandFont-normal-400.woff`. If the HTML file and fonts are deployed to another location, choose `fontUrlPrefix` so that it matches the deployed URL path.
## **Save Resources Externally**
Self-contained HTML is easy to move around, but embedded Base64 resources can make the file large. If your application needs external image files, implement [ILinkEmbedController](https://reference.aspose.com/slides/java/com.aspose.slides/ilinkembedcontroller/) and pass it to the [HtmlOptions](https://reference.aspose.com/slides/java/com.aspose.slides/htmloptions/) constructor.
When you externalize resources, choose two paths deliberately:
- The file system output path, where your application writes generated images, fonts, audio, or video.
- The URL path, which is what the browser uses from the HTML document to load those files.
## **Export Media Files**
[VideoPlayerHtmlController](https://reference.aspose.com/slides/java/com.aspose.slides/videoplayerhtmlcontroller/) exports video and audio files and writes HTML that can play them in a browser. Its constructor takes:
- `path`: the directory where generated media files will be written.
- `fileName`: the HTML file name being generated.
- `baseUri`: the absolute URI prefix used in the HTML links to media files.
The generated HTML references media files by file name only, relative to the HTML document, so `path` must be the directory that also receives the HTML file. `baseUri` has to be an absolute URI: for local preview, build a `file:///` URI from the output directory; for a deployed application, use the absolute URL of the published directory.
```java
import com.aspose.slides.*;
java.nio.file.Path outputDirectory = java.nio.file.Paths.get(System.getProperty("user.dir"), "html-output");
java.nio.file.Files.createDirectories(outputDirectory);
String htmlFileName = "presentation.html";
String mediaBaseUri = outputDirectory.toUri().toString();
Presentation presentation = new Presentation();
try {
java.nio.file.Path videoFilePath = java.nio.file.Paths.get("intro.mp4");
byte[] videoData = java.nio.file.Files.readAllBytes(videoFilePath);
IVideo video = presentation.getVideos().addVideo(videoData);
ISlide slide = presentation.getSlides().get_Item(0);
slide.getShapes().addVideoFrame(20, 20, 480, 270, video);
String mediaDirectoryPath = outputDirectory.toString();
VideoPlayerHtmlController controller = new VideoPlayerHtmlController(mediaDirectoryPath, htmlFileName, mediaBaseUri);
HtmlFormatter formatter = HtmlFormatter.createCustomFormatter(controller);
SVGOptions svgOptions = new SVGOptions(controller);
SlideImageFormat slideImageFormat = SlideImageFormat.svg(svgOptions);
HtmlOptions htmlOptions = new HtmlOptions(controller);
htmlOptions.setHtmlFormatter(formatter);
htmlOptions.setSlideImageFormat(slideImageFormat);
java.nio.file.Path htmlFilePath = outputDirectory.resolve(htmlFileName);
presentation.save(htmlFilePath.toString(), SaveFormat.Html, htmlOptions);
} finally {
presentation.dispose();
}
```
Use output directories that are unique per export job, especially in server applications. Shared output paths can cause files from different conversions to overwrite each other.
## **Performance and Resource Management**
HTML conversion is a rendering operation, so processing time and memory use depend on slide count, image resolution, fonts, effects, charts, and embedded media. Higher `PicturesCompression` DPI values, embedded fonts, SVG output, and retained cropped image areas can improve fidelity but usually increase output size.
For batch conversion:
- Dispose every [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) instance promptly.
- Use separate output directories for separate jobs.
- Avoid embedding common fonts unless fidelity requires it.
- Lower image DPI when the HTML is for preview or thumbnails.
- Keep the source presentation, generated HTML, and external resources together until deployment paths are final.
## **FAQ**
### Are hyperlinks preserved in HTML output?
Yes. Presentation hyperlinks are exported to HTML and remain clickable when the target URL is valid.
### Can I convert presentations to HTML in parallel?
Yes, but do not share one [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) instance across threads. Process different files with separate presentation instances, separate streams, and separate output directories. See the [multithreading guidance](https://docs.aspose.com/slides/java/multithreading/) for details.
### Is a Presentation object thread-safe?
No. A single [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) instance should be loaded, modified, saved, and disposed on one thread. For parallel work, create an independent instance per thread or process.
### Why is the generated HTML file large?
The default export can embed resources directly in the HTML. Embedded fonts, high-DPI images, media, SVG content, and retained cropped image areas also increase size. Use external resources, exclude common fonts from embedding, and lower `PicturesCompression` when smaller output is more important than maximum fidelity.
### Why does a PowerPoint font size such as 24 pt appear as 17.999819 pt in HTML?
This can happen because PowerPoint and HTML use different DPI models. PowerPoint stores text sizes in typographic points based on 72 DPI, while HTML layout is based on CSS pixels in a 96 DPI model. When Aspose.Slides exports a presentation to HTML, the font size is translated between these systems, and the conversion may introduce small rounding differences.
These values do not indicate a real visual font-size change. They are only a mathematical side effect of converting text metrics between PowerPoint and HTML.
### How should I choose baseUri for media export?
Choose `baseUri` from the browser's point of view and pass it as an absolute URI. For local preview, you can derive it from the output directory with `outputDirectory.toUri().toString()`. For deployment, use the absolute URL of the published directory. The file system `path` and browser `baseUri` do not have to be the same string, but they must describe the same location, and that location has to be the directory holding the generated HTML file because media links are written relative to it.
### Can I include hidden slides?
Yes. Set `ShowHiddenSlides` to `true` on [HtmlOptions](https://reference.aspose.com/slides/java/com.aspose.slides/htmloptions/) when hidden slides must be exported.
## Related articles
- [Export Presentations to HTML with Externally Linked Images](https://docs.aspose.com/slides/java/exporting-presentations-to-html-with-externally-linked-images/)
# Convert PPT and PPTX to JPG in Java
> Convert PowerPoint (PPT, PPTX) slides to high-quality JPG images in Java with Aspose.Slides for Java using fast, reliable code examples.
Source: https://docs.aspose.com/slides/java/convert-powerpoint-to-jpg/
Updated: 2026-08-13
## **Introduction**
Converting PowerPoint and OpenDocument presentations to JPG images helps with sharing slides, optimizing performance, and embedding content into websites or applications. Aspose.Slides allows you to transform PPTX, PPT, and ODP files into high-quality JPEG images. This guide explains different methods for conversion.
With these features, it's easy to implement your own presentation viewer and create a thumbnail for every slide. This may be useful if you want to protect presentation slides from copying or demonstrate the presentation in read-only mode. Aspose.Slides allows you to convert the whole presentation or a specific slide into image formats.
## **Convert PowerPoint PPT/PPTX to JPG**
Here are the steps to convert PPT/PPTX to JPG:
1. Create an instance of [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) type.
2. Get the slide object of [ISlide](https://reference.aspose.com/slides/java/com.aspose.slides/ISlide) type from [Presentation.getSlides()](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation#getSlides--) collection.
3. Create the thumbnail of each slide and then convert it into JPG. [**ISlide.getImage(float scaleX, float scaleY)**](https://reference.aspose.com/slides/java/com.aspose.slides/ISlide#getImage-float-float-) method is used to get a thumbnail of a slide, it returns [Images](https://reference.aspose.com/slides/java/com.aspose.slides/Images) object as a result. [getImage](https://reference.aspose.com/slides/java/com.aspose.slides/ISlide#getImage-com.aspose.slides.IRenderingOptions-float-float-) method has to be called from the needed slide of [ISlide](https://reference.aspose.com/slides/java/com.aspose.slides/ISlide) type, the scales of the resulting thumbnail are passed into the method.
4. After you get the slide thumbnail, call [**IImage.save(String formatName, int imageFormat)**](https://reference.aspose.com/slides/java/com.aspose.slides/IImage#save(String formatName, int imageFormat)) method from the thumbnail object. Pass the resulting file name and the image format into it.
**Note**: PPT/PPTX to JPG conversion differs from the conversion to other types in Aspose.Slides API. For other types, you usually use [**IPresentation.Save(String fname, int format, ISaveOptions options)**](https://reference.aspose.com/slides/java/com.aspose.slides/IPresentation#save-java.lang.String-int-com.aspose.slides.ISaveOptions-) method, but here you need [**IImage.save(String formatName, int imageFormat)**](https://reference.aspose.com/slides/java/com.aspose.slides/IImage#save(String formatName, int imageFormat)) method.
```java
import com.aspose.slides.*;
Presentation pres = new Presentation("PowerPoint-Presentation.pptx");
try {
for (ISlide sld : pres.getSlides()) {
// Creates a full scale image
IImage slideImage = sld.getImage(1f, 1f);
// Saves the image to disk in JPEG format
try {
slideImage.save(String.format("Slide_%d.jpg", sld.getSlideNumber()), ImageFormat.Jpeg);
} finally {
if (slideImage != null) slideImage.dispose();
}
}
} finally {
if (pres != null) pres.dispose();
}
```
## **Convert PowerPoint PPT/PPTX to JPG with Customized Dimensions**
To change the dimension of the resulting thumbnail and JPG image, you can set the *ScaleX* and *ScaleY* values by passing them into the [**ISlide.getImage(float scaleX, float scaleY)**](https://reference.aspose.com/slides/java/com.aspose.slides/ISlide#getImage-float-float-) methods:
```java
import com.aspose.slides.*;
Presentation pres = new Presentation("PowerPoint-Presentation.pptx");
try {
// Defines dimensions
int desiredX = 1200;
int desiredY = 800;
// Gets scaled values of X and Y
float ScaleX = (float) (1.0 / pres.getSlideSize().getSize().getWidth()) * desiredX;
float ScaleY = (float) (1.0 / pres.getSlideSize().getSize().getHeight()) * desiredY;
for (ISlide sld : pres.getSlides())
{
// Creates a full scale image
IImage slideImage = sld.getImage(ScaleX, ScaleY);
// Saves the image to disk in JPEG format
try {
slideImage.save(String.format("Slide_%d.jpg", sld.getSlideNumber()), ImageFormat.Jpeg);
} finally {
if (slideImage != null) slideImage.dispose();
}
}
} finally {
if (pres != null) pres.dispose();
}
```
## **Render Comments When Saving Slides as Images**
Aspose.Slides for Java provides a facility that allows you to render comments in a presentation's slides when you are converting those slides into images. This Java code demonstrates the operation:
```java
import com.aspose.slides.*;
import java.awt.Dimension;
Presentation pres = new Presentation("presentation.pptx");
try {
NotesCommentsLayoutingOptions notesOptions = new NotesCommentsLayoutingOptions();
notesOptions.setNotesPosition(NotesPositions.BottomTruncated);
notesOptions.setCommentsPosition(CommentsPositions.Right);
notesOptions.setCommentsAreaWidth(200);
IRenderingOptions opts = new RenderingOptions();
opts.setSlidesLayoutOptions(notesOptions);
for (ISlide sld : pres.getSlides()) {
IImage slideImage = sld.getImage(opts, new Dimension(740, 960));
try {
slideImage.save(String.format("Slide_%d.png", sld.getSlideNumber()));
} finally {
if (slideImage != null) slideImage.dispose();
}
}
} finally {
if (pres != null) pres.dispose();
}
```
Aspose provides a [FREE Collage web app](https://products.aspose.app/slides/collage). Using this online service, you can merge [JPG to JPG](https://products.aspose.app/slides/collage/jpg) or PNG to PNG images, create [photo grids](https://products.aspose.app/slides/collage/photo-grid), and so on.
Using the same principles described in this article, you can convert images from one format to another. For more information, see these pages: convert [image to JPG](https://products.aspose.com/slides/java/conversion/image-to-jpg/); convert [JPG to image](https://products.aspose.com/slides/java/conversion/jpg-to-image/); convert [JPG to PNG](https://products.aspose.com/slides/java/conversion/jpg-to-png/), convert [PNG to JPG](https://products.aspose.com/slides/java/conversion/png-to-jpg/); convert [PNG to SVG](https://products.aspose.com/slides/java/conversion/png-to-svg/), convert [SVG to PNG](https://products.aspose.com/slides/java/conversion/svg-to-png/).
## **FAQ**
### Does this method support batch conversion?
Yes, Aspose.Slides allows batch conversion of multiple slides to JPG in a single operation.
### Does the conversion support SmartArt, charts, and other complex objects?
Yes, Aspose.Slides renders all content, including SmartArt, charts, tables, shapes, and more. However, the rendering accuracy may vary slightly compared to PowerPoint, especially when using custom or missing fonts.
### Are there any limitations on the number of slides that can be processed?
Aspose.Slides itself does not impose any strict limits on the number of slides you can process. However, you may encounter out-of-memory error when working with large presentations or high-resolution images.
## **See Also**
See other options to convert PPT/PPTX into image like:
- [PPT/PPTX to SVG conversion](https://docs.aspose.com/slides/java/render-a-slide-as-an-svg-image/).
## Related articles
- [Convert PowerPoint Slides to PNG in Java](https://docs.aspose.com/slides/java/convert-powerpoint-to-png/)
# Convert PowerPoint Presentations to Markdown in Java
> Convert PPT and PPTX presentations to Markdown in Java and control where exported bitmap, metafile, and SVG images are saved and referenced.
Source: https://docs.aspose.com/slides/java/convert-powerpoint-to-markdown/
Updated: 2026-10-01
## **Overview**
Aspose.Slides for Java can convert PPT and PPTX presentations to Markdown for documentation, static-site, content-migration, and version-control workflows. You can choose a Markdown flavor, control how slide content is rendered, and decide where exported images are stored and how the generated Markdown references them.
By default, Markdown export uses text-only output. To export visual content, set the export type with the [MarkdownSaveOptions.setExportType](https://reference.aspose.com/slides/java/com.aspose.slides/markdownsaveoptions/) method to the `Sequential` or `Visual` value from the [MarkdownExportType](https://reference.aspose.com/slides/java/com.aspose.slides/markdownexporttype/) enumeration. `Sequential` renders slide items separately and in order, whereas `Visual` keeps grouped items together to preserve their visual relationship. The `TextOnly` value does not emit image resources, so the image-saving callbacks are not invoked in that mode.
## **Convert a Presentation to Markdown**
Load the source file with the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class, and then call the [Presentation.save](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) method with the `Md` value from the [SaveFormat](https://reference.aspose.com/slides/java/com.aspose.slides/saveformat/) enumeration.
```java
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
Presentation presentation = new Presentation("presentation.pptx");
try {
presentation.save("presentation.md", SaveFormat.Md);
} finally {
presentation.dispose();
}
```
## **Select a Markdown Flavor**
The [MarkdownSaveOptions.setFlavor](https://reference.aspose.com/slides/java/com.aspose.slides/markdownsaveoptions/) method controls the Markdown specification used for the output. The [Flavor](https://reference.aspose.com/slides/java/com.aspose.slides/flavor/) enumeration includes CommonMark, GitHub Flavored Markdown, and other supported variants.
The following example exports a presentation as CommonMark:
```java
import com.aspose.slides.Flavor;
import com.aspose.slides.MarkdownSaveOptions;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
Presentation presentation = new Presentation("presentation.pptx");
try {
MarkdownSaveOptions options = new MarkdownSaveOptions();
options.setFlavor(Flavor.CommonMark);
presentation.save("presentation.md", SaveFormat.Md, options);
} finally {
presentation.dispose();
}
```
## **Control Repeated Spaces**
When preparing slide text for documentation, text processing, or publication, use [MarkdownSaveOptions.setHandleRepeatedSpaces](https://reference.aspose.com/slides/java/com.aspose.slides/markdownsaveoptions/#setHandleRepeatedSpaces-int-) to control consecutive regular spaces.
Single spaces remain regular spaces in all three modes. The following self-contained example creates text with one, two, and three consecutive spaces and exports the same slide using each mode.
```java
import com.aspose.slides.Flavor;
import com.aspose.slides.HandleRepeatedSpaces;
import com.aspose.slides.IAutoShape;
import com.aspose.slides.ISlide;
import com.aspose.slides.MarkdownSaveOptions;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
import com.aspose.slides.ShapeType;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 20, 20, 600, 100);
shape.getTextFrame().setText("One space; two spaces; three spaces.");
int[] modes = {
HandleRepeatedSpaces.None,
HandleRepeatedSpaces.AlternateSpacesToNbsp,
HandleRepeatedSpaces.MultipleSpacesToNbsp
};
String[] modeNames = {"None", "AlternateSpacesToNbsp", "MultipleSpacesToNbsp"};
for (int i = 0; i < modes.length; i++) {
MarkdownSaveOptions options = new MarkdownSaveOptions();
options.setFlavor(Flavor.CommonMark);
options.setHandleRepeatedSpaces(modes[i]);
presentation.save("spaces-" + modeNames[i] + ".md", SaveFormat.Md, options);
}
} finally {
presentation.dispose();
}
```
The exported text lines are shown below. These excerpts omit the slide separator and the two trailing spaces added by the exporter.
`None`:
```markdown
One space; two spaces; three spaces.
```
`AlternateSpacesToNbsp`:
```markdown
One space; two spaces; three spaces.
```
`MultipleSpacesToNbsp`:
```markdown
One space; two spaces; three spaces.
```
In a typical HTML-based Markdown viewer, consecutive regular spaces collapse visually even though they remain in the source. Both replacement modes preserve the visible spacing in this example; their source differs for the three-space sequence.
Choose `None` when downstream tools need ordinary space characters without HTML entities. Choose a replacement mode when visible spacing matters more. A text-processing pipeline consuming that output may need to decode ` ` and normalize the resulting nonbreaking spaces. Nonbreaking spaces also affect where a viewer can wrap text.
## **Remove Empty Lines**
The [MarkdownSaveOptions.setRemoveEmptyLines](https://reference.aspose.com/slides/java/com.aspose.slides/markdownsaveoptions/#setRemoveEmptyLines-boolean-) method controls whether empty or whitespace-only lines are removed during export. The default value is `false`. This controls vertical separation, independently of how repeated spaces within text are represented.
The following example creates two text paragraphs separated by an empty paragraph and a paragraph containing three regular spaces. It exports both settings. The `\r` characters create paragraph boundaries in the text frame; [HandleRepeatedSpaces.None](https://reference.aspose.com/slides/java/com.aspose.slides/handlerepeatedspaces/#None) makes the treatment of ordinary spaces easier to inspect.
```java
import com.aspose.slides.Flavor;
import com.aspose.slides.HandleRepeatedSpaces;
import com.aspose.slides.IAutoShape;
import com.aspose.slides.ISlide;
import com.aspose.slides.MarkdownSaveOptions;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
import com.aspose.slides.ShapeType;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 20, 20, 600, 300);
// Include an empty paragraph and a paragraph containing three regular spaces.
shape.getTextFrame().setText("First paragraph.\r\r \rSecond paragraph.");
MarkdownSaveOptions options = new MarkdownSaveOptions();
options.setFlavor(Flavor.CommonMark);
options.setHandleRepeatedSpaces(HandleRepeatedSpaces.None);
options.setRemoveEmptyLines(false);
presentation.save("empty-lines-kept.md", SaveFormat.Md, options);
options.setRemoveEmptyLines(true);
presentation.save("empty-lines-removed.md", SaveFormat.Md, options);
} finally {
presentation.dispose();
}
```
With `false`, the generated Markdown is:
```markdown
---
First paragraph.
Second paragraph.
```
With `true`, it becomes:
```markdown
---
First paragraph.
Second paragraph.
```
When [setRemoveEmptyLines](https://reference.aspose.com/slides/java/com.aspose.slides/markdownsaveoptions/#setRemoveEmptyLines-boolean-) is set to `false`, the exported Markdown preserves the empty and whitespace-only paragraphs. The ` ` line represents an empty paragraph.
When [setRemoveEmptyLines](https://reference.aspose.com/slides/java/com.aspose.slides/markdownsaveoptions/#setRemoveEmptyLines-boolean-) is set to `true`, these blank paragraphs are removed. The two text paragraphs become a single Markdown paragraph with a line break between them. This line break is preserved by two trailing spaces after `First paragraph.`—Markdown syntax for a hard line break.
The slide separator (`---`) remains in both outputs. Keep [setRemoveEmptyLines](https://reference.aspose.com/slides/java/com.aspose.slides/markdownsaveoptions/#setRemoveEmptyLines-boolean-) set to `false` when you need to preserve paragraph separation. If your presentation contains lists or code blocks, check the exported result in your target Markdown viewer, since blank lines can affect how that content is interpreted.
## **Export Images Using the Default Local-Saving Behavior**
The [MarkdownSaveOptions](https://reference.aspose.com/slides/java/com.aspose.slides/markdownsaveoptions/) class provides two methods for configuring locally saved images:
- [setBasePath](https://reference.aspose.com/slides/java/com.aspose.slides/markdownsaveoptions/) specifies the base directory for the Markdown document and its resources.
- [setImagesSaveFolderName](https://reference.aspose.com/slides/java/com.aspose.slides/markdownsaveoptions/) specifies the image subdirectory. Its default value is `Images`.
The following example renders visual content, writes images to `output/assets`, and creates relative image references in the Markdown document:
```java
import com.aspose.slides.MarkdownExportType;
import com.aspose.slides.MarkdownSaveOptions;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Path outputDirectory = Paths.get("output");
Files.createDirectories(outputDirectory);
Presentation presentation = new Presentation("presentation.pptx");
try {
MarkdownSaveOptions options = new MarkdownSaveOptions();
options.setExportType(MarkdownExportType.Visual);
options.setBasePath(outputDirectory.toString());
options.setImagesSaveFolderName("assets");
Path markdownPath = outputDirectory.resolve("presentation.md");
presentation.save(markdownPath.toString(), SaveFormat.Md, options);
} finally {
presentation.dispose();
}
```
This behavior also serves as the fallback when a custom image-saving handler returns `false`.
## **Customize Image Saving and Markdown Links**
Use the [MarkdownSaveOptions.setImageSaving](https://reference.aspose.com/slides/java/com.aspose.slides/markdownsaveoptions/) method to register a callback for non-SVG bitmap and metafile resources emitted during Markdown export. Its `MarkdownImageSavingHandler` callback receives the [IImage](https://reference.aspose.com/slides/java/com.aspose.slides/iimage/) object, its [ImageFormat](https://reference.aspose.com/slides/java/com.aspose.slides/imageformat/) value, and the generated Markdown link as a one-element `String[]` parameter. Save or upload the image with the supplied format, and replace `link[0]` with the reference that must appear in the Markdown output.
Resources emitted in SVG format are handled separately. Register a callback with the [MarkdownSaveOptions.setSvgImageSaving](https://reference.aspose.com/slides/java/com.aspose.slides/markdownsaveoptions/) method. Its `MarkdownSvgImageSavingHandler` callback receives an [ISvgImage](https://reference.aspose.com/slides/java/com.aspose.slides/isvgimage/) object and the one-element `String[] link` parameter. An SVG has no `ImageFormat` argument; write or upload its XML data from the [ISvgImage.getSvgData](https://reference.aspose.com/slides/java/com.aspose.slides/isvgimage/) method instead. Depending on the export mode and visual grouping, an SVG in the source presentation can be rasterized or combined with other content; the resulting non-SVG resource is then passed to the image-saving callback. Register both callbacks when every exported visual resource requires custom processing.
The handler return value determines who processes the image:
- Return `true` after the handler has saved, uploaded, transformed, or otherwise processed the image and assigned a valid value to `link[0]`. Aspose.Slides writes that value to the Markdown document and does not perform its default local save.
- Return `false` to let Aspose.Slides save the image locally and generate its link according to the values set by [MarkdownSaveOptions.setBasePath](https://reference.aspose.com/slides/java/com.aspose.slides/markdownsaveoptions/) and [MarkdownSaveOptions.setImagesSaveFolderName](https://reference.aspose.com/slides/java/com.aspose.slides/markdownsaveoptions/).
A handler that returns `true` takes responsibility for the image. If it returns `true` without assigning a valid, nonempty link, the export fails with an `InvalidOperationException`.
### **Save Images to a CDN Origin Directory and Use External URLs**
The following example treats `cdn-origin/presentations/quarterly-report` as a mounted or synchronized CDN origin directory. Each handler extracts the generated file name, saves the image to that custom directory, and replaces the generated local reference with a public CDN URL. The sample itself performs no network upload: the URL becomes valid only after the directory is mounted as the CDN origin or its files are published to the CDN. For object storage, replace the file-system write with the storage SDK's upload operation and assign `link[0]` only after the upload succeeds.
```java
import com.aspose.slides.MarkdownExportType;
import com.aspose.slides.MarkdownSaveOptions;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.function.Function;
Path outputDirectory = Paths.get("output");
String publicBaseUrl = "https://cdn.example.com/presentations/quarterly-report";
Path storageDirectory = Paths.get("cdn-origin", "presentations", "quarterly-report");
Files.createDirectories(outputDirectory);
Files.createDirectories(storageDirectory);
Function getFileNameFromLink = generatedLink -> {
String urlCompatibleLink = generatedLink.replace('\\', '/');
return urlCompatibleLink.substring(urlCompatibleLink.lastIndexOf('/') + 1);
};
Function buildPublicUrl = fileName -> {
try {
String encodedFileName = URLEncoder.encode(fileName, "UTF-8").replace("+", "%20");
return publicBaseUrl + "/" + encodedFileName;
} catch (UnsupportedEncodingException exception) {
System.err.println("Could not encode the image file name: " + exception.getMessage());
return null;
}
};
Presentation presentation = new Presentation("presentation.pptx");
try {
MarkdownSaveOptions options = new MarkdownSaveOptions();
options.setExportType(MarkdownExportType.Visual);
options.setBasePath(outputDirectory.toString());
options.setImagesSaveFolderName("fallback-images");
options.setImageSaving((image, format, link) -> {
if (image.getWidth() < 128 || image.getHeight() < 128) {
return false;
}
String fileName = getFileNameFromLink.apply(link[0]);
String publicUrl = buildPublicUrl.apply(fileName);
if (publicUrl == null) {
return false;
}
Path storagePath = storageDirectory.resolve(fileName);
image.save(storagePath.toString(), format);
link[0] = publicUrl;
return true;
});
options.setSvgImageSaving((svgImage, link) -> {
String fileName = getFileNameFromLink.apply(link[0]);
String publicUrl = buildPublicUrl.apply(fileName);
if (publicUrl == null) {
return false;
}
Path storagePath = storageDirectory.resolve(fileName);
try {
Files.write(storagePath, svgImage.getSvgData());
} catch (IOException exception) {
System.err.println("Could not save the SVG image: " + exception.getMessage());
return false;
}
link[0] = publicUrl;
return true;
});
Path markdownPath = outputDirectory.resolve("presentation.md");
presentation.save(markdownPath.toString(), SaveFormat.Md, options);
} finally {
presentation.dispose();
}
```
The bitmap handler deliberately returns `false` for images smaller than 128 × 128 pixels, so Aspose.Slides saves those images to `output/fallback-images` using the default behavior. Larger bitmap and metafile resources, as well as SVG resources, are handled by the custom code. For example, a generated local reference such as `fallback-images/image1.png` becomes `https://cdn.example.com/presentations/quarterly-report/image1.png`. The handlers use operating-system paths only when writing files; links written to Markdown use forward slashes and URL-escaped file names. Apply the same rule when building relative links: use `/`, not the platform-specific directory separator.
## **FAQ**
**Can one handler process both raster images and SVG images?**
No. Use [MarkdownSaveOptions.setImageSaving](https://reference.aspose.com/slides/java/com.aspose.slides/markdownsaveoptions/) for emitted bitmap and metafile resources and [MarkdownSaveOptions.setSvgImageSaving](https://reference.aspose.com/slides/java/com.aspose.slides/markdownsaveoptions/) for resources emitted as SVG. The former provides an [IImage](https://reference.aspose.com/slides/java/com.aspose.slides/iimage/) object and an [ImageFormat](https://reference.aspose.com/slides/java/com.aspose.slides/imageformat/) value; the latter provides an [ISvgImage](https://reference.aspose.com/slides/java/com.aspose.slides/isvgimage/) object whose SVG data can be read with [ISvgImage.getSvgData](https://reference.aspose.com/slides/java/com.aspose.slides/isvgimage/). A source SVG that is rasterized during export is processed by the image-saving callback instead.
**What happens when an image-saving handler returns `false`?**
Aspose.Slides uses its default local-saving behavior. The image location and generated reference are controlled by the values set with [MarkdownSaveOptions.setBasePath](https://reference.aspose.com/slides/java/com.aspose.slides/markdownsaveoptions/) and [MarkdownSaveOptions.setImagesSaveFolderName](https://reference.aspose.com/slides/java/com.aspose.slides/markdownsaveoptions/).
**Can a handler provide a URL without saving the image locally?**
Yes. The handler can upload the image to object storage or pass it to another service, assign the resulting URL to `link[0]`, and return `true`. The handler must complete the processing itself; returning `true` prevents the default local save.
**Why does Markdown export throw an `InvalidOperationException` from a handler?**
This exception occurs when the handler returns `true` but does not provide a valid link. Assign the relative path or external URL that should be written to Markdown before returning `true`.
**Which path separator should image links use?**
Use forward slashes in Markdown links and URLs. Use `Path.resolve` only for file-system paths, then construct or normalize the Markdown reference separately.
**Are hyperlinks preserved during Markdown export?**
Yes. Text [hyperlinks](https://docs.aspose.com/slides/java/manage-hyperlinks/) are preserved as standard Markdown links. Slide [transitions](https://docs.aspose.com/slides/java/slide-transition/) and [animations](https://docs.aspose.com/slides/java/powerpoint-animation/) are not converted.
**Can presentations be converted to Markdown in parallel?**
You can process different presentation files in parallel, but do not share the same [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) instance between threads. Follow the [multithreading guidelines](https://docs.aspose.com/slides/java/multithreading/) and use a separate instance for each file.
# Convert PowerPoint Presentations to PDF with Notes in Java
> Convert formats PPT and PPTX to PDF with notes using Aspose.Slides for Java. Preserve layouts and speaker notes for professional presentations.
Source: https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf-with-notes/
Updated: 2026-09-21
## **Overview**
In this article, you will learn how to convert PowerPoint presentations to PDF format with speaker notes using Aspose.Slides. This guide will cover the necessary steps and provide code examples to help you achieve this task efficiently. By the end of this article, you will be able to:
- Implement the conversion process to transform PowerPoint slides into PDF documents while preserving the speaker notes.
- Customize the output PDF to ensure that the speaker notes are included and formatted according to your requirements.
To set the notes page dimensions and orientation before export, see [Notes Page Size](https://docs.aspose.com/slides/java/notes-size/).
## **Convert PowerPoint to PDF with Notes**
The `save` method in the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class can be used to convert a PPT or PPTX presentation to a PDF with speaker notes. With Aspose.Slides, you simply load the presentation, configure the layout options using the [NotesCommentsLayoutingOptions](https://reference.aspose.com/slides/java/com.aspose.slides/notescommentslayoutingoptions/) class to include speaker notes, and then save the file as a PDF. The following code snippet demonstrates how to convert a sample presentation to a PDF in Notes Slide view.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("sample.pptx");
// Configure PDF options for rendering speaker notes.
NotesCommentsLayoutingOptions notesOptions = new NotesCommentsLayoutingOptions();
notesOptions.setNotesPosition(NotesPositions.BottomFull); // Render speaker notes below the slide.
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setSlidesLayoutOptions(notesOptions);
// Save the presentation to PDF with speaker notes.
presentation.save("output.pdf", SaveFormat.Pdf, pdfOptions);
presentation.dispose();
```
You may want to check out the Aspose [Online PowerPoint to PDF Converter](https://products.aspose.app/slides/conversion).
## Related articles
- [Note](https://docs.aspose.com/slides/java/examples/elements/note/)
- [Convert PowerPoint Presentations to TIFF with Notes in Java](https://docs.aspose.com/slides/java/convert-powerpoint-to-tiff-with-notes/)
# Convert PPT and PPTX to PDF in Java [Advanced Features Included]
> Convert PowerPoint PPT/PPTX to high-quality, searchable PDFs in Java using Aspose.Slides, with fast code examples and advanced conversion options.
Source: https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf/
Updated: 2026-10-26
## **Overview**
Converting PowerPoint presentations (PPT, PPTX, ODP, etc.) into PDF format in Java offers several advantages, including compatibility across different devices and preserving the layout and formatting of your presentation. This guide demonstrates how to convert presentations to PDF documents, use various options to control image quality, include hidden slides, password-protect PDF files, detect font substitutions, select specific slides for conversion, and apply compliance standards to output documents.
## **PowerPoint to PDF Conversions**
Using Aspose.Slides, you can convert presentations in the following formats to PDF:
* **PPT**
* **PPTX**
* **ODP**
To convert a presentation to PDF, pass the file name as an argument to the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class and then save the presentation as a PDF using a [save](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#save-java.lang.String-int-) method. The [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class exposes the [save](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#save-java.lang.String-int-) method that is typically used to convert a presentation to PDF.
Aspose.Slides for Java inserts its API information and version number into output documents. For example, when converting a presentation to PDF, Aspose.Slides populates the Application field with "*Aspose.Slides*" and the PDF Producer field with a value in "*Aspose.Slides v XX.XX*" form. **Note** that you cannot instruct Aspose.Slides to change or remove this information from output documents.
Aspose.Slides allows you to convert:
* Entire presentations to PDF
* Specific slides from a presentation to PDF
Aspose.Slides exports presentations to PDF, ensuring the resulting PDFs closely match the original presentations. Elements and attributes are rendered accurately in the conversion, including:
* Images
* Text boxes and shapes
* Text formatting
* Paragraph formatting
* Hyperlinks
* Headers and footers
* Bullets
* Tables
## **Convert PowerPoint to PDF**
The standard PowerPoint-to-PDF conversion process uses default options. In this case, Aspose.Slides tries to convert the provided presentation to PDF using optimal settings at the maximum quality levels.
The following example loads a presentation and saves all visible slides to PDF using the default export settings.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("PowerPoint.ppt");
try {
presentation.save("PPT-to-PDF.pdf", SaveFormat.Pdf);
} finally {
presentation.dispose();
}
```
Aspose offers a free online [**PowerPoint to PDF converter**](https://products.aspose.app/slides/conversion/ppt-to-pdf) that demonstrates the presentation-to-PDF conversion process. You can run a test with this converter for a live implementation of the procedure described here.
## **Convert PowerPoint to PDF with Options**
Aspose.Slides provides custom options—properties under the [PdfOptions](https://reference.aspose.com/slides/java/com.aspose.slides/pdfoptions/) class—that allow you to customize the resulting PDF, lock the PDF with a password, or specify how the conversion process should proceed.
### **Convert PowerPoint to PDF with Custom Options**
Using custom conversion options, you can define your preferred quality setting for raster images, specify how metafiles should be handled, set a compression level for text, configure DPI for images, and more.
The following example exports a presentation to PDF 1.5 with JPEG quality set to 90, image resolution set to 300 DPI, metafiles saved as PNG, and Flate text compression.
```java
import com.aspose.slides.*;
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setJpegQuality((byte)90);
pdfOptions.setSufficientResolution(300);
pdfOptions.setSaveMetafilesAsPng(true);
pdfOptions.setTextCompression(PdfTextCompression.Flate);
pdfOptions.setCompliance(PdfCompliance.Pdf15);
Presentation presentation = new Presentation("PowerPoint.pptx");
try {
presentation.save("PowerPoint-to-PDF.pdf", SaveFormat.Pdf, pdfOptions);
} finally {
presentation.dispose();
}
```
### **Automatically Select Image Compression**
When a presentation contains many photographs or screenshots, reducing the size of the exported PDF can make it easier to email or download. Call [PdfOptions.setBestImagesCompressionRatio](https://reference.aspose.com/slides/java/com.aspose.slides/pdfoptions/#setBestImagesCompressionRatio-boolean-) with `true` to automatically select the most appropriate compression algorithm for each image during PDF export.
The following example loads an existing presentation, enables automatic image compression selection, and saves it as a PDF document. All other PDF export settings retain their default values.
```java
import com.aspose.slides.PdfOptions;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setBestImagesCompressionRatio(true);
Presentation presentation = new Presentation("image-heavy.pptx");
try {
presentation.save("image-heavy.pdf", SaveFormat.Pdf, pdfOptions);
} finally {
presentation.dispose();
}
```
This option selects a compression algorithm for each image. Lowering the value passed to [setJpegQuality](https://reference.aspose.com/slides/java/com.aspose.slides/pdfoptions/#setJpegQuality-byte-) instead reduces JPEG image quality, while lowering the value passed to [setSufficientResolution](https://reference.aspose.com/slides/java/com.aspose.slides/pdfoptions/#setSufficientResolution-float-) allows images to be downsampled to a lower resolution, which can reduce detail. Enabling automatic compression selection does not itself lower either of these settings.
Selecting image compression algorithms requires additional processing time and memory. The size reduction depends on the presentation's images and export settings; a fixed reduction is not guaranteed for every presentation.
### **Preserve Embedded OLE Files as PDF Attachments**
If a presentation contains an embedded Excel workbook, you may want PDF recipients to access the workbook's data as well as view the slides. Call [setIncludeOleData](https://reference.aspose.com/slides/java/com.aspose.slides/pdfoptions/#setIncludeOleData-boolean-) with `true` to preserve embedded OLE files as attachments in the resulting PDF.
The default value is `false`: the OLE object's preview image or icon is rendered on the PDF page, but its embedded file is not included as an attachment. Setting the option to `true` additionally includes the file data. The preview remains a visual representation; the attachment lets recipients open or save the embedded file separately. The OLE object does not become an interactive Excel worksheet on the PDF page.
The following example loads a presentation that already contains an embedded Excel workbook and exports it to PDF with the workbook attached.
```java
import com.aspose.slides.*;
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setIncludeOleData(true);
Presentation presentation = new Presentation("presentation.pptx");
try {
presentation.save("presentation.pdf", SaveFormat.Pdf, pdfOptions);
} finally {
presentation.dispose();
}
```
To check the result:
1. Open the exported PDF in a viewer that supports file attachments, such as Adobe Acrobat Reader.
2. Open the viewer's **Attachments** panel and locate the embedded workbook.
3. Save the attachment and open it in Excel to inspect its data, or open it directly if the viewer permits it. The preview on the PDF page is separate from the attachment.
The PDF/A standards impose restrictions on attachments: PDF/A-1 prohibits embedded files, PDF/A-2 permits only PDF/A attachments, and PDF/A-3 permits other file types, including Excel workbooks. These are requirements of the standards, not restrictions specific to Aspose.Slides. This example uses the default PDF compliance setting and does not demonstrate PDF/A export.
### **Convert PowerPoint to PDF with Hidden Slides**
If a presentation contains hidden slides, you can use the [setShowHiddenSlides](https://reference.aspose.com/slides/java/com.aspose.slides/pdfoptions/#setShowHiddenSlides-boolean-) method from the [PdfOptions](https://reference.aspose.com/slides/java/com.aspose.slides/pdfoptions/) class to include the hidden slides as pages in the resulting PDF.
The following example exports a presentation to PDF, including any hidden slides.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("PowerPoint.pptx");
try {
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setShowHiddenSlides(true);
presentation.save("PowerPoint-to-PDF.pdf", SaveFormat.Pdf, pdfOptions);
} finally {
presentation.dispose();
}
```
### **Convert PowerPoint to a Password-Protected PDF**
The following example exports a presentation to a PDF that requires the password `password` to open. The access permissions allow printing, including high-quality printing.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("PowerPoint.pptx");
try {
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setPassword("password");
pdfOptions.setAccessPermissions(PdfAccessPermissions.PrintDocument | PdfAccessPermissions.HighQualityPrint);
presentation.save("PPTX-to-PDF.pdf", SaveFormat.Pdf, pdfOptions);
} finally {
presentation.dispose();
}
```
### **Detect Font Substitutions**
Aspose.Slides provides the [setWarningCallback](https://reference.aspose.com/slides/java/com.aspose.slides/saveoptions/#setWarningCallback-com.aspose.slides.IWarningCallback-) method under the [PdfOptions](https://reference.aspose.com/slides/java/com.aspose.slides/pdfoptions/) class, enabling you to detect font substitutions during the presentation-to-PDF conversion process.
The following example exports a presentation to PDF and prints font substitution warnings to the console. A warning is printed only when an unavailable font is substituted during export.
```java
import com.aspose.slides.*;
class FontSubstitutionHandler implements IWarningCallback {
public int warning(IWarningInfo warning) {
if (warning.getWarningType() == WarningType.DataLoss && warning.getDescription().startsWith("Font will be substituted")) {
System.out.println("Font substitution warning: " + warning.getDescription());
}
return ReturnAction.Continue;
}
}
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setWarningCallback(new FontSubstitutionHandler());
Presentation presentation = new Presentation("sample.pptx");
try {
presentation.save("output.pdf", SaveFormat.Pdf, pdfOptions);
} finally {
presentation.dispose();
}
```
For more information on font substitution, see the [Font Substitution](https://docs.aspose.com/slides/java/font-substitution/) article.
### **Handle Fonts Without a Dedicated Bold Typeface**
A presentation can apply bold formatting to text even when its font has no dedicated bold typeface. The text can still appear bold through synthetic bolding, which artificially thickens the regular glyphs. When that text looks too heavy or otherwise differs from the intended appearance in PDF, try calling [PdfOptions.setRasterizeUnsupportedFontStyles](https://reference.aspose.com/slides/java/com.aspose.slides/pdfoptions/#setRasterizeUnsupportedFontStyles-boolean-) with `true`. This option renders the affected text as a bitmap during PDF export and can improve its appearance for certain fonts. Its default value is `false`.
The sample presentation contains two text boxes: one with regular text and one with bold formatting applied to the same font, which has no dedicated bold typeface. The following example loads the presentation, enables rasterization of unsupported font styles, and exports it to PDF:
```java
import com.aspose.slides.PdfOptions;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setRasterizeUnsupportedFontStyles(true);
Presentation presentation = new Presentation("unsupported-bold.pptx");
try {
presentation.save("rasterized.pdf", SaveFormat.Pdf, pdfOptions);
} finally {
presentation.dispose();
}
```
The following previews show the disabled output and the enabled output. In this example, the bold text has heavier strokes with the option disabled. With the option enabled, its strokes are lighter; the regular text is unchanged. Compare the results before choosing the setting for your presentation.
| Option disabled (`false`, the default) | Option enabled (`true`) |
|---|---|
|  |  |
In this example, enabling the option turns only the bold text into a bitmap: it cannot be selected, copied, or searched as text without OCR, and its edges appear softer at 800% zoom. The regular text remains searchable. With the option disabled, both strings remain text.
This option rasterizes text formatted as bold when its font has no dedicated bold typeface. [Font substitution](https://docs.aspose.com/slides/java/font-substitution/) instead selects another font when the original is unavailable.
## **Convert Selected Slides from PowerPoint to PDF**
The following example exports slides 1 and 3 from a presentation to PDF. Slide numbers in this array are one-based, and the input presentation must contain at least three slides.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("PowerPoint.pptx");
try {
int[] slides = { 1, 3 };
presentation.save("PPTX-to-PDF.pdf", slides, SaveFormat.Pdf);
} finally {
presentation.dispose();
}
```
## **Convert PowerPoint to PDF with Custom Slide Size**
The following example copies the first slide from a presentation into a new presentation with a slide size of 612 × 792 points (8.5 × 11 inches). It scales the slide content to fit and exports the single slide to PDF.
```java
import com.aspose.slides.*;
float slideWidth = 612;
float slideHeight = 792;
Presentation presentation = new Presentation("SelectedSlides.pptx");
Presentation resizedPresentation = new Presentation();
try {
resizedPresentation.getSlideSize().setSize(slideWidth, slideHeight, SlideSizeScaleType.EnsureFit);
ISlide slide = presentation.getSlides().get_Item(0);
resizedPresentation.getSlides().insertClone(0, slide);
// Remove the empty slide the new presentation was created with.
resizedPresentation.getSlides().removeAt(1);
resizedPresentation.save("PDF_with_custom_slide_size.pdf", SaveFormat.Pdf);
} finally {
resizedPresentation.dispose();
presentation.dispose();
}
```
## **Convert PowerPoint to PDF in Notes Slide View**
The following example exports a presentation to PDF, placing each slide's speaker notes below the slide. Use a presentation containing speaker notes to see the result.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("SelectedSlides.pptx");
try {
NotesCommentsLayoutingOptions notesOptions = new NotesCommentsLayoutingOptions();
notesOptions.setNotesPosition(NotesPositions.BottomFull);
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setSlidesLayoutOptions(notesOptions);
presentation.save("PDF_with_notes.pdf", SaveFormat.Pdf, pdfOptions);
} finally {
presentation.dispose();
}
```
## **Accessibility and Compliance Standards for PDF**
Aspose.Slides allows you to use a conversion procedure that complies with [Web Content Accessibility Guidelines (**WCAG**)](https://www.w3.org/TR/WCAG-TECHS/pdf.html). You can export a PowerPoint document to PDF using any of these compliance standards: **PDF/A1a**, **PDF/A1b**, and **PDF/UA**.
This code demonstrates a PowerPoint-to-PDF conversion process that produces multiple PDFs based on different compliance standards:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("pres.pptx");
try {
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setCompliance(PdfCompliance.PdfA1a);
presentation.save("pres-a1a-compliance.pdf", SaveFormat.Pdf, pdfOptions);
pdfOptions.setCompliance(PdfCompliance.PdfA1b);
presentation.save("pres-a1b-compliance.pdf", SaveFormat.Pdf, pdfOptions);
pdfOptions.setCompliance(PdfCompliance.PdfUa);
presentation.save("pres-ua-compliance.pdf", SaveFormat.Pdf, pdfOptions);
} finally {
presentation.dispose();
}
```
Aspose.Slides supports PDF conversion operations, allowing you to convert PDF files to popular file formats. You can perform [PDF to HTML](https://products.aspose.com/slides/java/conversion/pdf-to-html/), [PDF to image](https://products.aspose.com/slides/java/conversion/pdf-to-image/), [PDF to JPG](https://products.aspose.com/slides/java/conversion/pdf-to-jpg/), and [PDF to PNG](https://products.aspose.com/slides/java/conversion/pdf-to-png/) conversions. Other PDF conversion operations to specialized formats—[PDF to SVG](https://products.aspose.com/slides/java/conversion/pdf-to-svg/), [PDF to TIFF](https://products.aspose.com/slides/java/conversion/pdf-to-tiff/), and [PDF to XML](https://products.aspose.com/slides/java/conversion/pdf-to-xml/)—are also supported.
> **Note:** When exporting to PDF/UA, Aspose.Slides treats complex graphics such as SmartArt, charts, and formulas as a single figure. Individual path elements are not preserved as separate content and may be marked as artifacts; alternative text is provided only for the whole figure.
## **FAQ**
**Can I convert multiple PowerPoint files to PDF in bulk?**
Yes, Aspose.Slides supports batch conversion of multiple PPT or PPTX files to PDF. You can iterate through your files and apply the conversion process programmatically.
**Is it possible to password-protect the converted PDF?**
Yes. Use the [PdfOptions](https://reference.aspose.com/slides/java/com.aspose.slides/pdfoptions/) class to set a password and define access permissions during the conversion process.
**How do I include hidden slides in the PDF?**
Call [setShowHiddenSlides](https://reference.aspose.com/slides/java/com.aspose.slides/pdfoptions/#setShowHiddenSlides-boolean-) with `true` in the [PdfOptions](https://reference.aspose.com/slides/java/com.aspose.slides/pdfoptions/) class to include hidden slides in the resulting PDF.
**Can Aspose.Slides maintain high image quality in the PDF?**
Yes, you can control image quality by using methods such as [setJpegQuality](https://reference.aspose.com/slides/java/com.aspose.slides/pdfoptions/#setJpegQuality-byte-) and [setSufficientResolution](https://reference.aspose.com/slides/java/com.aspose.slides/pdfoptions/#setSufficientResolution-float-) in the [PdfOptions](https://reference.aspose.com/slides/java/com.aspose.slides/pdfoptions/) class to ensure high-quality images in your PDF.
**Does Aspose.Slides support PDF/A compliance standards?**
Yes, Aspose.Slides allows you to export PDFs that comply with [various standards](https://reference.aspose.com/slides/java/com.aspose.slides/pdfcompliance/), including PDF/A1a, PDF/A1b, and PDF/UA, ensuring your documents meet accessibility and archival requirements.
## **Additional Resources**
- [Aspose.Slides for Java Documentation](https://docs.aspose.com/slides/java/)
- [Aspose.Slides for Java API Reference](https://reference.aspose.com/slides/java/)
- [Aspose Free Online Converters](https://products.aspose.app/slides/conversion)
Related feature: [Export presentations to PDF](https://docs.aspose.com/slides/features/pdf-export/).
# Convert PowerPoint Slides to PNG in Java
> Convert PowerPoint presentations to high-quality PNG images quickly with Aspose.Slides for Java, ensuring precise, automated results.
Source: https://docs.aspose.com/slides/java/convert-powerpoint-to-png/
Updated: 2026-10-14
## **Overview**
This article explains how to convert presentation slides to PNG images using Aspose.Slides for Java. You can load presentations in formats such as PPT, PPTX, and ODP, render each slide, and save it as a separate PNG image.
The examples below demonstrate rendering at the default scale, increasing the scale, specifying the output dimensions in pixels, and choosing a gradient rendering style.
## **Convert PowerPoint to PNG**
Load a presentation with the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class and access its slides through the [Presentation.getSlides](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#getSlides--) collection. The example renders every slide with [ISlide.getImage](https://reference.aspose.com/slides/java/com.aspose.slides/islide/#getImage--) without parameters to create a thumbnail. It then calls [IImage.save](https://reference.aspose.com/slides/java/com.aspose.slides/iimage/#save-java.lang.String-int-) with [ImageFormat.Png](https://reference.aspose.com/slides/java/com.aspose.slides/imageformat/#Png) to save each rendered slide as a PNG image.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("presentation.pptx");
try {
int slideCount = presentation.getSlides().size();
for (int index = 0; index < slideCount; index++) {
ISlide slide = presentation.getSlides().get_Item(index);
IImage image = slide.getImage();
try {
image.save("slide_" + index + ".png", ImageFormat.Png);
} finally {
image.dispose();
}
}
} finally {
presentation.dispose();
}
```
The parameterless [ISlide.getImage](https://reference.aspose.com/slides/java/com.aspose.slides/islide/#getImage--) overload renders at a scale of 0.2. For example, a slide measuring 720 × 540 points produces a 144 × 108 pixel thumbnail. To control the output dimensions, use the overloads with scale factors or an explicit image size shown below.
## **Convert PowerPoint to PNG With Custom Dimensions**
Pass horizontal and vertical scale factors to [ISlide.getImage](https://reference.aspose.com/slides/java/com.aspose.slides/islide/#getImage-float-float-) to control the rendered dimensions. In this example, both factors are 2, so a slide measuring 720 × 540 points produces a 1440 × 1080 pixel image. Equal scale factors preserve the slide's aspect ratio. Each image is saved in PNG format with [IImage.save](https://reference.aspose.com/slides/java/com.aspose.slides/iimage/#save-java.lang.String-int-).
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("presentation.pptx");
try {
float scaleX = 2f;
float scaleY = scaleX;
int slideCount = presentation.getSlides().size();
for (int index = 0; index < slideCount; index++) {
ISlide slide = presentation.getSlides().get_Item(index);
IImage image = slide.getImage(scaleX, scaleY);
try {
image.save("slide_" + index + ".png", ImageFormat.Png);
} finally {
image.dispose();
}
}
} finally {
presentation.dispose();
}
```
## **Convert PowerPoint to PNG With Custom Size**
To specify output dimensions in pixels, pass a size to [ISlide.getImage](https://reference.aspose.com/slides/java/com.aspose.slides/islide/#getImage-java.awt.Dimension-) instead of scale factors. This example renders every slide at 960 × 720 pixels and saves the result with [IImage.save](https://reference.aspose.com/slides/java/com.aspose.slides/iimage/#save-java.lang.String-int-). Choose dimensions that match the slide's aspect ratio to avoid stretching the image.
```java
import com.aspose.slides.*;
import java.awt.Dimension;
Presentation presentation = new Presentation("presentation.pptx");
try {
Dimension imageSize = new Dimension(960, 720);
int slideCount = presentation.getSlides().size();
for (int index = 0; index < slideCount; index++) {
ISlide slide = presentation.getSlides().get_Item(index);
IImage image = slide.getImage(imageSize);
try {
image.save("slide_" + index + ".png", ImageFormat.Png);
} finally {
image.dispose();
}
}
} finally {
presentation.dispose();
}
```
## **Choose a Gradient Rendering Style**
Suppose a slide contains gradient fills, but the transitions in the exported PNG look lighter or otherwise different from what you see in PowerPoint. You can use the [SaveOptions.setGradientStyle](https://reference.aspose.com/slides/java/com.aspose.slides/saveoptions/#setGradientStyle-int-) method inherited by [RenderingOptions](https://reference.aspose.com/slides/java/com.aspose.slides/renderingoptions/) to choose how the gradients are rendered.
Download [gradient-styles.pptx](https://docs.aspose.com/slides/java/convert-powerpoint-to-png/gradient-styles.pptx) and place it in the application's working directory. Its first slide contains two linear gradients: cyan to orange at the top and blue to yellow at the bottom. Each gradient has two stops, at 0% and 100%.
The following example loads this presentation and renders the same first slide in both modes with [ISlide.getImage](https://reference.aspose.com/slides/java/com.aspose.slides/islide/#getImage-com.aspose.slides.IRenderingOptions-float-float-).
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("gradient-styles.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
int[] gradientStyles = { GradientStyle.Default, GradientStyle.PowerPointUI };
for (int style : gradientStyles) {
RenderingOptions options = new RenderingOptions();
options.setGradientStyle(style);
String styleName = style == GradientStyle.Default ? "Default" : "PowerPointUI";
IImage image = slide.getImage(options, 1f, 1f);
try {
image.save("gradient-" + styleName + ".png", ImageFormat.Png);
} finally {
image.dispose();
}
}
} finally {
presentation.dispose();
}
```
The images below show the output from the same slide, with both gradients in each image:
| Default | PowerPointUI |
| --- | --- |
|  |  |
In this example, `Default` produces lighter intermediate colors, while `PowerPointUI` produces darker intermediate colors. The difference depends on the colors and stops in the gradient.
Choose `Default` when the standard Aspose.Slides output suits your needs. Try `PowerPointUI` when your priority is matching the appearance in PowerPoint. Compare both outputs with your intended result; neither mode is universally preferable.
## **FAQ**
**How can I export a specific shape, such as a chart or picture, instead of the entire slide?**
Aspose.Slides supports [generating thumbnails for individual shapes](https://docs.aspose.com/slides/java/create-shape-thumbnails/), allowing you to render a shape as a PNG image.
**Is parallel conversion supported on a server?**
Yes. Use a separate presentation instance for each thread or process; [do not share a single instance across threads](https://docs.aspose.com/slides/java/multithreading/).
**What are the evaluation limitations when exporting to PNG?**
Evaluation mode adds a watermark to output images and applies [other restrictions](https://docs.aspose.com/slides/java/licensing/) until a license is applied.
## Related articles
- [Convert PPT and PPTX to JPG in Java](https://docs.aspose.com/slides/java/convert-powerpoint-to-jpg/)
# Convert PowerPoint Presentations to SWF Flash in Java
> Convert PowerPoint (PPT/PPTX) to SWF Flash in Java with Aspose.Slides. Step‑by‑step code samples, fast quality output, no PowerPoint automation.
Source: https://docs.aspose.com/slides/java/convert-powerpoint-to-swf-flash/
Updated: 2026-08-05
## **Overview**
This article explains how to convert PowerPoint presentations to SWF by using Aspose.Slides. It shows how to save a presentation as an SWF file with the [Presentation.save](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#save-java.lang.String-int-com.aspose.slides.ISaveOptions-) method and how to configure the export with [SwfOptions](https://reference.aspose.com/slides/java/com.aspose.slides/swfoptions/), including viewer settings and notes or comments layout.
## **Convert Presentations to Flash**
The [save](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation#save-java.lang.String-int-com.aspose.slides.ISaveOptions-) method exposed by [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation) class can be used to convert the whole presentation into **SWF** document. The following example shows how to convert a presentation into **SWF** document by using options provided by [**SWFOptions**](https://reference.aspose.com/slides/java/com.aspose.slides/SwfOptions) class.You can also include comments in generated SWF using [**ISWFOptions**](https://reference.aspose.com/slides/java/com.aspose.slides/ISwfOptions) class and [**INotesCommentsLayoutingOptions**](https://reference.aspose.com/slides/java/com.aspose.slides/INotesCommentsLayoutingOptions) interface.
```java
import com.aspose.slides.*;
Presentation pres = new Presentation("Sample.pptx");
try {
NotesCommentsLayoutingOptions layoutingOptions = new NotesCommentsLayoutingOptions();
layoutingOptions.setNotesPosition(NotesPositions.BottomFull);
SwfOptions swfOptions = new SwfOptions();
swfOptions.setViewerIncluded(false);
swfOptions.setSlidesLayoutOptions(layoutingOptions);
// Saving presentation
pres.save("Sample.swf", SaveFormat.Swf, swfOptions);
} finally {
if (pres != null) pres.dispose();
}
```
## **FAQ**
### Can I include hidden slides in the SWF?
Yes. Enable the hidden slides using the [setShowHiddenSlides](https://reference.aspose.com/slides/java/com.aspose.slides/swfoptions/#setShowHiddenSlides-boolean-) method in [SwfOptions](https://reference.aspose.com/slides/java/com.aspose.slides/swfoptions/). By default, hidden slides are not exported.
### How can I control compression and the final SWF size?
Use the [setCompressed](https://reference.aspose.com/slides/java/com.aspose.slides/swfoptions/#setCompressed-boolean-) method and [adjust JPEG quality](https://reference.aspose.com/slides/java/com.aspose.slides/swfoptions/#setJpegQuality-int-) to balance file size and image fidelity.
### What is 'setViewerIncluded' for, and when should I disable it?
[setViewerIncluded](https://reference.aspose.com/slides/java/com.aspose.slides/swfoptions/#setViewerIncluded-boolean-) adds an embedded player UI (navigation controls, panels, search). Disable it if you plan to use your own player or need a bare SWF frame without UI.
### What happens if a source font is missing on the export machine?
Aspose.Slides will substitute the font you specify via [setDefaultRegularFont](https://reference.aspose.com/slides/java/com.aspose.slides/saveoptions/#setDefaultRegularFont-java.lang.String-) in [SwfOptions](https://reference.aspose.com/slides/java/com.aspose.slides/swfoptions/) to avoid an unintended fallback.
## Related articles
- [Extract Flash Objects from Presentations in Java](https://docs.aspose.com/slides/java/flash/)
# Convert PowerPoint Presentations to TIFF with Notes in Java
> Convert PowerPoint presentations to TIFF with notes using Aspose.Slides for Java. Learn how to export slides with speaker notes efficiently.
Source: https://docs.aspose.com/slides/java/convert-powerpoint-to-tiff-with-notes/
Updated: 2026-08-13
## **Introduction**
Aspose.Slides for Java provides a simple solution for converting PowerPoint and OpenDocument presentations (PPT, PPTX, and ODP) with notes to the TIFF format. This format is widely used for high-quality image storage, printing, and document archiving. With Aspose.Slides, you can not only export entire presentations with speaker notes but also generate slide thumbnails in the Notes Slide view. The conversion process is simple and efficient, utilizing the `save` method of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class to transform the entire presentation into a series of TIFF images while preserving the notes and layout.
## **Convert a Presentation to TIFF with Notes**
Saving a PowerPoint or OpenDocument presentation to TIFF with notes using Aspose.Slides for Java involves the following steps:
1. Instantiate the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class: Load a PowerPoint or OpenDocument file.
1. Configure the output layout options: Use the [NotesCommentsLayoutingOptions](https://reference.aspose.com/slides/java/com.aspose.slides/notescommentslayoutingoptions/) class to specify how notes and comments should be displayed.
1. Save the presentation to TIFF: Pass the configured options to the [save](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#save-java.lang.String-int-com.aspose.slides.ISaveOptions-) method.
Let's say we have a "speaker_notes.pptx" file with the following slide:

The code snippet below demonstrates how to convert the presentation to a TIFF image in Notes Slide view using the [setSlidesLayoutOptions](https://reference.aspose.com/slides/java/com.aspose.slides/tiffoptions/#setSlidesLayoutOptions-com.aspose.slides.ISlidesLayoutOptions-) method.
```java
import com.aspose.slides.*;
// Instantiate the Presentation class that represents a presentation file.
Presentation presentation = new Presentation("speaker_notes.pptx");
try {
NotesCommentsLayoutingOptions notesOptions = new NotesCommentsLayoutingOptions();
notesOptions.setNotesPosition(NotesPositions.BottomFull); // Display the notes below the slide.
// Configure the TIFF options with Notes layouting.
TiffOptions tiffOptions = new TiffOptions();
tiffOptions.setDpiX(300);
tiffOptions.setDpiY(300);
tiffOptions.setSlidesLayoutOptions(notesOptions);
// Save the presentation to TIFF with the speaker notes.
presentation.save("TIFF_with_notes.tiff", SaveFormat.Tiff, tiffOptions);
} finally {
presentation.dispose();
}
```
The result:

Check out Aspose [Free PowerPoint to Poster Converter](https://products.aspose.app/slides/conversion/convert-ppt-to-poster-online).
## **FAQ**
### Can I control the position of the notes area in the resulting TIFF?
Yes. Use the [notes layout settings](https://reference.aspose.com/slides/java/com.aspose.slides/tiffoptions/#setSlidesLayoutOptions-com.aspose.slides.ISlidesLayoutOptions-) to choose among options like `None`, `BottomTruncated`, or `BottomFull`, which respectively hide notes, fit them into a single page, or allow them to flow onto additional pages.
### How can I reduce the size of a TIFF file with notes without visible loss of quality?
Pick an [efficient compression](https://reference.aspose.com/slides/java/com.aspose.slides/tiffoptions/#setCompressionType-int-) (e.g., `LZW` or `RLE`), set a reasonable DPI, and, if acceptable, use a lower [pixel format](https://reference.aspose.com/slides/java/com.aspose.slides/tiffoptions/#setPixelFormat-int-) (such as 8 bpp or 1 bpp for monochrome). Slightly reducing the [image dimensions](https://reference.aspose.com/slides/java/com.aspose.slides/tiffoptions/#setImageSize-java.awt.Dimension-) can also help without noticeably hurting readability.
### Does the font in the notes affect the result if the original fonts are missing from the system?
Yes. Missing fonts trigger [substitution](https://docs.aspose.com/slides/java/font-selection-sequence/), which can change text metrics and appearance. To avoid this, [supply the required fonts](https://docs.aspose.com/slides/java/custom-font/) or set a default [fallback font](https://docs.aspose.com/slides/java/fallback-font/) so the intended typefaces are used.
## Related articles
- [Convert PowerPoint Presentations to PDF with Notes in Java](https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf-with-notes/)
# Convert PowerPoint Presentations to TIFF in Java
> Learn how to easily convert PowerPoint (PPT, PPTX) presentations to high-quality TIFF images using Aspose.Slides for Java, with code examples.
Source: https://docs.aspose.com/slides/java/convert-powerpoint-to-tiff/
Updated: 2026-08-25
## **Introduction**
TIFF (**Tagged Image File Format**) is a widely-used, lossless raster image format known for its exceptional quality and detailed preservation of graphics. Designers, photographers, and desktop publishers often choose TIFF to maintain layers, color accuracy, and original settings in their images.
Using Aspose.Slides, you can effortlessly convert your PowerPoint slides (PPT, PPTX) and OpenDocument slides (ODP) directly into high-quality TIFF images, ensuring your presentations retain maximum visual fidelity.
## **Convert a Presentation to TIFF**
Using the [save](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#save-java.lang.String-int-) method provided by the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class, you can quickly convert an entire PowerPoint presentation to TIFF. The resulting TIFF images correspond to the default slide size.
This code demonstrates how to convert a PowerPoint presentation to TIFF:
```java
import com.aspose.slides.*;
// Instantiate the Presentation class that represents a presentation file (PPT, PPTX, ODP, etc.).
Presentation presentation = new Presentation("presentation.pptx");
try {
// Save the presentation as TIFF.
presentation.save("output.tiff", SaveFormat.Tiff);
} finally {
presentation.dispose();
}
```
## **Convert a Presentation to Black-and-White TIFF**
The method [setBwConversionMode](https://reference.aspose.com/slides/java/com.aspose.slides/tiffoptions/#setBwConversionMode-int-) in the [TiffOptions](https://reference.aspose.com/slides/java/com.aspose.slides/tiffoptions/) class allows you to specify the algorithm used when converting a colored slide or image to a black-and-white TIFF. Note that this setting applies only when the [setCompressionType](https://reference.aspose.com/slides/java/com.aspose.slides/tiffoptions/#setCompressionType-int-) method is set to `CCITT4` or `CCITT3`.
[TiffOptions.setBwConversionMode](https://reference.aspose.com/slides/java/com.aspose.slides/tiffoptions/#setBwConversionMode-int-) is an export-level setting that selects a pixel-conversion algorithm for the complete TIFF image. To define how an individual shape should appear when black-and-white display mode is active, use [IShape.setBlackWhiteMode](https://reference.aspose.com/slides/java/com.aspose.slides/ishape/#setBlackWhiteMode-byte-). See [Control Black-and-White Rendering for Shapes](https://docs.aspose.com/slides/java/shape-formatting/#control-black-and-white-rendering-for-shapes) for examples.
Let's say we have a "sample.pptx" file with the following slide:

This code demonstrates how to convert the colored slide to a black-and-white TIFF:
```java
import com.aspose.slides.*;
TiffOptions tiffOptions = new TiffOptions();
tiffOptions.setCompressionType(TiffCompressionTypes.CCITT4);
tiffOptions.setBwConversionMode(BlackWhiteConversionMode.Dithering);
Presentation presentation = new Presentation("sample.pptx");
try {
presentation.save("output.tiff", SaveFormat.Tiff, tiffOptions);
} finally {
presentation.dispose();
}
```
The result:

## **Convert a Presentation to TIFF with Custom Size**
If you require a TIFF image with specific dimensions, you can set your desired values using methods available in [TiffOptions](https://reference.aspose.com/slides/java/com.aspose.slides/tiffoptions/). For instance, the [setImageSize](https://reference.aspose.com/slides/java/com.aspose.slides/tiffoptions/#setImageSize-java.awt.Dimension-) method allows you to define the size of the resulting image.
This code demonstrates how to convert a PowerPoint presentation to TIFF images with a custom size:
```java
import com.aspose.slides.*;
import java.awt.Dimension;
// Instantiate the Presentation class that represents a presentation file (PPT, PPTX, ODP, etc.).
Presentation presentation = new Presentation("presentation.pptx");
try {
TiffOptions tiffOptions = new TiffOptions();
// Set the compression type.
tiffOptions.setCompressionType(TiffCompressionTypes.Default);
/*
Compression types:
Default - Specifies the default compression scheme (LZW).
None - Specifies no compression.
CCITT3
CCITT4
LZW
RLE
*/
// The depth depends on the compression type and cannot be set manually.
// Set the image DPI.
tiffOptions.setDpiX(200);
tiffOptions.setDpiY(200);
// Set the image size.
tiffOptions.setImageSize(new Dimension(1728, 1078));
NotesCommentsLayoutingOptions notesOptions = new NotesCommentsLayoutingOptions();
notesOptions.setNotesPosition(NotesPositions.BottomFull);
tiffOptions.setSlidesLayoutOptions(notesOptions);
// Save the presentation as TIFF with the specified size.
presentation.save("tiff-ImageSize.tiff", SaveFormat.Tiff, tiffOptions);
} finally {
presentation.dispose();
}
```
## **Convert a Presentation to TIFF with Custom Image Pixel Format**
Using the [setPixelFormat](https://reference.aspose.com/slides/java/com.aspose.slides/tiffoptions/#setPixelFormat-int-) method from the [TiffOptions](https://reference.aspose.com/slides/java/com.aspose.slides/tiffoptions/) class, you can specify your preferred pixel format for the resulting TIFF image.
This code demonstrates how to convert a PowerPoint presentation to a TIFF image with a custom pixel format:
```java
import com.aspose.slides.*;
// Instantiate the Presentation class that represents a presentation file (PPT, PPTX, ODP, etc.).
Presentation presentation = new Presentation("presentation.pptx");
try {
TiffOptions tiffOptions = new TiffOptions();
tiffOptions.setPixelFormat(ImagePixelFormat.Format8bppIndexed);
/*
ImagePixelFormat contains the following values (as stated in the documentation):
Format1bppIndexed - 1 bit per pixel, indexed.
Format4bppIndexed - 4 bits per pixel, indexed.
Format8bppIndexed - 8 bits per pixel, indexed.
Format24bppRgb - 24 bits per pixel, RGB.
Format32bppArgb - 32 bits per pixel, ARGB.
*/
// Save the presentation as TIFF with the specified pixel format.
presentation.save("Tiff-PixelFormat.tiff", SaveFormat.Tiff, tiffOptions);
} finally {
presentation.dispose();
}
```
Check out Aspose's [FREE PowerPoint to Poster converter](https://products.aspose.app/slides/conversion/convert-ppt-to-poster-online).
## **FAQ**
**Can I convert an individual slide instead of entire PowerPoint presentation to TIFF?**
Yes. Aspose.Slides allows you to convert individual slides from PowerPoint and OpenDocument presentations into TIFF images separately.
**Is there any limit to the number of slides when converting a presentation to TIFF?**
No, Aspose.Slides does not impose any restrictions on the number of slides. You can convert presentations of any size into TIFF format.
**Are PowerPoint animations and transition effects preserved when converting slides to TIFF?**
No, TIFF is a static image format. Therefore, animations and transition effects are not preserved; only static snapshots of slides are exported.
## Related articles
- [Convert Presentation Slides to Images in Java](https://docs.aspose.com/slides/java/convert-slide/)
# Convert PowerPoint Presentations to Video in Java
> Learn how to convert PowerPoint presentations to video in Java. Discover sample code and automation techniques to streamline your workflow.
Source: https://docs.aspose.com/slides/java/convert-powerpoint-to-video/
Updated: 2026-11-08
## **Introduction**
By converting your PowerPoint or OpenDocument presentation to video, you gain:
**Increased accessibility:** All devices, regardless of platform, are equipped with video players by default, making it easier for users to open or play videos compared to traditional presentation applications.
**Wider reach:** Videos enable you to reach a larger audience and present information in a more engaging format. Surveys and statistics indicate that people prefer to watch and consume video content over other forms, making your message more impactful.
You may want to check our [**PowerPoint to Video Online Converter**](https://products.aspose.app/slides/video) because it is a live and effective implementation of the process described here.
## **PowerPoint to Video Conversion in Aspose.Slides**
In [Aspose.Slides 22.11](https://docs.aspose.com/slides/java/aspose-slides-for-java-22-11-release-notes/), we implemented support for presentation to video conversion.
* Use **Aspose.Slides** to generate a set of frames (from the presentation slides) that correspond to a certain FPS (frames per second)
* Use a third-party utility like **ffmpeg** ([for java](https://github.com/bramp/ffmpeg-cli-wrapper)) to create a video based on the frames.
### **Convert PowerPoint to Video**
1. Add this to your POM file:
```xml
net.bramp.ffmpegffmpeg0.7.0
```
2. Download ffmpeg [here](https://ffmpeg.org/download.html).
4. Run the PowerPoint to video Java code.
This Java code shows you how to convert a presentation (containing a figure and two animation effects) to a video:
```java
import com.aspose.slides.*;
import java.io.IOException;
import java.util.ArrayList;
Presentation presentation = new Presentation();
try {
// Adds a smile shape and then animates it
IAutoShape smile = presentation.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.SmileyFace, 110, 20, 500, 500);
ISequence mainSequence = presentation.getSlides().get_Item(0).getTimeline().getMainSequence();
IEffect effectIn = mainSequence.addEffect(smile, EffectType.Fly, EffectSubtype.TopLeft, EffectTriggerType.AfterPrevious);
IEffect effectOut = mainSequence.addEffect(smile, EffectType.Fly, EffectSubtype.BottomRight, EffectTriggerType.AfterPrevious);
effectIn.getTiming().setDuration(2f);
effectOut.setPresetClassType(EffectPresetClassType.Exit);
final int fps = 33;
ArrayList frames = new ArrayList();
PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation);
try
{
PresentationPlayer player = new PresentationPlayer(animationsGenerator, fps);
try {
player.setFrameTick((sender, arguments) ->
{
try {
String frame = String.format("frame_%04d.png", sender.getFrameIndex());
arguments.getFrame().save(frame, ImageFormat.Png);
frames.add(frame);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
animationsGenerator.run(presentation.getSlides());
} finally {
if (player != null) player.dispose();
}
} finally {
if (animationsGenerator != null) animationsGenerator.dispose();
}
// Configure ffmpeg binaries folder. See this page: https://github.com/rosenbjerg/FFMpegCore#installation
FFmpeg ffmpeg = new FFmpeg("path/to/ffmpeg");
FFprobe ffprobe = new FFprobe("path/to/ffprobe");
FFmpegBuilder builder = new FFmpegBuilder()
.addExtraArgs("-start_number", "1")
.setInput("frame_%04d.png")
.addOutput("output.avi")
.setVideoFrameRate(FFmpeg.FPS_24)
.setFormat("avi")
.done();
FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);
executor.createJob(builder).run();
} catch (IOException e) {
e.printStackTrace();
}
```
## **Video Effects**
You can apply animations to objects on slides and use transitions between slides.
You may want to see these articles: [PowerPoint Animation](https://docs.aspose.com/slides/java/powerpoint-animation/), [Shape Animation](https://docs.aspose.com/slides/java/shape-animation/), and [Shape Effect](https://docs.aspose.com/slides/java/shape-effect/).
Animations and transitions make slideshows more engaging and interesting—and they do the same thing for videos. Let's add another slide and transition to the code for the previous presentation:
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try {
// Adds a smile shape and animates it
// ...
// Adds a new slide and animated transition
ISlide newSlide = presentation.getSlides().addEmptySlide(presentation.getSlides().get_Item(0).getLayoutSlide());
newSlide.getBackground().setType(BackgroundType.OwnBackground);
newSlide.getBackground().getFillFormat().setFillType(FillType.Solid);
newSlide.getBackground().getFillFormat().getSolidFillColor().setColor(Color.MAGENTA);
newSlide.getSlideShowTransition().setType(TransitionType.Push);
} finally {
if (presentation != null) presentation.dispose();
}
```
Aspose.Slides also supports animation for texts. So we animate paragraphs on objects, which will appear one after the other (with the delay set to a second):
```java
import com.aspose.slides.*;
import java.io.IOException;
import java.util.ArrayList;
Presentation presentation = new Presentation();
try {
// Adds text and animations
IAutoShape autoShape = presentation.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 210, 120, 300, 300);
Paragraph para1 = new Paragraph();
para1.getPortions().add(new Portion("Aspose Slides for Java"));
Paragraph para2 = new Paragraph();
para2.getPortions().add(new Portion("convert PowerPoint Presentation with text to video"));
Paragraph para3 = new Paragraph();
para3.getPortions().add(new Portion("paragraph by paragraph"));
IParagraphCollection paragraphCollection = autoShape.getTextFrame().getParagraphs();
paragraphCollection.add(para1);
paragraphCollection.add(para2);
paragraphCollection.add(para3);
paragraphCollection.add(new Paragraph());
ISequence mainSequence = presentation.getSlides().get_Item(0).getTimeline().getMainSequence();
IEffect effect1 = mainSequence.addEffect(para1, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
IEffect effect2 = mainSequence.addEffect(para2, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
IEffect effect3 = mainSequence.addEffect(para3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
effect1.getTiming().setTriggerDelayTime(1f);
effect2.getTiming().setTriggerDelayTime(1f);
effect3.getTiming().setTriggerDelayTime(1f);
final int fps = 33;
ArrayList frames = new ArrayList();
PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation);
try
{
PresentationPlayer player = new PresentationPlayer(animationsGenerator, fps);
try {
player.setFrameTick((sender, arguments) ->
{
try {
String frame = String.format("frame_%04d.png", sender.getFrameIndex());
arguments.getFrame().save(frame, ImageFormat.Png);
frames.add(frame);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
animationsGenerator.run(presentation.getSlides());
} finally {
if (player != null) player.dispose();
}
} finally {
if (animationsGenerator != null) animationsGenerator.dispose();
}
// Configure ffmpeg binaries folder. See this page: https://github.com/rosenbjerg/FFMpegCore#installation
FFmpeg ffmpeg = new FFmpeg("path/to/ffmpeg");
FFprobe ffprobe = new FFprobe("path/to/ffprobe");
FFmpegBuilder builder = new FFmpegBuilder()
.addExtraArgs("-start_number", "1")
.setInput("frame_%04d.png")
.addOutput("output.avi")
.setVideoFrameRate(FFmpeg.FPS_24)
.setFormat("avi")
.done();
FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);
executor.createJob(builder).run();
} catch (IOException e) {
e.printStackTrace();
}
```
## **Video Conversion Classes**
To allow you to perform PowerPoint to video conversion tasks, Aspose.Slides provides the [PresentationAnimationsGenerator](https://reference.aspose.com/slides/java/com.aspose.slides/presentationanimationsgenerator/) and [PresentationPlayer](https://reference.aspose.com/slides/java/com.aspose.slides/presentationplayer/) classes.
[PresentationAnimationsGenerator](https://reference.aspose.com/slides/java/com.aspose.slides/presentationanimationsgenerator/) allows you to set the frame size for the video (that will be created later) through its constructor. If you pass an instance of the presentation, `Presentation.SlideSize` will be used and it generates animations that [PresentationPlayer](https://reference.aspose.com/slides/java/com.aspose.slides/presentationplayer/) uses.
When animations are generated, a `NewAnimation` event is generated for each subsequent animation, which has the [IPresentationAnimationPlayer](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentationanimationplayer/) parameter. The latter is a class that represents a player for a separate animation.
[](https://docs.aspose.com/slides/java/convert-powerpoint-to-video/visual-convert-powerpoint-to-video-f34cee01f867.svg)
*Conceptual pipeline with matched rates for intended pacing. The article’s samples configure rendering at 33 FPS but request AVI output at 24 FPS. Coordinate the encoder’s image-sequence input and output rates with the rendered frames; this diagram does not measure those samples’ resulting playback.*
To work with [IPresentationAnimationPlayer](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentationanimationplayer/), the [Duration](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentationanimationplayer/#getDuration--) (the full duration of the animation) property and [SetTimePosition](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentationanimationplayer/#setTimePosition-double-) method are used. Each animation position is set within the *0 to duration* range, and then the `getFrame` method will return an [IImage](https://reference.aspose.com/slides/java/com.aspose.slides/iimage/) that corresponds to the animation state at that moment:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
// Adds a smile shape and animates it
IAutoShape smile = presentation.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.SmileyFace, 110, 20, 500, 500);
ISequence mainSequence = presentation.getSlides().get_Item(0).getTimeline().getMainSequence();
IEffect effectIn = mainSequence.addEffect(smile, EffectType.Fly, EffectSubtype.TopLeft, EffectTriggerType.AfterPrevious);
IEffect effectOut = mainSequence.addEffect(smile, EffectType.Fly, EffectSubtype.BottomRight, EffectTriggerType.AfterPrevious);
effectIn.getTiming().setDuration(2f);
effectOut.setPresetClassType(EffectPresetClassType.Exit);
PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation);
try {
animationsGenerator.setNewAnimation(animationPlayer ->
{
System.out.println(String.format("Animation total duration: %f", animationPlayer.getDuration()));
animationPlayer.setTimePosition(0); // initial animation state
// initial animation state bitmap
animationPlayer.getFrame().save("firstFrame.png", ImageFormat.Png);
animationPlayer.setTimePosition(animationPlayer.getDuration()); // final state of the animation
// last frame of the animation
animationPlayer.getFrame().save("lastFrame.png", ImageFormat.Png);
});
// generate the animations - this is what raises the events handled above
animationsGenerator.run(presentation.getSlides());
} finally {
if (animationsGenerator != null) animationsGenerator.dispose();
}
} finally {
if (presentation != null) presentation.dispose();
}
```
To make all animations in a presentation play at once, the [PresentationPlayer](https://reference.aspose.com/slides/java/com.aspose.slides/presentationplayer/) class is used. This class takes a [PresentationAnimationsGenerator](https://reference.aspose.com/slides/java/com.aspose.slides/presentationanimationsgenerator/) instance and FPS for effects in its constructor and then calls the `FrameTick` event for all the animations to get them played:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("animated.pptx");
try {
PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation);
try {
PresentationPlayer player = new PresentationPlayer(animationsGenerator, 33);
try {
player.setFrameTick((sender, arguments) ->
{
arguments.getFrame().save("frame_" + sender.getFrameIndex() + ".png", ImageFormat.Png);
});
animationsGenerator.run(presentation.getSlides());
} finally {
if (player != null) player.dispose();
}
} finally {
if (animationsGenerator != null) animationsGenerator.dispose();
}
} finally {
if (presentation != null) presentation.dispose();
}
```
Then the generated frames can be compiled to produce a video. See the [Convert PowerPoint to Video](https://docs.aspose.com/slides/java/convert-powerpoint-to-video/#convert-powerpoint-to-video) section.
## **Supported Animations and Effects**
**Entrance**:
| Animation Type | Aspose.Slides | PowerPoint |
|---|---|---|
| **Appear** |  |  |
| **Fade** |  |  |
| **Fly In** |  |  |
| **Float In** |  |  |
| **Split** |  |  |
| **Wipe** |  |  |
| **Shape** |  |  |
| **Wheel** |  |  |
| **Random Bars** |  |  |
| **Grow & Turn** |  |  |
| **Zoom** |  |  |
| **Swivel** |  |  |
| **Bounce** |  |  |
**Emphasis**:
| Animation Type | Aspose.Slides | PowerPoint |
|---|---|---|
| **Pulse** |  |  |
| **Color Pulse** |  |  |
| **Teeter** |  |  |
| **Spin** |  |  |
| **Grow/Shrink** |  |  |
| **Desaturate** |  |  |
| **Darken** |  |  |
| **Lighten** |  |  |
| **Transparency** |  |  |
| **Object Color** |  |  |
| **Complementary Color** |  |  |
| **Line Color** |  |  |
| **Fill Color** |  |  |
**Exit**:
| Animation Type | Aspose.Slides | PowerPoint |
|---|---|---|
| **Disappear** |  |  |
| **Fade** |  |  |
| **Fly Out** |  |  |
| **Float Out** |  |  |
| **Split** |  |  |
| **Wipe** |  |  |
| **Shape** |  |  |
| **Random Bars** |  |  |
| **Shrink & Turn** |  |  |
| **Zoom** |  |  |
| **Swivel** |  |  |
| **Bounce** |  |  |
**Motion Paths:**
| Animation Type | Aspose.Slides | PowerPoint |
|---|---|---|
| **Lines** |  |  |
| **Arcs** |  |  |
| **Turns** |  |  |
| **Shapes** |  |  |
| **Loops** |  |  |
| **Custom Path** |  |  |
## **FAQ**
### Is it possible to convert presentations that are password protected?
Yes, Aspose.Slides allows working with [password-protected presentations](https://docs.aspose.com/slides/java/password-protected-presentation/). When processing such files, you need to provide the correct password so that the library can access the content of the presentation.
### Does Aspose.Slides support usage in cloud solutions?
Yes, Aspose.Slides can be integrated into cloud applications and services. The library is designed to work in server environments, ensuring high performance and scalability for batch processing of files.
### Are there any size limitations for presentations during conversion?
Aspose.Slides is capable of handling presentations of virtually any size. However, when working with very large files, additional system resources may be required, and it is sometimes recommended to optimize the presentation to improve performance.
# Convert PowerPoint Presentations to Word Documents in Java
> Convert PowerPoint PPT and PPTX slides to editable Word documents in Java using Aspose.Slides with precise layout, images and formatting preserved.
Source: https://docs.aspose.com/slides/java/convert-powerpoint-to-word/
Updated: 2026-08-05
## **Overview**
This article provides a solution for developers on converting PowerPoint and OpenDocument presentations to Word documents using Aspose.Slides and Aspose.Words. The step-by-step guide walks you through every stage of the conversion process.
## **Convert PowerPoint to Word**
Follow the instructions below to convert a PowerPoint or OpenDocument presentation to a Word document:
1. Download [Aspose.Slides for Java](https://downloads.aspose.com/slides/java) and [Aspose.Words for Java](https://downloads.aspose.com/words/java) libraries.
2. Add *aspose-slides-x.x-jdk16.jar* and *aspose-words-x.x-jdk16.jar* to your CLASSPATH.
3. Use this code snippet to convert the PowerPoint to Word:
```java
import com.aspose.slides.*;
import com.aspose.words.*;
import java.io.ByteArrayOutputStream;
Presentation pres = new Presentation("sample.pptx");
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
for (ISlide slide : pres.getSlides()) {
// generates a slide image as a byte array stream
IImage image = slide.getImage(1, 1);
ByteArrayOutputStream imageStream = new ByteArrayOutputStream();
image.save(imageStream, ImageFormat.Png);
image.dispose();
builder.insertImage(imageStream.toByteArray());
// inserts slide's texts
for (IShape shape : slide.getShapes()) {
if (shape instanceof AutoShape) {
builder.writeln(((AutoShape) shape).getTextFrame().getText());
}
}
builder.insertBreak(BreakType.PAGE_BREAK);
}
doc.save("output.docx");
pres.dispose();
```
## **FAQ**
### What components need to be installed to convert PowerPoint and OpenDocument presentations to Word documents?
You only need to add the respective package for [Aspose.Slides for Java](https://releases.aspose.com/slides/java/) and [Aspose.Words for Java](https://releases.aspose.com/words/java/) to your project. Both libraries operate as standalone APIs, and there is no requirement for Microsoft Office to be installed.
### Are all PowerPoint and OpenDocument presentation formats supported?
Aspose.Slides [supports all presentation formats](https://docs.aspose.com/slides/java/supported-file-formats/), including PPT, PPTX, ODP, and other common file types. This ensures that you can work with presentations created in various versions of Microsoft PowerPoint.
# Convert PowerPoint Presentations to XML in Java
> Convert PowerPoint and OpenDocument presentations to PowerPoint XML files or streams in Java with Aspose.Slides for Java.
Source: https://docs.aspose.com/slides/java/convert-powerpoint-to-xml/
Updated: 2026-09-29
## **Overview**
Aspose.Slides for Java can convert PowerPoint presentations to the PowerPoint XML Presentation format. XML output is useful when you need a text-based representation for inspecting presentation structure, troubleshooting generated documents, comparing output in automated tests, or integrating with a workflow that consumes XML instead of a presentation package.
Use the [Presentation.save](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#save-java.lang.String-int-) method with the `Xml` value from the [SaveFormat](https://reference.aspose.com/slides/java/com.aspose.slides/saveformat/) class. You can write the result directly to a file or to a stream.
`SaveFormat.Xml` creates a PowerPoint XML Presentation. It does not extract the individual Office Open XML parts stored inside a PPTX package. If you need the exact PPTX package parts, such as `ppt/presentation.xml` or individual slide XML files, inspect the PPTX package itself.
## **Convert a Presentation to an XML File**
Load a source presentation with the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class, and then pass the output path and `SaveFormat.Xml` to [Presentation.save](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#save-java.lang.String-int-). The source can be any presentation format supported for loading, such as PPT, PPTX, or ODP.
The following example converts a PPTX presentation to an XML file:
```java
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
Presentation presentation = new Presentation("presentation.pptx");
try {
presentation.save("presentation.xml", SaveFormat.Xml);
} finally {
presentation.dispose();
}
```
## **Write the XML Output to a Stream**
Use the stream overload of [Presentation.save](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#save-java.io.OutputStream-int-) when the XML must remain in memory or be passed to another component, such as a web service, storage provider, or XML processing pipeline. The following example writes the result to a [ByteArrayOutputStream](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/io/ByteArrayOutputStream.html) and obtains the resulting XML as a byte array:
```java
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
import java.io.ByteArrayOutputStream;
Presentation presentation = new Presentation("presentation.pptx");
try (ByteArrayOutputStream xmlStream = new ByteArrayOutputStream()) {
presentation.save(xmlStream, SaveFormat.Xml);
byte[] xmlData = xmlStream.toByteArray();
// Pass xmlData to the next component in the workflow.
} finally {
presentation.dispose();
}
```
## **Compare XML with Presentation and Export Formats**
Choose the output format according to how the result will be used:
| Format | Output | Typical use |
| --- | --- | --- |
| PowerPoint XML (`.xml`) | A PowerPoint XML Presentation | Inspecting structure, troubleshooting, comparing generated output, and XML-based integration |
| PPT (`.ppt`) | A legacy binary presentation file | Compatibility with older PowerPoint workflows |
| PPTX (`.pptx`) | An Office Open XML package containing multiple parts | Regular PowerPoint editing and presentation exchange |
| PDF or TIFF | Fixed-layout pages or a multi-page image | Viewing, printing, and archiving |
| PNG, JPEG, or SVG | A rendered representation of an individual slide | Thumbnails, previews, and image assets |
| HTML or HTML5 | Web-oriented presentation output | Browser viewing and web publishing |
Unlike PPT and PPTX, XML output is primarily intended for inspection and data-oriented workflows. Unlike PDF, TIFF, HTML, and slide image formats, it represents presentation data rather than rendering slides as pages or visual assets. The [supported file formats](https://docs.aspose.com/slides/java/supported-file-formats/) table lists every format that Aspose.Slides can load, import, save, or render.
## **FAQ**
**Is `SaveFormat.Xml` the same as saving a PPTX file?**
No. PPTX is a package containing multiple Office Open XML parts, whereas `SaveFormat.Xml` creates a PowerPoint XML Presentation file.
**Can I save the XML output without creating a file on disk?**
Yes. Pass a writable stream to [Presentation.save](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#save-java.io.OutputStream-int-). For example, use a [ByteArrayOutputStream](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/io/ByteArrayOutputStream.html) for in-memory processing.
**Can Aspose.Slides load the exported XML file again?**
Yes. Pass the XML file or a stream to the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#Presentation-java.lang.String-) constructor. [Presentation.getSourceFormat](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#getSourceFormat--) then returns `SourceFormat.Xml`. [PresentationFactory.getPresentationInfo](https://reference.aspose.com/slides/java/com.aspose.slides/presentationfactory/#getPresentationInfo-java.lang.String-) reports `LoadFormat.Unknown` for this format, so do not use it to decide whether an XML file can be opened.
**Does XML conversion render each slide as a page or image?**
No. XML conversion writes structured presentation data. Use PDF or TIFF for page-oriented output, or PNG, JPEG, and SVG for individual slide images.
# Convert PowerPoint Presentations to XPS in Java
> Convert PowerPoint PPT/PPTX to high-quality, platform-independent XPS in Java using Aspose.Slides. Get step-by-step guide and sample code.
Source: https://docs.aspose.com/slides/java/convert-powerpoint-to-xps/
Updated: 2026-08-13
## **Overview**
Aspose.Slides allows you to convert PowerPoint presentations to XPS by saving a PPT or PPTX file in the XPS format. This article explains when the XPS format may be useful and shows how to perform the conversion with Aspose.Slides using either default settings or custom [XpsOptions](https://reference.aspose.com/slides/java/com.aspose.slides/xpsoptions/) settings.
## **About XPS**
Microsoft developed [XPS](https://docs.fileformat.com/page-description-language/xps/) as an alternative to [PDF](https://docs.fileformat.com/pdf/). It allows you to print content by outputting a file very similar to a PDF. The XPS format is based on XML. The layout or structure of an XPS file remains the same on all operating systems and printers.
## **When to Use Microsoft XPS Format**
To see how Aspose.Slides converts PPT or PPTX presentation to the XPS format, you can check out [this free online converter app](https://products.aspose.app/slides/conversion).
If you want to cut down on storage costs, you can convert your Microsoft PowerPoint presentation to the XPS format. This way, you will find it easier to save, share, and print your documents.
Microsoft continues to implement strong support for XPS in Windows (even in Windows 10), so you may want to consider saving files to this format. If you are dealing with Windows 8.1, Windows 8, Windows 7, and Windows Vista, then XPS might actually be your best option for certain operations.
- **Windows 8** uses the OXPS (Open XPS) format for XPS files. OXPS is a standardized version of the original XPS format. Windows 8 provides better support for XPS files than it does for PDF files.
- **XPS:** Built-in XPS viewer/reader and printing to XPS feature available.
- **PDF**: PDF reader available but no printing to PDF feature.
- **Windows 7 and Windows Vista** use the original XPS format. These operating systems also provide better support for XPS files than they do for PDFs.
- **XPS**: Built-in XPS viewer and printing to XPS feature available.
- **PDF**: No PDF reader. No printing to PDF feature.
|
|
| :- | :- |
Microsoft eventually implemented support for printing operations in PDF through the Print to PDF feature in Windows 10. Previously, users were expected to print documents through the XPS format.
## **XPS Conversion with Aspose.Slides**
In [**Aspose.Slides**](https://products.aspose.com/slides/java/) for Java, you can use the [**Save**](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation#save-java.lang.String-int-com.aspose.slides.ISaveOptions-) method exposed by the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class to convert the entire presentation into an XPS document.
When converting a presentation to XPS, you have to save the presentation using either of these settings:
- Default settings (without [**XPSOptions**](https://reference.aspose.com/slides/java/com.aspose.slides/xpsoptions))
- Custom settings (with [**XPSOptions**](https://reference.aspose.com/slides/java/com.aspose.slides/xpsoptions))
### **Convert Presentations to XPS Using Default Settings**
This sample code in Java shows you how to convert a presentation to an XPS document using standard settings:
```java
import com.aspose.slides.*;
// Instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation("Convert_XPS.pptx");
try {
// Saving the presentation to XPS document
pres.save("XPS_Output_Without_XPSOption.xps", SaveFormat.Xps);
} finally {
if (pres != null) pres.dispose();
}
```
### **Convert Presentations to XPS Using Custom Settings**
This sample code shows you how to convert a presentation to an XPS document using custom settings in Java:
```java
import com.aspose.slides.*;
// Instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation("Convert_XPS_Options.pptx");
try {
// Instantiate the XpsOptions class
XpsOptions options = new XpsOptions();
// Save MetaFiles as PNG
options.setSaveMetafilesAsPng(true);
// Save the presentation to XPS document
pres.save("XPS_Output_With_Options.xps", SaveFormat.Xps, options);
} finally {
if (pres != null) pres.dispose();
}
```
## **FAQ**
### Can I save to XPS into a stream instead of a file?
Yes—Aspose.Slides lets you export directly to a stream, which is ideal for web APIs, server-side pipelines, or any scenario where you want to send the XPS without touching the file system.
### Are hidden slides carried over to XPS, and can I exclude them?
By default, only regular (visible) slides are rendered. You can [include or exclude hidden slides](https://reference.aspose.com/slides/java/com.aspose.slides/xpsoptions/#setShowHiddenSlides-boolean-) through [export settings](https://reference.aspose.com/slides/java/com.aspose.slides/xpsoptions/) before saving to XPS, ensuring the output contains exactly the pages you intend.
# Convert PowerPoint Presentations in Java | HTML, PNG, PDF, Word, TIFF
> Convert PowerPoint presentations to other formats using Aspose.Slides for Java. Fast, accurate, and seamless PPT and PPTX conversion.
Source: https://docs.aspose.com/slides/java/convert-powerpoint/
Updated: 2025-11-17
---
lastmod: 2025-11-17T20:34:00+04:00
title: Convert PowerPoint Presentations in Java | HTML, PNG, PDF, Word, TIFF
linktitle: Convert PowerPoint
type: docs
weight: 20
url: /java/convert-powerpoint/
keywords:
- convert PowerPoint
- convert presentation
- convert slide
- convert PPT
- convert PPTX
- export PowerPoint
- export presentation
- export slide
- export PPT
- export PPTX
- Java
- Aspose.Slides
description: "Convert PowerPoint presentations to other formats using Aspose.Slides for Java. Fast, accurate, and seamless PPT and PPTX conversion."
---
## Related articles
- [Convert OpenDocument Presentations in Java](https://docs.aspose.com/slides/java/convert-openoffice-odp/)
- [Convert PPTX to PPT in Java](https://docs.aspose.com/slides/java/convert-pptx-to-ppt/)
# Convert PPT to PPTX in Java
> Convert legacy PPT files to PPTX in Java with Aspose.Slides. Includes Java examples for single-file and batch conversion, error handling, and fidelity notes.
Source: https://docs.aspose.com/slides/java/convert-ppt-to-pptx/
Updated: 2026-08-25
## **Overview**
PPT is the legacy binary PowerPoint format, while PPTX is the newer Open XML format. Aspose.Slides for Java can load a PPT file and save it as PPTX without Microsoft PowerPoint. This article shows how to convert one file or a directory of files and explains what to verify after conversion.
## **Convert a PPT File to PPTX**
Load the source file with the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class, then call [Presentation.save](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#save-java.lang.String-int-) with [SaveFormat.Pptx](https://reference.aspose.com/slides/java/com.aspose.slides/saveformat/#Pptx). The `finally` block disposes the presentation and releases its resources.
```java
// Load the legacy PPT presentation.
com.aspose.slides.Presentation presentation = new com.aspose.slides.Presentation("presentation.ppt");
try {
// Save the presentation in PPTX format.
presentation.save("presentation.pptx", com.aspose.slides.SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The file extension does not select the output format by itself; the [SaveFormat.Pptx](https://reference.aspose.com/slides/java/com.aspose.slides/saveformat/#Pptx) argument does. Keep the input and output paths different if you need to retain the original PPT file.
## **Convert Multiple PPT Files**
The following example converts every `.ppt` file in one directory. Each file is processed independently, so one failed conversion does not stop the rest of the batch.
```java
java.io.File inputDirectory = new java.io.File("input");
java.io.File outputDirectory = new java.io.File("output");
if (!outputDirectory.exists() && !outputDirectory.mkdirs()) {
throw new IllegalStateException("Cannot create the output directory: " + outputDirectory);
}
java.io.File[] inputFiles = inputDirectory.listFiles((directory, name) -> name.toLowerCase(java.util.Locale.ROOT).endsWith(".ppt"));
if (inputFiles == null) {
throw new IllegalStateException("Cannot read the input directory: " + inputDirectory);
}
for (java.io.File inputFile : inputFiles) {
String inputPath = inputFile.getPath();
String fileName = inputFile.getName();
String outputFileName = fileName.substring(0, fileName.length() - 4) + ".pptx";
String outputPath = new java.io.File(outputDirectory, outputFileName).getPath();
com.aspose.slides.Presentation presentation = null;
try {
presentation = new com.aspose.slides.Presentation(inputPath);
presentation.save(outputPath, com.aspose.slides.SaveFormat.Pptx);
System.out.println("Converted: " + inputPath);
} catch (Exception exception) {
System.err.println("Failed: " + inputPath + " (" + exception.getMessage() + ")");
} finally {
if (presentation != null) {
presentation.dispose();
}
}
}
```
For production workloads, log the complete exception, decide whether an existing output file may be overwritten, and write failed file names to a retry or review queue. Corrupt files, password-protected files opened without the required password, inaccessible paths, and unsupported content can all cause a conversion to fail. See [Password-Protected Presentations](https://docs.aspose.com/slides/java/password-protected-presentation/) for loading encrypted files.
## **Fidelity and Legacy Features**
Conversion normally preserves slides, masters, layouts, text, shapes, images, tables, and charts. However, PPT and PPTX do not represent every feature in exactly the same way. A legacy feature that has no PPTX equivalent, or is not supported by the library, may be normalized, omitted, or displayed differently.
Check the converted file when it contains animations, transitions, embedded or linked OLE objects, ActiveX controls, embedded media, uncommon fonts, or VBA macros. A plain PPTX file is not a macro-enabled format, so use an appropriate macro-enabled workflow when VBA must remain available. Also verify that required fonts and external resources are present in the environment where the converted presentation will be opened or rendered.
For important documents, reopen the generated PPTX programmatically and inspect key slide counts and content, then compare its appearance and slide-show behavior in the intended viewer. Do not treat a successful [Presentation.save](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#save-java.lang.String-int-) call as proof that every legacy feature has an exact PPTX representation.
## **When to Use PPTX**
Use PPTX when the presentation will be edited in current PowerPoint versions, exchanged with systems that work with Open XML packages, or stored in a format that is easier to inspect and recover than legacy binary PPT. Keep the original PPT as an archival or rollback copy until the converted presentation has passed your fidelity checks.
If you need PDF, HTML, images, XPS, or another output type instead, use the format-specific guidance in [Convert Presentations to Multiple Formats](https://docs.aspose.com/slides/java/convert-presentation/) rather than assuming that all targets preserve editable PowerPoint features.
## **Online Converter**
For an occasional file or a quick comparison, you can use the [online PPT to PPTX converter](https://products.aspose.app/slides/conversion/ppt-to-pptx). For repeatable conversions, batch processing, or application-level error handling, use the Java API.
## **Related Articles**
- [PPT vs PPTX](https://docs.aspose.com/slides/java/ppt-vs-pptx/)
- [Save Presentations in Java](https://docs.aspose.com/slides/java/save-presentation/)
- [Supported File Formats](https://docs.aspose.com/slides/java/supported-file-formats/)
- [Open Presentations in Java](https://docs.aspose.com/slides/java/open-presentation/)
## **FAQ**
**Can I convert PPT to PPTX without Microsoft PowerPoint installed?**
Yes. Aspose.Slides for Java loads and saves presentation files without requiring Microsoft PowerPoint.
**Will PPT-to-PPTX conversion preserve all content exactly?**
It preserves common presentation content, but exact fidelity is not guaranteed for every legacy or unsupported feature. Review the generated file when it contains macros, OLE or ActiveX objects, media, specialized animations, or uncommon fonts.
**Can I convert a password-protected PPT file?**
Yes, if you supply the correct password when loading the file. A missing or incorrect password causes the load operation to fail.
**Should I delete the PPT file after conversion?**
Keep the original until you have verified the PPTX in the viewers and workflows that matter to you. This provides a rollback copy if a legacy feature converts differently.
## Related articles
- [PPT to PPTX conversion](https://docs.aspose.com/slides/java/ppt-to-pptx-conversion/)
# Convert PPTX to PPT in Java
> Easily convert PPTX to PPT with Aspose.Slides for Java—ensure seamless compatibility with PowerPoint formats while preserving your presentation’s layout and quality.
Source: https://docs.aspose.com/slides/java/convert-pptx-to-ppt/
Updated: 2026-08-05
## **Overview**
This article explains how to convert PowerPoint Presentation in PPTX format into PPT format using Java. The following topic is covered.
- Convert PPTX to PPT in Java
## **Convert PPTX to PPT in Java**
For Java sample code to convert PPTX to PPT, please see the section below i.e. [Convert PPTX to PPT](https://docs.aspose.com/slides/java/convert-pptx-to-ppt/#convert-pptx-to-ppt). It just loads the PPTX file and saves in PPT format. By specifiying different save formats, you can also save PPTX file into many other formats like PDF, XPS, ODP, HTML etc. as disscussed in these articles.
- [Convert PPTX to PDF in Java](https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf/)
- [Convert PPTX to XPS in Java](https://docs.aspose.com/slides/java/convert-powerpoint-to-xps/)
- [Convert PPTX to HTML in Java](https://docs.aspose.com/slides/java/convert-powerpoint-to-html/)
- [Convert PPTX to ODP in Java](https://docs.aspose.com/slides/java/save-presentation/)
- [Convert PPTX to PNG in Java](https://docs.aspose.com/slides/java/convert-powerpoint-to-png/)
## **Convert PPTX to PPT**
To convert a PPTX to PPT simply pass the file name and save format to the **Save** method of [**Presentation**](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class. The Java code sample below converts a Presentation from PPTX to PPT using default options.
```java
import com.aspose.slides.*;
// instantiate a Presentation object that represents a PPTX file
Presentation presentation = new Presentation("template.pptx");
// save the presentation as PPT
presentation.save("output.ppt", SaveFormat.Ppt);
```
## **FAQ**
### Do all PPTX effects and features survive when saving to the legacy PPT (97–2003) format?
Not always. The PPT format lacks some newer capabilities (e.g., certain effects, objects, and behaviors), so features may be simplified or rasterized during conversion.
### Can I convert only selected slides to PPT instead of the entire presentation?
Direct saving targets the whole presentation. To convert specific slides, create a new presentation with just those slides and save it as PPT; alternatively, use a service/API that supports per-slide conversion parameters.
### Are password-protected presentations supported?
Yes. You can detect whether a file is protected, open it with a password, and also [configure protection/encryption settings](https://docs.aspose.com/slides/java/password-protected-presentation/) for the saved PPT.
## Related articles
- [Convert PowerPoint Presentations in Java | HTML, PNG, PDF, Word, TIFF](https://docs.aspose.com/slides/java/convert-powerpoint/)
# Convert Presentations to Multiple Formats in Java
> Convert PowerPoint and OpenDocument presentations to PPTX, PDF, HTML, images, XPS, TIFF, and more with Aspose.Slides for Java.
Source: https://docs.aspose.com/slides/java/convert-presentation/
Updated: 2026-09-01
## **Overview**
Aspose.Slides for Java can load PowerPoint and OpenDocument presentations and save or render them to many other formats without Microsoft PowerPoint, OpenOffice, or LibreOffice. You can convert legacy PPT files to modern PPTX, export presentations to fixed-layout documents such as PDF and XPS, publish slides as HTML, or render slides as image files for previews, thumbnails, and archives.
Most document conversions use the same general workflow: load the source file, choose the required output format, and apply format-specific options when needed. For image formats, each slide is rendered separately and then saved as a raster or vector image. The dedicated articles linked below provide the implementation details for each case.
## **Choose a Conversion Scenario**
Use the articles below for complete Java examples and format-specific options.
| Scenario | Use it when you need to | Article |
| --- | --- | --- |
| PPT/PPTX/ODP to PPTX | Modernize legacy PPT files, normalize existing PPTX files, or convert OpenDocument presentations to PowerPoint PPTX. | [Convert PPT to PPTX](https://docs.aspose.com/slides/java/convert-ppt-to-pptx/), [Convert ODP to PPTX](https://docs.aspose.com/slides/java/convert-odp-to-pptx/), [Save Presentations](https://docs.aspose.com/slides/java/save-presentation/) |
| PPTX to PPT | Save a modern PowerPoint presentation to the older binary PPT format for compatibility with older workflows. | [Convert PPTX to PPT](https://docs.aspose.com/slides/java/convert-pptx-to-ppt/) |
| PPT/PPTX/ODP to PDF | Create portable, searchable, fixed-layout documents for sharing, printing, or archiving. | [Convert PowerPoint to PDF](https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf/) |
| PPT/PPTX/ODP to PDF with notes | Export speaker notes together with slide content. | [Convert PowerPoint to PDF with Notes](https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf-with-notes/) |
| PPT/PPTX/ODP to HTML | Publish presentations as HTML pages and control images, fonts, notes, and responsive layout options. | [Convert PowerPoint to HTML](https://docs.aspose.com/slides/java/convert-powerpoint-to-html/) |
| PPT/PPTX/ODP to HTML5 | Export slides to HTML5 for browser-based viewing with preserved formatting and interactivity. | [Convert Presentations to HTML5](https://docs.aspose.com/slides/java/export-to-html5/) |
| PPT/PPTX/ODP to PNG | Render each slide to a PNG image for previews, thumbnails, or web output. | [Convert PowerPoint to PNG](https://docs.aspose.com/slides/java/convert-powerpoint-to-png/) |
| PPT/PPTX/ODP to JPG | Render slides to JPG images and control image dimensions and quality. | [Convert PowerPoint to JPG](https://docs.aspose.com/slides/java/convert-powerpoint-to-jpg/) |
| Slide to SVG | Export individual slides as scalable vector graphics. | [Render Slide as SVG](https://docs.aspose.com/slides/java/render-a-slide-as-an-svg-image/) |
| PPT/PPTX/ODP to XPS | Generate fixed-layout XPS documents. | [Convert PowerPoint to XPS](https://docs.aspose.com/slides/java/convert-powerpoint-to-xps/) |
| PPT/PPTX/ODP to TIFF | Save a presentation as a multi-page TIFF file for printing, scanning, fax, or archival workflows. | [Convert PowerPoint to TIFF](https://docs.aspose.com/slides/java/convert-powerpoint-to-tiff/) |
| PPT/PPTX/ODP to TIFF with notes | Save slides with speaker notes to TIFF. | [Convert PowerPoint to TIFF with Notes](https://docs.aspose.com/slides/java/convert-powerpoint-to-tiff-with-notes/) |
| PPT/PPTX to Word | Convert slides to a Word document when you need document-style output. | [Convert PowerPoint to Word](https://docs.aspose.com/slides/java/convert-powerpoint-to-word/) |
| PPT/PPTX to Markdown | Extract presentation content into Markdown for documentation and text-based workflows. | [Convert PowerPoint to Markdown](https://docs.aspose.com/slides/java/convert-powerpoint-to-markdown/) |
| PPT/PPTX/ODP to XML | Create a text-based PowerPoint XML Presentation for inspection, comparison, troubleshooting, or XML-based workflows. | [Convert PowerPoint to XML](https://docs.aspose.com/slides/java/convert-powerpoint-to-xml/) |
| PPT/PPTX to animated GIF | Create an animated GIF from slides. | [Convert PowerPoint to Animated GIF](https://docs.aspose.com/slides/java/convert-powerpoint-to-animated-gif/) |
| PPT/PPTX to video | Build a video export workflow from presentation slides. | [Convert PowerPoint to Video](https://docs.aspose.com/slides/java/convert-powerpoint-to-video/) |
| Presentation to XAML | Export slides to XAML for Java UI scenarios. | [Export Presentations to XAML](https://docs.aspose.com/slides/java/export-to-xaml/) |
For a broader list of input and output formats, see [Supported File Formats](https://docs.aspose.com/slides/java/supported-file-formats/).
## **PowerPoint and OpenDocument Conversion**
Aspose.Slides for Java supports conversion from commonly used presentation formats such as PPT, PPTX, PPS, PPSX, POT, POTX, and ODP. The same conversion API is used for PowerPoint and OpenDocument files, so a workflow that saves a PPTX file to PDF can usually be applied to an ODP file by changing only the input file.
When converting ODP files, remember that PowerPoint and OpenDocument applications do not support every layout and formatting feature in exactly the same way. If an ODP file was created in LibreOffice or OpenOffice Impress, review the output and use the options described in [Convert OpenDocument Presentations](https://docs.aspose.com/slides/java/convert-openoffice-odp/) when you need format-specific guidance.
## **PPT to PPTX Conversion**
PPT is the older binary PowerPoint format, while PPTX is the modern Office Open XML format. Aspose.Slides for Java supports high-fidelity PPT to PPTX conversion while preserving complex presentation structures such as masters, layouts, slides, charts, grouped shapes, placeholders, text frames, textures, and picture fills.
For details, see [Convert PPT to PPTX](https://docs.aspose.com/slides/java/convert-ppt-to-pptx/) and [PPT vs PPTX](https://docs.aspose.com/slides/java/ppt-vs-pptx/).
## **Fixed-Layout Export**
PDF, XPS, and TIFF are useful when the output should look the same across devices and should not be edited as a presentation. The dedicated PDF, XPS, and TIFF articles explain how to control compliance, hidden slides, notes, image quality, compression, pixel format, and output size.
## **HTML and Image Export**
HTML and HTML5 export are useful for browser viewing, web publishing, and lightweight sharing. Image export is useful when each slide must become a separate preview, thumbnail, or raster asset. Use the PNG, JPG, and SVG articles for format-specific rendering guidance.
## **FAQ**
**Do I need Microsoft PowerPoint to convert presentations?**
No. Aspose.Slides for Java is a standalone library and does not require Microsoft PowerPoint or Office automation.
**Can I batch convert many presentations?**
Yes. Load each presentation, save it to the required format, and dispose of the presentation object after processing. For parallel processing, use separate presentation instances and follow the [multithreading](https://docs.aspose.com/slides/java/multithreading/) guidance.
**Can I export only selected slides?**
Yes. Several export methods allow you to pass slide indexes or render individual slides, depending on the output format. See the dedicated article for the target format.
**Can I include hidden slides when exporting to PDF or XPS?**
Yes. Use the hidden-slide export settings described in the [PDF](https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf/) and [XPS](https://docs.aspose.com/slides/java/convert-powerpoint-to-xps/) conversion articles.
**Can I create PDF/A output?**
Yes. PDF compliance settings are available for PDF export. See [Convert PowerPoint to PDF](https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf/) for details.
**How are fonts handled during conversion?**
Aspose.Slides can use embedded fonts, font fallback, and font substitution settings. See [Embedded Font](https://docs.aspose.com/slides/java/embedded-font/), [Fallback Font](https://docs.aspose.com/slides/java/fallback-font/), and [Font Substitution](https://docs.aspose.com/slides/java/font-substitution/).
## Related articles
- [Convert OpenDocument Presentations in Java](https://docs.aspose.com/slides/java/convert-openoffice-odp/)
- [Supported File Formats](https://docs.aspose.com/slides/java/supported-file-formats/)
# Convert Presentation Slides to Images in Java
> Convert slides from PPT, PPTX, and ODP presentations to PNG, JPEG, GIF, TIFF, EMF, and other image formats in Java with Aspose.Slides.
Source: https://docs.aspose.com/slides/java/convert-slide/
Updated: 2026-10-26
## **Introduction**
Aspose.Slides for Java can render individual slides from PowerPoint and OpenDocument presentations as PNG, JPEG, GIF, TIFF, and other image formats.
To convert a slide into an image, follow these steps:
1. Load the presentation with the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class.
2. Select the slide that you want to render.
3. If necessary, configure rendering with the [RenderingOptions](https://reference.aspose.com/slides/java/com.aspose.slides/renderingoptions/) or [TiffOptions](https://reference.aspose.com/slides/java/com.aspose.slides/tiffoptions/) class.
4. Call the [ISlide.getImage](https://reference.aspose.com/slides/java/com.aspose.slides/islide/#getImage--) method. It returns an [IImage](https://reference.aspose.com/slides/java/com.aspose.slides/iimage/) object.
5. Call the [IImage.save](https://reference.aspose.com/slides/java/com.aspose.slides/iimage/#save-java.lang.String-int-) method and specify the output format with an [ImageFormat](https://reference.aspose.com/slides/java/com.aspose.slides/imageformat/) value.
## **Convert a Slide to a PNG Image**
The simplest conversion uses the default rendering settings. The resulting [IImage](https://reference.aspose.com/slides/java/com.aspose.slides/iimage/) object can be processed in memory or saved to a file.
The following Java example renders the first slide and saves it as a PNG image:
```java
import com.aspose.slides.IImage;
import com.aspose.slides.ISlide;
import com.aspose.slides.ImageFormat;
import com.aspose.slides.Presentation;
Presentation presentation = new Presentation("Presentation.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
IImage image = slide.getImage();
try {
image.save("Slide_0.png", ImageFormat.Png);
} finally {
image.dispose();
}
} finally {
presentation.dispose();
}
```
## **Convert Slides to Images with Custom Sizes**
Use the [ISlide.getImage](https://reference.aspose.com/slides/java/com.aspose.slides/islide/#getImage-java.awt.Dimension-) overload that accepts a [Dimension](https://docs.oracle.com/javase/8/docs/api/java/awt/Dimension.html) value to render a slide with exact pixel dimensions.
The following example creates a 1820 × 1040 JPEG image:
```java
import com.aspose.slides.IImage;
import com.aspose.slides.ISlide;
import com.aspose.slides.ImageFormat;
import com.aspose.slides.Presentation;
import java.awt.Dimension;
Dimension imageSize = new Dimension(1820, 1040);
Presentation presentation = new Presentation("Presentation.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
IImage image = slide.getImage(imageSize);
try {
image.save("Slide_0.jpg", ImageFormat.Jpeg);
} finally {
image.dispose();
}
} finally {
presentation.dispose();
}
```
## **Convert Slides with Notes and Comments to Images**
By default, slide images do not include notes or comments. Pass a [NotesCommentsLayoutingOptions](https://reference.aspose.com/slides/java/com.aspose.slides/notescommentslayoutingoptions/) object to the [RenderingOptions.setSlidesLayoutOptions](https://reference.aspose.com/slides/java/com.aspose.slides/renderingoptions/#setSlidesLayoutOptions-com.aspose.slides.ISlidesLayoutOptions-) method to control where notes and comments appear.
The following example places truncated notes below the slide and comments to its right:
```java
import com.aspose.slides.CommentsPositions;
import com.aspose.slides.IImage;
import com.aspose.slides.ISlide;
import com.aspose.slides.ImageFormat;
import com.aspose.slides.NotesCommentsLayoutingOptions;
import com.aspose.slides.NotesPositions;
import com.aspose.slides.Presentation;
import com.aspose.slides.RenderingOptions;
import java.awt.Color;
float scaleX = 2f;
float scaleY = scaleX;
Color commentsAreaColor = new Color(250, 235, 215);
NotesCommentsLayoutingOptions layoutOptions = new NotesCommentsLayoutingOptions();
layoutOptions.setNotesPosition(NotesPositions.BottomTruncated);
layoutOptions.setCommentsPosition(CommentsPositions.Right);
layoutOptions.setCommentsAreaWidth(500);
layoutOptions.setCommentsAreaColor(commentsAreaColor);
RenderingOptions renderingOptions = new RenderingOptions();
renderingOptions.setSlidesLayoutOptions(layoutOptions);
Presentation presentation = new Presentation("Presentation_with_notes_and_comments.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
IImage image = slide.getImage(renderingOptions, scaleX, scaleY);
try {
image.save("Image_with_notes_and_comments_0.gif", ImageFormat.Gif);
} finally {
image.dispose();
}
} finally {
presentation.dispose();
}
```
For slide-to-image conversion, do not pass [BottomFull](https://reference.aspose.com/slides/java/com.aspose.slides/notespositions/) to the [NotesCommentsLayoutingOptions.setNotesPosition](https://reference.aspose.com/slides/java/com.aspose.slides/notescommentslayoutingoptions/#setNotesPosition-int-) method. Notes can contain more text than the fixed image size can accommodate. Use [BottomTruncated](https://reference.aspose.com/slides/java/com.aspose.slides/notespositions/) instead.
## **Convert Slides to Images Using TIFF Options**
The [TiffOptions](https://reference.aspose.com/slides/java/com.aspose.slides/tiffoptions/) class lets you control the size, resolution, and other properties of the rendered TIFF image.
The following example renders the first slide as a 2160 × 2880 TIFF image at 300 DPI:
```java
import com.aspose.slides.IImage;
import com.aspose.slides.ISlide;
import com.aspose.slides.ImageFormat;
import com.aspose.slides.Presentation;
import com.aspose.slides.TiffOptions;
import java.awt.Dimension;
Dimension imageSize = new Dimension(2160, 2880);
TiffOptions tiffOptions = new TiffOptions();
tiffOptions.setImageSize(imageSize);
tiffOptions.setDpiX(300);
tiffOptions.setDpiY(300);
Presentation presentation = new Presentation("sample.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
IImage image = slide.getImage(tiffOptions);
try {
image.save("output.tiff", ImageFormat.Tiff);
} finally {
image.dispose();
}
} finally {
presentation.dispose();
}
```
TIFF support is not guaranteed in Java versions earlier than JDK 9.
## **Convert All Slides to Images**
Iterate through the slide collection to convert the entire presentation into a series of images. Hidden slides are included unless you explicitly skip them.
The following example renders every slide as a JPEG image with horizontal and vertical scale factors of 2:
```java
import com.aspose.slides.IImage;
import com.aspose.slides.ISlide;
import com.aspose.slides.ImageFormat;
import com.aspose.slides.Presentation;
float scaleX = 2f;
float scaleY = scaleX;
Presentation presentation = new Presentation("Presentation.pptx");
try {
int slideCount = presentation.getSlides().size();
for (int index = 0; index < slideCount; index++) {
ISlide slide = presentation.getSlides().get_Item(index);
IImage image = slide.getImage(scaleX, scaleY);
try {
image.save("Slide_" + index + ".jpg", ImageFormat.Jpeg);
} finally {
image.dispose();
}
}
} finally {
presentation.dispose();
}
```
## **Create Enhanced Metafile Output**
Enhanced Metafile (EMF) is useful when vector-based graphics must be exchanged with Microsoft Office or other Windows applications that support Windows metafiles. Unlike a pixel-based image, an EMF can retain vector drawing operations that scale without the same loss of sharpness. However, EMF is primarily a compatibility format for applications with Windows metafile support, not a universal interchange format. In addition, complex slide content, such as bitmap images and some effects, may be stored as rasterized elements inside the vector metafile container.
### **Export a Slide to EMF**
The [ISlide.writeAsEmf](https://reference.aspose.com/slides/java/com.aspose.slides/islide/#writeAsEmf-java.io.OutputStream-) method writes an [ISlide](https://reference.aspose.com/slides/java/com.aspose.slides/islide/) to a target stream in EMF format. The following example loads a presentation, selects the first slide, and writes it to an EMF file stream:
```java
import com.aspose.slides.ISlide;
import com.aspose.slides.Presentation;
import java.io.FileOutputStream;
Presentation presentation = new Presentation("Presentation.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
FileOutputStream emfStream = new FileOutputStream("Slide_0.emf");
try {
slide.writeAsEmf(emfStream);
} finally {
emfStream.close();
}
} finally {
presentation.dispose();
}
```
The caller owns the stream passed to [ISlide.writeAsEmf](https://reference.aspose.com/slides/java/com.aspose.slides/islide/#writeAsEmf-java.io.OutputStream-) and is responsible for closing it, as shown above.
### **Convert an SVG Image to EMF and Add It to a Presentation**
Use [ISvgImage.writeAsEmf](https://reference.aspose.com/slides/java/com.aspose.slides/isvgimage/#writeAsEmf-java.io.OutputStream-) to convert SVG content to EMF. The resulting bytes can be added to the presentation through [IImageCollection.addImage](https://reference.aspose.com/slides/java/com.aspose.slides/iimagecollection/#addImage-byte---) and placed on a slide with [IShapeCollection.addPictureFrame](https://reference.aspose.com/slides/java/com.aspose.slides/ishapecollection/#addPictureFrame-int-float-float-float-float-com.aspose.slides.IPPImage-).
The following example creates an [SvgImage](https://reference.aspose.com/slides/java/com.aspose.slides/svgimage/) from SVG markup, converts it to an in-memory EMF, inserts the metafile on the first slide, and saves the presentation:
```java
import com.aspose.slides.IPPImage;
import com.aspose.slides.ISlide;
import com.aspose.slides.ISvgImage;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
import com.aspose.slides.ShapeType;
import com.aspose.slides.SvgImage;
import java.io.ByteArrayOutputStream;
String svgContent = "";
ISvgImage svgImage = new SvgImage(svgContent);
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
ByteArrayOutputStream emfStream = new ByteArrayOutputStream();
try {
svgImage.writeAsEmf(emfStream);
byte[] emfData = emfStream.toByteArray();
IPPImage image = presentation.getImages().addImage(emfData);
slide.getShapes().addPictureFrame(ShapeType.Rectangle, 20, 20, 200, 100, image);
} finally {
emfStream.close();
}
presentation.save("Presentation_with_emf.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
[ISvgImage.writeAsEmf](https://reference.aspose.com/slides/java/com.aspose.slides/isvgimage/#writeAsEmf-java.io.OutputStream-) does not take ownership of the destination stream. A [ByteArrayOutputStream](https://docs.oracle.com/javase/8/docs/api/java/io/ByteArrayOutputStream.html) stores all generated data in memory, so no position reset is required before calling `toByteArray`. The returned byte array remains valid after the stream is closed.
EMF generation is available on the operating systems supported by the selected Aspose.Slides for Java and JDK configuration, but rendering can differ across platforms when fonts or graphics dependencies are unavailable. Install the fonts used by the source content or configure suitable substitutions, follow the [platform requirements](https://docs.aspose.com/slides/java/system-requirements/) for Aspose.Slides for Java, and validate the result in the target EMF-consuming application. Linux and macOS applications often have limited or inconsistent support for displaying and editing Windows metafiles.
## **Color Emoji Rendering**
To render color emojis correctly when converting presentation slides to images, the emoji fonts used in the presentation must be installed and available on the system performing the conversion. For example, if the presentation uses **Segoe UI Emoji** and this font is missing, emojis may appear in monochrome in the output images.
## **FAQ**
**Does Aspose.Slides support rendering slides with animations?**
No. The [ISlide.getImage](https://reference.aspose.com/slides/java/com.aspose.slides/islide/#getImage--) method renders a static image of the slide and does not export animations.
**Can hidden slides be exported as images?**
Yes. Hidden slides can be rendered like regular slides. Include them in the processing loop, as shown in the example above.
**Are shadows and other effects preserved in slide images?**
Yes. Aspose.Slides renders shadows, transparency, and other supported graphical effects in slide images.
Related feature: [Render slides as images](https://docs.aspose.com/slides/features/slide-images/).
## Related articles
- [Convert PowerPoint Presentations to TIFF in Java](https://docs.aspose.com/slides/java/convert-powerpoint-to-tiff/)
# Create Charts Using VSTO and Aspose.Slides for Java
> Learn how to automate PowerPoint chart creation in Java. This step-by-step guide shows why Aspose.Slides for Java is a faster, more powerful alternative to Microsoft.Office.Interop.
Source: https://docs.aspose.com/slides/java/create-a-chart-in-a-microsoft-powerpoint-presentation/
Updated: 2026-08-13
Charts are visual representations of data that are widely used in presentations. This article shows the code for create a chart in Microsoft PowerPoint programmatically by using [VSTO](https://docs.aspose.com/slides/java/create-a-chart-in-a-microsoft-powerpoint-presentation/) and [Aspose.Slides for Java](https://docs.aspose.com/slides/java/create-a-chart-in-a-microsoft-powerpoint-presentation/).
## **Creating a Chart**
The code examples below describe the process of adding a simple 3D clustered column chart using VSTO. You create a presentation instance, add a default chart to it. Then use Microsoft Excel workbook to access and modify chart data along with setting chart properties. Lastly, save the presentation.
### **VSTO Example**
Using VSTO, the following steps are performed:
1. Create an instance of a Microsoft PowerPoint presentation.
1. Add a blank slide to the presentation.
1. Add a **3D clustered column** chart and access it.
1. Create a new Microsoft Excel Workbook instance and load chart data.
1. Access the chart data worksheet using Microsoft Excel Workbook instancefromworkbook.
1. Set the chart range in the worksheet and remove series 2 and 3 from the chart.
1. Modify the chart category data in the chart data worksheet.
1. Modify chart series 1 data in the chart data worksheet.
1. Now, access the chart title and setthefontrelatedproperties.
1. Access the chart value axis and set the major unit, minor units, max value and min values.
1. Access the chart depth or series axis and remove that as in this example, onlyoneserieisused.
1. Now, set the chart rotation angles in X and Y direction.
1. Save the presentation.
1. Close the instances of Microsoft Excel and PowerPoint.
**The output presentation, created with VSTO**

```csharp
EnsurePowerPointIsRunning(true, true);
//Instantiate slide object
Microsoft.Office.Interop.PowerPoint.Slide objSlide = null;
//Access the first slide of presentation
objSlide = objPres.Slides[1];
//Select firs slide and set its layout
objSlide.Select();
objSlide.Layout = Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutBlank;
//Add a default chart in slide
objSlide.Shapes.AddChart(Microsoft.Office.Core.XlChartType.xl3DColumn, 20F, 30F, 400F, 300F);
//Access the added chart
Microsoft.Office.Interop.PowerPoint.Chart ppChart = objSlide.Shapes[1].Chart;
//Access the chart data
Microsoft.Office.Interop.PowerPoint.ChartData chartData = ppChart.ChartData;
//Create instance to Excel workbook to work with chart data
Microsoft.Office.Interop.Excel.Workbook dataWorkbook = (Microsoft.Office.Interop.Excel.Workbook)chartData.Workbook;
//Accessing the data worksheet for chart
Microsoft.Office.Interop.Excel.Worksheet dataSheet = dataWorkbook.Worksheets[1];
//Setting the range of chart
Microsoft.Office.Interop.Excel.Range tRange = dataSheet.Cells.get_Range("A1", "B5");
//Applying the set range on chart data table
Microsoft.Office.Interop.Excel.ListObject tbl1 = dataSheet.ListObjects["Table1"];
tbl1.Resize(tRange);
//Setting values for categories and respective series data
((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("A2"))).FormulaR1C1 = "Bikes";
((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("A3"))).FormulaR1C1 = "Accessories";
((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("A4"))).FormulaR1C1 = "Repairs";
((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("A5"))).FormulaR1C1 = "Clothing";
((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("B2"))).FormulaR1C1 = "1000";
((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("B3"))).FormulaR1C1 = "2500";
((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("B4"))).FormulaR1C1 = "4000";
((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("B5"))).FormulaR1C1 = "3000";
//Setting chart title
ppChart.ChartTitle.Font.Italic = true;
ppChart.ChartTitle.Text = "2007 Sales";
ppChart.ChartTitle.Font.Size = 18;
ppChart.ChartTitle.Font.Color = Color.Black.ToArgb();
ppChart.ChartTitle.Format.Line.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
ppChart.ChartTitle.Format.Line.ForeColor.RGB = Color.Black.ToArgb();
//Accessing Chart value axis
Microsoft.Office.Interop.PowerPoint.Axis valaxis = ppChart.Axes(Microsoft.Office.Interop.PowerPoint.XlAxisType.xlValue, Microsoft.Office.Interop.PowerPoint.XlAxisGroup.xlPrimary);
//Setting values axis units
valaxis.MajorUnit = 2000.0F;
valaxis.MinorUnit = 1000.0F;
valaxis.MinimumScale = 0.0F;
valaxis.MaximumScale = 4000.0F;
//Accessing Chart Depth axis
Microsoft.Office.Interop.PowerPoint.Axis Depthaxis = ppChart.Axes(Microsoft.Office.Interop.PowerPoint.XlAxisType.xlSeriesAxis, Microsoft.Office.Interop.PowerPoint.XlAxisGroup.xlPrimary);
Depthaxis.Delete();
//Setting chart rotation
ppChart.Rotation = 20; //Y-Value
ppChart.Elevation = 15; //X-Value
ppChart.RightAngleAxes = false;
// Save the presentation as a PPTX
objPres.SaveAs("C:\\VSTOSampleChart", Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsDefault, MsoTriState.msoTrue);
//objPres.SaveAs(@"..\..\..\VSTOSampleChart", Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsDefault, MsoTriState.msoTrue);
//Close Workbook and presentation
dataWorkbook.Application.Quit();
objPres.Application.Quit();
```
[Source: Examples-CSharp-VSTO-VSTOChart-VSTOChart.cs](https://gist.githubusercontent.com/aspose-com-gists/a56eda38c01ad33dc653116c7bae4293/raw/60f36b65dcdc5f7368b2d455fe1ae74076eeae08/Examples-CSharp-VSTO-VSTOChart-VSTOChart.cs)
```csharp
public static void EnsurePowerPointIsRunning(bool blnAddPresentation)
{
EnsurePowerPointIsRunning(blnAddPresentation, false);
}
public static void EnsurePowerPointIsRunning()
{
EnsurePowerPointIsRunning(false, false);
}
public static void EnsurePowerPointIsRunning(bool blnAddPresentation, bool blnAddSlide)
{
string strName = null;
//
//Try accessing the name property. If it causes an exception then
//start a new instance of PowerPoint
try
{
strName = objPPT.Name;
}
catch (Exception ex)
{
StartPowerPoint();
}
//
//blnAddPresentation is used to ensure there is a presentation loaded
if (blnAddPresentation == true)
{
try
{
strName = objPres.Name;
}
catch (Exception ex)
{
objPres = objPPT.Presentations.Add(MsoTriState.msoTrue);
}
}
//
//BlnAddSlide is used to ensure there is at least one slide in the
//presentation
if (blnAddSlide)
{
try
{
strName = objPres.Slides[1].Name;
}
catch (Exception ex)
{
Microsoft.Office.Interop.PowerPoint.Slide objSlide = null;
Microsoft.Office.Interop.PowerPoint.CustomLayout objCustomLayout = null;
objCustomLayout = objPres.SlideMaster.CustomLayouts[1];
objSlide = objPres.Slides.AddSlide(1, objCustomLayout);
objSlide.Layout = Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText;
objCustomLayout = null;
objSlide = null;
}
}
}
```
[Source: Examples-CSharp-VSTO-VSTOChart-EnsurePowerPointIsRunning.cs](https://gist.githubusercontent.com/aspose-com-gists/a56eda38c01ad33dc653116c7bae4293/raw/60f36b65dcdc5f7368b2d455fe1ae74076eeae08/Examples-CSharp-VSTO-VSTOChart-EnsurePowerPointIsRunning.cs)
### **Aspose.Slides for Java Example**
Using Aspose.Slides for Java, the following steps are performed:
1. Create an instance of a Microsoft PowerPoint presentation.
1. Add a blank slide to the presentation.
1. Add a **3D clustered column** chart and access that.
1. Access the chart data worksheet using a Microsoft Excel Workbook instancefromworkbook.
1. Remove unused series 2 and 3.
1. Access chart categories and modify the labels.
1. Accesseries1 and modify the series values.
1. Now, access the chart title and set the font properties.
1. Access the chart value axis and set the major unit, minor units, max value and min values.
1. Now, set the chart rotation angles in X and Y direction.
1. Save the presentation to PPTX format.
**The output presentation, created with Aspose.Slides**

```java
//Create empty presentation
Presentation pres = new Presentation();
//Accessing first slide
ISlide slide = pres.getSlides().get_Item(0);
//Addding default chart
IChart ppChart = slide.getShapes().addChart(ChartType.ClusteredColumn3D, 20F, 30F, 400F, 300F);
//Getting Chart data
IChartData chartData = ppChart.getChartData();
//Removing Extra default series
chartData.getSeries().removeAt(1);
chartData.getSeries().removeAt(1);
//Modifying chart categories names
chartData.getCategories().get_Item(0).getAsCell().setValue("Bikes");
chartData.getCategories().get_Item(1).getAsCell().setValue("Accessories");
chartData.getCategories().get_Item(2).getAsCell().setValue("Repairs");
chartData.getCategories().get_Item(3).getAsCell().setValue("Clothing");
//Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
//Getting the chart data worksheet
IChartDataWorkbook fact = ppChart.getChartData().getChartDataWorkbook();
//Modifying chart series values for first category
chartData.getSeries().get_Item(0).getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 1, 1000));
chartData.getSeries().get_Item(0).getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 1, 2500));
chartData.getSeries().get_Item(0).getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 1, 4000));
chartData.getSeries().get_Item(0).getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 4, 1, 3000));
//Setting Chart title
ppChart.hasTitle(true);
ppChart.getChartTitle().addTextFrameForOverriding("2007 Sales");
IPortionFormat format = ppChart.getChartTitle().getTextFrameForOverriding().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat();
format.setFontItalic(NullableBool.True);
format.setFontHeight(18);
format.getFillFormat().setFillType(FillType.Solid);
format.getFillFormat().getSolidFillColor().setColor(java.awt.Color.BLACK);
////Setting Axis values
ppChart.getAxes().getVerticalAxis().isAutomaticMaxValue(false);
ppChart.getAxes().getVerticalAxis().isAutomaticMinValue(false);
ppChart.getAxes().getVerticalAxis().isAutomaticMajorUnit(false);
ppChart.getAxes().getVerticalAxis().isAutomaticMinorUnit(false);
ppChart.getAxes().getVerticalAxis().setMaxValue(4000.0F);
ppChart.getAxes().getVerticalAxis().setMinValue(0.0F);
ppChart.getAxes().getVerticalAxis().setMajorUnit(2000.0F);
ppChart.getAxes().getVerticalAxis().setMinorUnit(1000.0F);
ppChart.getAxes().getVerticalAxis().setTickLabelPosition(TickLabelPositionType.NextTo);
//Setting Chart rotation
ppChart.getRotation3D().setRotationX((byte)15);
ppChart.getRotation3D().setRotationY(20);
//Saving Presentation
pres.save("c:\\data\\AsposeSampleChart.pptx",com.aspose.slides.SaveFormat.Pptx);
```
[Source: Examples-src-main-java-com-aspose-slides-examples-Slides-Charts-CreateChart-CreateChart.java](https://gist.githubusercontent.com/aspose-com-gists/1f55f0222bc39a382d831900e8de7400/raw/fcbe2a8f5e54b9c91d2974b76d9db97928d16fe8/Examples-src-main-java-com-aspose-slides-examples-Slides-Charts-CreateChart-CreateChart.java)
## **FAQ**
### Can I create other types of charts like pie, line, or bar charts with Aspose.Slides?
Yes. Aspose.Slides supports a wide range of [chart types](https://docs.aspose.com/slides/java/create-chart/), including pie charts, line charts, bar charts, scatter plots, bubble charts, and more. You can specify the desired chart type using the [ChartType](https://reference.aspose.com/slides/java/com.aspose.slides/charttype/) class when adding a chart.
### Can I apply custom styles or themes to the chart?
Yes. You can fully customize the chart’s appearance, including colors, fonts, fills, outlines, gridlines, and layout. However, applying Office themes exactly as seen in PowerPoint requires manually setting individual styles.
### Can I export the chart as an image separately from the slide?
Yes, Aspose.Slides allows you to export any shape—including charts—as a separate image (e.g., PNG, JPEG) using the `getImage` method on the chart [shape](https://reference.aspose.com/slides/java/com.aspose.slides/shape/).
## Related articles
- [Create and Embed Excel Charts as OLE Objects Using VSTO and Aspose.Slides for Java](https://docs.aspose.com/slides/java/create-and-embed-an-excel-chart-as-an-ole-object-into-a-microsoft-powerpoint-slide/)
- [Creating Tables Using VSTO and Aspose.Slides for Java](https://docs.aspose.com/slides/java/creating-a-table-on-powerpoint-slide/)
- [Adding Text Dynamically Using VSTO and Aspose.Slides for Java](https://docs.aspose.com/slides/java/adding-text-dynamically-using-vsto-and-aspose-slides-for-java/)
# Create New Presentations Using VSTO and Aspose.Slides for Java
> Migrate from Microsoft Office automation to Aspose.Slides for Java and create new PowerPoint (PPT, PPTX) presentations in Java with clean, reliable code.
Source: https://docs.aspose.com/slides/java/create-a-new-presentation/
Updated: 2026-08-13
VSTO was developed to let developers build applications that could run inside Microsoft Office. VSTO is COM-based but it's wrapped inside a .NET object so that it can be used in .NET applications. VSTO needs .NET framework support as well as Microsoft Office CLR-based runtime. Although it can be used for making Microsoft Office add-ins it is nearly impossible to use as a server-side component. It also has serious deployment problems.
Aspose.Slides for Java is a component that can be used to manipulate Microsoft PowerPoint presentations, just like VSTO, but it has several advantages:
- Aspose.Slides contains managed code only and doesn’t require Microsoft Office runtime to be installed.
- It can be used as a client-side component or as a server side component.
- Deployment is easy since Aspose.Slides is contained in a single jar file.
## **Creating a Presentation**
Below are two code examples that illustrate how VSTO and Aspose.Slides for Java can be used to achieve the same goal. The first example is [VSTO](https://docs.aspose.com/slides/java/create-a-new-presentation/); [the second example](https://docs.aspose.com/slides/java/create-a-new-presentation/) uses Aspose.Slides.
### **VSTO Example**
**The VSTO output**

```csharp
//Note: PowerPoint is a namespace which has been defined above like this
//using PowerPoint = Microsoft.Office.Interop.PowerPoint;
//Create a presentation
PowerPoint.Presentation pres = Globals.ThisAddIn.Application
.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoFalse);
//Get the title slide layout
PowerPoint.CustomLayout layout = pres.SlideMaster.
CustomLayouts[PowerPoint.PpSlideLayout.ppLayoutTitle];
//Add a title slide.
PowerPoint.Slide slide = pres.Slides.AddSlide(1, layout);
//Set the title text
slide.Shapes.Title.TextFrame.TextRange.Text = "Slide Title Heading";
//Set the sub title text
slide.Shapes[2].TextFrame.TextRange.Text = "Slide Title Sub-Heading";
//Write the output to disk
pres.SaveAs("c:\\outVSTO.ppt",
PowerPoint.PpSaveAsFileType.ppSaveAsPresentation,
Microsoft.Office.Core.MsoTriState.msoFalse);
```
[Source: Examples-CSharp-VSTO-AddVSTOPresentation-AddVSTOPresentation.cs](https://gist.githubusercontent.com/aspose-com-gists/a56eda38c01ad33dc653116c7bae4293/raw/60f36b65dcdc5f7368b2d455fe1ae74076eeae08/Examples-CSharp-VSTO-AddVSTOPresentation-AddVSTOPresentation.cs)
### **Aspose.Slides for Java Example**
**The output from Aspose.Slides**

```java
//Create a presentation
Presentation pres = new Presentation();
//Add the title slide
ISlide slide = pres.getSlides().addEmptySlide(pres.getLayoutSlides().get_Item(0));
//Set the title text
((IAutoShape)slide.getShapes().get_Item(0)).getTextFrame().setText("Slide Title Heading");
//Set the sub title text
((IAutoShape)slide.getShapes().get_Item(1)).getTextFrame().setText("Slide Title Sub-Heading");
//Write output to disk
pres.save("c:\\data\\outAsposeSlides.pptx",SaveFormat.Pptx);
```
[Source: Examples-src-main-java-com-aspose-slides-examples-Presentation-Saving-CreatePresentation-CreatePresentation.java](https://gist.githubusercontent.com/aspose-com-gists/1f55f0222bc39a382d831900e8de7400/raw/3b85ca064d2b1615d87ceedce58ab524b30d25e9/Examples-src-main-java-com-aspose-slides-examples-Presentation-Saving-CreatePresentation-CreatePresentation.java)
## Related articles
- [Creating Tables Using VSTO and Aspose.Slides for Java](https://docs.aspose.com/slides/java/creating-a-table-on-powerpoint-slide/)
- [Migration from Microsoft Office Automation to Aspose.Slides for Java](https://docs.aspose.com/slides/java/migration-from-microsoft-office-automation-to-aspose/)
- [Format Text Using VSTO and Aspose.Slides for Java](https://docs.aspose.com/slides/java/format-text-using-vsto-and-aspose-slides-for-java/)
# Create and Embed Excel Charts as OLE Objects Using VSTO and Aspose.Slides for Java
> Migrate from Microsoft Office automation to Aspose.Slides for Java and embed Excel charts as OLE objects into PowerPoint (PPT, PPTX) slides in Java.
Source: https://docs.aspose.com/slides/java/create-and-embed-an-excel-chart-as-an-ole-object-into-a-microsoft-powerpoint-slide/
Updated: 2026-08-13
Charts are visual representations of your data and widely used in presentation slides. This article will show you the code to create and embed an Excel Chart as an OLE Object in the PowerPoint Slide programmatically by using [VSTO](https://docs.aspose.com/slides/java/create-and-embed-an-excel-chart-as-an-ole-object-into-a-microsoft-powerpoint-slide/) and [Aspose.Slides for Java](https://docs.aspose.com/slides/java/create-and-embed-an-excel-chart-as-an-ole-object-into-a-microsoft-powerpoint-slide/).
## **Creating and Embedding an Excel Chart**
The two code examples below are long and detailed because the task they're describing is involved. You create a Microsoft Excel workbook, create a chart and then create the Microsoft PowerPoint presentation that you'll embed the chart into. OLE objects contain links to the original document so a user that double-clicks the embedded file will launch the file and it's application.
### **VSTO Example**
Using VSTO, the following steps are performed:
1. Create an instance of the Microsoft Excel ApplicationClass object.
1. Create a new workbook with one sheet in it.
1. Add chart to the sheet.
1. Save the workbook.
1. Open the Excel workbook containing the worksheet with the chart data.
1. Get the ChartObjects collection for the sheet.
1. Get the chart to copy.
1. Create a Microsoft PowerPoint presentation.
1. Add a blank slide to the presentation.
1. Copy the chart from the Excel worksheet to the clipboard.
1. Paste the chart into the PowerPoint presentation.
1. Position the chart on the slide.
1. Save the presentation.
```csharp
CreateNewChartInExcel();
UseCopyPaste();
```
[Source: Examples-CSharp-VSTO-CreateandEmbedExcelChartAsOLEUsingVSTO-CreateAndEmbedExcelChartAsOLEUsingVSTO.cs](https://gist.githubusercontent.com/aspose-com-gists/a56eda38c01ad33dc653116c7bae4293/raw/60f36b65dcdc5f7368b2d455fe1ae74076eeae08/Examples-CSharp-VSTO-CreateandEmbedExcelChartAsOLEUsingVSTO-CreateAndEmbedExcelChartAsOLEUsingVSTO.cs)
```csharp
static void SetCellValue(xlNS.Worksheet targetSheet, string Cell, object Value)
{
targetSheet.get_Range(Cell, Cell).set_Value(xlNS.XlRangeValueDataType.xlRangeValueDefault, Value);
}
```
[Source: Examples-CSharp-VSTO-CreateandEmbedExcelChartAsOLEUsingVSTO-SetCellValue.cs](https://gist.githubusercontent.com/aspose-com-gists/a56eda38c01ad33dc653116c7bae4293/raw/60f36b65dcdc5f7368b2d455fe1ae74076eeae08/Examples-CSharp-VSTO-CreateandEmbedExcelChartAsOLEUsingVSTO-SetCellValue.cs)
```csharp
static void CreateNewChartInExcel()
{
// Declare a variable for the Excel ApplicationClass instance.
Microsoft.Office.Interop.Excel.ApplicationClass excelApplication = null;
// Declare variables for the Workbooks.Open method parameters.
string paramWorkbookPath = Application.StartupPath + @"\ChartData.xlsx";
object paramMissing = Type.Missing;
// Declare variables for the Chart.ChartWizard method.
object paramChartFormat = 1;
object paramCategoryLabels = 0;
object paramSeriesLabels = 0;
bool paramHasLegend = true;
object paramTitle = "Sales by Quarter";
object paramCategoryTitle = "Fiscal Quarter";
object paramValueTitle = "Billions";
try
{
// Create an instance of the Excel ApplicationClass object.
excelApplication = new Microsoft.Office.Interop.Excel.ApplicationClass();
// Create a new workbook with 1 sheet in it.
xlNS.Workbook newWorkbook = excelApplication.Workbooks.Add(xlNS.XlWBATemplate.xlWBATWorksheet);
// Change the name of the sheet.
xlNS.Worksheet targetSheet = (xlNS.Worksheet)(newWorkbook.Worksheets[1]);
targetSheet.Name = "Quarterly Sales";
// Insert some data for the chart into the sheet.
// A B C D E
// 1 Q1 Q2 Q3 Q4
// 2 N. America 1.5 2 1.5 2.5
// 3 S. America 2 1.75 2 2
// 4 Europe 2.25 2 2.5 2
// 5 Asia 2.5 2.5 2 2.75
SetCellValue(targetSheet, "A2", "N. America");
SetCellValue(targetSheet, "A3", "S. America");
SetCellValue(targetSheet, "A4", "Europe");
SetCellValue(targetSheet, "A5", "Asia");
SetCellValue(targetSheet, "B1", "Q1");
SetCellValue(targetSheet, "B2", 1.5);
SetCellValue(targetSheet, "B3", 2);
SetCellValue(targetSheet, "B4", 2.25);
SetCellValue(targetSheet, "B5", 2.5);
SetCellValue(targetSheet, "C1", "Q2");
SetCellValue(targetSheet, "C2", 2);
SetCellValue(targetSheet, "C3", 1.75);
SetCellValue(targetSheet, "C4", 2);
SetCellValue(targetSheet, "C5", 2.5);
SetCellValue(targetSheet, "D1", "Q3");
SetCellValue(targetSheet, "D2", 1.5);
SetCellValue(targetSheet, "D3", 2);
SetCellValue(targetSheet, "D4", 2.5);
SetCellValue(targetSheet, "D5", 2);
SetCellValue(targetSheet, "E1", "Q4");
SetCellValue(targetSheet, "E2", 2.5);
SetCellValue(targetSheet, "E3", 2);
SetCellValue(targetSheet, "E4", 2);
SetCellValue(targetSheet, "E5", 2.75);
// Get the range holding the chart data.
xlNS.Range dataRange = targetSheet.get_Range("A1", "E5");
// Get the ChartObjects collection for the sheet.
xlNS.ChartObjects chartObjects = (xlNS.ChartObjects)(targetSheet.ChartObjects(paramMissing));
// Add a Chart to the collection.
xlNS.ChartObject newChartObject = chartObjects.Add(0, 100, 600, 300);
newChartObject.Name = "Sales Chart";
// Create a new chart of the data.
newChartObject.Chart.ChartWizard(dataRange, xlNS.XlChartType.xl3DColumn, paramChartFormat, xlNS.XlRowCol.xlRows,
paramCategoryLabels, paramSeriesLabels, paramHasLegend, paramTitle, paramCategoryTitle, paramValueTitle, paramMissing);
// Save the workbook.
newWorkbook.SaveAs(paramWorkbookPath, paramMissing, paramMissing, paramMissing, paramMissing,
paramMissing, xlNS.XlSaveAsAccessMode.xlNoChange, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
if (excelApplication != null)
{
// Close Excel.
excelApplication.Quit();
}
}
}
```
[Source: Examples-CSharp-VSTO-CreateandEmbedExcelChartAsOLEUsingVSTO-CreateNewChartInExcel.cs](https://gist.githubusercontent.com/aspose-com-gists/a56eda38c01ad33dc653116c7bae4293/raw/60f36b65dcdc5f7368b2d455fe1ae74076eeae08/Examples-CSharp-VSTO-CreateandEmbedExcelChartAsOLEUsingVSTO-CreateNewChartInExcel.cs)
```csharp
static void UseCopyPaste()
{
// Declare variables to hold references to PowerPoint objects.
pptNS.ApplicationClass powerpointApplication = null;
pptNS.Presentation pptPresentation = null;
pptNS.Slide pptSlide = null;
pptNS.ShapeRange shapeRange = null;
// Declare variables to hold references to Excel objects.
xlNS.ApplicationClass excelApplication = null;
xlNS.Workbook excelWorkBook = null;
xlNS.Worksheet targetSheet = null;
xlNS.ChartObjects chartObjects = null;
xlNS.ChartObject existingChartObject = null;
string paramPresentationPath = Application.StartupPath + @"\ChartTest.pptx";
string paramWorkbookPath = Application.StartupPath + @"\ChartData.xlsx";
object paramMissing = Type.Missing;
try
{
// Create an instance of PowerPoint.
powerpointApplication = new pptNS.ApplicationClass();
// Create an instance Excel.
excelApplication = new xlNS.ApplicationClass();
// Open the Excel workbook containing the worksheet with the chart data.
excelWorkBook = excelApplication.Workbooks.Open(paramWorkbookPath,
paramMissing, paramMissing, paramMissing, paramMissing, paramMissing,
paramMissing, paramMissing, paramMissing, paramMissing, paramMissing,
paramMissing, paramMissing, paramMissing, paramMissing);
// Get the worksheet that contains the chart.
targetSheet =
(xlNS.Worksheet)(excelWorkBook.Worksheets["Quarterly Sales"]);
// Get the ChartObjects collection for the sheet.
chartObjects =
(xlNS.ChartObjects)(targetSheet.ChartObjects(paramMissing));
// Get the chart to copy.
existingChartObject =
(xlNS.ChartObject)(chartObjects.Item("Sales Chart"));
// Create a PowerPoint presentation.
pptPresentation =
powerpointApplication.Presentations.Add(
Microsoft.Office.Core.MsoTriState.msoTrue);
// Add a blank slide to the presentation.
pptSlide =
pptPresentation.Slides.Add(1, pptNS.PpSlideLayout.ppLayoutBlank);
// Copy the chart from the Excel worksheet to the clipboard.
existingChartObject.Copy();
// Paste the chart into the PowerPoint presentation.
shapeRange = pptSlide.Shapes.Paste();
// Position the chart on the slide.
shapeRange.Left = 60;
shapeRange.Top = 100;
// Save the presentation.
pptPresentation.SaveAs(paramPresentationPath, pptNS.PpSaveAsFileType.ppSaveAsOpenXMLPresentation, Microsoft.Office.Core.MsoTriState.msoTrue);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
// Release the PowerPoint slide object.
shapeRange = null;
pptSlide = null;
// Close and release the Presentation object.
if (pptPresentation != null)
{
pptPresentation.Close();
pptPresentation = null;
}
// Quit PowerPoint and release the ApplicationClass object.
if (powerpointApplication != null)
{
powerpointApplication.Quit();
powerpointApplication = null;
}
// Release the Excel objects.
targetSheet = null;
chartObjects = null;
existingChartObject = null;
// Close and release the Excel Workbook object.
if (excelWorkBook != null)
{
excelWorkBook.Close(false, paramMissing, paramMissing);
excelWorkBook = null;
}
// Quit Excel and release the ApplicationClass object.
if (excelApplication != null)
{
excelApplication.Quit();
excelApplication = null;
}
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
}
}
```
[Source: Examples-CSharp-VSTO-CreateandEmbedExcelChartAsOLEUsingVSTO-UseCopyPaste.cs](https://gist.githubusercontent.com/aspose-com-gists/a56eda38c01ad33dc653116c7bae4293/raw/60f36b65dcdc5f7368b2d455fe1ae74076eeae08/Examples-CSharp-VSTO-CreateandEmbedExcelChartAsOLEUsingVSTO-UseCopyPaste.cs)
### **Aspose.Slides for Java Example**
Using Aspose.Slides for .NET, the following steps are performed:
1. Create a workbook using Aspose.Cells for Java.
1. Create a Microsoft Excel chart.
1. Set the OLE size of the Excel Chart.
1. Get an image of the chart.
1. Embed the Excel chart as an OLE Object inside PPTX presentation using Aspose.Slides for Java.
1. Replace the object changed image with the image obtained in step 3 to cater for the object changed issue.
1. Write the output presentation to disk in PPTX format.
```java
try {
//Create a workbook
Workbook wb = new Workbook();
//Add an excel chart
int chartRows = 55;
int chartCols = 25;
int chartSheetIndex = AddExcelChartInWorkbook(wb, chartRows, chartCols);
//Set chart ole size
wb.getWorksheets().setOleSize(0, chartRows, 0, chartCols);
//Get the chart image and save to stream
com.aspose.cells.ImageOrPrintOptions opts= new com.aspose.cells.ImageOrPrintOptions();
opts.setImageFormat(com.aspose.cells.ImageFormat.getPng());
ByteArrayOutputStream imageStream=new ByteArrayOutputStream();
wb.getWorksheets().get(chartSheetIndex).getCharts().get(0).toImage(imageStream, opts);
//Save the workbook to stream
ByteArrayOutputStream bout=new ByteArrayOutputStream();
wb.save(bout,com.aspose.cells.SaveFormat.EXCEL_97_TO_2003);
//Create a presentation
Presentation pres = new Presentation();
ISlide sld = pres.getSlides().get_Item(0);
//Add the workbook on slide
AddExcelChartInPresentation(pres, sld, bout.toByteArray(), imageStream.toByteArray());
//Write the presentation to disk
pres.save("outputJ.pptx", SaveFormat.Pptx);
} catch (Exception e) {
}
```
[Source: Examples-src-main-java-com-aspose-slides-examples-Slides-Charts-EmbedChartAsOLEObject-EmbedChartAsOLEObject.java](https://gist.githubusercontent.com/aspose-com-gists/1f55f0222bc39a382d831900e8de7400/raw/9aa49dcea7f6b5635e44c02fa54f989b47252a75/Examples-src-main-java-com-aspose-slides-examples-Slides-Charts-EmbedChartAsOLEObject-EmbedChartAsOLEObject.java)
```java
static void AddExcelChartInPresentation(Presentation pres, ISlide sld, byte[] wbArray, byte[] imgChart) throws Exception
{
double oleHeight = pres.getSlideSize().getSize().getHeight();
double oleWidth = pres.getSlideSize().getSize().getWidth();
Workbook wb=new Workbook();
//Createing and EXCEL_97_TO_2003 LoadOptions object
com.aspose.cells.LoadOptions loadOptions = new com.aspose.cells.LoadOptions(com.aspose.cells.FileFormatType.EXCEL_97_TO_2003);
wb=new Workbook(new ByteArrayInputStream(wbArray),loadOptions);
IOleObjectFrame oof = sld.getShapes().addOleObjectFrame(0f, 0f, (float)oleWidth, (float)oleHeight, "Excel.Sheet.8", wbArray);
oof.getSubstitutePictureFormat().getPicture().setImage(pres.getImages().addImage(new ByteArrayInputStream(imgChart)));
}
```
[Source: Examples-src-main-java-com-aspose-slides-examples-Slides-Charts-EmbedChartAsOLEObject-AddExcelChartInPresentation.java](https://gist.githubusercontent.com/aspose-com-gists/1f55f0222bc39a382d831900e8de7400/raw/2dc498ca51305901fdc54f6337ba6aff05d476b4/Examples-src-main-java-com-aspose-slides-examples-Slides-Charts-EmbedChartAsOLEObject-AddExcelChartInPresentation.java)
```java
static int AddExcelChartInWorkbook(Workbook wb, int chartRows, int chartCols)
{
//Array of cell names
String[] cellsName = new String[]
{
"A1", "A2", "A3", "A4",
"B1", "B2", "B3", "B4",
"C1", "C2", "C3", "C4",
"D1", "D2", "D3", "D4",
"E1", "E2", "E3", "E4"
};
//Array of cell data
int[] cellsValue = new int[]
{
67,86,68,91,
44,64,89,48,
46,97,78,60,
43,29,69,26,
24,40,38,25
};
//Add a new worksheet to populate cells with data
int dataSheetIndex =wb.getWorksheets().add();
Worksheet dataSheet =wb.getWorksheets().get(dataSheetIndex);
String sheetName = "DataSheet";
dataSheet.setName(sheetName);
//Populate DataSheet with data
int size= Array.getLength(cellsName);
for (int i = 0; i < size; i++)
{
String cellName = cellsName[i];
int cellValue = cellsValue[i];
dataSheet.getCells().get(cellName).setValue(cellValue);
}
//Add a chart sheet
int WorksheetIndex = wb.getWorksheets().add(SheetType.CHART);
Worksheet chartSheet = wb.getWorksheets().get(WorksheetIndex);
chartSheet.setName("ChartSheet");
int chartSheetIdx = chartSheet.getIndex();
//Add a chart in ChartSheet with data series from DataSheet
int chIndex = chartSheet.getCharts().add(ChartType.COLUMN, 0, chartRows, 0, chartCols);
Chart chart=chartSheet.getCharts().get(chIndex);
chart.getNSeries().add(sheetName + "!A1:E1", false);
chart.getNSeries().add(sheetName + "!A2:E2", false);
chart.getNSeries().add(sheetName + "!A3:E3", false);
chart.getNSeries().add(sheetName + "!A4:E4", false);
//Set ChartSheet as active sheet
wb.getWorksheets().setActiveSheetIndex(chartSheetIdx);
return chartSheetIdx;
}
```
[Source: Examples-src-main-java-com-aspose-slides-examples-Slides-Charts-EmbedChartAsOLEObject-AddExcelChartInWorkbook.java](https://gist.githubusercontent.com/aspose-com-gists/1f55f0222bc39a382d831900e8de7400/raw/6312a1ad9c523b365c5a667131857da7bf03a059/Examples-src-main-java-com-aspose-slides-examples-Slides-Charts-EmbedChartAsOLEObject-AddExcelChartInWorkbook.java)
## Related articles
- [Creating Tables Using VSTO and Aspose.Slides for Java](https://docs.aspose.com/slides/java/creating-a-table-on-powerpoint-slide/)
- [Adding Text Dynamically Using VSTO and Aspose.Slides for Java](https://docs.aspose.com/slides/java/adding-text-dynamically-using-vsto-and-aspose-slides-for-java/)
- [Create Charts Using VSTO and Aspose.Slides for Java](https://docs.aspose.com/slides/java/create-a-chart-in-a-microsoft-powerpoint-presentation/)
# Create or Update PowerPoint Presentation Charts in Java
> Create and customize charts in PowerPoint presentations using Aspose.Slides for Java. Add, format, and edit charts with practical code examples in Java.
Source: https://docs.aspose.com/slides/java/create-chart/
Updated: 2026-11-18
## **Overview**
This article provides a comprehensive guide on how to create and customize charts using Aspose.Slides for Java. You will learn how to programmatically add a chart to a slide, populate it with data, and apply various formatting options to match your specific design requirements. Throughout the article, detailed code examples illustrate each step, from initializing the presentation and chart object to configuring series, axes, and legends. By following this guide, you'll gain a solid understanding of how to integrate dynamic chart generation into your Java applications, streamlining the process of creating data-driven presentations.
## **Create a Chart**
Charts help people quickly visualize data and gain insights that may not be immediately obvious from a table or spreadsheet.
**Why Create Charts?**
Using charts, you can:
* aggregate, condense, or summarize large amounts of data on a single slide in a presentation;
* expose patterns and trends in data;
* deduce the direction and momentum of data over time or with respect to a specific unit of measurement;
* spot outliers, aberrations, deviations, errors, and nonsensical data;
* communicate or present complex data.
In PowerPoint, you can create charts through the *Insert* function, which provides templates for designing many types of charts. Using Aspose.Slides, you can create both regular charts (based on popular chart types) and custom charts.
Use the [ChartType](https://reference.aspose.com/slides/java/com.aspose.slides/charttype/) enumeration in the [com.aspose.slides](https://reference.aspose.com/slides/java/com.aspose.slides/) package. The values in this enumeration correspond to different chart types.
### **Create Clustered Column Charts**
This example uses [addChart](https://reference.aspose.com/slides/java/com.aspose.slides/ishapecollection/#addChart-int-float-float-float-float-) to create a clustered column chart that compares two series across three categories. The series use red and green fills, and individual labels demonstrate category names, series names, and values. Worksheet index 0 refers to the first sheet in the embedded chart workbook.
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try
{
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 20, 20, 500, 300);
chart.getChartTitle().addTextFrameForOverriding("Sample Title");
chart.getChartTitle().getTextFrameForOverriding().getTextFrameFormat().setCenterText(NullableBool.True);
chart.getChartTitle().setHeight(20);
chart.setTitle(true);
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
int worksheetIndex = 0;
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
IChartDataCell seriesNameCell = workbook.getCell(worksheetIndex, 0, 1, "Series 1");
chart.getChartData().getSeries().add(seriesNameCell, chart.getType());
seriesNameCell = workbook.getCell(worksheetIndex, 0, 2, "Series 2");
chart.getChartData().getSeries().add(seriesNameCell, chart.getType());
IChartDataCell categoryCell = workbook.getCell(worksheetIndex, 1, 0, "Category 1");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(worksheetIndex, 2, 0, "Category 2");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(worksheetIndex, 3, 0, "Category 3");
chart.getChartData().getCategories().add(categoryCell);
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
IChartDataCell valueCell = workbook.getCell(worksheetIndex, 1, 1, 20);
series.getDataPoints().addDataPointForBarSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, 2, 1, 50);
series.getDataPoints().addDataPointForBarSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, 3, 1, 30);
series.getDataPoints().addDataPointForBarSeries(valueCell);
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(Color.RED);
series = chart.getChartData().getSeries().get_Item(1);
valueCell = workbook.getCell(worksheetIndex, 1, 2, 30);
series.getDataPoints().addDataPointForBarSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, 2, 2, 10);
series.getDataPoints().addDataPointForBarSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, 3, 2, 60);
series.getDataPoints().addDataPointForBarSeries(valueCell);
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(new Color(0, 128, 0));
IDataLabel label = series.getDataPoints().get_Item(0).getLabel();
label.getDataLabelFormat().setShowCategoryName(true);
label = series.getDataPoints().get_Item(1).getLabel();
label.getDataLabelFormat().setShowSeriesName(true);
label = series.getDataPoints().get_Item(2).getLabel();
label.getDataLabelFormat().setShowValue(true);
label.getDataLabelFormat().setShowSeriesName(true);
label.getDataLabelFormat().setSeparator("/");
presentation.save("AsposeChart.pptx", SaveFormat.Pptx);
}
finally
{
presentation.dispose();
}
```
The result:

### **Create Scatter Charts**
Scatter charts (also known as scatter plots or x-y graphs) are often used to check for patterns or demonstrate correlations between two variables.
Use a scatter chart when:
* You have paired numerical data.
* You have two variables that pair well together.
* You want to determine whether the two variables are related.
* You have an independent variable that has multiple values for a dependent variable.
This example plots two sets of x-y values. The first series uses straight lines with star markers, while the second uses smooth lines with circle markers; both use a marker size of 10, configured with [setSize](https://reference.aspose.com/slides/java/com.aspose.slides/imarker/#setSize-int-). The [setSymbol](https://reference.aspose.com/slides/java/com.aspose.slides/imarker/#setSymbol-int-) method controls the marker shape.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try
{
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ScatterWithSmoothLines, 20, 20, 500, 300);
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
int worksheetIndex = 0;
chart.getChartData().getSeries().clear();
IChartDataCell seriesNameCell = workbook.getCell(worksheetIndex, 1, 1, "Series 1");
chart.getChartData().getSeries().add(seriesNameCell, chart.getType());
seriesNameCell = workbook.getCell(worksheetIndex, 1, 3, "Series 2");
chart.getChartData().getSeries().add(seriesNameCell, chart.getType());
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
IChartDataCell xValueCell = workbook.getCell(worksheetIndex, 2, 1, 1);
IChartDataCell yValueCell = workbook.getCell(worksheetIndex, 2, 2, 3);
series.getDataPoints().addDataPointForScatterSeries(xValueCell, yValueCell);
xValueCell = workbook.getCell(worksheetIndex, 3, 1, 2);
yValueCell = workbook.getCell(worksheetIndex, 3, 2, 10);
series.getDataPoints().addDataPointForScatterSeries(xValueCell, yValueCell);
series.setType(ChartType.ScatterWithStraightLinesAndMarkers);
series.getMarker().setSize(10);
series.getMarker().setSymbol(MarkerStyleType.Star);
series = chart.getChartData().getSeries().get_Item(1);
xValueCell = workbook.getCell(worksheetIndex, 2, 3, 5);
yValueCell = workbook.getCell(worksheetIndex, 2, 4, 2);
series.getDataPoints().addDataPointForScatterSeries(xValueCell, yValueCell);
xValueCell = workbook.getCell(worksheetIndex, 3, 3, 3);
yValueCell = workbook.getCell(worksheetIndex, 3, 4, 1);
series.getDataPoints().addDataPointForScatterSeries(xValueCell, yValueCell);
xValueCell = workbook.getCell(worksheetIndex, 4, 3, 2);
yValueCell = workbook.getCell(worksheetIndex, 4, 4, 2);
series.getDataPoints().addDataPointForScatterSeries(xValueCell, yValueCell);
xValueCell = workbook.getCell(worksheetIndex, 5, 3, 5);
yValueCell = workbook.getCell(worksheetIndex, 5, 4, 1);
series.getDataPoints().addDataPointForScatterSeries(xValueCell, yValueCell);
series.getMarker().setSize(10);
series.getMarker().setSymbol(MarkerStyleType.Circle);
presentation.save("AsposeChart.pptx", SaveFormat.Pptx);
}
finally
{
presentation.dispose();
}
```
The result:

### **Create Pie Charts**
Pie charts are best used to show the part-to-whole relationship in data, especially when the data contains categorical labels with numeric values. However, if your data contains many parts or labels, you might want to consider using a bar chart instead.
This example creates a pie chart with three quarterly values. Each slice has a custom fill and border, and the labels display different combinations of values, percentages, and series information. The [setFirstSliceAngle](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseriesgroup/#setFirstSliceAngle-int-) method sets the first slice to start at 180 degrees.
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try
{
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Pie, 20, 20, 500, 300);
chart.getChartTitle().addTextFrameForOverriding("Sample Title");
chart.getChartTitle().getTextFrameForOverriding().getTextFrameFormat().setCenterText(NullableBool.True);
chart.getChartTitle().setHeight(20);
chart.setTitle(true);
chart.getChartData().getSeries().get_Item(0).getLabels().getDefaultDataLabelFormat().setShowValue(true);
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
int worksheetIndex = 0;
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
IChartDataCell categoryCell = workbook.getCell(0, 1, 0, "1st Qtr");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, 2, 0, "2nd Qtr");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, 3, 0, "3rd Qtr");
chart.getChartData().getCategories().add(categoryCell);
IChartDataCell seriesNameCell = workbook.getCell(0, 0, 1, "Series 1");
IChartSeries series = chart.getChartData().getSeries().add(seriesNameCell, chart.getType());
IChartDataCell valueCell = workbook.getCell(worksheetIndex, 1, 1, 20);
series.getDataPoints().addDataPointForPieSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, 2, 1, 50);
series.getDataPoints().addDataPointForPieSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, 3, 1, 30);
series.getDataPoints().addDataPointForPieSeries(valueCell);
chart.getChartData().getSeriesGroups().get_Item(0).setColorVaried(true);
IChartDataPoint firstSlice = series.getDataPoints().get_Item(0);
firstSlice.getFormat().getFill().setFillType(FillType.Solid);
firstSlice.getFormat().getFill().getSolidFillColor().setColor(Color.CYAN);
firstSlice.getFormat().getLine().getFillFormat().setFillType(FillType.Solid);
firstSlice.getFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.GRAY);
firstSlice.getFormat().getLine().setWidth(3.0);
firstSlice.getFormat().getLine().setStyle(LineStyle.ThinThick);
firstSlice.getFormat().getLine().setDashStyle(LineDashStyle.LargeDash);
IChartDataPoint secondSlice = series.getDataPoints().get_Item(1);
secondSlice.getFormat().getFill().setFillType(FillType.Solid);
secondSlice.getFormat().getFill().getSolidFillColor().setColor(new Color(165, 42, 42));
secondSlice.getFormat().getLine().getFillFormat().setFillType(FillType.Solid);
secondSlice.getFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.BLUE);
secondSlice.getFormat().getLine().setWidth(3.0);
secondSlice.getFormat().getLine().setStyle(LineStyle.Single);
secondSlice.getFormat().getLine().setDashStyle(LineDashStyle.LargeDashDot);
IChartDataPoint thirdSlice = series.getDataPoints().get_Item(2);
thirdSlice.getFormat().getFill().setFillType(FillType.Solid);
thirdSlice.getFormat().getFill().getSolidFillColor().setColor(new Color(255, 127, 80));
thirdSlice.getFormat().getLine().getFillFormat().setFillType(FillType.Solid);
thirdSlice.getFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.RED);
thirdSlice.getFormat().getLine().setWidth(2.0);
thirdSlice.getFormat().getLine().setStyle(LineStyle.ThinThin);
thirdSlice.getFormat().getLine().setDashStyle(LineDashStyle.LargeDashDotDot);
IDataLabel firstLabel = series.getDataPoints().get_Item(0).getLabel();
firstLabel.getDataLabelFormat().setShowValue(true);
IDataLabel secondLabel = series.getDataPoints().get_Item(1).getLabel();
secondLabel.getDataLabelFormat().setShowValue(true);
secondLabel.getDataLabelFormat().setShowLegendKey(true);
secondLabel.getDataLabelFormat().setShowPercentage(true);
IDataLabel thirdLabel = series.getDataPoints().get_Item(2).getLabel();
thirdLabel.getDataLabelFormat().setShowSeriesName(true);
thirdLabel.getDataLabelFormat().setShowPercentage(true);
series.getLabels().getDefaultDataLabelFormat().setShowLeaderLines(true);
chart.getChartData().getSeriesGroups().get_Item(0).setFirstSliceAngle(180);
presentation.save("PieChart.pptx", SaveFormat.Pptx);
}
finally
{
presentation.dispose();
}
```
The result:

To improve the readability of labels outside the pie, see [Format Leader Lines](https://docs.aspose.com/slides/java/chart-data-label/#format-leader-lines) for an example that positions labels and customizes the lines' color, width, transparency, and dash style.
### **Create Line Charts**
Line charts (also known as line graphs) are best used in situations where you want to demonstrate changes in value over time. Using a line chart, you can compare a large amount of data at once, track changes and trends over time, highlight anomalies in data series, and more.
This example uses [addChart](https://reference.aspose.com/slides/java/com.aspose.slides/ishapecollection/#addChart-int-float-float-float-float-) to create a line chart with the default series and categories, then saves the presentation as PPTX.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try
{
ISlide slide = presentation.getSlides().get_Item(0);
IChart lineChart = slide.getShapes().addChart(ChartType.Line, 20, 20, 500, 300);
presentation.save("lineChart.pptx", SaveFormat.Pptx);
}
finally
{
presentation.dispose();
}
```
By default, points on a line chart are joined by straight continuous lines. If you want the points to be joined by dashes instead, call [setDashStyle](https://reference.aspose.com/slides/java/com.aspose.slides/ilineformat/#setDashStyle-byte-) with a value from [LineDashStyle](https://reference.aspose.com/slides/java/com.aspose.slides/linedashstyle/):
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try
{
ISlide slide = presentation.getSlides().get_Item(0);
IChart lineChart = slide.getShapes().addChart(ChartType.Line, 20, 20, 500, 300);
for (IChartSeries series : lineChart.getChartData().getSeries())
{
series.getFormat().getLine().setDashStyle(LineDashStyle.Dash);
}
}
finally
{
presentation.dispose();
}
```
The result:

### **Create Tree Map Charts**
Tree map charts are best used for sales data when you want to show the relative size of data categories and quickly draw attention to items that are large contributors within each category.
This example creates a tree map with eight leaves grouped into four stems and two branches. The [setGroupingItem](https://reference.aspose.com/slides/java/com.aspose.slides/ichartcategorylevelsmanager/#setGroupingItem-int-java.lang.Object-) method assigns stems at grouping level 1 and branches at level 2. Values determine the relative rectangle sizes, while category labels and overlapping parent labels identify the hierarchy.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try
{
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Treemap, 20, 20, 500, 300);
chart.getChartData().getCategories().clear();
chart.getChartData().getSeries().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
workbook.clear(0);
// Branch 1
IChartDataCell categoryCell = workbook.getCell(0, "C1", "Leaf1");
IChartCategory leaf = chart.getChartData().getCategories().add(categoryCell);
leaf.getGroupingLevels().setGroupingItem(1, "Stem1");
leaf.getGroupingLevels().setGroupingItem(2, "Branch1");
categoryCell = workbook.getCell(0, "C2", "Leaf2");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, "C3", "Leaf3");
leaf = chart.getChartData().getCategories().add(categoryCell);
leaf.getGroupingLevels().setGroupingItem(1, "Stem2");
categoryCell = workbook.getCell(0, "C4", "Leaf4");
chart.getChartData().getCategories().add(categoryCell);
// Branch 2
categoryCell = workbook.getCell(0, "C5", "Leaf5");
leaf = chart.getChartData().getCategories().add(categoryCell);
leaf.getGroupingLevels().setGroupingItem(1, "Stem3");
leaf.getGroupingLevels().setGroupingItem(2, "Branch2");
categoryCell = workbook.getCell(0, "C6", "Leaf6");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, "C7", "Leaf7");
leaf = chart.getChartData().getCategories().add(categoryCell);
leaf.getGroupingLevels().setGroupingItem(1, "Stem4");
categoryCell = workbook.getCell(0, "C8", "Leaf8");
chart.getChartData().getCategories().add(categoryCell);
IChartSeries series = chart.getChartData().getSeries().add(ChartType.Treemap);
series.getLabels().getDefaultDataLabelFormat().setShowCategoryName(true);
IChartDataCell valueCell = workbook.getCell(0, "D1", 4);
series.getDataPoints().addDataPointForTreemapSeries(valueCell);
valueCell = workbook.getCell(0, "D2", 5);
series.getDataPoints().addDataPointForTreemapSeries(valueCell);
valueCell = workbook.getCell(0, "D3", 3);
series.getDataPoints().addDataPointForTreemapSeries(valueCell);
valueCell = workbook.getCell(0, "D4", 6);
series.getDataPoints().addDataPointForTreemapSeries(valueCell);
valueCell = workbook.getCell(0, "D5", 9);
series.getDataPoints().addDataPointForTreemapSeries(valueCell);
valueCell = workbook.getCell(0, "D6", 9);
series.getDataPoints().addDataPointForTreemapSeries(valueCell);
valueCell = workbook.getCell(0, "D7", 4);
series.getDataPoints().addDataPointForTreemapSeries(valueCell);
valueCell = workbook.getCell(0, "D8", 3);
series.getDataPoints().addDataPointForTreemapSeries(valueCell);
series.setParentLabelLayout(ParentLabelLayoutType.Overlapping);
presentation.save("Treemap.pptx", SaveFormat.Pptx);
}
finally
{
presentation.dispose();
}
```
The result:

### **Create Waterfall Charts**
A waterfall chart shows how positive and negative changes contribute to a final value. For example, a profit breakdown can start with revenue, subtract costs, and add other income. Change columns float between the previous and new running values, while total columns extend from zero to the accumulated value.
The following example uses amounts in thousands of US dollars:
| Category | Workbook value | Column type |
| --- | ---: | --- |
| Revenue | 1000 | Increase |
| Cost of sales | -400 | Decrease |
| Gross profit | 600 | Intermediate total |
| Operating expenses | -200 | Decrease |
| Other income | 50 | Increase |
| Net profit | 450 | Final total |
To mark a point as an intermediate or final total, call its [setSetAsTotal](https://reference.aspose.com/slides/java/com.aspose.slides/chartdatapoint/#setSetAsTotal-boolean-) method with `true`. Supply the actual accumulated amount in that point's workbook cell: `600` for gross profit (`1000 - 400`) and `450` for net profit (`600 - 200 + 50`). The method marks the column as a total; it does not calculate or populate the cell value. Do not use zero as a placeholder or supply another change for a total point. A total column displays the accumulated value without adding it again to the running value.
This complete Java example creates a chart using the `Waterfall` member of [ChartType](https://reference.aspose.com/slides/java/com.aspose.slides/charttype/), clears the default data, and fills the embedded workbook. Worksheet index `0` selects the first worksheet; column A contains category names and column B contains values. Each value cell is added with [addDataPointForWaterfallSeries](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapointcollection/#addDataPointForWaterfallSeries-com.aspose.slides.IChartDataCell-). The zero-based point indices `2` and `5` identify the intermediate and final totals. Calling [setShowValue](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabelformat/#setShowValue-boolean-) with `true` displays the amounts on the columns. No input presentation or workbook is required.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try
{
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Waterfall, 20, 20, 680, 200);
chart.setTitle(true);
chart.getChartTitle().addTextFrameForOverriding("Profit breakdown (USD thousands)");
chart.getChartTitle().setOverlay(false);
chart.setLegend(false);
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
int worksheetIndex = 0;
workbook.clear(worksheetIndex);
IChartDataCell seriesNameCell = workbook.getCell(worksheetIndex, 0, 1, "Profit");
IChartSeries series = chart.getChartData().getSeries().add(seriesNameCell, ChartType.Waterfall);
String[] categories = new String[] { "Revenue", "Cost of sales", "Gross profit", "Operating expenses", "Other income", "Net profit" };
double[] values = new double[] { 1000, -400, 600, -200, 50, 450 };
for (int i = 0; i < categories.length; i++)
{
IChartDataCell categoryCell = workbook.getCell(worksheetIndex, i + 1, 0, categories[i]);
chart.getChartData().getCategories().add(categoryCell);
IChartDataCell valueCell = workbook.getCell(worksheetIndex, i + 1, 1, values[i]);
series.getDataPoints().addDataPointForWaterfallSeries(valueCell);
}
// The third and sixth points represent totals, not additional changes.
series.getDataPoints().get_Item(2).setSetAsTotal(true);
series.getDataPoints().get_Item(5).setSetAsTotal(true);
series.setShowConnectorLines(true);
series.getLabels().getDefaultDataLabelFormat().setShowValue(true);
presentation.save("WaterfallChart.pptx", SaveFormat.Pptx);
}
finally
{
presentation.dispose();
}
```
Call the series-level [setShowConnectorLines](https://reference.aspose.com/slides/java/com.aspose.slides/chartseries/#setShowConnectorLines-boolean-) method with `true` to show lines linking consecutive columns and make the running value easier to follow. To hide these lines, replace the method call in the example with `series.setShowConnectorLines(false);` before saving. This changes only the line visibility, not the data or totals.
The saved presentation shows gross profit of 600 and net profit of 450, with both totals drawn from zero:

### **Create Stock Charts**
Stock charts are used to display financial data such as open, high, low, and close prices, helping analyze market trends and volatility. They offer essential insights into stock performance, aiding investors and analysts in making informed decisions.
This example creates an open-high-low-close chart with four series in that order and three categories. The [setUpDownBars](https://reference.aspose.com/slides/java/com.aspose.slides/iupdownbarsmanager/#setUpDownBars-boolean-) method enables up/down bars, and [getHiLowLinesFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseriesgroup/#getHiLowLinesFormat--) controls the high-low lines that show the price ranges, while the individual series lines and minor horizontal gridlines are hidden.
The manager returned by [getUpDownBars](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseriesgroup/#getUpDownBars--) exposes separate formatting objects through [getUpBarsFormat](https://reference.aspose.com/slides/java/com.aspose.slides/iupdownbarsmanager/#getUpBarsFormat--) and [getDownBarsFormat](https://reference.aspose.com/slides/java/com.aspose.slides/iupdownbarsmanager/#getDownBarsFormat--). Use each object's [getFill](https://reference.aspose.com/slides/java/com.aspose.slides/iformat/#getFill--) and [getLine](https://reference.aspose.com/slides/java/com.aspose.slides/iformat/#getLine--) methods to set its fill and outline independently. This example uses green bars with dark-green outlines for rising intervals and orange-red bars with dark-red outlines for falling intervals.
Provide numeric values for all four series at each category, with High and Low enclosing Open and Close. The bars compare Close with Open **within the same category**, not with the previous category: A falls from 72 to 25, while B rises from 25 to 38 and C rises from 38 to 50. Equal Open and Close values produce no visible filled interval. Up/down bars span Open–Close; high-low lines span Low–High. These bars belong to the series group and are not ordinary bar-chart series.
This formatting also works with [Line and LineWithMarkers](https://reference.aspose.com/slides/java/com.aspose.slides/charttype/) charts containing at least two series in the same group and corresponding numeric values for each category. For these non-stacked line charts, up/down bars compare the first and last series: a higher last value produces an up bar, and a lower last value produces a down bar. Reversing those series reverses the classification. The example below uses [OpenHighLowClose](https://reference.aspose.com/slides/java/com.aspose.slides/charttype/); do not assume that other stock, stacked-line, or 3D variants use the same data arrangement or interval interpretation.
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try
{
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.OpenHighLowClose, 20, 20, 500, 150, false);
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
IChartDataCell categoryCell = workbook.getCell(0, 1, 0, "A");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, 2, 0, "B");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, 3, 0, "C");
chart.getChartData().getCategories().add(categoryCell);
IChartDataCell seriesNameCell = workbook.getCell(0, 0, 1, "Open");
chart.getChartData().getSeries().add(seriesNameCell, ChartType.OpenHighLowClose);
seriesNameCell = workbook.getCell(0, 0, 2, "High");
chart.getChartData().getSeries().add(seriesNameCell, ChartType.OpenHighLowClose);
seriesNameCell = workbook.getCell(0, 0, 3, "Low");
chart.getChartData().getSeries().add(seriesNameCell, ChartType.OpenHighLowClose);
seriesNameCell = workbook.getCell(0, 0, 4, "Close");
chart.getChartData().getSeries().add(seriesNameCell, ChartType.OpenHighLowClose);
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
IChartDataCell valueCell = workbook.getCell(0, 1, 1, 72);
series.getDataPoints().addDataPointForStockSeries(valueCell);
valueCell = workbook.getCell(0, 2, 1, 25);
series.getDataPoints().addDataPointForStockSeries(valueCell);
valueCell = workbook.getCell(0, 3, 1, 38);
series.getDataPoints().addDataPointForStockSeries(valueCell);
series = chart.getChartData().getSeries().get_Item(1);
valueCell = workbook.getCell(0, 1, 2, 172);
series.getDataPoints().addDataPointForStockSeries(valueCell);
valueCell = workbook.getCell(0, 2, 2, 57);
series.getDataPoints().addDataPointForStockSeries(valueCell);
valueCell = workbook.getCell(0, 3, 2, 57);
series.getDataPoints().addDataPointForStockSeries(valueCell);
series = chart.getChartData().getSeries().get_Item(2);
valueCell = workbook.getCell(0, 1, 3, 12);
series.getDataPoints().addDataPointForStockSeries(valueCell);
valueCell = workbook.getCell(0, 2, 3, 12);
series.getDataPoints().addDataPointForStockSeries(valueCell);
valueCell = workbook.getCell(0, 3, 3, 13);
series.getDataPoints().addDataPointForStockSeries(valueCell);
series = chart.getChartData().getSeries().get_Item(3);
valueCell = workbook.getCell(0, 1, 4, 25);
series.getDataPoints().addDataPointForStockSeries(valueCell);
valueCell = workbook.getCell(0, 2, 4, 38);
series.getDataPoints().addDataPointForStockSeries(valueCell);
valueCell = workbook.getCell(0, 3, 4, 50);
series.getDataPoints().addDataPointForStockSeries(valueCell);
IUpDownBarsManager upDownBars = chart.getChartData().getSeriesGroups().get_Item(0).getUpDownBars();
upDownBars.setUpDownBars(true);
upDownBars.getUpBarsFormat().getFill().setFillType(FillType.Solid);
upDownBars.getUpBarsFormat().getFill().getSolidFillColor().setColor(new Color(50, 205, 50));
upDownBars.getUpBarsFormat().getLine().getFillFormat().setFillType(FillType.Solid);
upDownBars.getUpBarsFormat().getLine().getFillFormat().getSolidFillColor().setColor(new Color(0, 100, 0));
upDownBars.getUpBarsFormat().getLine().setWidth(2);
upDownBars.getDownBarsFormat().getFill().setFillType(FillType.Solid);
upDownBars.getDownBarsFormat().getFill().getSolidFillColor().setColor(new Color(255, 69, 0));
upDownBars.getDownBarsFormat().getLine().getFillFormat().setFillType(FillType.Solid);
upDownBars.getDownBarsFormat().getLine().getFillFormat().getSolidFillColor().setColor(new Color(139, 0, 0));
upDownBars.getDownBarsFormat().getLine().setWidth(2);
chart.getChartData().getSeriesGroups().get_Item(0).getHiLowLinesFormat().getLine().getFillFormat().setFillType(FillType.Solid);
for (IChartSeries stockSeries : chart.getChartData().getSeries())
{
stockSeries.getFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
}
chart.getAxes().getVerticalAxis().getMinorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
presentation.save("Stock-chart.pptx", SaveFormat.Pptx);
}
finally
{
presentation.dispose();
}
```
The result, exported from PowerPoint:

### **Create Box and Whisker Charts**
Box and whisker charts are used to display the distribution of data by summarizing key statistical measures, such as the median, quartiles, and potential outliers. They are particularly useful in exploratory data analysis and statistical studies to quickly understand data variability and identify any anomalies.
This example creates a box and whisker chart from six values. The [setQuartileMethod](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#setQuartileMethod-int-) method selects the exclusive quartile calculation. The example also enables mean lines, mean markers, inner points, and outlier points.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try
{
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.BoxAndWhisker, 20, 20, 500, 300);
chart.getChartData().getCategories().clear();
chart.getChartData().getSeries().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
workbook.clear(0);
IChartDataCell categoryCell = workbook.getCell(0, "A1", "Category 1");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, "A2", "Category 2");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, "A3", "Category 3");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, "A4", "Category 4");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, "A5", "Category 5");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, "A6", "Category 6");
chart.getChartData().getCategories().add(categoryCell);
IChartSeries series = chart.getChartData().getSeries().add(ChartType.BoxAndWhisker);
series.setQuartileMethod(QuartileMethodType.Exclusive);
series.setShowMeanLine(true);
series.setShowMeanMarkers(true);
series.setShowInnerPoints(true);
series.setShowOutlierPoints(true);
IChartDataCell valueCell = workbook.getCell(0, "B1", 15);
series.getDataPoints().addDataPointForBoxAndWhiskerSeries(valueCell);
valueCell = workbook.getCell(0, "B2", 41);
series.getDataPoints().addDataPointForBoxAndWhiskerSeries(valueCell);
valueCell = workbook.getCell(0, "B3", 16);
series.getDataPoints().addDataPointForBoxAndWhiskerSeries(valueCell);
valueCell = workbook.getCell(0, "B4", 10);
series.getDataPoints().addDataPointForBoxAndWhiskerSeries(valueCell);
valueCell = workbook.getCell(0, "B5", 23);
series.getDataPoints().addDataPointForBoxAndWhiskerSeries(valueCell);
valueCell = workbook.getCell(0, "B6", 16);
series.getDataPoints().addDataPointForBoxAndWhiskerSeries(valueCell);
presentation.save("BoxAndWhisker.pptx", SaveFormat.Pptx);
}
finally
{
presentation.dispose();
}
```
### **Create Funnel Charts**
Funnel charts are used to visualize processes that involve sequential stages, where the volume of data decreases as it progresses from one step to the next. They are especially helpful for analyzing conversion rates, identifying bottlenecks, and tracking the efficiency of sales or marketing processes.
This example uses [addChart](https://reference.aspose.com/slides/java/com.aspose.slides/ishapecollection/#addChart-int-float-float-float-float-) to add a funnel chart to the first slide of an existing presentation. It replaces the default data with six categories and values ranging from 50 to 500, then saves the updated presentation. The input presentation must contain at least one slide.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("test.pptx");
try
{
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Funnel, 50, 50, 500, 400);
chart.getChartData().getCategories().clear();
chart.getChartData().getSeries().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
workbook.clear(0);
IChartDataCell categoryCell = workbook.getCell(0, "A1", "Category 1");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, "A2", "Category 2");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, "A3", "Category 3");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, "A4", "Category 4");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, "A5", "Category 5");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, "A6", "Category 6");
chart.getChartData().getCategories().add(categoryCell);
IChartSeries series = chart.getChartData().getSeries().add(ChartType.Funnel);
IChartDataCell valueCell = workbook.getCell(0, "B1", 50);
series.getDataPoints().addDataPointForFunnelSeries(valueCell);
valueCell = workbook.getCell(0, "B2", 100);
series.getDataPoints().addDataPointForFunnelSeries(valueCell);
valueCell = workbook.getCell(0, "B3", 200);
series.getDataPoints().addDataPointForFunnelSeries(valueCell);
valueCell = workbook.getCell(0, "B4", 300);
series.getDataPoints().addDataPointForFunnelSeries(valueCell);
valueCell = workbook.getCell(0, "B5", 400);
series.getDataPoints().addDataPointForFunnelSeries(valueCell);
valueCell = workbook.getCell(0, "B6", 500);
series.getDataPoints().addDataPointForFunnelSeries(valueCell);
presentation.save("Funnel.pptx", SaveFormat.Pptx);
}
finally
{
presentation.dispose();
}
```
The result:

### **Create Sunburst Charts**
Sunburst charts are used to visualize hierarchical data, displaying levels as concentric rings. They help illustrate part-to-whole relationships and are ideal for representing nested categories and subcategories in a clear, compact format.
This example creates a sunburst chart with eight leaves grouped into four stems and two branches. The [setGroupingItem](https://reference.aspose.com/slides/java/com.aspose.slides/ichartcategorylevelsmanager/#setGroupingItem-int-java.lang.Object-) method assigns stems at grouping level 1 and branches at level 2. Category labels identify the segments, and the values determine their relative sizes.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try
{
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Sunburst, 20, 20, 500, 300);
chart.getChartData().getCategories().clear();
chart.getChartData().getSeries().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
workbook.clear(0);
// Branch 1
IChartDataCell categoryCell = workbook.getCell(0, "C1", "Leaf1");
IChartCategory leaf = chart.getChartData().getCategories().add(categoryCell);
leaf.getGroupingLevels().setGroupingItem(1, "Stem1");
leaf.getGroupingLevels().setGroupingItem(2, "Branch1");
categoryCell = workbook.getCell(0, "C2", "Leaf2");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, "C3", "Leaf3");
leaf = chart.getChartData().getCategories().add(categoryCell);
leaf.getGroupingLevels().setGroupingItem(1, "Stem2");
categoryCell = workbook.getCell(0, "C4", "Leaf4");
chart.getChartData().getCategories().add(categoryCell);
// Branch 2
categoryCell = workbook.getCell(0, "C5", "Leaf5");
leaf = chart.getChartData().getCategories().add(categoryCell);
leaf.getGroupingLevels().setGroupingItem(1, "Stem3");
leaf.getGroupingLevels().setGroupingItem(2, "Branch2");
categoryCell = workbook.getCell(0, "C6", "Leaf6");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, "C7", "Leaf7");
leaf = chart.getChartData().getCategories().add(categoryCell);
leaf.getGroupingLevels().setGroupingItem(1, "Stem4");
categoryCell = workbook.getCell(0, "C8", "Leaf8");
chart.getChartData().getCategories().add(categoryCell);
IChartSeries series = chart.getChartData().getSeries().add(ChartType.Sunburst);
series.getLabels().getDefaultDataLabelFormat().setShowCategoryName(true);
IChartDataCell valueCell = workbook.getCell(0, "D1", 4);
series.getDataPoints().addDataPointForSunburstSeries(valueCell);
valueCell = workbook.getCell(0, "D2", 5);
series.getDataPoints().addDataPointForSunburstSeries(valueCell);
valueCell = workbook.getCell(0, "D3", 3);
series.getDataPoints().addDataPointForSunburstSeries(valueCell);
valueCell = workbook.getCell(0, "D4", 6);
series.getDataPoints().addDataPointForSunburstSeries(valueCell);
valueCell = workbook.getCell(0, "D5", 9);
series.getDataPoints().addDataPointForSunburstSeries(valueCell);
valueCell = workbook.getCell(0, "D6", 9);
series.getDataPoints().addDataPointForSunburstSeries(valueCell);
valueCell = workbook.getCell(0, "D7", 4);
series.getDataPoints().addDataPointForSunburstSeries(valueCell);
valueCell = workbook.getCell(0, "D8", 3);
series.getDataPoints().addDataPointForSunburstSeries(valueCell);
presentation.save("Sunburst.pptx", SaveFormat.Pptx);
}
finally
{
presentation.dispose();
}
```
The result:

### **Create Histogram Charts**
Histogram charts show how numerical values are distributed across intervals (bins). For monthly reports on order processing times, use the same bin width and thresholds to keep intervals consistent and make distributions easier to compare.
Call [setAggregationType](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setAggregationType-int-) on the horizontal axis with a mode from [AxisAggregationType](https://reference.aspose.com/slides/java/com.aspose.slides/axisaggregationtype/). [setBinWidth](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setBinWidth-double-) applies only to `ByBinWidth`; [setNumberOfBins](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setNumberOfBins-long-) applies only to `ByNumberOfBins`. Use `Automatic` to let the chart choose the bins.
#### **Use a Fixed Bin Width**
This example groups processing times into 10-minute intervals, with separate bins for times at or below 10 minutes and above 40 minutes. Enable these bins with [setUnderflowBin](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setUnderflowBin-boolean-) and [setOverflowBin](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setOverflowBin-boolean-). When supplying explicit thresholds through [setUnderflowBin](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setUnderflowBin-double-) and [setOverflowBin](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setOverflowBin-double-), call [setAutomaticUnderflowBin](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setAutomaticUnderflowBin-boolean-) and [setAutomaticOverflowBin](https://reference.aspose.com/slides/java/com.aspose.slides/iaxis/#setAutomaticOverflowBin-boolean-) with `false`.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try
{
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Histogram, 20, 20, 680, 200);
chart.setLegend(false);
chart.setTitle(false);
chart.getChartData().getCategories().clear();
chart.getChartData().getSeries().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
workbook.clear(0);
IChartSeries series = chart.getChartData().getSeries().add(ChartType.Histogram);
double[] values = { 5, 10, 10, 11, 15, 20, 20, 21, 25, 30, 30, 31, 35, 40, 40, 41, 50 };
for (int i = 0; i < values.length; i++)
{
IChartDataCell valueCell = workbook.getCell(0, i, 0, values[i]);
series.getDataPoints().addDataPointForHistogramSeries(valueCell);
}
IAxis axis = chart.getAxes().getHorizontalAxis();
axis.setAggregationType(AxisAggregationType.ByBinWidth);
axis.setBinWidth(10);
axis.setUnderflowBin(true);
axis.setAutomaticUnderflowBin(false);
axis.setUnderflowBin(10);
axis.setOverflowBin(true);
axis.setAutomaticOverflowBin(false);
axis.setOverflowBin(40);
presentation.save("Histogram-bin-width.pptx", SaveFormat.Pptx);
}
finally
{
presentation.dispose();
}
```
The presentation displayed in PowerPoint shows bin counts of **3, 4, 4, 4, and 2**. The underflow bin includes `5, 10, 10`, so its threshold is inclusive. The overflow bin includes only `41, 50`, so its threshold is exclusive; both values equal to `40` remain in the preceding interval. The interior bins contain values greater than their lower boundary and less than or equal to their upper boundary.

#### **Specify the Number of Bins**
For a fixed level of detail instead of fixed intervals, request five bins for the same data. This example leaves underflow and overflow bins disabled. The chart determines the width from the data range, so boundaries can change between reports.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try
{
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Histogram, 20, 20, 680, 200);
chart.setLegend(false);
chart.setTitle(false);
chart.getChartData().getCategories().clear();
chart.getChartData().getSeries().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
workbook.clear(0);
IChartSeries series = chart.getChartData().getSeries().add(ChartType.Histogram);
double[] values = { 5, 10, 10, 11, 15, 20, 20, 21, 25, 30, 30, 31, 35, 40, 40, 41, 50 };
for (int i = 0; i < values.length; i++)
{
IChartDataCell valueCell = workbook.getCell(0, i, 0, values[i]);
series.getDataPoints().addDataPointForHistogramSeries(valueCell);
}
IAxis axis = chart.getAxes().getHorizontalAxis();
axis.setAggregationType(AxisAggregationType.ByNumberOfBins);
axis.setNumberOfBins(5);
presentation.save("Histogram-bin-count.pptx", SaveFormat.Pptx);
}
finally
{
presentation.dispose();
}
```
The five bins have counts of **4, 4, 4, 4, and 1**. Compare this distribution with the fixed-width result above: the input values are identical, but the boundaries differ.

### **Create Radar Charts**
Radar charts are used to display multivariate data in a two-dimensional format, allowing for easy comparison of several variables simultaneously. They are particularly useful for identifying patterns, strengths, and weaknesses across multiple performance metrics or attributes.
This example uses [addChart](https://reference.aspose.com/slides/java/com.aspose.slides/ishapecollection/#addChart-int-float-float-float-float-) to create a radar chart with the default series and categories, then saves the presentation as PPTX.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try
{
ISlide slide = presentation.getSlides().get_Item(0);
slide.getShapes().addChart(ChartType.Radar, 20, 20, 500, 300);
presentation.save("Radar-chart.pptx", SaveFormat.Pptx);
}
finally
{
presentation.dispose();
}
```
The result:

### **Create Multi-Category Charts**
Multi-category charts are used to display data that involves more than one categorical grouping, allowing you to compare values across multiple dimensions simultaneously. They are particularly helpful when you need to analyze trends and relationships within complex, multi-layered datasets.
This example creates a clustered column chart with eight categories arranged in four pairs. The [setGroupingItem](https://reference.aspose.com/slides/java/com.aspose.slides/ichartcategorylevelsmanager/#setGroupingItem-int-java.lang.Object-) method gives each pair a shared label at grouping level 1, producing a category axis with both individual and group labels.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try
{
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 20, 20, 500, 300);
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
workbook.clear(0);
int worksheetIndex = 0;
IChartDataCell categoryCell = workbook.getCell(0, "c2", "A");
IChartCategory category = chart.getChartData().getCategories().add(categoryCell);
category.getGroupingLevels().setGroupingItem(1, "Group1");
categoryCell = workbook.getCell(0, "c3", "B");
category = chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, "c4", "C");
category = chart.getChartData().getCategories().add(categoryCell);
category.getGroupingLevels().setGroupingItem(1, "Group2");
categoryCell = workbook.getCell(0, "c5", "D");
category = chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, "c6", "E");
category = chart.getChartData().getCategories().add(categoryCell);
category.getGroupingLevels().setGroupingItem(1, "Group3");
categoryCell = workbook.getCell(0, "c7", "F");
category = chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(0, "c8", "G");
category = chart.getChartData().getCategories().add(categoryCell);
category.getGroupingLevels().setGroupingItem(1, "Group4");
categoryCell = workbook.getCell(0, "c9", "H");
category = chart.getChartData().getCategories().add(categoryCell);
IChartDataCell seriesNameCell = workbook.getCell(0, "D1", "Series 1");
IChartSeries series = chart.getChartData().getSeries().add(seriesNameCell, ChartType.ClusteredColumn);
IChartDataCell valueCell = workbook.getCell(worksheetIndex, "D2", 10);
series.getDataPoints().addDataPointForBarSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, "D3", 20);
series.getDataPoints().addDataPointForBarSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, "D4", 30);
series.getDataPoints().addDataPointForBarSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, "D5", 40);
series.getDataPoints().addDataPointForBarSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, "D6", 50);
series.getDataPoints().addDataPointForBarSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, "D7", 60);
series.getDataPoints().addDataPointForBarSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, "D8", 70);
series.getDataPoints().addDataPointForBarSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, "D9", 80);
series.getDataPoints().addDataPointForBarSeries(valueCell);
presentation.save("AsposeChart.pptx", SaveFormat.Pptx);
}
finally
{
presentation.dispose();
}
```
The result:

#### **Remove a Quarter Label**
Download [quarters.pptx](https://docs.aspose.com/slides/java/create-chart/quarters.pptx) and place it in the working directory. Its chart shows nine months and a single sales series with values from 10 through 18. On the category axis, Q1 spans January through March, Q2 spans April through June, and Q3 spans July through September.
April is the fourth category (index 3) and holds the Q2 label. Use [getGroupingLevels](https://reference.aspose.com/slides/java/com.aspose.slides/ichartcategory/#getGroupingLevels--) to access April's grouping levels, then call [deleteGroupingItem](https://reference.aspose.com/slides/java/com.aspose.slides/ichartcategorylevelsmanager/#deleteGroupingItem-int-) with level 1 to remove its quarter label. Level 0 represents the month itself and cannot be removed with this method.
```java
import com.aspose.slides.*;
import java.util.StringJoiner;
Presentation presentation = new Presentation("quarters.pptx");
try {
IChart chart = (IChart) presentation.getSlides().get_Item(0).getShapes().get_Item(0);
IChartCategory april = chart.getChartData().getCategories().get_Item(3);
april.getGroupingLevels().deleteGroupingItem(1);
presentation.save("quarters-updated.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
Presentation reopened = new Presentation("quarters-updated.pptx");
try {
IChart updatedChart = (IChart) reopened.getSlides().get_Item(0).getShapes().get_Item(0);
IChartData data = updatedChart.getChartData();
StringJoiner months = new StringJoiner(", ");
for (IChartCategory month : data.getCategories()) {
months.add(String.valueOf(month.getAsCell().getValue()));
}
StringJoiner sales = new StringJoiner(", ");
for (IChartDataPoint point : data.getSeries().get_Item(0).getDataPoints()) {
sales.add(String.valueOf(point.getValue().getData()));
}
System.out.println(months);
System.out.println(sales);
} finally {
reopened.dispose();
}
```
After reopening the chart, the example prints the original months (`Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep`) and sales values (`10, 11, 12, 13, 14, 15, 16, 17, 18`) in the same order. Open `quarters-updated.pptx` in PowerPoint to compare the axis labels. The Q2 label and the group boundary before April disappear, so Q1 spans January through June. Q3 still begins in July.

### **Create Map Charts**
Map charts are used to visualize geographical data by mapping information to specific locations such as countries, states, or cities. They are particularly useful for analyzing regional trends, demographic data, and spatial distributions in a clear, visually engaging manner.
This example uses [addChart](https://reference.aspose.com/slides/java/com.aspose.slides/ishapecollection/#addChart-int-float-float-float-float-) to create a map chart with the default geographical data and saves it for viewing in PowerPoint.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try
{
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Map, 20, 20, 500, 300);
presentation.save("mapChart.pptx", SaveFormat.Pptx);
}
finally
{
presentation.dispose();
}
```
The result:

The picture above shows the saved presentation opened in PowerPoint. Aspose.Slides writes the map chart and its data correctly, but it does not draw map charts itself: when a slide holding one is rendered to an image or converted to PDF or SVG, the chart area comes out blank. Other shapes on the same slide are unaffected.
### **Create Combination Charts**
A combination chart (or combo chart) combines two or more chart types in a single graph. This chart lets you highlight, compare, or examine differences between two or more data sets, helping you identify relationships between them.

This example combines two clustered column series with a line series across four categories. The columns use the primary vertical axis, while [setPlotOnSecondAxis](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#setPlotOnSecondAxis-boolean-) places the line on a secondary vertical axis on the right. The helper functions configure the title, legend, axis labels, and gridlines.
```java
import com.aspose.slides.*;
import java.awt.Color;
class ComboChartExample
{
void createComboChart()
{
Presentation presentation = new Presentation();
try
{
IChart chart = createChartWithFirstSeries(presentation.getSlides().get_Item(0));
addSecondSeriesToChart(chart);
addThirdSeriesToChart(chart);
setPrimaryAxesFormat(chart);
setSecondaryAxesFormat(chart);
presentation.save("combo-chart.pptx", SaveFormat.Pptx);
}
finally
{
presentation.dispose();
}
}
IChart createChartWithFirstSeries(ISlide slide)
{
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 600, 400);
chart.setTitle(true);
chart.getChartTitle().addTextFrameForOverriding("Chart Title");
chart.getChartTitle().setOverlay(false);
IPortionFormat portionFormat = chart.getChartTitle().getTextFrameForOverriding().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat();
portionFormat.setFontBold(NullableBool.False);
portionFormat.setFontHeight(18f);
chart.getLegend().setPosition(LegendPositionType.Bottom);
chart.getLegend().getTextFormat().getPortionFormat().setFontHeight(12f);
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
int worksheetIndex = 0;
IChartDataCell categoryCell = workbook.getCell(worksheetIndex, 1, 0, "Category 1");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(worksheetIndex, 2, 0, "Category 2");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(worksheetIndex, 3, 0, "Category 3");
chart.getChartData().getCategories().add(categoryCell);
categoryCell = workbook.getCell(worksheetIndex, 4, 0, "Category 4");
chart.getChartData().getCategories().add(categoryCell);
IChartDataCell seriesNameCell = workbook.getCell(worksheetIndex, 0, 1, "Series 1");
IChartSeries series = chart.getChartData().getSeries().add(seriesNameCell, chart.getType());
series.getParentSeriesGroup().setOverlap((byte) -25);
series.getParentSeriesGroup().setGapWidth(220);
IChartDataCell valueCell = workbook.getCell(worksheetIndex, 1, 1, 4.3);
series.getDataPoints().addDataPointForBarSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, 2, 1, 2.5);
series.getDataPoints().addDataPointForBarSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, 3, 1, 3.5);
series.getDataPoints().addDataPointForBarSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, 4, 1, 4.5);
series.getDataPoints().addDataPointForBarSeries(valueCell);
return chart;
}
void addSecondSeriesToChart(IChart chart)
{
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
final int worksheetIndex = 0;
IChartDataCell seriesNameCell = workbook.getCell(worksheetIndex, 0, 2, "Series 2");
IChartSeries series = chart.getChartData().getSeries().add(seriesNameCell, ChartType.ClusteredColumn);
series.getParentSeriesGroup().setOverlap((byte) -25);
series.getParentSeriesGroup().setGapWidth(220);
IChartDataCell valueCell = workbook.getCell(worksheetIndex, 1, 2, 2.4);
series.getDataPoints().addDataPointForBarSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, 2, 2, 4.4);
series.getDataPoints().addDataPointForBarSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, 3, 2, 1.8);
series.getDataPoints().addDataPointForBarSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, 4, 2, 2.8);
series.getDataPoints().addDataPointForBarSeries(valueCell);
}
void addThirdSeriesToChart(IChart chart)
{
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
final int worksheetIndex = 0;
IChartDataCell seriesNameCell = workbook.getCell(worksheetIndex, 0, 3, "Series 3");
IChartSeries series = chart.getChartData().getSeries().add(seriesNameCell, ChartType.Line);
IChartDataCell valueCell = workbook.getCell(worksheetIndex, 1, 3, 2.0);
series.getDataPoints().addDataPointForLineSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, 2, 3, 2.0);
series.getDataPoints().addDataPointForLineSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, 3, 3, 3.0);
series.getDataPoints().addDataPointForLineSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, 4, 3, 5.0);
series.getDataPoints().addDataPointForLineSeries(valueCell);
series.setPlotOnSecondAxis(true);
}
void setPrimaryAxesFormat(IChart chart)
{
IAxis horizontalAxis = chart.getAxes().getHorizontalAxis();
horizontalAxis.getTextFormat().getPortionFormat().setFontHeight(12f);
horizontalAxis.getFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
setAxisTitle(horizontalAxis, "X Axis");
IAxis verticalAxis = chart.getAxes().getVerticalAxis();
verticalAxis.getTextFormat().getPortionFormat().setFontHeight(12f);
verticalAxis.getFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
setAxisTitle(verticalAxis, "Y Axis 1");
ILineFillFormat majorGridLinesFormat = verticalAxis.getMajorGridLinesFormat().getLine().getFillFormat();
majorGridLinesFormat.setFillType(FillType.Solid);
majorGridLinesFormat.getSolidFillColor().setColor(new Color(217, 217, 217));
}
void setSecondaryAxesFormat(IChart chart)
{
IAxis secondaryHorizontalAxis = chart.getAxes().getSecondaryHorizontalAxis();
secondaryHorizontalAxis.setPosition(AxisPositionType.Bottom);
secondaryHorizontalAxis.setCrossType(CrossesType.Maximum);
secondaryHorizontalAxis.setVisible(false);
secondaryHorizontalAxis.getMajorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
secondaryHorizontalAxis.getMinorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
IAxis secondaryVerticalAxis = chart.getAxes().getSecondaryVerticalAxis();
secondaryVerticalAxis.setPosition(AxisPositionType.Right);
secondaryVerticalAxis.getTextFormat().getPortionFormat().setFontHeight(12f);
secondaryVerticalAxis.getFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
secondaryVerticalAxis.getMajorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
secondaryVerticalAxis.getMinorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
setAxisTitle(secondaryVerticalAxis, "Y Axis 2");
}
void setAxisTitle(IAxis axis, String axisTitle)
{
axis.setTitle(true);
axis.getTitle().setOverlay(false);
IPortionFormat titlePortionFormat = axis.getTitle().addTextFrameForOverriding(axisTitle).getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat();
titlePortionFormat.setFontBold(NullableBool.False);
titlePortionFormat.setFontHeight(12f);
}
}
ComboChartExample example = new ComboChartExample();
example.createComboChart();
```
## **Update Charts**
Aspose.Slides for Java enables you to update PowerPoint charts by modifying chart data, formatting, and styling. This functionality simplifies the process of keeping presentations up-to-date with dynamic content and ensures that charts accurately reflect current data and visual standards.
This example updates the chart named "My chart" on the first slide of an existing presentation. It requires two column series with three data points each, with category labels in column A and series names in the first row of the first worksheet. The example uses [getCell](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdataworkbook/#getCell-int-int-int-java.lang.Object-) to change workbook cells, updates series values, adds a third series, and changes the chart to clustered cylinders through [setType](https://reference.aspose.com/slides/java/com.aspose.slides/ichart/#setType-int-).
```java
import com.aspose.slides.*;
final String chartName = "My chart";
Presentation presentation = new Presentation("ExistingChart.pptx");
try
{
ISlide slide = presentation.getSlides().get_Item(0);
for (IShape shape : slide.getShapes())
{
if (shape instanceof IChart && chartName.equals(shape.getName()))
{
IChart chart = (IChart) shape;
int worksheetIndex = 0;
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
workbook.getCell(worksheetIndex, 1, 0, "Modified Category 1");
workbook.getCell(worksheetIndex, 2, 0, "Modified Category 2");
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
workbook.getCell(worksheetIndex, 0, 1, "New_Series 1");
series.getDataPoints().get_Item(0).getValue().setData(90);
series.getDataPoints().get_Item(1).getValue().setData(123);
series.getDataPoints().get_Item(2).getValue().setData(44);
series = chart.getChartData().getSeries().get_Item(1);
workbook.getCell(worksheetIndex, 0, 2, "New_Series 2");
series.getDataPoints().get_Item(0).getValue().setData(23);
series.getDataPoints().get_Item(1).getValue().setData(67);
series.getDataPoints().get_Item(2).getValue().setData(99);
IChartDataCell seriesNameCell = workbook.getCell(worksheetIndex, 0, 3, "Series 3");
series = chart.getChartData().getSeries().add(seriesNameCell, chart.getType());
IChartDataCell valueCell = workbook.getCell(worksheetIndex, 1, 3, 20);
series.getDataPoints().addDataPointForBarSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, 2, 3, 50);
series.getDataPoints().addDataPointForBarSeries(valueCell);
valueCell = workbook.getCell(worksheetIndex, 3, 3, 30);
series.getDataPoints().addDataPointForBarSeries(valueCell);
chart.setType(ChartType.ClusteredCylinder);
}
}
presentation.save("AsposeChartModified.pptx", SaveFormat.Pptx);
}
finally
{
presentation.dispose();
}
```
## **Set Data Range for a Chart**
To inspect the range already used by an existing chart, see [Retrieve a Chart's Data Range](https://docs.aspose.com/slides/java/chart-workbook/#retrieve-a-charts-data-range).
Aspose.Slides for Java provides the flexibility to define a specific data range from a worksheet as the source for your chart's data. This means you can directly map a portion of your worksheet to the chart, allowing you to control which cells contribute to the chart's series and categories. As a result, you can easily update and synchronize your charts with the latest data changes in your worksheet, ensuring that your PowerPoint presentations reflect current and accurate information.
This example uses [setRange](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/#setRange-java.lang.String-) to set the data source of the chart named "My chart" on the first slide of an existing presentation to `Sheet1!A1:B4`. The chart workbook must contain that worksheet and a populated range with a series heading in the first row, category labels in column A, and three values in column B.
```java
import com.aspose.slides.*;
final String chartName = "My chart";
Presentation presentation = new Presentation("ExistingChart.pptx");
try
{
ISlide slide = presentation.getSlides().get_Item(0);
for (IShape shape : slide.getShapes())
{
if (shape instanceof IChart && chartName.equals(shape.getName()))
{
IChart chart = (IChart) shape;
chart.getChartData().setRange("Sheet1!A1:B4");
}
}
presentation.save("SetDataRange.pptx", SaveFormat.Pptx);
}
finally
{
presentation.dispose();
}
```
## **Use Default Markers in Charts**
When you use default markers in charts, each chart series gets a different default marker symbol automatically.
This example uses [addChart](https://reference.aspose.com/slides/java/com.aspose.slides/ishapecollection/#addChart-int-float-float-float-float-) to create a chart with two line series and a legend. The marker settings accessed through [getMarker](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#getMarker--) retain the automatically assigned marker symbols. The first series includes a negative value and a missing value, represented by `null`, while the second has a value for every category.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try
{
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.LineWithMarkers, 10, 10, 400, 400);
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
IChartDataCell seriesNameCell = workbook.getCell(0, 0, 1, "Series 1");
IChartSeries series = chart.getChartData().getSeries().add(seriesNameCell, chart.getType());
IChartDataCell categoryCell = workbook.getCell(0, 1, 0, "C1");
chart.getChartData().getCategories().add(categoryCell);
IChartDataCell valueCell = workbook.getCell(0, 1, 1, 24);
series.getDataPoints().addDataPointForLineSeries(valueCell);
categoryCell = workbook.getCell(0, 2, 0, "C2");
chart.getChartData().getCategories().add(categoryCell);
valueCell = workbook.getCell(0, 2, 1, 23);
series.getDataPoints().addDataPointForLineSeries(valueCell);
categoryCell = workbook.getCell(0, 3, 0, "C3");
chart.getChartData().getCategories().add(categoryCell);
valueCell = workbook.getCell(0, 3, 1, -10);
series.getDataPoints().addDataPointForLineSeries(valueCell);
categoryCell = workbook.getCell(0, 4, 0, "C4");
chart.getChartData().getCategories().add(categoryCell);
valueCell = workbook.getCell(0, 4, 1, null);
series.getDataPoints().addDataPointForLineSeries(valueCell);
seriesNameCell = workbook.getCell(0, 0, 2, "Series 2");
IChartSeries secondSeries = chart.getChartData().getSeries().add(seriesNameCell, chart.getType());
valueCell = workbook.getCell(0, 1, 2, 30);
secondSeries.getDataPoints().addDataPointForLineSeries(valueCell);
valueCell = workbook.getCell(0, 2, 2, 10);
secondSeries.getDataPoints().addDataPointForLineSeries(valueCell);
valueCell = workbook.getCell(0, 3, 2, 60);
secondSeries.getDataPoints().addDataPointForLineSeries(valueCell);
valueCell = workbook.getCell(0, 4, 2, 40);
secondSeries.getDataPoints().addDataPointForLineSeries(valueCell);
chart.setLegend(true);
chart.getLegend().setOverlay(false);
presentation.save("DefaultMarkersInChart.pptx", SaveFormat.Pptx);
}
finally
{
presentation.dispose();
}
```
## **FAQ**
**What chart types are supported by Aspose.Slides for Java?**
Aspose.Slides for Java supports a wide range of chart types, including bar, line, pie, area, scatter, histogram, radar, and many more. This flexibility allows you to choose the most appropriate chart type for your data visualization needs.
**How do I add a new chart to a slide?**
To add a chart, you first create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class, retrieve the desired slide using its index, and then call the method to add a chart, specifying the chart type and initial data. This process integrates the chart directly into your presentation.
**How can I update the data displayed in a chart?**
You can update a chart's data by accessing its data workbook ([IChartDataWorkbook](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdataworkbook/)), clearing any default series and categories, and then adding your custom data. This allows you to programmatically refresh the chart to reflect the latest data.
**Is it possible to customize the appearance of the chart?**
Yes, Aspose.Slides for Java provides extensive customization options. You can modify colors, fonts, labels, legends, and other formatting elements to tailor the chart's appearance to your specific design requirements.
Related feature: [Create editable charts](https://docs.aspose.com/slides/features/create-charts/).
# Specify Fallback Fonts for Presentations in Java
> Master Aspose.Slides for Java to set fallback fonts in PPT, PPTX and ODP files, safeguarding consistent text display on any device or OS.
Source: https://docs.aspose.com/slides/java/create-fallback-font/
Updated: 2026-08-13
## **Overview**
Aspose.Slides allows you to specify fallback fonts for presentation rendering and export operations. Fallback fonts are used when the primary font does not contain glyphs for particular characters.
Fallback behavior is configured through fallback rules. Each rule associates a Unicode range with one or more fonts that may contain the required glyphs. You can define rules for different character ranges, add or remove fallback fonts from existing rules, and organize multiple rules in a fallback font rules collection.
Fallback rules are runtime rendering settings. They do not modify the presentation file itself and are not stored inside the PPTX file.
## **Fallback Rules**
Aspose.Slides supports [IFontFallBackRule](https://reference.aspose.com/slides/java/com.aspose.slides/IFontFallBackRule) interface and [FontFallBackRule](https://reference.aspose.com/slides/java/com.aspose.slides/FontFallBackRule) class to specify the rules to apply a fallback font. [FontFallBackRule](https://reference.aspose.com/slides/java/com.aspose.slides/FontFallBackRule) class represents an association between the specified Unicode range, used for searching missed glyphs, and a list of fonts that may contain proper glyphs:
```java
import com.aspose.slides.*;
long startUnicodeIndex = 0x0B80;
long endUnicodeIndex = 0x0BFF;
IFontFallBackRule firstRule = new FontFallBackRule(startUnicodeIndex, endUnicodeIndex, "Vijaya");
IFontFallBackRule secondRule = new FontFallBackRule(0x3040, 0x309F, "MS Mincho, MS Gothic");
//Using multiple ways you can add fonts list:
String[] fontNames = new String[] { "Segoe UI Emoji, Segoe UI Symbol", "Arial" };
IFontFallBackRule thirdRule = new FontFallBackRule(0x1F300, 0x1F64F, fontNames);
```
It is also possible to [remove](https://reference.aspose.com/slides/java/com.aspose.slides/FontFallBackRule#remove-java.lang.String-) fallback font or [addFallBackFonts](https://reference.aspose.com/slides/java/com.aspose.slides/FontFallBackRule#addFallBackFonts-java.lang.String-) into existing [FontFallBackRule](https://reference.aspose.com/slides/java/com.aspose.slides/FontFallBackRule) object.
[FontFallBackRulesCollection](https://reference.aspose.com/slides/java/com.aspose.slides/FontFallBackRulesCollection) can be used to organize a list of [FontFallBackRule](https://reference.aspose.com/slides/java/com.aspose.slides/FontFallBackRule) objects, when there is a need to specify fallback font replacement rules for multiple Unicode ranges.
- [Create Fallback Fonts Collection](https://docs.aspose.com/slides/java/create-fallback-fonts-collection/)
## **FAQ**
### What is the difference between a fallback font, font substitution, and font embedding?
A fallback font is used only for characters missing in the primary font. [Font substitution](https://docs.aspose.com/slides/java/font-substitution/) replaces the entire specified font with another font. [Font embedding](https://docs.aspose.com/slides/java/embedded-font/) packages the fonts inside the output file so recipients can view the text as intended.
### Are fallback fonts applied during exports like PDF, PNG, or SVG, or only on-screen rendering?
Yes. Fallback affects all [rendering and export operations](https://docs.aspose.com/slides/java/convert-presentation/) where characters must be drawn but are absent in the source font.
### Does configuring fallback change the presentation file itself, and will the setting persist for future openings?
No. Fallback rules are runtime rendering settings in your code; they are not stored inside the .pptx and won’t appear in PowerPoint.
### Does the operating system (Windows/Linux/macOS) and the set of font directories affect fallback selection?
Yes. The engine resolves fonts from available system folders and any [additional paths](https://docs.aspose.com/slides/java/custom-font/) you provide. If a font isn’t physically available, a rule referencing it cannot take effect.
### Does fallback work for WordArt, SmartArt, and charts?
Yes. When these objects contain text, the same glyph-substitution mechanism applies to render missing characters.
## Related articles
- [Manage Fallback Fonts for Presentations in Java](https://docs.aspose.com/slides/java/fallback-font/)
- [Configure Fallback Font Collections in Java](https://docs.aspose.com/slides/java/create-fallback-fonts-collection/)
- [Streamline Font Replacement in Presentations Using Java](https://docs.aspose.com/slides/java/font-replacement/)
# Configure Fallback Font Collections in Java
> Set up a fallback fonts collection in Aspose.Slides for Java to keep text consistent and crisp in PowerPoint and OpenDocument presentations.
Source: https://docs.aspose.com/slides/java/create-fallback-fonts-collection/
Updated: 2026-08-13
## **Overview**
Aspose.Slides allows you to configure a collection of fallback font rules for a presentation. Each fallback rule is represented by the `FontFallBackRule` class and can be added to a `FontFallBackRulesCollection`, which implements the `IFontFallBackRulesCollection` interface.
After creating the collection, you can assign it to the `FontFallBackRulesCollection` property of the presentation’s `FontsManager`. The `FontsManager` controls fonts across the presentation, and each `Presentation` instance has its own `FontsManager`.
Once the `FontsManager` is initialized with the fallback font collection, the specified fallback fonts are applied during presentation rendering.
## **Apply Fallback Rules**
Instances of [FontFallBackRule](https://reference.aspose.com/slides/java/com.aspose.slides/FontFallBackRule) class can be organized into [FontFallBackRulesCollection](https://reference.aspose.com/slides/java/com.aspose.slides/FontFallBackRulesCollection), that implements [IFontFallBackRulesCollection](https://reference.aspose.com/slides/java/com.aspose.slides/IFontFallBackRulesCollection) interface. It is possible to add or remove rules from the collection.
Then this collection may be assigned to [FontFallBackRulesCollection](https://reference.aspose.com/slides/java/com.aspose.slides/FontFallBackRulesCollection) method of the [FontsManager](https://reference.aspose.com/slides/java/com.aspose.slides/FontsManager) class. FontsManager controls fonts across the presentation.
Each [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) has a [getFontsManager](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation#getFontsManager--) method with its own instance of the [FontsManager](https://reference.aspose.com/slides/java/com.aspose.slides/FontsManager) class.
Here is an examples how to create fallback fonts rules collection and assign in into the [FontsManager](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation#getFontsManager--) of a certain presentation:
```java
import com.aspose.slides.*;
Presentation pres = new Presentation();
try {
IFontFallBackRulesCollection userRulesList = new FontFallBackRulesCollection();
userRulesList.add(new FontFallBackRule(0x0B80, 0x0BFF, "Vijaya"));
userRulesList.add(new FontFallBackRule(0x3040, 0x309F, "MS Mincho, MS Gothic"));
pres.getFontsManager().setFontFallBackRulesCollection(userRulesList);
} finally {
if (pres != null) pres.dispose();
}
```
After FontsManager is initialised with fallback fonts collection, the fallback fonts are applied during presentation rendering.
Read more how to [Render Presentation with Fallback Font](https://docs.aspose.com/slides/java/render-presentation-with-fallback-font/).
## **FAQ**
### Will my fallback rules be embedded into the PPTX file and visible in PowerPoint after saving?
No. Fallback rules are runtime rendering settings; they are not serialized into PPTX and will not appear in PowerPoint's UI.
### Does fallback apply to text inside SmartArt, WordArt, charts, and tables?
Yes. The same glyph-substitution mechanism is used for any text in these objects.
### Does Aspose distribute any fonts with the library?
No. You add and use fonts on your side and under your own responsibility.
### Can replacement/substitution for missing fonts and fallback for missing glyphs be used together?
Yes. They are independent stages of the same font-resolution pipeline: first the engine resolves font availability ([replacement](https://docs.aspose.com/slides/java/font-replacement/)/[substitution](https://docs.aspose.com/slides/java/font-substitution/)), then fallback fills gaps for missing glyphs in available fonts.
## Related articles
- [Render Presentations with Fallback Fonts in Java](https://docs.aspose.com/slides/java/render-presentation-with-fallback-font/)
- [Manage Fallback Fonts for Presentations in Java](https://docs.aspose.com/slides/java/fallback-font/)
- [Specify Fallback Fonts for Presentations in Java](https://docs.aspose.com/slides/java/create-fallback-font/)
# Create Presentations in Java
> Create presentations in Java with Aspose.Slides—produce PPT, PPTX, and ODP files, benefit from OpenDocument support, and save them programmatically for reliable results.
Source: https://docs.aspose.com/slides/java/create-presentation/
Updated: 2026-09-27
## **Overview**
This article shows how to create a presentation in Aspose.Slides, add a shape with text to its first slide, and save the result as a PPTX file. To open an existing presentation and save it in another format, see [Open Presentations](https://docs.aspose.com/slides/java/open-presentation/) and [Save Presentations](https://docs.aspose.com/slides/java/save-presentation/). A short FAQ at the end covers common questions about formats, templates, slide sizing, units, memory usage, threading, licensing, digital signatures, and VBA support.
Before you begin, add Aspose.Slides for Java to your project from Aspose's Maven repository. See [Installation](https://docs.aspose.com/slides/java/installation/) for the Maven setup and for what Linux needs in addition.
## **Create a Presentation**
Creating a PowerPoint file from scratch in Aspose.Slides for Java starts with an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class. The constructor supplies a blank presentation with a single slide, ready for shapes, text, charts, or any other content your application needs. Once you modify that slide, or add new ones, you can save the result to PPTX, legacy PPT, or OpenDocument formats.
To create a presentation and put a shape with text on its first slide, follow these steps:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class. A new presentation already contains one empty slide.
1. Get that slide by its index, 0, from the collection that [getSlides](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#getSlides--) returns.
1. Add an [IAutoShape](https://reference.aspose.com/slides/java/com.aspose.slides/iautoshape/) of the `Cloud` type with the [addAutoShape](https://reference.aspose.com/slides/java/com.aspose.slides/ishapecollection/#addAutoShape-int-float-float-float-float-) method, and set its text with [setText](https://reference.aspose.com/slides/java/com.aspose.slides/itextframe/#setText-java.lang.String-).
1. Save the presentation as a PPTX file with the [save](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#save-java.lang.String-int-) method.
The example below is a complete program. In the Maven project from [Installation](https://docs.aspose.com/slides/java/installation/), save it as *src/main/java/HelloSlides.java* and run `mvn compile exec:java`.
```java
import com.aspose.slides.*;
public class HelloSlides {
public static void main(String[] args) {
// Create a presentation. It already contains one empty slide.
Presentation presentation = new Presentation();
try {
// Get the first slide.
ISlide slide = presentation.getSlides().get_Item(0);
// Add a cloud shape and put text in it.
IAutoShape autoShape = slide.getShapes().addAutoShape(ShapeType.Cloud, 20, 20, 200, 80);
autoShape.getTextFrame().setText("Hello, Aspose!");
// Save the presentation as a PPTX file.
presentation.save("new_presentation.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
}
}
```
The cloud's top-left corner is 20 points from the left edge and 20 points from the top edge of the slide, and the shape is 200 points wide and 80 points high. The program saves *new_presentation.pptx* with one slide that holds the cloud and its text. Without a license, Aspose.Slides also adds an evaluation watermark to every slide it saves; see [Licensing](https://docs.aspose.com/slides/java/licensing/).
The result:

## **FAQ**
### What formats can I save a new presentation to?
You can save to [PPTX, PPT, and ODP](https://docs.aspose.com/slides/java/save-presentation/), and export to [PDF](https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf/), [XPS](https://docs.aspose.com/slides/java/convert-powerpoint-to-xps/), [HTML](https://docs.aspose.com/slides/java/convert-powerpoint-to-html/), [SVG](https://docs.aspose.com/slides/java/render-a-slide-as-an-svg-image/), and [images](https://docs.aspose.com/slides/java/convert-powerpoint-to-png/), among others.
### Can I start from a template (POTX/POTM) and save as a regular PPTX?
Yes. Load the template and save to the desired format; POTX/POTM/PPTM and similar formats [are supported](https://docs.aspose.com/slides/java/supported-file-formats/).
### How do I control slide size/aspect ratio when creating a presentation?
Set the [slide size](https://docs.aspose.com/slides/java/slide-size/) (including presets like 4:3 and 16:9 or custom dimensions) and choose how content should scale.
### In what units are sizes and coordinates measured?
In points: 1 inch equals 72 units.
### How do I handle very large presentations (with many media files) to reduce memory usage?
Use [BLOB management strategies](https://docs.aspose.com/slides/java/manage-blob/), limit in-memory storage by leveraging temporary files, and prefer file-based workflows over purely in-memory streams.
### Can I create/save presentations in parallel?
You cannot operate on the same [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) instance from [multiple threads](https://docs.aspose.com/slides/java/multithreading/). Run separate, isolated instances per thread or process.
### How do I remove the trial watermark and limitations?
[Apply a license](https://docs.aspose.com/slides/java/licensing/) once per process. The license XML must remain unmodified, and the license setup should be synchronized if multiple threads are involved.
### Can I digitally sign the PPTX I create?
Yes. [Digital signatures](https://docs.aspose.com/slides/java/digital-signature-in-powerpoint/) (adding and verifying) are supported for presentations.
### Are macros (VBA) supported in created presentations?
Yes. You can [create/edit VBA projects](https://docs.aspose.com/slides/java/presentation-via-vba/) and save macro-enabled files such as PPTM/PPSM.
# Create Thumbnails of Presentation Shapes in Java
> Generate high-quality shape thumbnails from PowerPoint slides with Aspose.Slides for Java – easily create and export presentation thumbnails.
Source: https://docs.aspose.com/slides/java/create-shape-thumbnails/
Updated: 2026-11-08
## **Introduction**
Aspose.Slides for Java can be used to create presentation files in which each page corresponds to a slide. The slides can be viewed by opening the presentation files using Microsoft PowerPoint. However, developers sometimes need to view the images of the shapes separately in an image viewer. In such cases, Aspose.Slides for Java helps them generate thumbnail images of the slide shapes.
This article explains how to generate slide thumbnails in different ways:
- Generating a shape thumbnail inside a slide.
- Generating a shape thumbnail for a slide shape with user-defined dimensions.
- Generating a shape thumbnail in the bounds of a shape's appearance.
## **Generate a Shape Thumbnail from a Slide**
To generate a shape thumbnail from any slide using Aspose.Slides for Java, do this:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class.
1. Obtain the reference of any slide using its ID or index.
1. [Get the shape thumbnail image](https://reference.aspose.com/slides/java/com.aspose.slides/ishape/#getImage--) of the referenced slide on default scale.
1. Save the thumbnail image in your preferred image format.
This sample code shows you how to generate a shape thumbnail from a slide:
```java
import com.aspose.slides.*;
// Instantiate a Presentation class that represents the presentation file
Presentation pres = new Presentation("Thumbnail.pptx");
try {
// Create a full scale image
IImage slideImage = pres.getSlides().get_Item(0).getShapes().get_Item(0).getImage();
// Save the image to disk in PNG format
try {
slideImage.save("output.png", ImageFormat.Png);
} finally {
if (slideImage != null) slideImage.dispose();
}
} finally {
if (pres != null) pres.dispose();
}
```
## **Generate a User-Defined Scaling Factor Thumbnail**
To generate the shape thumbnail of a slide using Aspose.Slides for Java, do this:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class.
1. Obtain the reference of any slide using its ID or index.
1. [Get the shape thumbnail image](https://reference.aspose.com/slides/java/com.aspose.slides/ishape/#getImage-int-float-float-) of the referenced slide with user-defined dimensions.
1. Save the thumbnail image in your preferred image format.
This sample code shows you how to generate a shape thumbnail based on a defined scaling factor:
```java
import com.aspose.slides.*;
// Instantiate a Presentation class that represents the presentation file
Presentation pres = new Presentation("Thumbnail.pptx");
try {
// Create an image scaled by a factor of 2 in both directions
IImage slideImage = pres.getSlides().get_Item(0).getShapes().get_Item(0).getImage(ShapeThumbnailBounds.Shape, 2, 2);
// Save the image to disk in PNG format
try {
slideImage.save("output.png", ImageFormat.Png);
} finally {
if (slideImage != null) slideImage.dispose();
}
} finally {
if (pres != null) pres.dispose();
}
```
## **Create a Bounds-Based Shape Appearance Thumbnail**
This method of creating thumbnails of shapes allows developers to generate a thumbnail in the bounds of the shape's appearance. It takes into account all the shape effects. The generated shape thumbnail is restricted by the slide bounds. To generate a thumbnail of a slide shape in the bound of its appearance, do this:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class.
1. Obtain the reference of any slide using its ID or index.
1. Get the thumbnail image of the referenced slide with shape bounds as appearance.
1. Save the thumbnail image in your preferred image format.
This sample code is based on the steps above:
```java
import com.aspose.slides.*;
// Instantiate a Presentation class that represents the presentation file
Presentation pres = new Presentation("Thumbnail.pptx");
try {
// Create a full scale image
IImage slideImage = pres.getSlides().get_Item(0).getShapes().get_Item(0).getImage(ShapeThumbnailBounds.Appearance, 1, 1);
// Save the image to disk in PNG format
try {
slideImage.save("output.png", ImageFormat.Png);
} finally {
if (slideImage != null) slideImage.dispose();
}
} finally {
if (pres != null) pres.dispose();
}
```
## **Get the Actual Visual Bounds of a Shape**
The frame properties of [IShape](https://reference.aspose.com/slides/java/com.aspose.slides/ishape/)—its `getX()`, `getY()`, `getWidth()`, and `getHeight()` methods—describe the rectangle stored in the presentation model. The content that is actually rendered can extend beyond that frame or occupy a different axis-aligned rectangle. Rotation, outlines, arrowheads, text layout and overflow, generated SmartArt geometry, and other rendering effects can all change the occupied area.
Use [Shape.getVisualBounds](https://reference.aspose.com/slides/java/com.aspose.slides/shape/#getVisualBounds--) to calculate that occupied area without creating an image. The method returns a [Rectangle2D.Float](https://docs.oracle.com/javase/8/docs/api/java/awt/geom/Rectangle2D.Float.html) in slide coordinates. The returned rectangle is not clipped to the slide, so its coordinates can be negative when content extends beyond the slide origin.
[Shape.getVisualBounds](https://reference.aspose.com/slides/java/com.aspose.slides/shape/#getVisualBounds--) is not currently declared by the [IShape](https://reference.aspose.com/slides/java/com.aspose.slides/ishape/) interface. Therefore, keep the shape obtained from the slide's shape collection as an interface value and cast it only when calling the method.
The following example gets and compares the frame and visual bounds:
```java
import com.aspose.slides.*;
import java.awt.geom.Rectangle2D;
Presentation presentation = new Presentation("example.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
IShape shape = slide.getShapes().get_Item(0);
Rectangle2D.Float visualBounds = ((Shape) shape).getVisualBounds();
Rectangle2D.Float frameBounds = new Rectangle2D.Float(
shape.getX(), shape.getY(), shape.getWidth(), shape.getHeight());
System.out.println("Frame bounds: " + frameBounds);
System.out.println("Visual bounds: " + visualBounds);
} finally {
presentation.dispose();
}
```
The same [Rectangle2D.Float](https://docs.oracle.com/javase/8/docs/api/java/awt/geom/Rectangle2D.Float.html) can be used to align nearby shapes to its left, right, top, or bottom edge; reserve enough space in a generated layout; or detect content outside a permitted region. Visual bounds are especially useful for SmartArt, text boxes, arrows, pictures, rotated shapes, and group shapes, where the stored frame may not represent the full rendered result.
Use [Shape.getVisualBounds](https://reference.aspose.com/slides/java/com.aspose.slides/shape/#getVisualBounds--) when you need coordinates for layout or validation and do not need a bitmap. Use [IShape.getImage](https://reference.aspose.com/slides/java/com.aspose.slides/ishape/#getImage--) when you need to render the shape. With [ShapeThumbnailBounds](https://reference.aspose.com/slides/java/com.aspose.slides/shapethumbnailbounds/), `ShapeThumbnailBounds.Shape` sizes the image from the shape bounds, including outline settings, while `ShapeThumbnailBounds.Appearance` sizes it from the shape's appearance and restricts the result to the slide bounds. In contrast, [Shape.getVisualBounds](https://reference.aspose.com/slides/java/com.aspose.slides/shape/#getVisualBounds--) returns only the calculated rectangle and does not clip it to the slide.
[](https://docs.aspose.com/slides/java/create-shape-thumbnails/visual-shape-thumbnail-bounds-06704045c8a9.svg)
*The rotated arrow extends left of the slide. Its visual bounds include that area. The Appearance thumbnail clips at the slide edge.*
## **FAQ**
**What image formats can be used when saving shape thumbnails?**
[PNG, JPEG, BMP, GIF, TIFF](https://reference.aspose.com/slides/java/com.aspose.slides/imageformat/), and others. Shapes can also be [exported as vector SVG](https://reference.aspose.com/slides/java/com.aspose.slides/shape/#writeAsSvg-java.io.OutputStream-com.aspose.slides.ISVGOptions-) by saving the shape’s content as SVG.
**What is the difference between Shape and Appearance bounds when rendering a thumbnail?**
`Shape` uses the shape’s geometry; `Appearance` takes [visual effects](https://docs.aspose.com/slides/java/shape-effect/) (shadows, glows, etc.) into account.
**What happens if a shape is marked as hidden? Will it still render as a thumbnail?**
A hidden shape remains part of the model and can be rendered; the hidden flag affects slideshow display but does not prevent generating the shape’s image.
**Are group shapes, charts, SmartArt, and other complex objects supported?**
Yes. Any object represented as [Shape](https://reference.aspose.com/slides/java/com.aspose.slides/shape/) (including [GroupShape](https://reference.aspose.com/slides/java/com.aspose.slides/groupshape/), [Chart](https://reference.aspose.com/slides/java/com.aspose.slides/chart/), and [SmartArt](https://reference.aspose.com/slides/java/com.aspose.slides/smartart/)) can be saved as a thumbnail or as SVG.
**Do system-installed fonts affect the quality of thumbnails for text shapes?**
Yes. You should [provide the required fonts](https://docs.aspose.com/slides/java/custom-font/) (or [configure font substitutions](https://docs.aspose.com/slides/java/font-substitution/)) to avoid unwanted fallbacks and text reflow.
# Creating Tables Using VSTO and Aspose.Slides for Java
> Migrate from Microsoft Office automation to Aspose.Slides for Java and create tables in PowerPoint (PPT, PPTX) slides in Java with flexible formatting.
Source: https://docs.aspose.com/slides/java/creating-a-table-on-powerpoint-slide/
Updated: 2026-08-13
Tables are widely used to display data on presentation slides. This article shows how to create a 15 x 15 table with a font size of 10 programmatically using first [VSTO 2008](https://docs.aspose.com/slides/java/creating-a-table-on-powerpoint-slide/) and then [Aspose.Slides for Java](https://docs.aspose.com/slides/java/creating-a-table-on-powerpoint-slide/).
## **Creating Tables**
### **VSTO 2008 Example**
The following steps add a table to a Microsoft PowerPoint slide using VSTO:
1. Create a presentation.
1. Add an empty slide is added to the presentation.
1. Add a 15 x 15 table to the slide.
1. Add text to each cell of the table with a font size of 10.
1. Save the presentation to disk.
```csharp
//Create a presentation
PowerPoint.Presentation pres = Globals.ThisAddIn.Application
.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoFalse);
//Add a blank slide
PowerPoint.Slide sld = pres.Slides.Add(1, PowerPoint.PpSlideLayout.ppLayoutBlank);
//Add a 15 x 15 table
PowerPoint.Shape shp = sld.Shapes.AddTable(15, 15, 10, 10, pres.PageSetup.SlideWidth - 20, 300);
PowerPoint.Table tbl = shp.Table;
int i = -1;
int j = -1;
//Loop through all the rows
foreach (PowerPoint.Row row in tbl.Rows)
{
i = i + 1;
j = -1;
//Loop through all the cells in the row
foreach (PowerPoint.Cell cell in row.Cells)
{
j = j + 1;
//Get text frame of each cell
PowerPoint.TextFrame tf = cell.Shape.TextFrame;
//Add some text
tf.TextRange.Text = "T" + i.ToString() + j.ToString();
//Set font size of the text as 10
tf.TextRange.Paragraphs(0, tf.TextRange.Text.Length).Font.Size = 10;
}
}
//Save the presentation to disk
pres.SaveAs("d:\\tblVSTO.ppt",
PowerPoint.PpSaveAsFileType.ppSaveAsPresentation,
Microsoft.Office.Core.MsoTriState.msoFalse);
```
[Source: Examples-CSharp-VSTO-CreateTableUsingVSTO-CreateTableUsingVSTO.cs](https://gist.githubusercontent.com/aspose-com-gists/a56eda38c01ad33dc653116c7bae4293/raw/60f36b65dcdc5f7368b2d455fe1ae74076eeae08/Examples-CSharp-VSTO-CreateTableUsingVSTO-CreateTableUsingVSTO.cs)
### **Aspose.Slides for Java Example**
The following steps add a table to a Microsoft PowerPoint slide using Aspose.Slides:
1. Create a presentation.
1. Add a 15 x 15 table to the first slide.
1. Add text to each cell of the table with a font size of 10.
1. Write the presentation to disk.
```java
Presentation pres = new Presentation();
//Access first slide
ISlide sld = pres.getSlides().get_Item(0);
//Define columns with widths and rows with heights
double[] dblCols = { 50, 50, 50 };
double[] dblRows = { 50, 30, 30, 30, 30 };
//Add a table
ITable tbl = sld.getShapes().addTable(50, 50, dblCols,dblRows);
//Set border format for each cell
for (int i=0;i
# Create Excel Charts and Embed Them in Presentations as OLE Objects
> Create an Excel chart with Aspose.Cells for Java and embed the workbook in a PowerPoint presentation with Aspose.Slides, including a chart preview.
Source: https://docs.aspose.com/slides/java/creating-excel-chart-and-embedding-it-in-presentation-as-ole-object/
Updated: 2026-10-20
## **Overview**
This article shows how to create an Excel column chart with Aspose.Cells for Java and embed its workbook in a PowerPoint presentation with Aspose.Slides for Java. The embedded workbook contains both the source data and the chart. A separate PNG preview displays the chart on the slide before the OLE object is activated.
The result is an embedded Excel object, not a native PowerPoint chart. Editing the workbook through OLE requires a desktop application that supports OLE activation and a compatible Excel installation.
## **Prerequisites**
Add Aspose.Cells for Java and Aspose.Slides for Java to your project dependencies. Run the example inside a Java method. Microsoft Office is not required to generate the presentation with these libraries.
No input files are required: the example creates the data and chart in memory, then writes `OutputChart.pptx` to the current working directory. Apply licenses for both products when running outside evaluation mode.
## **How the Embedding Works**
1. Create a workbook with a data worksheet and a chart sheet.
1. Make the chart sheet active so that the workbook opens on the chart.
1. Set the workbook's OLE display range and render the chart to PNG.
1. Save the workbook as XLSX in memory and embed those bytes in a slide.
1. Assign the PNG as the OLE object's preview and save the presentation as PPTX.
The workbook display range and the frame on the slide have different roles. [setOleSize](https://reference.aspose.com/cells/java/com.aspose.cells/worksheetcollection/#setOleSize-int-int-int-int-) takes zero-based start/end row and column indices. [ChartCollection.add](https://reference.aspose.com/cells/java/com.aspose.cells/chartcollection/#add-int-int-int-int-int-) instead takes the top row, left column, bottom row, and right column. The example uses row index 55 and column index 25 as the lower-right boundaries; these values are layout choices, not the number of data rows or columns.
The slide frame uses points. The example fits it within the slide and centers it while preserving the PNG's aspect ratio, rather than stretching the preview to fill the slide.
## **Create and Embed the Chart**
The following complete example populates `DataSheet` with four rows and five columns of values. Each row becomes a chart series. `ChartSheet` is selected as the active sheet before the workbook is saved.
The workbook is explicitly saved as XLSX, matching the `xlsx` extension passed to [OleEmbeddedDataInfo](https://reference.aspose.com/slides/java/com.aspose.slides/oleembeddeddatainfo/). The PNG is loaded directly from its bytes without an intermediate bitmap conversion. Assigning it through [getSubstitutePictureFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ioleobjectframe/#getSubstitutePictureFormat--) replaces the default OLE placeholder.
```java
import com.aspose.cells.Chart;
import com.aspose.cells.ChartType;
import com.aspose.cells.ImageOrPrintOptions;
import com.aspose.cells.ImageType;
import static com.aspose.cells.SaveFormat.XLSX;
import static com.aspose.slides.SaveFormat.Pptx;
import com.aspose.cells.SheetType;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;
import com.aspose.slides.IImage;
import com.aspose.slides.Images;
import com.aspose.slides.IOleObjectFrame;
import com.aspose.slides.IPPImage;
import com.aspose.slides.ISlide;
import com.aspose.slides.OleEmbeddedDataInfo;
import com.aspose.slides.Presentation;
import java.io.ByteArrayOutputStream;
try {
Workbook workbook = new Workbook();
try {
Worksheet dataSheet = workbook.getWorksheets().get(0);
dataSheet.setName("DataSheet");
int[][] values = {
{ 67, 44, 46, 43, 24 },
{ 86, 64, 97, 29, 40 },
{ 68, 89, 78, 69, 38 },
{ 91, 48, 60, 26, 25 }
};
for (int row = 0; row < values.length; row++) {
for (int column = 0; column < values[row].length; column++) {
dataSheet.getCells().get(row, column).putValue(values[row][column]);
}
}
int chartSheetIndex = workbook.getWorksheets().add(SheetType.CHART);
Worksheet chartSheet = workbook.getWorksheets().get(chartSheetIndex);
chartSheet.setName("ChartSheet");
int lastChartRow = 55;
int lastChartColumn = 25;
int chartIndex = chartSheet.getCharts().add(ChartType.COLUMN, 0, 0, lastChartRow, lastChartColumn);
Chart chart = chartSheet.getCharts().get(chartIndex);
for (int row = 1; row <= values.length; row++) {
chart.getNSeries().add("DataSheet!A" + row + ":E" + row, false);
}
workbook.getWorksheets().setActiveSheetIndex(chartSheetIndex);
workbook.getWorksheets().setOleSize(0, lastChartRow, 0, lastChartColumn);
// Render the chart preview and serialize the editable workbook separately.
ImageOrPrintOptions imageOptions = new ImageOrPrintOptions();
imageOptions.setImageType(ImageType.PNG);
ByteArrayOutputStream chartImageStream = new ByteArrayOutputStream();
chart.toImage(chartImageStream, imageOptions);
byte[] chartImageBytes = chartImageStream.toByteArray();
ByteArrayOutputStream workbookStream = new ByteArrayOutputStream();
workbook.save(workbookStream, XLSX);
byte[] workbookBytes = workbookStream.toByteArray();
IImage chartImage = Images.fromData(chartImageBytes);
try {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
double slideWidth = presentation.getSlideSize().getSize().getWidth();
double slideHeight = presentation.getSlideSize().getSize().getHeight();
// Fit the preview within the slide without changing its aspect ratio.
double scale = Math.min(slideWidth / chartImage.getWidth(), slideHeight / chartImage.getHeight());
float frameWidth = (float) (chartImage.getWidth() * scale);
float frameHeight = (float) (chartImage.getHeight() * scale);
float frameX = (float) ((slideWidth - frameWidth) / 2);
float frameY = (float) ((slideHeight - frameHeight) / 2);
OleEmbeddedDataInfo embeddedData = new OleEmbeddedDataInfo(workbookBytes, "xlsx");
IOleObjectFrame oleFrame = slide.getShapes().addOleObjectFrame(frameX, frameY, frameWidth, frameHeight, embeddedData);
IPPImage previewImage = presentation.getImages().addImage(chartImage);
oleFrame.getSubstitutePictureFormat().getPicture().setImage(previewImage);
presentation.save("OutputChart.pptx", Pptx);
} finally {
presentation.dispose();
}
} finally {
chartImage.dispose();
}
} finally {
workbook.dispose();
}
} catch (Exception exception) {
System.err.println("Could not create the presentation: " + exception.getMessage());
}
```
## **Expected Result**
`OutputChart.pptx` contains one slide with an embedded Excel workbook and a chart preview. The workbook contains the original data and a column chart with four series. The preview is centered on the slide and retains its proportions.

In a compatible desktop PowerPoint environment with Excel available, double-click the object to activate and edit the embedded workbook. Activation and editing depend on the host application's OLE support and security settings.
## **FAQ**
**Why is a preview image needed?**
The embedded workbook and its slide preview are separate content. Supply a chart image so the slide shows the chart instead of the default "EMBEDDED OLE OBJECT" placeholder. See [Object Preview Issue when Adding OleObjectFrame](https://docs.aspose.com/slides/java/object-preview-issue-when-adding-oleobjectframe/).
**Does the preview update automatically when I change the workbook in code?**
Treat the preview as a snapshot. When updating workbook data programmatically, regenerate the chart image and replace the preview as well as the embedded workbook data.
**Can I use XLS instead of XLSX?**
Yes. Save the workbook in XLS format and use `xls` as the embedded data extension. The extension must match the actual workbook format; changing the extension alone does not convert the data.
**Why might the object change size after activation?**
The host application can update the OLE object's presentation when it activates the workbook. The workbook's OLE display range and the slide frame dimensions both matter. See [Working Solution for Chart Resizing in PPTX](https://docs.aspose.com/slides/java/working-solution-for-chart-resizing-in-pptx/).
## **Related Sections**
- [Working Solution for Chart Resizing in PPTX](https://docs.aspose.com/slides/java/working-solution-for-chart-resizing-in-pptx/)
- [Object Preview Issue when Adding OleObjectFrame](https://docs.aspose.com/slides/java/object-preview-issue-when-adding-oleobjectframe/)
- [Update OLE Objects Automatically Using a PowerPoint Add-In](https://docs.aspose.com/slides/java/updating-ole-objects-automatically-using-ms-powerpoint-add-in/)
## Related articles
- [Create and Embed Excel Charts as OLE Objects Using VSTO and Aspose.Slides for Java](https://docs.aspose.com/slides/java/create-and-embed-an-excel-chart-as-an-ole-object-into-a-microsoft-powerpoint-slide/)
- [Working Solution for Chart Resizing in PPTX](https://docs.aspose.com/slides/java/working-solution-for-chart-resizing-in-pptx/)
- [Manage OLE in Presentations Using Java](https://docs.aspose.com/slides/java/manage-ole/)
# Create and Modify Custom Animation Behaviors in Java
> Create, inspect, and modify custom animation behaviors and editable motion paths in PowerPoint presentations with Aspose.Slides for Java.
Source: https://docs.aspose.com/slides/java/custom-animation/
Updated: 2026-11-08
## **Overview**
Custom animation behaviors let you control individual operations within an animation effect, such as changing a color, rotating a shape, or following an editable motion path. This guide shows how to create and combine behaviors, configure their timing, inspect and modify existing animations, and verify that their properties survive saving and reopening a presentation.
For predefined effects and click triggers, see [Shape Animation](https://docs.aspose.com/slides/java/shape-animation/).
## **Understand the Animation Model**
An animation is organized as **Timeline → Sequence → Effect → Behaviors**:
- The [getTimeline](https://reference.aspose.com/slides/java/com.aspose.slides/ibaseslide/#getTimeline--) method returns the slide timeline, which contains its main sequence and interactive sequences.
- An [ISequence](https://reference.aspose.com/slides/java/com.aspose.slides/isequence/) contains effects, potentially targeting different shapes.
- An [IEffect](https://reference.aspose.com/slides/java/com.aspose.slides/ieffect/) identifies a target shape, preset, subtype, and effect timing.
- The collection returned by [IEffect.getBehaviors](https://reference.aspose.com/slides/java/com.aspose.slides/ieffect/#getBehaviors--) contains the operations that implement the effect: changing color, moving, rotating, setting a property, and so on.
## **Create Individual Behaviors**
Call [ISequence.addEffect](https://reference.aspose.com/slides/java/com.aspose.slides/isequence/#addEffect-com.aspose.slides.IShape-int-int-int-) to create an effect and access the [getBehaviors](https://reference.aspose.com/slides/java/com.aspose.slides/ieffect/#getBehaviors--) collection. A preset can populate this collection automatically. Keep its operations when extending the preset, or use [clear](https://reference.aspose.com/slides/java/com.aspose.slides/ibehaviorcollection/#clear--) when deliberately replacing them.
[IBehaviorFactory](https://reference.aspose.com/slides/java/com.aspose.slides/ibehaviorfactory/) creates the eight behavior types illustrated below. Motion is covered in [Build a Motion Path](https://docs.aspose.com/slides/java/custom-animation/#build-a-motion-path). Each snippet includes its imports; place its executable statements inside a method. Later editing examples state which output file they use.
### **Rotation**
Use [createRotationEffect](https://reference.aspose.com/slides/java/com.aspose.slides/ibehaviorfactory/#createRotationEffect--) to create a rotation. [getBy](https://reference.aspose.com/slides/java/com.aspose.slides/irotationeffect/#getBy--) specifies a relative angle in degrees; [getFrom](https://reference.aspose.com/slides/java/com.aspose.slides/irotationeffect/#getFrom--) and [getTo](https://reference.aspose.com/slides/java/com.aspose.slides/irotationeffect/#getTo--) specify endpoints.
The example starts with a Spin effect, replaces its preset operations with one rotation behavior, and gives that operation a two-second duration. A relative angle of 90 degrees expresses a quarter-turn from the shape's starting orientation, so no explicit starting angle is needed.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 160, 80);
IEffect effect = slide.getTimeline().getMainSequence().addEffect(shape, EffectType.Spin, EffectSubtype.None, EffectTriggerType.OnClick);
effect.getBehaviors().clear();
IBehaviorFactory factory = new BehaviorFactory();
IRotationEffect rotation = factory.createRotationEffect();
rotation.setBy(90f);
rotation.getTiming().setDuration(2f);
effect.getBehaviors().add(rotation);
presentation.save("rotation.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
`rotation.pptx` contains one shape and one rotation behavior. The collection, timing, and rotation-editing examples below use this file.
### **Scale**
Use [createScaleEffect](https://reference.aspose.com/slides/java/com.aspose.slides/ibehaviorfactory/#createScaleEffect--) with X/Y percentages: [getFrom](https://reference.aspose.com/slides/java/com.aspose.slides/iscaleeffect/#getFrom--) and [getTo](https://reference.aspose.com/slides/java/com.aspose.slides/iscaleeffect/#getTo--) describe the starting and ending size, while [getBy](https://reference.aspose.com/slides/java/com.aspose.slides/iscaleeffect/#getBy--) describes a relative change. Here, 100 means the original size.
The example grows both dimensions from 100% to 125% over two seconds. Using equal horizontal and vertical percentages keeps the shape's proportions; different percentages would stretch one dimension more than the other.
```java
import com.aspose.slides.*;
import java.awt.geom.Point2D;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 160, 80);
IEffect effect = slide.getTimeline().getMainSequence().addEffect(shape, EffectType.GrowShrink, EffectSubtype.None, EffectTriggerType.OnClick);
effect.getBehaviors().clear();
IBehaviorFactory factory = new BehaviorFactory();
IScaleEffect scale = factory.createScaleEffect();
scale.setFrom(new Point2D.Float(100, 100));
scale.setTo(new Point2D.Float(125, 125));
scale.getTiming().setDuration(2f);
effect.getBehaviors().add(scale);
presentation.save("scale.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
### **Color**
Use [createColorEffect](https://reference.aspose.com/slides/java/com.aspose.slides/ibehaviorfactory/#createColorEffect--) to change the fill from blue to orange. [getFrom](https://reference.aspose.com/slides/java/com.aspose.slides/icoloreffect/#getFrom--) and [getTo](https://reference.aspose.com/slides/java/com.aspose.slides/icoloreffect/#getTo--) are colors; [getBy](https://reference.aspose.com/slides/java/com.aspose.slides/icoloreffect/#getBy--) is a color offset. [IBehavior.getProperties](https://reference.aspose.com/slides/java/com.aspose.slides/ibehavior/#getProperties--) identifies the attribute being animated.
The shape's solid fill is initialized to blue, matching the animation's starting color. Selecting the fill-color attribute tells the behavior which part of the shape to change; the color endpoints alone do not identify that attribute. The saved effect describes a two-second transition to orange.
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 160, 80);
shape.getFillFormat().setFillType(FillType.Solid);
shape.getFillFormat().getSolidFillColor().setColor(Color.BLUE);
IEffect effect = slide.getTimeline().getMainSequence().addEffect(shape, EffectType.ChangeFillColor, EffectSubtype.None, EffectTriggerType.OnClick);
effect.getBehaviors().clear();
IBehaviorFactory factory = new BehaviorFactory();
IColorEffect color = factory.createColorEffect();
color.getProperties().add(BehaviorProperty.getFillColor().getValue());
color.getFrom().setColor(Color.BLUE);
Color orange = new Color(255, 165, 0);
color.getTo().setColor(orange);
color.getTiming().setDuration(2f);
effect.getBehaviors().add(color);
presentation.save("color.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
### **Filter**
Use [createFilterEffect](https://reference.aspose.com/slides/java/com.aspose.slides/ibehaviorfactory/#createFilterEffect--) to select a wipe. [getType](https://reference.aspose.com/slides/java/com.aspose.slides/ifiltereffect/#getType--), [getSubtype](https://reference.aspose.com/slides/java/com.aspose.slides/ifiltereffect/#getSubtype--), and [getReveal](https://reference.aspose.com/slides/java/com.aspose.slides/ifiltereffect/#getReveal--) specify the filter, direction, and whether to reveal or hide the shape.
This example configures a two-second wipe that reveals the shape using the right-direction subtype. The filter settings belong to the behavior inside the effect, so they are configured after the preset's original operations have been removed.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 160, 80);
IEffect effect = slide.getTimeline().getMainSequence().addEffect(shape, EffectType.Wipe, EffectSubtype.None, EffectTriggerType.OnClick);
effect.getBehaviors().clear();
IBehaviorFactory factory = new BehaviorFactory();
IFilterEffect filter = factory.createFilterEffect();
filter.setType(FilterEffectType.Wipe);
filter.setSubtype(FilterEffectSubtype.Right);
filter.setReveal(FilterEffectRevealType.In);
filter.getTiming().setDuration(2f);
effect.getBehaviors().add(filter);
presentation.save("filter.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
### **Property**
Use [createPropertyEffect](https://reference.aspose.com/slides/java/com.aspose.slides/ibehaviorfactory/#createPropertyEffect--) to animate opacity. [getFrom](https://reference.aspose.com/slides/java/com.aspose.slides/ipropertyeffect/#getFrom--), [getTo](https://reference.aspose.com/slides/java/com.aspose.slides/ipropertyeffect/#getTo--), and [getBy](https://reference.aspose.com/slides/java/com.aspose.slides/ipropertyeffect/#getBy--) are strings interpreted using [getValueType](https://reference.aspose.com/slides/java/com.aspose.slides/ipropertyeffect/#getValueType--) and [getCalcMode](https://reference.aspose.com/slides/java/com.aspose.slides/ipropertyeffect/#getCalcMode--). Choose endpoints or a relative offset rather than setting all three indiscriminately.
Here, the selected attribute is opacity, and the numeric strings represent a change from 25% opacity to full opacity. Linear interpolation describes a gradual change between those values. When adapting this example to another attribute, choose a value type and endpoint values appropriate to that attribute.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 160, 80);
IEffect effect = slide.getTimeline().getMainSequence().addEffect(shape, EffectType.Fade, EffectSubtype.None, EffectTriggerType.OnClick);
effect.getBehaviors().clear();
IBehaviorFactory factory = new BehaviorFactory();
IPropertyEffect property = factory.createPropertyEffect();
property.getProperties().add(BehaviorProperty.getStyleOpacity().getValue());
property.setValueType(PropertyValueType.Number);
property.setCalcMode(PropertyCalcModeType.Linear);
property.setFrom("0.25");
property.setTo("1");
property.getTiming().setDuration(2f);
effect.getBehaviors().add(property);
presentation.save("property.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
### **Set**
Use [createSetEffect](https://reference.aspose.com/slides/java/com.aspose.slides/ibehaviorfactory/#createSetEffect--) to assign visibility through [getTo](https://reference.aspose.com/slides/java/com.aspose.slides/iseteffect/#getTo--). A set behavior does not interpolate between endpoints.
The example selects the visibility attribute and assigns the string `visible` when the behavior runs. The rectangle is already visible in this minimal presentation, so the assignment may not produce an obvious visual change on its own. Such an operation is useful as part of a larger effect that also controls when the shape becomes hidden or visible.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 160, 80);
IEffect effect = slide.getTimeline().getMainSequence().addEffect(shape, EffectType.Appear, EffectSubtype.None, EffectTriggerType.OnClick);
effect.getBehaviors().clear();
IBehaviorFactory factory = new BehaviorFactory();
ISetEffect set = factory.createSetEffect();
set.getProperties().add(BehaviorProperty.getStyleVisibility().getValue());
set.setTo("visible");
effect.getBehaviors().add(set);
presentation.save("set.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
### **Command**
Use [createCommandEffect](https://reference.aspose.com/slides/java/com.aspose.slides/ibehaviorfactory/#createCommandEffect--) and configure [getType](https://reference.aspose.com/slides/java/com.aspose.slides/icommandeffect/#getType--), [getCommandString](https://reference.aspose.com/slides/java/com.aspose.slides/icommandeffect/#getCommandString--), and [getShapeTarget](https://reference.aspose.com/slides/java/com.aspose.slides/icommandeffect/#getShapeTarget--). Place a WAV recording named `sample.wav` in the working directory. This example embeds it with [addAudioFrameEmbedded](https://reference.aspose.com/slides/java/com.aspose.slides/ishapecollection/#addAudioFrameEmbedded-float-float-float-float-java.io.InputStream-) and attaches a play command to the audio frame.
The audio frame is both the effect's target and the command's target. This connects the play request to the embedded recording; a command string by itself does not identify which media object to control. The effect is configured to start on a click during the slideshow.
```java
import com.aspose.slides.*;
import java.io.FileInputStream;
import java.io.IOException;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
try (FileInputStream audioStream = new FileInputStream("sample.wav")) {
IAudioFrame audioFrame = slide.getShapes().addAudioFrameEmbedded(100, 100, 40, 40, audioStream);
IEffect effect = slide.getTimeline().getMainSequence().addEffect(audioFrame, EffectType.MediaPlay, EffectSubtype.None, EffectTriggerType.OnClick);
effect.getBehaviors().clear();
IBehaviorFactory factory = new BehaviorFactory();
ICommandEffect command = factory.createCommandEffect();
command.setType(CommandEffectType.Call);
command.setCommandString("play");
command.setShapeTarget(audioFrame);
effect.getBehaviors().add(command);
presentation.save("command.pptx", SaveFormat.Pptx);
} catch (IOException exception) {
System.out.println("Unable to read sample.wav: " + exception.getMessage());
}
} finally {
presentation.dispose();
}
```
Saving stores the command in `command.pptx`; it does not play the recording. Playback requires a slideshow player that supports the command and its media target.
## **Manage the Behavior Collection**
[IBehaviorCollection](https://reference.aspose.com/slides/java/com.aspose.slides/ibehaviorcollection/) supports [add](https://reference.aspose.com/slides/java/com.aspose.slides/ibehaviorcollection/#add-com.aspose.slides.IBehavior-), [insert](https://reference.aspose.com/slides/java/com.aspose.slides/ibehaviorcollection/#insert-int-com.aspose.slides.IBehavior-), [remove](https://reference.aspose.com/slides/java/com.aspose.slides/ibehaviorcollection/#remove-com.aspose.slides.IBehavior-), and [removeAt](https://reference.aspose.com/slides/java/com.aspose.slides/ibehaviorcollection/#removeAt-int-). This example opens `rotation.pptx`, adds scaling, moves it before rotation, and removes the rotation. Removing and reinserting the same object changes its stored position without making a copy.
The sequence of edits changes the collection from rotation–scale to scale–rotation, then to scale only. Indices refer to the current collection, so the removal uses the rotation's new index after reordering. The final enumeration confirms which behavior will be saved.
```java
import com.aspose.slides.*;
import java.awt.geom.Point2D;
Presentation presentation = new Presentation("rotation.pptx");
try {
IEffect effect = presentation.getSlides().get_Item(0).getTimeline().getMainSequence().get_Item(0);
IBehaviorCollection behaviors = effect.getBehaviors();
IBehaviorFactory factory = new BehaviorFactory();
IScaleEffect scale = factory.createScaleEffect();
scale.setTo(new Point2D.Float(125, 125));
scale.getTiming().setDuration(2f);
behaviors.add(scale);
behaviors.remove(scale);
behaviors.insert(0, scale);
behaviors.removeAt(1);
for (IBehavior behavior : behaviors)
System.out.println(behavior.getClass().getSimpleName());
presentation.save("collection-edited.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The output is `ScaleEffect`: only scaling remains. Collection order does not, by itself, schedule behaviors one after another. Clear the collection only when replacing all its operations.
## **Configure Behavior Timing**
[IBehavior.getTiming](https://reference.aspose.com/slides/java/com.aspose.slides/ibehavior/#getTiming--) exposes [ITiming](https://reference.aspose.com/slides/java/com.aspose.slides/itiming/), independently of [IEffect.getTiming](https://reference.aspose.com/slides/java/com.aspose.slides/ieffect/#getTiming--). Effect timing schedules the enclosing effect; behavior timing describes an operation inside it.
### **Set Duration, Delay, Repetition, and Acceleration**
Open `rotation.pptx` and set the duration ([getDuration](https://reference.aspose.com/slides/java/com.aspose.slides/itiming/#getDuration--)) and trigger delay ([getTriggerDelayTime](https://reference.aspose.com/slides/java/com.aspose.slides/itiming/#getTriggerDelayTime--)) in seconds, then configure the repeat count through [setRepeatCount](https://reference.aspose.com/slides/java/com.aspose.slides/itiming/#setRepeatCount-float-). [getAccelerate](https://reference.aspose.com/slides/java/com.aspose.slides/itiming/#getAccelerate--) and [getDecelerate](https://reference.aspose.com/slides/java/com.aspose.slides/itiming/#getDecelerate--) are fractions of the duration; keep their sum at most 1.
The input file is the one created in the rotation example, where the first behavior is known to be a rotation. This example changes only that behavior's timing; its 90-degree angle remains intact. Keeping the angle and timing separate makes it easier to adjust the pace without rebuilding the animation.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("rotation.pptx");
try {
IEffect effect = presentation.getSlides().get_Item(0).getTimeline().getMainSequence().get_Item(0);
IRotationEffect rotation = (IRotationEffect)effect.getBehaviors().get_Item(0);
rotation.getTiming().setDuration(2f);
rotation.getTiming().setTriggerDelayTime(0.5f);
rotation.getTiming().setRepeatCount(3f);
rotation.getTiming().setAccelerate(0.2f);
rotation.getTiming().setDecelerate(0.2f);
presentation.save("timing.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The behavior uses a two-second duration, a half-second delay, and a repeat count of 3. The first and last 20% of its duration are used for acceleration and deceleration.
Other repeat policies include [getRepeatDuration](https://reference.aspose.com/slides/java/com.aspose.slides/itiming/#getRepeatDuration--), [getRepeatUntilEndSlide](https://reference.aspose.com/slides/java/com.aspose.slides/itiming/#getRepeatUntilEndSlide--), and [getRepeatUntilNextClick](https://reference.aspose.com/slides/java/com.aspose.slides/itiming/#getRepeatUntilNextClick--); choose a policy rather than enabling them all together. [getAutoReverse](https://reference.aspose.com/slides/java/com.aspose.slides/itiming/#getAutoReverse--) plays the animation backwards after the forward pass. Acceleration and deceleration apply to continuous changes, not discrete assignments or commands.
## **Build a Motion Path**
Use [createMotionEffect](https://reference.aspose.com/slides/java/com.aspose.slides/ibehaviorfactory/#createMotionEffect--) to create motion. Its [getFrom](https://reference.aspose.com/slides/java/com.aspose.slides/imotioneffect/#getFrom--), [getTo](https://reference.aspose.com/slides/java/com.aspose.slides/imotioneffect/#getTo--), and [getBy](https://reference.aspose.com/slides/java/com.aspose.slides/imotioneffect/#getBy--) describe percentage-based coordinates or offsets. For an editable route, create a [MotionPath](https://reference.aspose.com/slides/java/com.aspose.slides/motionpath/) and assign it with [IMotionEffect.setPath](https://reference.aspose.com/slides/java/com.aspose.slides/imotioneffect/#setPath-com.aspose.slides.IMotionPath-). [IMotionPath](https://reference.aspose.com/slides/java/com.aspose.slides/imotionpath/) stores the path commands.
[MotionCommandPathType](https://reference.aspose.com/slides/java/com.aspose.slides/motioncommandpathtype/) selects the operation:
| Command | Points | Meaning |
| --- | --- | --- |
| MoveTo | One | Set the starting position. |
| LineTo | One | Move along a straight segment to its endpoint. |
| CurveTo | Three | Follow a cubic curve defined by two control points and an endpoint. |
| CloseLoop | None | Return to the starting position. |
| End | None | Finish the path. |
[MotionPathPointsType](https://reference.aspose.com/slides/java/com.aspose.slides/motionpathpointstype/) describes point-editing characteristics, such as corner or smooth points. It does not replace the command type. Use a curve point type for the curve example below, and a corner point type for the straight segments.
Path coordinates are normalized to slide dimensions: an X displacement of 0.25 represents one quarter of the slide width, not 0.25 points. Positive Y runs downward. Absolute commands specify positions in the path coordinate system; relative commands specify offsets from the current position. This is separate from [getOrigin](https://reference.aspose.com/slides/java/com.aspose.slides/imotioneffect/#getOrigin--), which selects the path's reference frame, and [getPathEditMode](https://reference.aspose.com/slides/java/com.aspose.slides/imotioneffect/#getPathEditMode--), which controls how the path moves when the shape is moved.
### **Create a Straight Path**
Create a motion behavior with a starting point, one straight segment, and an end command. [IMotionPath.add](https://reference.aspose.com/slides/java/com.aspose.slides/imotionpath/#add-int-java.awt.geom.Point2D.Float---int-boolean-) takes the command type, its points, the point type, and a relative-coordinate flag.
The starting command establishes (0, 0), and the line ends at (0.25, 0), giving the route a horizontal displacement of one quarter of the slide width. The ending command has no coordinate points. Once the path is assigned, adding the motion behavior to the effect connects that route to the rectangle.
```java
import com.aspose.slides.*;
import java.awt.geom.Point2D;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 160, 80);
IEffect effect = slide.getTimeline().getMainSequence().addEffect(shape, EffectType.PathRight, EffectSubtype.None, EffectTriggerType.OnClick);
effect.getBehaviors().clear();
IBehaviorFactory factory = new BehaviorFactory();
IMotionEffect motion = factory.createMotionEffect();
motion.setOrigin(MotionOriginType.Layout);
motion.getTiming().setDuration(2f);
IMotionPath path = new MotionPath();
path.add(MotionCommandPathType.MoveTo, new Point2D.Float[] { new Point2D.Float(0, 0) }, MotionPathPointsType.Auto, false);
path.add(MotionCommandPathType.LineTo, new Point2D.Float[] { new Point2D.Float(0.25f, 0) }, MotionPathPointsType.Corner, false);
path.add(MotionCommandPathType.End, new Point2D.Float[0], MotionPathPointsType.None, false);
motion.setPath(path);
effect.getBehaviors().add(motion);
presentation.save("motion.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
`motion.pptx` contains one motion behavior with three path commands. The following file-editing examples use this known structure.
### **Compare Absolute and Relative Coordinates**
These two path objects describe the same route. The absolute command ends at (0.3, 0.1); the relative command adds (0.1, 0.1) to the current position, (0.2, 0).
Both paths start at the same position. For the relative line, add its X and Y offsets to the current position to obtain the endpoint; for the absolute line, read the endpoint directly. Switching the flag without converting the coordinates would describe a different route.
```java
import com.aspose.slides.*;
import java.awt.geom.Point2D;
MotionPath absolutePath = new MotionPath();
absolutePath.add(MotionCommandPathType.MoveTo, new Point2D.Float[] { new Point2D.Float(0.2f, 0) }, MotionPathPointsType.Auto, false);
absolutePath.add(MotionCommandPathType.LineTo, new Point2D.Float[] { new Point2D.Float(0.3f, 0.1f) }, MotionPathPointsType.Corner, false);
MotionPath relativePath = new MotionPath();
relativePath.add(MotionCommandPathType.MoveTo, new Point2D.Float[] { new Point2D.Float(0.2f, 0) }, MotionPathPointsType.Auto, false);
relativePath.add(MotionCommandPathType.LineTo, new Point2D.Float[] { new Point2D.Float(0.1f, 0.1f) }, MotionPathPointsType.Corner, true);
```
Assign either path to a motion behavior to use it in a presentation. The final Boolean argument selects relative coordinates for that command.
### **Replace a Line with a Curve**
Open `motion.pptx` and replace its line command with a cubic curve. Supply the two control points first, followed by the endpoint.
The starting position is supplied by the preceding command. The first two points shape the curve, while the third is its destination; they are not three successive destinations. Updating the command type, point-editing type, and point array together keeps the segment consistent with its new geometry.
```java
import com.aspose.slides.*;
import java.awt.geom.Point2D;
Presentation presentation = new Presentation("motion.pptx");
try {
IEffect effect = presentation.getSlides().get_Item(0).getTimeline().getMainSequence().get_Item(0);
IMotionEffect motion = (IMotionEffect)effect.getBehaviors().get_Item(0);
IMotionPath path = motion.getPath();
path.get_Item(1).setCommandType(MotionCommandPathType.CurveTo);
path.get_Item(1).setPointsType(MotionPathPointsType.CurveSmooth);
path.get_Item(1).setPoints(new Point2D.Float[] { new Point2D.Float(0.1f, 0), new Point2D.Float(0.2f, 0.1f), new Point2D.Float(0.3f, 0.1f) });
presentation.save("curve.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The path in `curve.pptx` still has three commands; its middle command now defines a curve.
[](https://docs.aspose.com/slides/java/custom-animation/visual-custom-animation-b1f00ab59d82.svg)
*The original line ends at (0.25, 0). Its cubic replacement uses control points (0.1, 0) and (0.2, 0.1), then ends at (0.3, 0.1). The preceding command supplies the start; control points are not successive destinations.*
## **Inspect and Edit a Saved Path**
Each [IMotionCmdPath](https://reference.aspose.com/slides/java/com.aspose.slides/imotioncmdpath/) exposes [getPoints](https://reference.aspose.com/slides/java/com.aspose.slides/imotioncmdpath/#getPoints--), [getCommandType](https://reference.aspose.com/slides/java/com.aspose.slides/imotioncmdpath/#getCommandType--), [getPointsType](https://reference.aspose.com/slides/java/com.aspose.slides/imotioncmdpath/#getPointsType--), and [isRelative](https://reference.aspose.com/slides/java/com.aspose.slides/imotioncmdpath/#isRelative--). The following examples use the known three-command path in `motion.pptx`. For arbitrary input, locate the intended effect and check command types and point counts before editing by index.
### **Read Commands and Coordinates**
Read the path without changing it. End and close-loop commands need no points, so allow for a null point array.
The output pairs each numeric command type with its relative-coordinate flag before listing its points. This lets you distinguish an endpoint from an offset before modifying the path. A curve would list three points, whereas the straight line in this file lists only one.
```java
import com.aspose.slides.*;
import java.awt.geom.Point2D;
Presentation presentation = new Presentation("motion.pptx");
try {
IEffect effect = presentation.getSlides().get_Item(0).getTimeline().getMainSequence().get_Item(0);
IMotionEffect motion = (IMotionEffect)effect.getBehaviors().get_Item(0);
IMotionPath path = motion.getPath();
for (IMotionCmdPath segment : path)
{
System.out.println(segment.getCommandType() + ", relative: " + segment.isRelative());
if (segment.getPoints() != null)
for (Point2D.Float point : segment.getPoints())
System.out.println("X=" + point.x + ", Y=" + point.y);
}
} finally {
presentation.dispose();
}
```
The listing contains a starting point, an absolute line ending at (0.25, 0), and an end command.
### **Change an Endpoint**
Open `motion.pptx` and replace the line's point array to move its endpoint.
In the input file, index 0 is the starting command and index 1 is the line. Replacing the line's single point changes its destination without changing its command type, timing, or position in the collection. Because the command uses absolute coordinates, the new pair specifies a position rather than an added offset.
```java
import com.aspose.slides.*;
import java.awt.geom.Point2D;
Presentation presentation = new Presentation("motion.pptx");
try {
IEffect effect = presentation.getSlides().get_Item(0).getTimeline().getMainSequence().get_Item(0);
IMotionEffect motion = (IMotionEffect)effect.getBehaviors().get_Item(0);
motion.getPath().get_Item(1).setPoints(new Point2D.Float[] { new Point2D.Float(0.4f, 0.1f) });
presentation.save("motion-endpoint.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The line in `motion-endpoint.pptx` ends at (0.4, 0.1); the original file is unchanged.
### **Replace a Segment**
Use [insert](https://reference.aspose.com/slides/java/com.aspose.slides/imotionpath/#insert-int-int-java.awt.geom.Point2D.Float---int-boolean-) and [removeAt](https://reference.aspose.com/slides/java/com.aspose.slides/imotionpath/#removeAt-int-) to replace the line in `motion.pptx`. Inserting shifts the old line to index 2.
This demonstrates replacing a command object rather than editing its existing coordinates. After insertion, the collection temporarily contains the starting command, the new line, the old line, and the end command. Removing index 2 discards the old line and leaves the new route in place.
```java
import com.aspose.slides.*;
import java.awt.geom.Point2D;
Presentation presentation = new Presentation("motion.pptx");
try {
IEffect effect = presentation.getSlides().get_Item(0).getTimeline().getMainSequence().get_Item(0);
IMotionEffect motion = (IMotionEffect)effect.getBehaviors().get_Item(0);
IMotionPath path = motion.getPath();
path.insert(1, MotionCommandPathType.LineTo, new Point2D.Float[] { new Point2D.Float(0.2f, 0.1f) }, MotionPathPointsType.Corner, false);
path.removeAt(2);
presentation.save("motion-edited.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The saved path still has three commands, with the new line ending at (0.2, 0.1) and the end command last.
## **Modify and Verify an Existing Behavior**
When the behavior's index is unknown, select it by type. This example opens `rotation.pptx`, finds its [IRotationEffect](https://reference.aspose.com/slides/java/com.aspose.slides/irotationeffect/), changes the angle, and checks the saved value after reopening.
The type check allows the loop to skip behaviors that are not rotations. The second load reads the saved file into a separate presentation object, so the comparison checks persisted data rather than the value still held in memory. This example still assumes the known effect is first in the main sequence; selecting a behavior by type does not locate the correct effect in an arbitrary presentation.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("rotation.pptx");
try {
IEffect effect = presentation.getSlides().get_Item(0).getTimeline().getMainSequence().get_Item(0);
for (IBehavior behavior : effect.getBehaviors())
{
if (behavior instanceof IRotationEffect) {
IRotationEffect rotation = (IRotationEffect) behavior;
rotation.setBy(180f);
}
}
presentation.save("rotation-edited.pptx", SaveFormat.Pptx);
Presentation reopened = new Presentation("rotation-edited.pptx");
try {
IEffect savedEffect = reopened.getSlides().get_Item(0).getTimeline().getMainSequence().get_Item(0);
for (IBehavior behavior : savedEffect.getBehaviors())
{
if (behavior instanceof IRotationEffect) {
IRotationEffect rotation = (IRotationEffect) behavior;
System.out.println("Rotation preserved: " + (Math.abs(rotation.getBy() - 180f) < 0.001f));
}
}
} finally {
reopened.dispose();
}
} finally {
presentation.dispose();
}
```
The output is `Rotation preserved: true`. Apply the same type-checking pattern to other behaviors. For a complete preservation check, compare the target shape, effect, behavior types and order, timing, and path commands. Use a numeric tolerance for floating-point values. For a presentation with an unknown animation layout, see [Read Shape Animations](https://docs.aspose.com/slides/java/shape-animation/#read-shape-animations) for traversal of main and interactive sequences.
## **Behavior Order, Presets, and Playback**
The order in [IBehaviorCollection](https://reference.aspose.com/slides/java/com.aspose.slides/ibehaviorcollection/) is the stored order of an effect's operations. It is not a playlist in which every behavior automatically waits for the preceding one. Timing and the enclosing effect determine scheduling. Behaviors can overlap, and operations on the same property may interact through [getAdditive](https://reference.aspose.com/slides/java/com.aspose.slides/ibehavior/#getAdditive--) and [getAccumulate](https://reference.aspose.com/slides/java/com.aspose.slides/ibehavior/#getAccumulate--). Do not use collection reordering alone to schedule “move, then rotate”; use explicit timing or separate effects as described in [Shape Animation](https://docs.aspose.com/slides/java/shape-animation/).
The effect's [getType](https://reference.aspose.com/slides/java/com.aspose.slides/ieffect/#getType--) and [getSubtype](https://reference.aspose.com/slides/java/com.aspose.slides/ieffect/#getSubtype--) describe its preset. They are not a complete description of an edited behavior tree. Choose the preset and subtype before customizing behaviors: changing the preset can rebuild the collection and discard your custom operations. For example, changing a customized Spin effect to Fade can replace its rotation behavior with set and filter behaviors. Inspect the collection again after changing a preset or subtype. Clearing preset behaviors can also remove visibility or initialization operations that the preset needs. The examples deliberately use visible shapes and replace the behaviors; they do not reconstruct every preset's implementation.
## **Format Compatibility**
A preserved behavior tree does not guarantee identical playback in every viewer or export renderer. Check the saved data and the rendered output separately.
| Format or output | What to verify |
| --- | --- |
| PPTX | Use as the primary format for these examples. Reopen it to verify the editable behavior tree, then check playback in the intended PowerPoint version. |
| PPT | Legacy binary representation can differ from PPTX. Test a separate save-and-reopen cycle and playback; do not infer support for every custom combination from successful PPTX output. |
| PDF, PNG, JPEG, and other static slide images | Contain a static slide representation, not a playable behavior timeline or a guaranteed final animation frame. |
| [HTML5](https://docs.aspose.com/slides/java/export-to-html5/) | Can play supported animations when shape animation is enabled in the export options. Test custom combinations in the browser. |
| [Animated GIF](https://docs.aspose.com/slides/java/convert-powerpoint-to-animated-gif/) | Stores rendered frames, not editable behaviors or click-triggered interaction. Check the actual rendered motion. |
| [Video](https://docs.aspose.com/slides/java/convert-powerpoint-to-video/) | Render animation frames and encode them as video. Support is limited to the renderer's [supported animations and effects](https://docs.aspose.com/slides/java/convert-powerpoint-to-video/#supported-animations-and-effects); commands and interactive events do not become an editable timeline. |
## **FAQ**
**Why does my effect contain behaviors before I add any?**
Creating a predefined effect can create its underlying operations. Inspect them before deciding whether to extend the preset or replace its behaviors.
**Does moving a behavior to the beginning make it play first?**
Not necessarily. Collection order is not a substitute for timing. Check delays, durations, and interactions between operations on the same property.
**Why does an end command have no points?**
It marks the end of the path and needs no coordinates. Check for a null point array when inspecting a path read from a file.
**Is a successful round trip sufficient to confirm playback?**
No. Reopening confirms preservation of the properties you checked. Test the slideshow player or animated export separately to confirm its visual behavior.
# Customize PowerPoint Fonts in Java
> Customize fonts in PowerPoint slides with Aspose.Slides for Java to keep your presentations sharp and consistent across any device.
Source: https://docs.aspose.com/slides/java/custom-font/
Updated: 2026-09-29
## **Overview**
Aspose.Slides allows you to use custom fonts in presentations without installing them on the operating system. You can load fonts from custom folders, provide fonts for a specific presentation through document-level font sources, or load external fonts directly from binary data.
Loaded fonts are used when a presentation is rendered or exported, for example to PDF, images, and other supported formats. This helps keep the presentation output consistent across different environments. The article also explains how to inspect the font folders used by Aspose.Slides and how to clear the font cache after working with external fonts.
Registering custom fonts for rendering is separate from embedding fonts into a PPTX file. If a font must be stored inside the presentation itself, use the font embedding features explicitly.
A presentation theme can reference different font families for individual writing systems. These mappings store font names but do not install or load the font files. See [Script-Specific Theme Fonts](https://docs.aspose.com/slides/java/script-specific-font-mappings/) to manage the mappings, and use the loading options below to make the referenced fonts available for consistent rendering.
Aspose Slides allows you to load these fonts using the [loadExternalFonts](https://reference.aspose.com/slides/java/com.aspose.slides/fontsloader/#loadExternalFonts-java.lang.String---) method:
* TrueType (.ttf) and TrueType Collection (.ttc) fonts. See [TrueType](https://en.wikipedia.org/wiki/TrueType).
* OpenType (.otf) fonts. See [OpenType](https://en.wikipedia.org/wiki/OpenType).
## **Load Custom Fonts**
Aspose.Slides allows you to load fonts used in a presentation without installing them on the system. This affects export output—such as PDF, images, and other supported formats—so the resulting documents look consistent across environments. Fonts are loaded from custom directories.
1. Specify one or more folders that contain the font files.
2. Call the static [FontsLoader.loadExternalFonts](https://reference.aspose.com/slides/java/com.aspose.slides/fontsloader/#loadExternalFonts-java.lang.String---) method to load fonts from those folders.
3. Load and render/export the presentation.
4. Call [FontsLoader.clearCache](https://reference.aspose.com/slides/java/com.aspose.slides/fontsloader/#clearCache--) to clear the font cache.
The following code example demonstrates the font loading process:
```java
import com.aspose.slides.*;
// Define folders that contain custom font files.
String[] fontFolders = new String[] { "assets/fonts", "global/fonts" };
// Load custom fonts from the specified folders.
FontsLoader.loadExternalFonts(fontFolders);
Presentation presentation = null;
try {
presentation = new Presentation("sample.pptx");
// Render/export the presentation (e.g., to PDF, images, or other formats) using the loaded fonts.
presentation.save("output.pdf", SaveFormat.Pdf);
} finally {
if (presentation != null) presentation.dispose();
// Clear the font cache after the work is finished.
FontsLoader.clearCache();
}
```
[FontsLoader.loadExternalFonts](https://reference.aspose.com/slides/java/com.aspose.slides/fontsloader/#loadExternalFonts-java.lang.String---) adds additional folders to the font search paths, but it does not change the font initialization order.
Fonts are initialized in this order:
1. The default operating system font path.
1. The paths loaded via [FontsLoader](https://reference.aspose.com/slides/java/com.aspose.slides/fontsloader/).
## **Get Custom Font Folders**
Aspose.Slides provides the [getFontFolders](https://reference.aspose.com/slides/java/com.aspose.slides/fontsloader/#getFontFolders--) method to allow you to find font folders. This method returns folders added through the `LoadExternalFonts` method and system font folders.
This Java code shows you how to use [getFontFolders](https://reference.aspose.com/slides/java/com.aspose.slides/fontsloader/#getFontFolders--):
```java
import com.aspose.slides.*;
// This line outputs folders where font files are searched.
// Those are folders added through the LoadExternalFonts method and system font folders.
String[] fontFolders = FontsLoader.getFontFolders();
```
## **Specify Custom Fonts Used with a Presentation**
Aspose.Slides provides the [setDocumentLevelFontSources](https://reference.aspose.com/slides/java/com.aspose.slides/iloadoptions/#setDocumentLevelFontSources-com.aspose.slides.IFontSources-) property to allow you to specify external fonts that will be used with the presentation.
This Java code shows you how to use the [setDocumentLevelFontSources](https://reference.aspose.com/slides/java/com.aspose.slides/iloadoptions/#setDocumentLevelFontSources-com.aspose.slides.IFontSources-) property:
```java
import com.aspose.slides.*;
import java.nio.file.Files;
import java.nio.file.Paths;
byte[] memoryFont1 = Files.readAllBytes(Paths.get("customfonts/CustomFont1.ttf"));
byte[] memoryFont2 = Files.readAllBytes(Paths.get("customfonts/CustomFont2.ttf"));
LoadOptions loadOptions = new LoadOptions();
loadOptions.getDocumentLevelFontSources().setFontFolders(new String[] { "assets/fonts", "global/fonts" });
loadOptions.getDocumentLevelFontSources().setMemoryFonts(new byte[][] { memoryFont1, memoryFont2 });
Presentation pres = new Presentation("MyPresentation.pptx", loadOptions);
try {
// Work with the presentation
// CustomFont1, CustomFont2, and fonts from assets\fonts & global\fonts folders and their subfolders are available to the presentation
} finally {
if (pres != null) pres.dispose();
}
```
## **Manage Fonts Externally**
Aspose.Slides provides the [loadExternalFont](https://reference.aspose.com/slides/java/com.aspose.slides/fontsloader/#loadExternalFont-byte---)(byte[] data) method to allow you to load external fonts from binary data.
This Java code demonstrates the byte array font loading process:
```java
import com.aspose.slides.*;
import java.nio.file.Files;
import java.nio.file.Paths;
FontsLoader.loadExternalFont(Files.readAllBytes(Paths.get("ARIALN.TTF")));
FontsLoader.loadExternalFont(Files.readAllBytes(Paths.get("ARIALNBI.TTF")));
FontsLoader.loadExternalFont(Files.readAllBytes(Paths.get("ARIALNI.TTF")));
try
{
Presentation pres = new Presentation("");
try {
// external font loaded during the presentation lifetime
} finally {
}
}
finally
{
FontsLoader.clearCache();
}
```
## **FAQ**
### Do custom fonts affect export to all formats (PDF, PNG, SVG, HTML)?
Yes. Connected fonts are used by the renderer across all export formats.
### Are custom fonts automatically embedded into the resulting PPTX?
No. Registering a font for rendering is not the same as embedding it into a PPTX. If you need the font carried inside the presentation file, you must use the explicit [embedding features](https://docs.aspose.com/slides/java/embedded-font/).
### Can I control fallback behavior when a custom font lacks certain glyphs?
Yes. Configure [font substitution](https://docs.aspose.com/slides/java/font-substitution/), [replacement rules](https://docs.aspose.com/slides/java/font-replacement/), and [fallback sets](https://docs.aspose.com/slides/java/fallback-font/) to define exactly which font is used when the requested glyph is missing.
### Can I use fonts in Linux/Docker containers without installing them system-wide?
Partly. Aspose.Slides can use fonts from your own folders or from byte arrays without installing them, but Java's font support still needs at least one installed font in the image. Without one, loading fails with the error "Fontconfig head is null, check your fonts or fonts configuration". See [Deploy Fonts](https://docs.aspose.com/slides/java/deploy-fonts/).
### What about licensing—can I embed any custom font without restrictions?
You are responsible for font licensing compliance. Terms vary; some licenses prohibit embedding or commercial use. Always review the font’s EULA before distributing outputs.
# Customize Presentation Shapes in Java
> Create and customize shapes in PowerPoint presentations with Aspose.Slides for Java: geometry paths, curved corners, composite shapes.
Source: https://docs.aspose.com/slides/java/custom-shape/
Updated: 2026-10-22
## **Overview**
This article explains how to customize presentation shapes in Aspose.Slides by editing shape geometry through edit points and geometry paths. It shows how to work with [GeometryPath](https://reference.aspose.com/slides/java/com.aspose.slides/geometrypath/) and [IGeometryPath](https://reference.aspose.com/slides/java/com.aspose.slides/igeometrypath/) to modify existing shapes, perform basic path editing operations, add or remove points, and apply updated geometry back to a shape.
It also demonstrates how to create custom and composite shapes, build shapes with curved corners, determine whether a shape geometry is closed, inspect shape elements, and convert Java AWT text outlines into geometry paths.
## **Change a Shape Using Edit Points**
In PowerPoint, you can use **Edit Points** to modify a square:
* Move a corner inward or outward.
* Adjust the curvature at a point.
* Add new points.
Editing points lets you modify a shape’s outline or use an existing shape as the basis for a new one.
## **Shape Editing Tips**

When editing PowerPoint shapes, keep these concepts in mind:
* A shape (or its path) can either be closed or open.
* A shape’s path consists of anchor points connected by segments.
* A segment can be straight or curved. Anchor points and control handles determine its shape.
* Anchor points exist as corner points, straight points, or smooth points:
* At a corner point, adjoining segments can meet at an angle.
* At a smooth point, the two control handles are aligned and equally distant from the anchor point.
* At a straight point, the two control handles are aligned but can be different distances from the anchor point.
* Moving anchor points or adjusting their handles changes the shape’s outline.
To edit PowerPoint shapes through edit points, **Aspose.Slides** provides the [GeometryPath](https://reference.aspose.com/slides/java/com.aspose.slides/geometrypath/) class and [IGeometryPath](https://reference.aspose.com/slides/java/com.aspose.slides/igeometrypath/) interface.
* A [GeometryPath](https://reference.aspose.com/slides/java/com.aspose.slides/geometrypath/) instance represents a geometry path of the [IGeometryShape](https://reference.aspose.com/slides/java/com.aspose.slides/igeometryshape/) object.
* To retrieve the [GeometryPath](https://reference.aspose.com/slides/java/com.aspose.slides/geometrypath/) from the [IGeometryShape](https://reference.aspose.com/slides/java/com.aspose.slides/igeometryshape/) instance, you can use the [IGeometryShape.getGeometryPaths](https://reference.aspose.com/slides/java/com.aspose.slides/igeometryshape/#getGeometryPaths--) method.
* To set the [GeometryPath](https://reference.aspose.com/slides/java/com.aspose.slides/geometrypath/) for a shape, you can use these methods: [IGeometryShape.setGeometryPath](https://reference.aspose.com/slides/java/com.aspose.slides/igeometryshape/#setGeometryPath-com.aspose.slides.IGeometryPath-) for shapes with a single path and [IGeometryShape.setGeometryPaths](https://reference.aspose.com/slides/java/com.aspose.slides/igeometryshape/#setGeometryPaths-com.aspose.slides.IGeometryPath---) for shapes with multiple paths.
* To add segments, you can use the methods under [IGeometryPath](https://reference.aspose.com/slides/java/com.aspose.slides/igeometrypath/).
* Using the [IGeometryPath.setStroke](https://reference.aspose.com/slides/java/com.aspose.slides/igeometrypath/#setStroke-boolean-) and [IGeometryPath.setFillMode](https://reference.aspose.com/slides/java/com.aspose.slides/igeometrypath/#setFillMode-byte-) methods, you can set the appearance for a geometry path.
* Using the [IGeometryPath.getPathData](https://reference.aspose.com/slides/java/com.aspose.slides/igeometrypath/#getPathData--) method, you can retrieve the geometry path of a [GeometryShape](https://reference.aspose.com/slides/java/com.aspose.slides/geometryshape/) as an array of path segments.
* To access additional shape geometry customization options, you can read a [java.awt.Shape](https://docs.oracle.com/javase/8/docs/api/java/awt/Shape.html) through its [PathIterator](https://docs.oracle.com/javase/8/docs/api/java/awt/geom/PathIterator.html) and replay the segments on a [GeometryPath](https://reference.aspose.com/slides/java/com.aspose.slides/geometrypath/).
## **Simple Editing Operations**
Use the following methods to edit a geometry path. Overloads that accept an index insert a segment at that zero-based position in the path’s segment array.
| Operation | Method |
| --- | --- |
| Append or insert a straight line. | [GeometryPath.lineTo](https://reference.aspose.com/slides/java/com.aspose.slides/geometrypath/#lineTo-float-float-) |
| Append or insert a cubic Bézier curve with two control points and an endpoint. | [GeometryPath.cubicBezierTo](https://reference.aspose.com/slides/java/com.aspose.slides/geometrypath/#cubicBezierTo-float-float-float-float-float-float-) |
| Append or insert a quadratic Bézier curve with one control point and an endpoint. | [GeometryPath.quadraticBezierTo](https://reference.aspose.com/slides/java/com.aspose.slides/geometrypath/#quadraticBezierTo-float-float-float-float-) |
| Append an elliptical arc with the specified dimensions and angles in degrees. | [GeometryPath.arcTo](https://reference.aspose.com/slides/java/com.aspose.slides/geometrypath/#arcTo-float-float-float-float-) |
| Close the current figure by connecting its endpoint to its starting point. | [GeometryPath.closeFigure](https://reference.aspose.com/slides/java/com.aspose.slides/geometrypath/#closeFigure--) |
| Set the starting point of a figure. | [GeometryPath.moveTo](https://reference.aspose.com/slides/java/com.aspose.slides/geometrypath/#moveTo-float-float-) |
| Remove a segment at a zero-based index. | [GeometryPath.removeAt](https://reference.aspose.com/slides/java/com.aspose.slides/geometrypath/#removeAt-int-) |
## **Add Custom Points to a Shape**
This example inserts two points into a rectangular shape using [GeometryPath.lineTo](https://reference.aspose.com/slides/java/com.aspose.slides/geometrypath/#lineTo-float-float-) and applies the edited path with [IGeometryShape.setGeometryPath](https://reference.aspose.com/slides/java/com.aspose.slides/igeometryshape/#setGeometryPath-com.aspose.slides.IGeometryPath-). The coordinates are local to the shape: both new points are at its center, 100 points from the left and 50 points from the top. Segment indices 1 and 4 place them on the top and bottom edges, pulling those edges inward.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 200, 100);
IGeometryPath geometryPath = shape.getGeometryPaths()[0];
geometryPath.lineTo(100, 50, 1);
geometryPath.lineTo(100, 50, 4);
shape.setGeometryPath(geometryPath);
} finally {
presentation.dispose();
}
```

## **Remove Points from a Shape**
This example changes a heart-shaped outline by removing the segment at zero-based index 2 with [GeometryPath.removeAt](https://reference.aspose.com/slides/java/com.aspose.slides/geometrypath/#removeAt-int-). Applying the modified path with [IGeometryShape.setGeometryPath](https://reference.aspose.com/slides/java/com.aspose.slides/igeometryshape/#setGeometryPath-com.aspose.slides.IGeometryPath-) updates the shape’s contour.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Heart, 100, 100, 300, 300);
IGeometryPath path = shape.getGeometryPaths()[0];
path.removeAt(2);
shape.setGeometryPath(path);
} finally {
presentation.dispose();
}
```

## **Create a Custom Shape**
This example builds a five-pointed star with [GeometryPath](https://reference.aspose.com/slides/java/com.aspose.slides/geometrypath/). Alternating outer and inner radii of 100 and 50 points define the tips and indentations; a 72-degree step spaces the five tips evenly. The path is closed with [GeometryPath.closeFigure](https://reference.aspose.com/slides/java/com.aspose.slides/geometrypath/#closeFigure--) and applied to a rectangular shape using [IGeometryShape.setGeometryPath](https://reference.aspose.com/slides/java/com.aspose.slides/igeometryshape/#setGeometryPath-com.aspose.slides.IGeometryPath-), replacing its outline.
```java
import com.aspose.slides.*;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.List;
List points = new ArrayList<>();
float outerRadius = 100f;
float innerRadius = 50f;
int angleStep = 72;
for (int angle = -90; angle < 270; angle += angleStep)
{
double radians = angle * (Math.PI / 180f);
double x = outerRadius * Math.cos(radians);
double y = outerRadius * Math.sin(radians);
Point2D.Float point = new Point2D.Float((float)x + outerRadius, (float)y + outerRadius);
points.add(point);
radians = Math.PI * (angle + angleStep / 2) / 180.0;
x = innerRadius * Math.cos(radians);
y = innerRadius * Math.sin(radians);
point = new Point2D.Float((float)x + outerRadius, (float)y + outerRadius);
points.add(point);
}
GeometryPath starPath = new GeometryPath();
starPath.moveTo(points.get(0));
for (int i = 1; i < points.size(); i++)
{
starPath.lineTo(points.get(i));
}
starPath.closeFigure();
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, outerRadius * 2, outerRadius * 2);
shape.setGeometryPath(starPath);
} finally {
presentation.dispose();
}
```

## **Create a Composite Custom Shape**
This example defines two closed [GeometryPath](https://reference.aspose.com/slides/java/com.aspose.slides/geometrypath/) objects for the top and bottom thirds of a shape. Applying both paths with [IGeometryShape.setGeometryPaths](https://reference.aspose.com/slides/java/com.aspose.slides/igeometryshape/#setGeometryPaths-com.aspose.slides.IGeometryPath---) creates a single composite shape with a gap across its middle third.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 200, 100);
GeometryPath topPath = new GeometryPath();
topPath.moveTo(0, 0);
topPath.lineTo(shape.getWidth(), 0);
topPath.lineTo(shape.getWidth(), shape.getHeight() / 3);
topPath.lineTo(0, shape.getHeight() / 3);
topPath.closeFigure();
GeometryPath bottomPath = new GeometryPath();
bottomPath.moveTo(0, shape.getHeight() / 3 * 2);
bottomPath.lineTo(shape.getWidth(), shape.getHeight() / 3 * 2);
bottomPath.lineTo(shape.getWidth(), shape.getHeight());
bottomPath.lineTo(0, shape.getHeight());
bottomPath.closeFigure();
shape.setGeometryPaths(new GeometryPath[] { topPath, bottomPath });
} finally {
presentation.dispose();
}
```

## **Create a Custom Shape with Curved Corners**
This example combines straight segments with [GeometryPath.arcTo](https://reference.aspose.com/slides/java/com.aspose.slides/geometrypath/#arcTo-float-float-float-float-) to create a shape with inward-curved corners. Each corner size sets the arc’s width and height in points, and the -90-degree sweep draws a counterclockwise quarter ellipse. The completed path is applied with [IGeometryShape.setGeometryPath](https://reference.aspose.com/slides/java/com.aspose.slides/igeometryshape/#setGeometryPath-com.aspose.slides.IGeometryPath-), and the presentation is saved in PPTX format.
```java
import com.aspose.slides.*;
import java.awt.geom.Point2D;
float shapeX = 20f;
float shapeY = 20f;
float shapeWidth = 300f;
float shapeHeight = 200f;
float leftTopSize = 50f;
float rightTopSize = 20f;
float rightBottomSize = 40f;
float leftBottomSize = 10f;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Custom, shapeX, shapeY, shapeWidth, shapeHeight);
Point2D.Float topLeft = new Point2D.Float(leftTopSize, 0);
Point2D.Float topRight = new Point2D.Float(shapeWidth - rightTopSize, 0);
Point2D.Float rightBottom = new Point2D.Float(shapeWidth, shapeHeight - rightBottomSize);
Point2D.Float bottomLeft = new Point2D.Float(leftBottomSize, shapeHeight);
Point2D.Float leftTop = new Point2D.Float(0, leftTopSize);
GeometryPath geometryPath = new GeometryPath();
geometryPath.moveTo(topLeft);
geometryPath.lineTo(topRight);
geometryPath.arcTo(rightTopSize, rightTopSize, 180, -90);
geometryPath.lineTo(rightBottom);
geometryPath.arcTo(rightBottomSize, rightBottomSize, -90, -90);
geometryPath.lineTo(bottomLeft);
geometryPath.arcTo(leftBottomSize, leftBottomSize, 0, -90);
geometryPath.lineTo(leftTop);
geometryPath.arcTo(leftTopSize, leftTopSize, 90, -90);
geometryPath.closeFigure();
shape.setGeometryPath(geometryPath);
presentation.save("output.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Find Out If a Shape Geometry Is Closed**
The following helper checks whether every nonempty geometry path ends with a closing segment. It reads [IGeometryPath.getPathData](https://reference.aspose.com/slides/java/com.aspose.slides/igeometrypath/#getPathData--) and compares the final segment’s [IPathSegment.getPathCommand](https://reference.aspose.com/slides/java/com.aspose.slides/ipathsegment/#getPathCommand--) with [PathCommandType.Close](https://reference.aspose.com/slides/java/com.aspose.slides/pathcommandtype/). It returns false when there are no nonempty paths. This checks the final command of each path; it does not inspect every subfigure within a path. The example prints `true` for a rectangle.
```java
import com.aspose.slides.*;
class GeometryInspector {
boolean isGeometryClosed(IGeometryShape geometryShape) {
boolean hasNonemptyPath = false;
for (IGeometryPath geometryPath : geometryShape.getGeometryPaths()) {
IPathSegment[] segments = geometryPath.getPathData();
if (segments.length == 0) {
continue;
}
hasNonemptyPath = true;
IPathSegment lastSegment = segments[segments.length - 1];
if (lastSegment.getPathCommand() != PathCommandType.Close) {
return false;
}
}
return hasNonemptyPath;
}
}
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 200, 100);
GeometryInspector inspector = new GeometryInspector();
boolean closed = inspector.isGeometryClosed(shape);
System.out.println(closed);
} finally {
presentation.dispose();
}
```
## **Extract and Inspect Shape Elements**
Use [IGeometryShape.createShapeElements](https://reference.aspose.com/slides/java/com.aspose.slides/igeometryshape/#createShapeElements--) to inspect an existing shape as elements containing path points and point types. Cast each returned [IShapeElement](https://reference.aspose.com/slides/java/com.aspose.slides/ishapeelement/) to [ShapeElement](https://reference.aspose.com/slides/java/com.aspose.slides/shapeelement/) to retrieve the point and type arrays through [getPathPoints](https://reference.aspose.com/slides/java/com.aspose.slides/shapeelement/#getPathPoints--) and [getPathTypes](https://reference.aspose.com/slides/java/com.aspose.slides/shapeelement/#getPathTypes--) methods. This representation is useful for contour analysis or passing geometry to custom drawing tools.
The example opens input.pptx, finds the first geometry shape directly on the first slide, and prints its path segments. Use a presentation containing a shape with straight and curved segments to see both kinds of output. It does not search inside groups.
```java
import com.aspose.slides.*;
import java.awt.geom.Point2D;
Presentation presentation = new Presentation("input.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
IGeometryShape shape = null;
for (IShape candidate : slide.getShapes()) {
if (candidate instanceof IGeometryShape) {
shape = (IGeometryShape) candidate;
break;
}
}
if (shape == null) {
System.out.println("No geometry shape found on the first slide.");
} else {
for (IShapeElement element : shape.createShapeElements()) {
ShapeElement shapeElement = (ShapeElement) element;
Point2D.Float[] points = shapeElement.getPathPoints();
byte[] types = shapeElement.getPathTypes();
System.out.println("Shape element:");
for (int i = 0; i < points.length; i++) {
int pointType = types[i] & 0x07; // Keep the segment type, excluding flags.
switch (pointType) {
case 0:
System.out.println("Start figure at " + points[i]);
break;
case 1:
System.out.println("Line to " + points[i]);
break;
case 3:
System.out.println("Cubic Bezier: controls " + points[i] + ", " + points[i + 1] + "; end " + points[i + 2]);
i += 2; // Consume both control points and the endpoint.
break;
}
if ((types[i] & 0x80) != 0) {
System.out.println("Close subpath back to its starting point.");
}
}
}
}
} finally {
presentation.dispose();
}
```
The arrays correspond by index: `points[i]` is a point and `types[i]` describes its role. Type `0` starts a figure, and type `1` draws a line from the previous point to the current point. A cubic Bézier segment starts at the previous endpoint and uses three consecutive type-`3` entries: two control points followed by the new endpoint. The loop consumes these three entries together and checks the endpoint for closure.
Point types also contain flags. Mask with `0x07` to identify the segment type, and test `0x80` separately to detect a closed subpath. For example, `129` (`0x81`) means a line endpoint that closes a subpath, and `131` (`0x83`) means a Bézier endpoint that closes one. Java stores these flags in signed bytes; masking preserves the intended bit values. Comparing the raw value only with `1` or `3` would miss these cases. Other flags, such as dash (`0x10`) and marker (`0x20`), do not change the base segment type.
**Coordinates and transformations.** Points are measured in points (1/72 inch), with X increasing to the right and Y increasing downward. For an ungrouped shape, the extracted coordinates already include the position returned by [getX](https://reference.aspose.com/slides/java/com.aspose.slides/shape/#getX--) and [getY](https://reference.aspose.com/slides/java/com.aspose.slides/shape/#getY--) and reflect its current width and height. For example, an unrotated rectangle at `(100, 200)` with size `120 × 80` has contour bounds `(100, 200)`–`(220, 280)`. Do not add the shape's position again. Subtract its X and Y to obtain coordinates relative to its unrotated frame.
The extracted points do not apply the shape's rotation, returned by [getRotation](https://reference.aspose.com/slides/java/com.aspose.slides/shape/#getRotation--), or horizontal and vertical flips. To reproduce the displayed contour, apply those transformations around the shape's center. For grouped shapes, also account for the group coordinate mapping and transformations; do not assume that the extracted points are the final rendered slide coordinates or apply a translation or scale twice if it is already reflected in the child's frame.
**Inspection versus editing.** Extracted arrays describe the contour; changing them does not update the original shape. Choose this approach when your analysis or drawing code needs point/type arrays. Use [getGeometryPaths](https://reference.aspose.com/slides/java/com.aspose.slides/igeometryshape/#getGeometryPaths--) when you need geometry commands in the shape's local coordinate system or want to edit its geometry. Apply edited paths through [setGeometryPath](https://reference.aspose.com/slides/java/com.aspose.slides/igeometryshape/#setGeometryPath-com.aspose.slides.IGeometryPath-) or [setGeometryPaths](https://reference.aspose.com/slides/java/com.aspose.slides/igeometryshape/#setGeometryPaths-com.aspose.slides.IGeometryPath---).
## **Convert a Java AWT Shape to GeometryPath**
This example combines a rectangular outline with text converted to geometry. The outline's [setFillMode](https://reference.aspose.com/slides/java/com.aspose.slides/igeometrypath/#setFillMode-byte-) method disables its fill. A [GlyphVector](https://docs.oracle.com/javase/8/docs/api/java/awt/font/GlyphVector.html) creates the text outline in a [java.awt.Shape](https://docs.oracle.com/javase/8/docs/api/java/awt/Shape.html). Its [PathIterator](https://docs.oracle.com/javase/8/docs/api/java/awt/geom/PathIterator.html) supplies move, line, quadratic, cubic, and closing segments, which the example replays on a [GeometryPath](https://reference.aspose.com/slides/java/com.aspose.slides/geometrypath/).
The text uses a 40-point Arial font. The outline is offset 20 points horizontally and positioned with its visual top 10 points below the shape's top edge. The text path is filled, while the original rectangle remains an outline. Applying both paths with [IGeometryShape.setGeometryPaths](https://reference.aspose.com/slides/java/com.aspose.slides/igeometryshape/#setGeometryPaths-com.aspose.slides.IGeometryPath---) produces a single shape containing the rectangle and text.
```java
import com.aspose.slides.*;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.font.GlyphVector;
import java.awt.font.FontRenderContext;
import java.awt.geom.Rectangle2D;
import java.awt.geom.PathIterator;
import java.awt.image.BufferedImage;
Presentation presentation = new Presentation();
try {
// Create new shape
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 300, 100);
// Get geometry path of the shape
IGeometryPath originalPath = shape.getGeometryPaths()[0];
originalPath.setFillMode(PathFillModeType.None);
// Create new graphics path with text
Shape graphicsPath;
Font font = new Font("Arial", Font.PLAIN, 40);
String text = "Text in shape";
BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = image.createGraphics();
try
{
FontRenderContext fontContext = graphics.getFontRenderContext();
GlyphVector glyphVector = font.createGlyphVector(fontContext, text);
Rectangle2D textBounds = glyphVector.getVisualBounds();
float baseline = (float) -textBounds.getY() + 10;
graphicsPath = glyphVector.getOutline(20f, baseline);
}
finally {
graphics.dispose();
}
// Convert graphics path to geometry path
IGeometryPath textPath = new GeometryPath();
PathIterator pathIterator = graphicsPath.getPathIterator(null);
float[] points = new float[6];
while (!pathIterator.isDone())
{
int segmentType = pathIterator.currentSegment(points);
switch (segmentType)
{
case PathIterator.SEG_MOVETO:
textPath.moveTo(points[0], points[1]);
break;
case PathIterator.SEG_LINETO:
textPath.lineTo(points[0], points[1]);
break;
case PathIterator.SEG_QUADTO:
textPath.quadraticBezierTo(points[0], points[1], points[2], points[3]);
break;
case PathIterator.SEG_CUBICTO:
textPath.cubicBezierTo(points[0], points[1], points[2], points[3], points[4], points[5]);
break;
case PathIterator.SEG_CLOSE:
textPath.closeFigure();
break;
}
pathIterator.next();
}
textPath.setFillMode(PathFillModeType.Normal);
// Set combination of new geometry path and origin geometry path to the shape
shape.setGeometryPaths(new IGeometryPath[] { originalPath, textPath });
} finally {
presentation.dispose();
}
```

## **FAQ**
**What will happen to the fill and outline after replacing the geometry?**
The style remains with the shape; only the contour changes. The fill and outline are automatically applied to the new geometry.
**How do I correctly rotate a custom shape along with its geometry?**
Use the shape’s [setRotation](https://reference.aspose.com/slides/java/com.aspose.slides/shape/#setRotation-float-) method; the geometry rotates with the shape because it’s bound to the shape’s own coordinate system.
**Can I convert a custom shape to an image to "lock in" the result?**
Yes. Export the required [slide](https://docs.aspose.com/slides/java/convert-powerpoint-to-png/) area or the [shape](https://docs.aspose.com/slides/java/create-shape-thumbnails/) itself to a raster format; this simplifies further work with complex geometries.
# Customize Data Points in Treemap and Sunburst Charts in Java
> Learn how to create hierarchical data and customize levels, labels, and colors in Treemap and Sunburst charts with Aspose.Slides for Java.
Source: https://docs.aspose.com/slides/java/data-points-of-treemap-and-sunburst-chart/
Updated: 2026-08-05
## **Overview**
Treemap and Sunburst charts display the same kind of hierarchical data, but they use different layouts. A Treemap draws the hierarchy as nested rectangles whose areas represent leaf values. A Sunburst draws it as concentric rings: top-level groups are near the center, and leaf categories are on the outer ring.
In Aspose.Slides for Java, each numeric value is an [IChartDataPoint](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapoint/). Its [IChartDataPoint.getDataPointLevels](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapoint/#getDataPointLevels--) method provides access to the leaf and its parent groups. This article explains that mapping and shows how to create and format both chart types from the same sample data.


## **Understand Categories, Data Points, and Levels**
The sample used below has three category levels and one numeric series:
| Branch | Stem | Leaf | Revenue |
| --- | --- | --- | ---: |
| Consumer | Computers | Laptops | 12 |
| Consumer | Computers | Desktops | 8 |
| Consumer | Mobile | Phones | 15 |
| Consumer | Mobile | Tablets | 6 |
| Business | Services | Consulting | 10 |
| Business | Services | Support | 7 |
| Business | Software | Licenses | 11 |
| Business | Software | Subscriptions | 14 |
Each row creates one leaf category and one data point. The category grouping levels describe the path from that leaf to its parents. For the first row, the path is `Consumer > Computers > Laptops`.
The indexes returned by [IChartDataPoint.getDataPointLevels](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapoint/#getDataPointLevels--) run from the leaf upward:
| `getDataPointLevels()` index | Logical level | Treemap representation | Sunburst representation |
| ---: | --- | --- | --- |
| `0` | Leaf | Value rectangle | Outer-ring segment |
| `1` | Stem | Parent rectangle or header | Middle-ring segment |
| `2` | Branch | Top-level rectangle or header | Inner-ring segment |
This order is the same for both chart types even though their visual layouts differ. A parent segment is shared by several leaves. To format it, use the corresponding level of the first data point in that group. For example, the `Consumer` branch starts with the `Laptops` point, while the `Software` stem starts with the `Licenses` point. Keeping references to those points is clearer and safer than using unexplained expressions such as `dataPoints.get_Item(0)` or `dataPoints.get_Item(6)`.
## **Create and Customize Both Chart Types**
The following complete example creates a Treemap on the first slide and a Sunburst on the second slide. It builds the hierarchy, displays the value for `Tablets`, applies fixed colors to selected levels, formats a branch label, and saves the presentation.
```java
Presentation presentation = new Presentation();
try {
final int worksheetIndex = 0;
final int leafLevelIndex = 0;
final int stemLevelIndex = 1;
final int branchLevelIndex = 2;
String[] branchNames = {
"Consumer", "Consumer", "Consumer", "Consumer",
"Business", "Business", "Business", "Business"
};
String[] stemNames = {
"Computers", "Computers", "Mobile", "Mobile",
"Services", "Services", "Software", "Software"
};
String[] leafNames = {
"Laptops", "Desktops", "Phones", "Tablets",
"Consulting", "Support", "Licenses", "Subscriptions"
};
double[] revenues = {12, 8, 15, 6, 10, 7, 11, 14};
int dataPointCount = leafNames.length;
int[] chartTypes = {ChartType.Treemap, ChartType.Sunburst};
int chartCount = chartTypes.length;
ILayoutSlide layoutSlide = presentation.getLayoutSlides().get_Item(0);
for (int chartIndex = 0; chartIndex < chartCount; chartIndex++) {
int chartType = chartTypes[chartIndex];
ISlide slide;
if (chartIndex == 0) {
slide = presentation.getSlides().get_Item(0);
} else {
slide = presentation.getSlides().addEmptySlide(layoutSlide);
}
IChart chart = slide.getShapes().addChart(chartType, 40, 40, 640, 440);
chart.setTitle(false);
chart.setLegend(false);
IChartData chartData = chart.getChartData();
chartData.getCategories().clear();
chartData.getSeries().clear();
IChartDataWorkbook workbook = chartData.getChartDataWorkbook();
workbook.clear(worksheetIndex);
// Add the leaf categories. A grouping item is set only when a new group begins;
// the following categories remain in that group until another item is set.
for (int dataIndex = 0; dataIndex < dataPointCount; dataIndex++) {
int rowIndex = dataIndex + 1;
String leafName = leafNames[dataIndex];
IChartDataCell categoryCell = workbook.getCell(worksheetIndex, rowIndex, 2, leafName);
IChartCategory category = chartData.getCategories().add(categoryCell);
String stemName = stemNames[dataIndex];
boolean startsNewStem = dataIndex == 0;
if (dataIndex > 0) {
String previousStemName = stemNames[dataIndex - 1];
startsNewStem = !stemName.equals(previousStemName);
}
if (startsNewStem) {
category.getGroupingLevels().setGroupingItem(stemLevelIndex, stemName);
}
String branchName = branchNames[dataIndex];
boolean startsNewBranch = dataIndex == 0;
if (dataIndex > 0) {
String previousBranchName = branchNames[dataIndex - 1];
startsNewBranch = !branchName.equals(previousBranchName);
}
if (startsNewBranch) {
category.getGroupingLevels().setGroupingItem(branchLevelIndex, branchName);
}
}
IChartDataCell seriesNameCell = workbook.getCell(worksheetIndex, 0, 3, "Revenue");
IChartSeries series = chartData.getSeries().add(seriesNameCell, chartType);
series.getLabels().getDefaultDataLabelFormat().setShowCategoryName(true);
IChartDataPoint laptopsDataPoint = null;
IChartDataPoint tabletsDataPoint = null;
IChartDataPoint licensesDataPoint = null;
for (int dataIndex = 0; dataIndex < dataPointCount; dataIndex++) {
int rowIndex = dataIndex + 1;
String leafName = leafNames[dataIndex];
double revenue = revenues[dataIndex];
IChartDataCell valueCell = workbook.getCell(worksheetIndex, rowIndex, 3, revenue);
IChartDataPoint dataPoint;
if (chartType == ChartType.Treemap) {
dataPoint = series.getDataPoints().addDataPointForTreemapSeries(valueCell);
} else {
dataPoint = series.getDataPoints().addDataPointForSunburstSeries(valueCell);
}
if ("Laptops".equals(leafName)) {
laptopsDataPoint = dataPoint;
} else if ("Tablets".equals(leafName)) {
tabletsDataPoint = dataPoint;
} else if ("Licenses".equals(leafName)) {
licensesDataPoint = dataPoint;
}
}
// Show the category and value on the Tablets leaf.
IChartDataPointLevel tabletsLeafLevel = tabletsDataPoint.getDataPointLevels().get_Item(leafLevelIndex);
IDataLabelFormat tabletsLabelFormat = tabletsLeafLevel.getLabel().getDataLabelFormat();
tabletsLabelFormat.setShowCategoryName(true);
tabletsLabelFormat.setShowValue(true);
tabletsLabelFormat.setSeparator("\n");
tabletsLabelFormat.setNumberFormat("$0");
// Format the Consumer branch through the first leaf in that branch.
IChartDataPointLevel consumerBranchLevel = laptopsDataPoint.getDataPointLevels().get_Item(branchLevelIndex);
IFillFormat consumerBranchFill = consumerBranchLevel.getFormat().getFill();
Color consumerBranchColor = new Color(31, 78, 121);
consumerBranchFill.setFillType(FillType.Solid);
consumerBranchFill.getSolidFillColor().setColor(consumerBranchColor);
IDataLabelFormat consumerLabelFormat = consumerBranchLevel.getLabel().getDataLabelFormat();
consumerLabelFormat.setShowCategoryName(true);
consumerLabelFormat.setShowSeriesName(false);
IFillFormat consumerLabelTextFill = consumerLabelFormat.getTextFormat().getPortionFormat().getFillFormat();
consumerLabelTextFill.setFillType(FillType.Solid);
consumerLabelTextFill.getSolidFillColor().setColor(Color.WHITE);
// Format the Software stem through the first leaf in that stem.
IChartDataPointLevel softwareStemLevel = licensesDataPoint.getDataPointLevels().get_Item(stemLevelIndex);
IFillFormat softwareStemFill = softwareStemLevel.getFormat().getFill();
Color softwareStemColor = new Color(112, 173, 71);
softwareStemFill.setFillType(FillType.Solid);
softwareStemFill.getSolidFillColor().setColor(softwareStemColor);
// ParentLabelLayout affects Treemap parent labels; Sunburst uses ring segments.
if (chartType == ChartType.Treemap) {
series.setParentLabelLayout(ParentLabelLayoutType.Overlapping);
}
}
presentation.save("hierarchical-charts.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The category cells and value cells use the same worksheet row, so their collection positions remain aligned. When you work with an existing chart rather than creating one, inspect the category rows first and store named references to the data points and levels you intend to format.
## **Behavior and Practical Considerations**
### **Treemap and Sunburst Differences**
- A Treemap uses area to communicate value and nested rectangles to communicate hierarchy. The [IChartSeries.setParentLabelLayout](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#setParentLabelLayout-int-) method controls how parent labels appear in this chart type.
- A Sunburst uses angle to communicate value and ring depth to communicate hierarchy. [IChartSeries.setParentLabelLayout](https://reference.aspose.com/slides/java/com.aspose.slides/ichartseries/#setParentLabelLayout-int-) does not control its ring labels.
- Both chart types use the same category grouping levels and the same leaf-to-parent order returned by [IChartDataPoint.getDataPointLevels](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapoint/#getDataPointLevels--), so the data-building and level-formatting code can be shared.
- Parent values are calculated from their descendant leaves. Do not add separate numeric points for branches or stems.
### **Sorting and Segment Order**
The chart layout engine determines the final placement of rectangles and ring segments. Arrange related category rows together before adding them, but do not rely on a specific rectangle position or start angle. If sequence carries meaning, include it in the labels or use a chart type with an explicit category axis.
### **Theme and Fixed Colors**
Unformatted chart levels inherit colors from the presentation theme. The example uses explicit RGB fills for predictable output. If the chart should follow theme changes, use scheme colors instead of fixed RGB values and avoid overriding every level. Also check label contrast after changing a branch or stem fill.
### **Labels and Available Space**
PowerPoint may hide or truncate labels when a segment is too small. Increasing the chart size, shortening category names, or showing fewer label fields usually produces a clearer result. A label can combine the category name, series name, and value through [IDataLabelFormat](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabelformat/), but enabling every field often makes hierarchical charts difficult to read.
### **Export and Rendering**
Saving to PPTX keeps the chart editable. When Aspose.Slides renders the presentation to PDF or an image, the supported fills and label settings are rendered with the chart. Font substitution and small differences in available layout space can change line wrapping or label visibility, so install the required fonts and verify important export targets.
## **FAQ**
**Why does changing a parent level affect several leaves?**
A branch or stem is a shared visual segment. Its [IChartDataPointLevel](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdatapointlevel/) can be reached through a descendant leaf, but the formatting belongs to the shared parent segment rather than only to that leaf.
**Why is a data label missing?**
First enable the required fields on the label's [IDataLabelFormat](https://reference.aspose.com/slides/java/com.aspose.slides/idatalabelformat/) object. Then check whether the segment has enough space. Treemap parent-label layout, chart dimensions, label length, font size, and the number of enabled fields all affect whether a label can be displayed.
**Can I set the exact order or coordinates of segments?**
You can control the source-row order and keep each group contiguous, but you cannot assign exact Treemap rectangles or Sunburst angles. The chart layout engine calculates them from the hierarchy, values, and available space.
**Why do colors change after the presentation theme changes?**
Theme-based fills are designed to follow the presentation palette. Apply explicit RGB colors to the levels that must remain fixed, or keep scheme colors when adapting to a new theme is preferred.
**Will custom formatting be preserved in PDF and image exports?**
Yes, supported chart fills and label settings are included during rendering. For consistent results across systems, make the required fonts available and test the final export size because label fitting is layout-dependent.
## **See Also**
- [Create Treemap charts](https://docs.aspose.com/slides/java/create-chart/#create-tree-map-charts)
- [Create Sunburst charts](https://docs.aspose.com/slides/java/create-chart/#create-sunburst-charts)
- [Export presentation charts](https://docs.aspose.com/slides/java/export-chart/)
- [Manage presentation themes](https://docs.aspose.com/slides/java/presentation-theme/)
# Security Manager Requirements
> Which Security Manager permissions Aspose.Slides for Java and the code that calls it need on Java 23 and earlier, and why there is nothing to configure on Java 24 and later.
Source: https://docs.aspose.com/slides/java/declaration/
Updated: 2026-09-29
## **Overview**
The Java Security Manager limits what code can do according to a security policy. Java 17 deprecated it for removal ([JEP 411](https://openjdk.org/jeps/411)), and Java 24 disabled it permanently ([JEP 486](https://openjdk.org/jeps/486)). This article explains what Aspose.Slides for Java needs when an application still runs with a Security Manager. If your application does not enable one, which is the default, there is nothing to configure.
## **Java 23 and Earlier**
When a Security Manager is enabled, the security policy must grant these permissions to the Aspose.Slides JAR file and to the application code that calls it:
- `java.util.PropertyPermission "*", "read"`: Aspose.Slides reads system properties.
- `java.io.FilePermission "<>", "read"`: Aspose.Slides reads font files and other files.
- `java.io.FilePermission "<>", "execute"`: Aspose.Slides starts operating-system programs, for example `reg` on Windows and `fc-match` on Linux.
- `java.io.FilePermission` with the `write` action for the folders where your application saves files.
Granting the permissions to the JAR file alone is not enough: the code that calls Aspose.Slides needs them too. Granting `java.security.AllPermission` to both also works.
Without the permission to read system properties or to start programs, Aspose.Slides fails on first use: creating a [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) object throws an `ExceptionInInitializerError`. Without read access to the font files, saving a presentation as PDF fails with the error "Cannot find any fonts installed on the system".
## **Java 24 and Later**
The Security Manager cannot be enabled on Java 24 and later, so there are no permissions to grant. Aspose.Slides runs with the permissions of the account that runs your application. To restrict what an application can access, the OpenJDK project recommends technologies outside the JDK, such as containers, hypervisors, and operating-system sandboxing features. See [JEP 486](https://openjdk.org/jeps/486).
## **FAQ**
**Can I use Aspose.Slides in an environment that runs applications under a restrictive Security Manager policy?**
Only if the policy grants the permissions listed above both to Aspose.Slides and to the code that calls it. They include reading all files and starting any program.
# Specify Default Presentation Fonts in Java
> Set default fonts in Aspose.Slides for Java to ensure proper PowerPoint (PPT, PPTX) and OpenDocument (ODP) conversion to PDF, XPS and images.
Source: https://docs.aspose.com/slides/java/default-font/
Updated: 2026-08-05
## **Overview**
Aspose.Slides allows you to specify default fonts that are used when a presentation is rendered. This is useful when generating slide thumbnails or exporting a presentation to formats such as PDF and XPS. Default fonts are configured through `LoadOptions` before the presentation is loaded.
The `setDefaultRegularFont` method defines the default font for regular text, while `setDefaultAsianFont` defines the default font for Asian text. After these options are set, the presentation can be loaded and rendered using the specified fonts.
## **Use Default Fonts for Rendering a Presentation**
Aspose.Slides lets you set the default font fore rendering the presentation to PDF, XPS or thumbnails. This article shows how to define DefaultRegular
Font and DefaultAsian Font for use as default fonts. Please follow the steps below to loading fonts from external directories by using Aspose.Slides for Java API:
1. Create an instance of [LoadOptions](https://reference.aspose.com/slides/java/com.aspose.slides/LoadOptions).
1. [Set the DefaultRegularFont](https://reference.aspose.com/slides/java/com.aspose.slides/LoadOptions#setDefaultRegularFont-java.lang.String-) to your desired font. In the following example, I have used Wingdings.
1. [Set the DefaultAsianFont](https://reference.aspose.com/slides/java/com.aspose.slides/LoadOptions#setDefaultAsianFont-java.lang.String-) to your desired font. I have used Wingdings in following sample.
1. Load the presentation using Presentation and setting the load options.
1. Now, generate the slide thumbnail, PDF and XPS to verify the results.
The implementation of the above is given below.
```java
import com.aspose.slides.*;
// Use load options to define the default regualr and asian fonts
LoadOptions loadOptions = new LoadOptions(LoadFormat.Auto);
loadOptions.setDefaultRegularFont("Wingdings");
loadOptions.setDefaultAsianFont("Wingdings");
// Load the presentation
Presentation pres = new Presentation("DefaultFonts.pptx", loadOptions);
try {
// Generate slide thumbnail
IImage slideImage = pres.getSlides().get_Item(0).getImage(1, 1);
try {
// save the image on the disk.
slideImage.save("output.png", ImageFormat.Png);
} finally {
if (slideImage != null) slideImage.dispose();
}
// Generate PDF
pres.save("output_out.pdf", SaveFormat.Pdf);
// Generate XPS
pres.save("output_out.xps", SaveFormat.Xps);
} finally {
if (pres != null) pres.dispose();
}
```
## **FAQ**
### What exactly do DefaultRegularFont and DefaultAsianFont affect—only export, or also thumbnails, PDF, XPS, HTML, and SVG?
They participate in the rendering pipeline for all supported outputs. This includes slide thumbnails, [PDF](https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf/), [XPS](https://docs.aspose.com/slides/java/convert-powerpoint-to-xps/), [raster images](https://docs.aspose.com/slides/java/convert-powerpoint-to-png/), [HTML](https://docs.aspose.com/slides/java/convert-powerpoint-to-html/), and [SVG](https://docs.aspose.com/slides/java/render-a-slide-as-an-svg-image/), because Aspose.Slides uses the same layout and glyph resolution logic across these targets.
### Are default fonts applied when simply reading and saving a PPTX without any rendering?
No. Default fonts matter when text must be measured and drawn. A straight open–save of a presentation does not change stored font runs or the file’s structure. Default fonts come into play during operations that render or reflow text.
### If I add my own font folders or supply fonts from memory, will they be considered when choosing default fonts?
Yes. [Custom font sources](https://docs.aspose.com/slides/java/custom-font/) expand the catalog of available families and glyphs that the engine can use. Default fonts and any [fallback rules](https://docs.aspose.com/slides/java/fallback-font/) will resolve against those sources first, yielding more reliable coverage on servers and in containers.
### Will default fonts affect text metrics (kerning, advances) and therefore line breaks and wrapping?
Yes. Changing the font changes glyph metrics and can alter line breaks, wrapping, and pagination during rendering. For layout stability, [embed the original fonts](https://docs.aspose.com/slides/java/embedded-font/) or select metrically compatible default and fallback families.
### Is there any point in setting default fonts if all fonts used in the presentation are embedded?
Often it’s not necessary, because [embedded fonts](https://docs.aspose.com/slides/java/embedded-font/) already ensure consistent appearance. Default fonts still help as a safety net for characters not covered by the embedded subset or when a file mixes embedded and non-embedded text.
# Deploy Fonts for Aspose.Slides for Java on Linux and in Docker
> Deploy fonts for Aspose.Slides for Java on Linux servers and in Docker containers: check which fonts are substituted, install font packages on Debian, Ubuntu, and Alpine, add your own font files, and set a default font.
Source: https://docs.aspose.com/slides/java/deploy-fonts/
Updated: 2026-09-29
## **Overview**
Aspose.Slides draws text with the fonts that are available to it when it renders a presentation, for example when it converts slides to PDF or to images. A Windows desktop usually has the fonts that presentations use. Linux servers and containers usually have few fonts, so Aspose.Slides draws the text with a substitute font. A substitute has different letter shapes and widths, so lines can wrap differently and text can overflow its shape, and characters that the substitute lacks are not drawn correctly. If no font is installed at all, Java's font support cannot start, and Aspose.Slides stops with an error.
This article shows how to check which fonts Aspose.Slides substitutes, how to install fonts on Debian, Ubuntu, and Alpine Linux, how to add your own font files, and how to set the font that is used when a font is missing. The examples run in Docker on the official Eclipse Temurin images, as in [Run Aspose.Slides for Java in Docker](https://docs.aspose.com/slides/java/how-to-run-aspose-slides-in-docker/). The package commands are Dockerfile instructions; on a Linux server, run the same commands as root.
For the font API itself, such as embedding fonts in a presentation and fallback and replacement rules, see [PowerPoint Fonts](https://docs.aspose.com/slides/java/powerpoint-fonts/).
## **Check Which Fonts Are Substituted**
The following Maven project reports the fonts that Aspose.Slides substitutes in the current environment. Create a folder named *font-check* and add the files below to it.
*pom.xml* is the one from [Run Aspose.Slides for Java in Docker](https://docs.aspose.com/slides/java/how-to-run-aspose-slides-in-docker/#create-the-project), with the artifact ID and the JAR file name changed to *font-check*:
```xml
4.0.0com.examplefont-check1.011UTF-8AsposeJavaAPIAspose Java APIhttps://releases.aspose.com/java/repo/com.asposeaspose-slides26.9jdk16font-checkorg.apache.maven.pluginsmaven-compiler-plugin3.15.0org.apache.maven.pluginsmaven-dependency-plugin3.11.0packagecopy-dependencies${project.build.directory}/lib
```
*src/main/java/FontCheck.java* adds one text box per font name to a slide and assigns the font with the [setLatinFont](https://reference.aspose.com/slides/java/com.aspose.slides/baseportionformat/#setLatinFont-com.aspose.slides.IFontData-) method. The font names come from the command line; without arguments, the program checks Calibri, Arial, and Times New Roman. It prints the folders in which Aspose.Slides looks for fonts ([FontsLoader.getFontFolders](https://reference.aspose.com/slides/java/com.aspose.slides/fontsloader/#getFontFolders--)), renders the slide to *output/fonts.pdf*, and prints the substitutions reported by [IFontsManager.getSubstitutions](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsmanager/#getSubstitutions--). The two optional steps at the start, loading a *fonts* folder and reading a `DEFAULT_FONT` variable, are explained later in this article.
```java
import com.aspose.slides.*;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
public class FontCheck {
public static void main(String[] args) {
// The fonts to check: the command-line arguments, or three common Office fonts.
String[] fontNames = args.length > 0 ? args : new String[] { "Calibri", "Arial", "Times New Roman" };
// Load the font files from the fonts folder in the working directory, if there is one.
File appFontFolder = new File("fonts");
if (appFontFolder.isDirectory()) {
FontsLoader.loadExternalFonts(new String[] { appFontFolder.getAbsolutePath() });
}
// Use the font named in the DEFAULT_FONT environment variable, if it is set, for text whose font is missing.
LoadOptions loadOptions = new LoadOptions();
String defaultFont = System.getenv("DEFAULT_FONT");
if (defaultFont != null && !defaultFont.isEmpty()) {
loadOptions.setDefaultRegularFont(defaultFont);
}
Set fontFolders = new LinkedHashSet<>(Arrays.asList(FontsLoader.getFontFolders()));
System.out.println("Font folders: " + String.join(", ", fontFolders));
Presentation presentation = new Presentation(loadOptions);
try {
ISlide slide = presentation.getSlides().get_Item(0);
for (int i = 0; i < fontNames.length; i++) {
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 50, 50 + i * 80, 600, 60);
shape.getTextFrame().setText("This text is set in " + fontNames[i] + ".");
shape.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().setLatinFont(new FontData(fontNames[i]));
}
File outputFolder = new File("output");
outputFolder.mkdirs();
presentation.save(new File(outputFolder, "fonts.pdf").getPath(), SaveFormat.Pdf);
List substitutions = new ArrayList<>();
for (FontSubstitutionInfo substitution : presentation.getFontsManager().getSubstitutions()) {
substitutions.add(substitution);
}
if (substitutions.isEmpty()) {
System.out.println("No font substitutions.");
} else {
System.out.println("Font substitutions:");
for (FontSubstitutionInfo substitution : substitutions) {
System.out.println(" " + substitution.getOriginalFontName() + " -> " + substitution.getSubstitutedFontName());
}
}
} finally {
presentation.dispose();
}
}
}
```
`getFontFolders` can return a folder more than once, so the program collects the folders in a set before it prints them.
*.dockerignore* keeps local build results out of the build context:
```text
target/
output/
```
*Dockerfile* builds the program with the Maven image and runs it on the Eclipse Temurin Java runtime image, which already contains fontconfig and the DejaVu fonts. [Run Aspose.Slides for Java in Docker](https://docs.aspose.com/slides/java/how-to-run-aspose-slides-in-docker/) explains each instruction.
```dockerfile
FROM maven:3.9-eclipse-temurin-21 AS build
WORKDIR /src
COPY pom.xml .
RUN mvn -B dependency:go-offline
COPY src ./src
RUN mvn -B package
FROM eclipse-temurin:21-jre
WORKDIR /app
COPY --from=build /src/target/font-check.jar .
COPY --from=build /src/target/lib ./lib
RUN mkdir output && chown ubuntu output
USER ubuntu
ENTRYPOINT ["java", "-cp", "font-check.jar:lib/*", "FontCheck"]
```
Build the image and run the check:
```bash
docker build -t font-check .
docker run --rm font-check
```
The image has only the DejaVu fonts, so all three fonts are replaced with DejaVu Sans:
```text
Font folders: /usr/share/fonts, /usr/local/share/fonts, /home/ubuntu/.local/share/fonts, /home/ubuntu/.fonts
Font substitutions:
Calibri -> DejaVu Sans
Arial -> DejaVu Sans
Times New Roman -> DejaVu Sans
```
To check the fonts of your own presentations, pass their names as arguments, for example `docker run --rm font-check "Segoe UI" Consolas`. To copy *output/fonts.pdf* out of the container, use the commands in [Copy the Output to Your Machine](https://docs.aspose.com/slides/java/how-to-run-aspose-slides-in-docker/#copy-the-output-to-your-machine).
## **Install Fonts on Debian and Ubuntu**
### **Microsoft Core Fonts**
The `ttf-mscorefonts-installer` package downloads and installs Microsoft's core fonts for the web, among them Arial, Times New Roman, Courier New, Verdana, Georgia, and Trebuchet MS. The fonts are licensed under Microsoft's end-user license agreement (EULA), and the package installs them only after the EULA is accepted. A Docker build cannot answer the prompt, so the installer declines the EULA and installs no fonts, while `apt-get install` still reports success. Accept the EULA with `debconf-set-selections` **before** the package is installed. Accepting it in a later instruction does not help: the package is then already installed, and apt does not run its installer again.
Add this instruction to the runtime stage of the *Dockerfile*, directly after its `FROM` line, so that it runs as root, before the `USER` instruction:
```dockerfile
RUN echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections \
&& apt-get update \
&& apt-get install -y --no-install-recommends ttf-mscorefonts-installer \
&& rm -rf /var/lib/apt/lists/*
```
Build the image and run the check again with the same two commands. Arial and Times New Roman are now installed:
```text
Font folders: /usr/share/fonts, /usr/local/share/fonts, /home/ubuntu/.local/share/fonts, /home/ubuntu/.fonts
Font substitutions:
Calibri -> Arial
```
Calibri, the default font of a presentation that Aspose.Slides creates, is not one of the core fonts, so it is still replaced. See [Set a Default Font for Missing Fonts](https://docs.aspose.com/slides/java/deploy-fonts/#set-a-default-font-for-missing-fonts).
The Ubuntu-based Eclipse Temurin images enable `multiverse`, the Ubuntu component that contains the package. On Debian, the package is in the `contrib` component, which the Debian images do not enable. In a Debian-based runtime stage, such as the one in [Use Another Base Image](https://docs.aspose.com/slides/java/how-to-run-aspose-slides-in-docker/#use-another-base-image), enable `contrib` in the same instruction:
```dockerfile
RUN sed -i 's/^Components: main$/Components: main contrib/' /etc/apt/sources.list.d/debian.sources \
&& echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections \
&& apt-get update \
&& apt-get install -y --no-install-recommends ttf-mscorefonts-installer \
&& rm -rf /var/lib/apt/lists/*
```
### **Other Font Packages**
Debian and Ubuntu also package freely licensed fonts, for example:
| Package | Fonts |
|---|---|
| `fonts-dejavu-core` | DejaVu Sans, DejaVu Serif, DejaVu Sans Mono |
| `fonts-liberation` | Liberation Sans, Serif, and Mono, with the same metrics as Arial, Times New Roman, and Courier New |
| `fonts-crosextra-carlito` | Carlito, with the same metrics as Calibri |
| `fonts-crosextra-caladea` | Caladea, with the same metrics as Cambria |
Install them with `apt-get install` in a `RUN` instruction of the runtime stage, the same way as the Microsoft core fonts. Aspose.Slides for Java does not apply the font aliases of the Linux font configuration: with `fonts-liberation` installed, text in Arial is still drawn with the general substitute font, not with Liberation Sans. To use a metric-compatible font in place of a missing one, set it as the [default font](https://docs.aspose.com/slides/java/deploy-fonts/#set-a-default-font-for-missing-fonts) or add a [font substitution rule](https://docs.aspose.com/slides/java/font-substitution/).
## **Add Your Own Font Files**
Fonts that the distributions do not package, such as your organization's fonts or other fonts that you are licensed to use on the server, can be added as font files. Put the font files, for example *.ttf* files, in a folder named *fonts* inside the *font-check* folder. The examples below use the files of Carlito, a font with the same metrics as Calibri, which you can download from [Google Fonts](https://fonts.google.com/specimen/Carlito).
### **Install the Fonts in a System Font Folder**
Aspose.Slides reads the fonts in the folders printed on the `Font folders` line. To install your fonts for every application in the image, copy them into */usr/local/share/fonts*, the folder for locally installed fonts. Add this instruction to the runtime stage of the *Dockerfile*, after the `RUN` instruction that installs the Microsoft core fonts:
```dockerfile
COPY fonts/ /usr/local/share/fonts/
```
Rebuild the image, then check Calibri and Carlito:
```bash
docker build -t font-check .
docker run --rm font-check Calibri Carlito
```
Carlito is no longer substituted:
```text
Font folders: /usr/share/fonts, /usr/local/share/fonts, /home/ubuntu/.local/share/fonts, /home/ubuntu/.fonts
Font substitutions:
Calibri -> Arial
```
### **Load Fonts from the Application Folder**
Instead of installing the fonts in a system folder, you can ship them with the application and load them with [FontsLoader.loadExternalFonts](https://reference.aspose.com/slides/java/com.aspose.slides/fontsloader/#loadExternalFonts-java.lang.String---). The fonts are then available to Aspose.Slides only, and they are deployed together with the application. *FontCheck* does this: when its working directory, */app* in the container, contains a *fonts* folder, the program passes that folder to `loadExternalFonts` before it creates the presentation. [Custom Font](https://docs.aspose.com/slides/java/custom-font/) describes the other ways to supply fonts, such as loading them from memory.
In the *Dockerfile*, remove the `COPY fonts/ /usr/local/share/fonts/` instruction and add this one after the instruction that copies the *lib* folder:
```dockerfile
COPY fonts/ ./fonts/
```
Rebuild the image and run the check with the same two commands. The application folder now appears among the font folders, and Carlito is still not substituted:
```text
Font folders: /app/fonts, /usr/share/fonts, /usr/local/share/fonts, /home/ubuntu/.local/share/fonts, /home/ubuntu/.fonts
Font substitutions:
Calibri -> Arial
```
`loadExternalFonts` adds fonts to the installed ones, but Java's font support still needs at least one installed font. In an image without any, `loadExternalFonts` stops with the error "Fontconfig head is null, check your fonts or fonts configuration".
## **Set a Default Font for Missing Fonts**
When a font is missing, Aspose.Slides uses a substitute that it chooses itself. To choose it yourself, pass the font name to the [setDefaultRegularFont](https://reference.aspose.com/slides/java/com.aspose.slides/loadoptions/#setDefaultRegularFont-java.lang.String-) method of [LoadOptions](https://reference.aspose.com/slides/java/com.aspose.slides/loadoptions/) and pass the options to the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) constructor. *FontCheck* reads the font name from the `DEFAULT_FONT` environment variable. With Carlito loaded, use it for missing fonts:
```bash
docker run --rm -e DEFAULT_FONT=Carlito font-check
```
Calibri is now drawn with Carlito, whose characters have the same widths as those of Calibri, so the text keeps its line breaks:
```text
Font folders: /app/fonts, /usr/share/fonts, /usr/local/share/fonts, /home/ubuntu/.local/share/fonts, /home/ubuntu/.fonts
Font substitutions:
Calibri -> Carlito
```
The default font replaces every missing font. To map individual fonts, for example Arial to Liberation Sans and Calibri to Carlito, use [font substitution rules](https://docs.aspose.com/slides/java/font-substitution/). Rules change the rendered output, but `getSubstitutions` does not reflect them, so check the fonts in the output file instead. For Asian text, also call [setDefaultAsianFont](https://reference.aspose.com/slides/java/com.aspose.slides/loadoptions/#setDefaultAsianFont-java.lang.String-); see [Default Font](https://docs.aspose.com/slides/java/default-font/).
## **Install Fonts on Alpine Linux**
The Alpine-based Eclipse Temurin image also contains the DejaVu fonts; [Run on Alpine Linux](https://docs.aspose.com/slides/java/how-to-run-aspose-slides-in-docker/#run-on-alpine-linux) describes its runtime stage. To install the Microsoft core fonts on it as well, replace the runtime stage of the *font-check* Dockerfile with this one:
```dockerfile
FROM eclipse-temurin:21-jre-alpine
RUN apk add --no-cache msttcorefonts-installer \
&& update-ms-fonts \
&& fc-cache -f
WORKDIR /app
COPY --from=build /src/target/font-check.jar .
COPY --from=build /src/target/lib ./lib
RUN adduser -D app && mkdir output && chown app output
USER app
ENTRYPOINT ["java", "-cp", "font-check.jar:lib/*", "FontCheck"]
```
`update-ms-fonts` downloads and installs the same Microsoft core fonts as the Debian and Ubuntu package, and their EULA applies in the same way. `fc-cache` updates the font cache of fontconfig. Build the image and run the check with the two commands from [Check Which Fonts Are Substituted](https://docs.aspose.com/slides/java/deploy-fonts/#check-which-fonts-are-substituted). It prints:
```text
Font folders: /usr/share/fonts, /home/app/.local/share/fonts, /home/app/.fonts
Font substitutions:
Calibri -> Arial
```
The other steps on this page work the same way on Alpine: copy the *fonts* folder to */usr/local/share/fonts* or to the application folder, and set `DEFAULT_FONT` to choose the default font. The Alpine image has no */usr/local/share/fonts* folder, so that folder appears on the `Font folders` line only after a `COPY` instruction creates it.
## **FAQ**
**Why does a presentation look different when it is converted on a server?**
The server does not have the fonts that the presentation uses, so Aspose.Slides draws the text with a substitute font whose letters have other widths. Run *FontCheck* with the presentation's font names to see which fonts are substituted, then install those fonts or load them from the application folder.
**The build installed ttf-mscorefonts-installer, but Arial is still substituted. Why?**
The EULA was not accepted before the package was installed, so the installer skipped the fonts. Put the `debconf-set-selections` command before `apt-get install` in the instruction that installs the package, as shown in [Microsoft Core Fonts](https://docs.aspose.com/slides/java/deploy-fonts/#microsoft-core-fonts), and rebuild the image.
**Does the computer that opens the PDF need the fonts?**
No. In these examples, the PDF contains the fonts that were used to draw the text, so it looks the same on any computer. The fonts are needed only where Aspose.Slides renders the presentation.
# Determine the Original Presentation Format in Java
> Read the original format of a loaded presentation in Java with Aspose.Slides for Java, compare detection APIs, and handle files, streams, and legacy formats.
Source: https://docs.aspose.com/slides/java/detect-presentation-source-format/
Updated: 2026-09-22
## **Overview**
After loading a presentation, call the [Presentation.getSourceFormat](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#getSourceFormat--) method to determine its original format. The method is also available through [IPresentation.getSourceFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentation/#getSourceFormat--). Use it when subsequent processing depends on the format from which the current instance was loaded.
The source format is distinct from the [SaveFormat](https://reference.aspose.com/slides/java/com.aspose.slides/saveformat/) selected for an output file. Saving to another format does not change the source format of the existing instance.
## **Read the Source Format of a File**
This example requires an existing `sample.pptx` file. It loads the file and selects an application processing policy using [Presentation.getSourceFormat](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#getSourceFormat--), rather than the filename. Change the input path to try other formats. The example prints the selected policy; replace the messages with your application logic.
```java
import com.aspose.slides.Presentation;
import com.aspose.slides.SourceFormat;
Presentation presentation = new Presentation("sample.pptx");
try {
switch (presentation.getSourceFormat()) {
case SourceFormat.Ppt:
case SourceFormat.Pps:
case SourceFormat.Pot:
System.out.println("Use the legacy PowerPoint processing policy.");
break;
case SourceFormat.Pptx:
System.out.println("Use the standard PPTX processing policy.");
break;
default:
System.out.println("Use the general policy for source format " + presentation.getSourceFormat() + ".");
break;
}
} finally {
presentation.dispose();
}
```
## **Recognize the Supported Values**
The [SourceFormat](https://reference.aspose.com/slides/java/com.aspose.slides/sourceformat/) class defines integer constants that distinguish the following presentation formats. The extensions below are conventional extensions, not a reconstruction of the original filename.
| SourceFormat value | Extension | Format |
| --- | --- | --- |
| `Ppt` | `.ppt` | PowerPoint 97–2003 presentation |
| `Pptx` | `.pptx` | Office Open XML presentation |
| `Pptm` | `.pptm` | Macro-enabled Office Open XML presentation |
| `Pps` | `.pps` | PowerPoint 97–2003 slide show |
| `Ppsx` | `.ppsx` | Office Open XML slide show |
| `Ppsm` | `.ppsm` | Macro-enabled Office Open XML slide show |
| `Pot` | `.pot` | PowerPoint 97–2003 template |
| `Potx` | `.potx` | Office Open XML template |
| `Potm` | `.potm` | Macro-enabled Office Open XML template |
| `Odp` | `.odp` | OpenDocument presentation |
| `Otp` | `.otp` | OpenDocument presentation template |
| `Fodp` | `.fodp` | Flat XML ODF presentation |
| `Xml` | `.xml` | PowerPoint XML presentation |
## **Read the Source Format of a Stream**
This example requires an existing `sample.pps` file. Reading its bytes into a memory stream models input received without a filename, such as a database value or an uploaded byte array. The [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) constructor receives only the stream.
```java
import com.aspose.slides.Presentation;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
try {
byte[] bytes = Files.readAllBytes(Paths.get("sample.pps"));
try (ByteArrayInputStream stream = new ByteArrayInputStream(bytes)) {
Presentation presentation = new Presentation(stream);
try {
System.out.println("Source format: " + presentation.getSourceFormat());
} finally {
presentation.dispose();
}
}
} catch (IOException exception) {
System.err.println("Cannot read the presentation: " + exception.getMessage());
}
```
PPT, PPS, and POT use the same underlying binary format. When loading by file path, the extension can help distinguish a slide show or template. Without a filename, legacy PPS and POT content may be reported as `SourceFormat.Ppt`; the PPS example above prints the integer value of `SourceFormat.Ppt`.
If your application must preserve the distinction, keep the original filename or subtype metadata separately. An extension is a useful hint for these legacy subtypes, but should not be the only basis for identifying arbitrary presentation content.
## **Compare Detection Before and After Loading**
Use [PresentationFactory.getPresentationInfo](https://reference.aspose.com/slides/java/com.aspose.slides/presentationfactory/#getPresentationInfo-java.lang.String-) and [IPresentationInfo.getLoadFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentationinfo/#getLoadFormat--) when you need to inspect a file before loading its complete presentation object model. Use [Presentation.getSourceFormat](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#getSourceFormat--) when the instance already exists.
This example requires `sample.pptx` and prints the integer values of `LoadFormat.Pptx` and `SourceFormat.Pptx`, respectively. In production, choose the API appropriate to your processing stage; an already loaded presentation does not need a second inspection solely to obtain its source format.
```java
import com.aspose.slides.Presentation;
import com.aspose.slides.IPresentationInfo;
import com.aspose.slides.PresentationFactory;
String path = "sample.pptx";
IPresentationInfo information = PresentationFactory.getInstance().getPresentationInfo(path);
System.out.println("Before loading: " + information.getLoadFormat());
Presentation presentation = new Presentation(path);
try {
System.out.println("After loading: " + presentation.getSourceFormat());
} finally {
presentation.dispose();
}
```
The results use constants from different classes: [LoadFormat](https://reference.aspose.com/slides/java/com.aspose.slides/loadformat/) and [SourceFormat](https://reference.aspose.com/slides/java/com.aspose.slides/sourceformat/). Do not compare their numeric values or assume that every format has identical detection results. PowerPoint XML can be reported as `LoadFormat.Unknown` before loading and `SourceFormat.Xml` after loading.
## **Keep Source and Output Formats Separate**
This example requires `sample.pptx` and writes `converted.odp`. It prints the integer value of `SourceFormat.Pptx` both before and after saving the original instance. Only the new instance loaded from the ODP output reports `Odp`.
```java
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
Presentation presentation = new Presentation("sample.pptx");
try {
System.out.println("Before saving: " + presentation.getSourceFormat());
presentation.save("converted.odp", SaveFormat.Odp);
System.out.println("After saving: " + presentation.getSourceFormat());
Presentation reopened = new Presentation("converted.odp");
try {
System.out.println("Reopened output: " + reopened.getSourceFormat());
} finally {
reopened.dispose();
}
} finally {
presentation.dispose();
}
```
A presentation created from scratch with `new Presentation()` reports `SourceFormat.Pptx`. It has no input file: this is the default value for a newly created instance, not evidence that a PPTX file was loaded. Track whether your application created or loaded the instance separately if that distinction matters.
## **Map a Source Format to an Extension**
The following example requires `sample.pptx`. It maps every currently supported [SourceFormat](https://reference.aspose.com/slides/java/com.aspose.slides/sourceformat/) value to a conventional extension, without parsing the input filename. The fallback avoids silently assigning an extension to an unrecognized value.
```java
import com.aspose.slides.Presentation;
import com.aspose.slides.SourceFormat;
Presentation presentation = new Presentation("sample.pptx");
try {
String extension;
switch (presentation.getSourceFormat()) {
case SourceFormat.Ppt:
extension = ".ppt";
break;
case SourceFormat.Pptx:
extension = ".pptx";
break;
case SourceFormat.Pptm:
extension = ".pptm";
break;
case SourceFormat.Pps:
extension = ".pps";
break;
case SourceFormat.Ppsx:
extension = ".ppsx";
break;
case SourceFormat.Ppsm:
extension = ".ppsm";
break;
case SourceFormat.Pot:
extension = ".pot";
break;
case SourceFormat.Potx:
extension = ".potx";
break;
case SourceFormat.Potm:
extension = ".potm";
break;
case SourceFormat.Odp:
extension = ".odp";
break;
case SourceFormat.Otp:
extension = ".otp";
break;
case SourceFormat.Fodp:
extension = ".fodp";
break;
case SourceFormat.Xml:
extension = ".xml";
break;
default:
extension = null;
break;
}
System.out.println(extension != null ? extension : "No extension mapping is available.");
} finally {
presentation.dispose();
}
```
This mapping does not convert a file or recover a legacy PPS/POT subtype lost during stream loading. For actual saving, select a [SaveFormat](https://reference.aspose.com/slides/java/com.aspose.slides/saveformat/) explicitly, or use the conversion shown in [Save Presentations in Their Original Format](https://docs.aspose.com/slides/java/save-presentation/#save-presentations-in-their-original-format).
## **Verify Formats by Saving and Reopening**
This self-contained example creates a presentation and writes three files in the working directory, overwriting files with the same names. It reopens each output both by path and through a memory stream. For PPTX and ODP, both routes report the saved format. For PPS, loading by path reports `Pps`, while loading the same bytes without a filename reports `Ppt`.
```java
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
Presentation presentation = new Presentation();
try {
int[] formats = { SaveFormat.Pptx, SaveFormat.Odp, SaveFormat.Pps };
String[] extensions = { "pptx", "odp", "pps" };
for (int i = 0; i < formats.length; i++) {
String path = "roundtrip." + extensions[i];
presentation.save(path, formats[i]);
Presentation fromFile = new Presentation(path);
try {
byte[] bytes = Files.readAllBytes(Paths.get(path));
try (ByteArrayInputStream stream = new ByteArrayInputStream(bytes)) {
Presentation fromStream = new Presentation(stream);
try {
System.out.println(extensions[i] + ": file=" + fromFile.getSourceFormat() + ", stream=" + fromStream.getSourceFormat());
} finally {
fromStream.dispose();
}
}
} finally {
fromFile.dispose();
}
}
} catch (IOException exception) {
System.err.println("Cannot read a saved presentation: " + exception.getMessage());
} finally {
presentation.dispose();
}
```
The following table summarizes source-format identification for presentations with matching extensions. Names denote constants; the Java examples print their integer values:
| Saved format | SourceFormat from a file path | SourceFormat from a nameless stream |
| --- | --- | --- |
| PPT | `Ppt` | `Ppt` |
| PPTX, PPTM | `Pptx`, `Pptm` respectively | Same as file path |
| PPS | `Pps` | `Ppt` |
| PPSX, PPSM | `Ppsx`, `Ppsm` respectively | Same as file path |
| POT | `Pot` | `Ppt` |
| POTX, POTM | `Potx`, `Potm` respectively | Same as file path |
| ODP, OTP | `Odp`, `Otp` respectively | Same as file path |
| FODP | `Fodp` | `Fodp` |
| PowerPoint XML | `Xml` | `Xml` |
PPS/POT content is identified as `Ppt` for nameless streams. The table describes format identification, not preservation of every presentation feature during conversion.
## **FAQ**
**Does saving to ODP change the source format of a presentation loaded from PPTX?**
No. The existing instance still reports `Pptx`. An instance loaded from the saved ODP file reports `Odp`.
**Can a stream always distinguish a legacy presentation, slide show, and template?**
No. PPT, PPS, and POT share the binary format. Keep filename or subtype metadata separately when that distinction is required.
**Which API should I use if the presentation is already loaded?**
Read [Presentation.getSourceFormat](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#getSourceFormat--). Use [PresentationFactory.getPresentationInfo](https://reference.aspose.com/slides/java/com.aspose.slides/presentationfactory/#getPresentationInfo-java.lang.String-) for inspection before loading.
# Developer Guide
> Discover the Aspose.Slides for Java Developer Guide for step-by-step APIs to build, edit, and convert PPT, PPTX and ODP presentations with ease.
Source: https://docs.aspose.com/slides/java/developer-guide/
Updated: 2025-11-18
---
lastmod: 2025-11-18T18:55:58+04:00
title: Developer Guide
type: docs
weight: 20
url: /java/developer-guide/
keywords:
- developer guide
- manage presentation
- presentation design
- professional presentation
- create presentation
- presentation viewer
- presentation security
- presentation properties
- view properties
- presentation comments
- presentation notes
- animation
- 3D presentation
- VBA project
- image processing
- PowerPoint
- OpenDocument
- presentation
- Java
- Aspose.Slides
description: "Discover the Aspose.Slides for Java Developer Guide for step-by-step APIs to build, edit, and convert PPT, PPTX and ODP presentations with ease."
---
# Add Digital Signatures to Presentations in Java
> Learn how to sign existing PPTX presentations with PFX certificates and use Aspose.Slides for Java to validate or remove digital signatures.
Source: https://docs.aspose.com/slides/java/digital-signature-in-powerpoint/
Updated: 2026-08-25
## **Overview**
A digital signature helps a recipient determine who signed a presentation and whether the signed content has changed. Three related security concepts are important here:
- A **digital certificate** is an electronic credential that associates an identity with a public key. A trusted certificate authority (CA) can issue a certificate, or an organization can use a self-signed certificate for internal workflows.
- A **digital signature** is created from the presentation content and the certificate holder's private key. The certificate's public key can then be used to verify the signature. A signature provides evidence of origin and integrity; it does not encrypt the presentation.
- **Password protection** controls whether a user can open or modify a presentation. It is separate from digital signing and is described in [Password-Protected Presentations](https://docs.aspose.com/slides/java/password-protected-presentation/).
PowerPoint provides the **Add a Digital Signature** command under **File > Info > Protect Presentation**.

After a signed presentation is opened, PowerPoint can display a signature-status notification.

Aspose.Slides exposes signatures through [IPresentation.getDigitalSignatures](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentation/#getDigitalSignatures--), which returns an [IDigitalSignatureCollection](https://reference.aspose.com/slides/java/com.aspose.slides/idigitalsignaturecollection/) whose items implement [IDigitalSignature](https://reference.aspose.com/slides/java/com.aspose.slides/idigitalsignature/). A presentation can contain multiple signatures.
## **Understand PFX Certificates and Passwords**
A PFX file, also known as a PKCS#12 file and commonly given a `.pfx` or `.p12` extension, can contain an X.509 certificate, its private key, and the certificate chain. The private key is what allows the holder to create a signature. A certificate without an accessible private key cannot be used to sign a presentation.
The PFX password protects the certificate package and private key. It is **not** a password for opening or editing the presentation. Do not commit PFX files or their passwords to source control. In production, limit access to the certificate file and obtain its password from a secret store or another protected configuration source. The examples below use an environment variable only to avoid embedding the password in code.
## **Add a Digital Signature to a Presentation**
To sign a real presentation workflow, load an existing PPTX file, create a [DigitalSignature](https://reference.aspose.com/slides/java/com.aspose.slides/digitalsignature/) from a PFX certificate and its password, add the signature to the presentation's collection, and save to a PPTX file.
```java
String certificatePassword = System.getenv("PFX_PASSWORD");
if (certificatePassword == null || certificatePassword.isEmpty()) {
throw new IllegalStateException("Set the PFX_PASSWORD environment variable.");
}
Presentation presentation = new Presentation("InputPresentation.pptx");
try {
DigitalSignature signature = new DigitalSignature("signing-certificate.pfx", certificatePassword);
signature.setComments("Approved for release.");
presentation.getDigitalSignatures().add(signature);
presentation.save("InputPresentation-signed.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
Saving the result under a new name preserves the unsigned source file. The value set by [IDigitalSignature.setComments](https://reference.aspose.com/slides/java/com.aspose.slides/idigitalsignature/#setComments-java.lang.String-) describes the purpose of the signature; it is not a security control.
## **Validate Digital Signatures**
When you load a signed PPTX file, inspect every item returned by [IPresentation.getDigitalSignatures](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentation/#getDigitalSignatures--). The [IDigitalSignature.isValid](https://reference.aspose.com/slides/java/com.aspose.slides/idigitalsignature/#isValid--) method indicates whether the embedded signature is valid for the current presentation content.
```java
Presentation presentation = new Presentation("InputPresentation-signed.pptx");
try {
IDigitalSignatureCollection signatures = presentation.getDigitalSignatures();
int signatureCount = signatures.size();
if (signatureCount == 0) {
System.out.println("The presentation does not contain digital signatures.");
} else {
boolean allSignaturesAreValid = true;
java.text.SimpleDateFormat signTimeFormat = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.security.cert.CertificateFactory certificateFactory = java.security.cert.CertificateFactory.getInstance("X.509");
for (IDigitalSignature signature : signatures) {
boolean signatureIsValid = signature.isValid();
String signatureStatus = signatureIsValid ? "VALID" : "INVALID";
java.util.Date signTime = signature.getSignTime();
String formattedSignTime = signTimeFormat.format(signTime);
byte[] certificateData = signature.getCertificate();
java.io.ByteArrayInputStream certificateStream = new java.io.ByteArrayInputStream(certificateData);
java.security.cert.X509Certificate certificate = (java.security.cert.X509Certificate) certificateFactory.generateCertificate(certificateStream);
javax.security.auth.x500.X500Principal signerPrincipal = certificate.getSubjectX500Principal();
String signerName = signerPrincipal.getName();
System.out.println(signerName + ", " + formattedSignTime + " -- " + signatureStatus);
allSignaturesAreValid &= signatureIsValid;
}
if (allSignaturesAreValid) {
System.out.println("All embedded signatures are valid for the current presentation.");
} else {
System.out.println("At least one embedded signature is invalid.");
}
}
} finally {
presentation.dispose();
}
```
An invalid result commonly means that the signed presentation content or signature data changed after signing, or that the file is damaged. Removing every signature produces an unsigned presentation, so checking only the validity of items is not enough: a security-sensitive workflow must also verify that the expected number of signatures and expected signer identities are present.
This validity result should not be treated as a complete certificate-trust decision. Depending on your security policy, your application may also need to build and validate the X.509 certificate chain, check certificate validity dates and revocation status, confirm the expected subject or thumbprint, verify key usage, and evaluate a trusted timestamp. The [IDigitalSignature.getSignTime](https://reference.aspose.com/slides/java/com.aspose.slides/idigitalsignature/#getSignTime--) value by itself is not proof from a trusted timestamp authority.
## **Remove Digital Signatures**
Removing signatures changes the presentation's security state. The following example loads a signed PPTX file, removes all signatures with [IDigitalSignatureCollection.clear](https://reference.aspose.com/slides/java/com.aspose.slides/idigitalsignaturecollection/#clear--), and saves an unsigned copy.
```java
Presentation presentation = new Presentation("InputPresentation-signed.pptx");
try {
presentation.getDigitalSignatures().clear();
presentation.save("InputPresentation-unsigned.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
To remove only one signature, call [IDigitalSignatureCollection.removeAt](https://reference.aspose.com/slides/java/com.aspose.slides/idigitalsignaturecollection/#removeAt-int-) with its zero-based index. Save to a new file unless overwriting the signed original is an explicit part of your workflow.
## **Editing and Format Considerations**
- A signature does not make a presentation read-only. Users and applications can still edit the file, but changes to signed content normally invalidate the existing signature.
- Complete all intended edits before signing. If a presentation must be changed, save the revised presentation and sign that revision again.
- Keep the final output in PPTX format. Converting a signed presentation to another format does not transfer the original PPTX signature as a valid signature for the converted file.
- Treat the certificate's private key as sensitive. Anyone who obtains the private key and its password may be able to create signatures that appear to come from that certificate holder.
- Retain the unsigned source or another controlled copy when your document-retention policy requires it.
## **FAQ**
**Does a digital signature encrypt the presentation?**
No. A digital signature provides evidence about origin and integrity, but presentation content remains readable unless separate encryption is applied. Use [password protection](https://docs.aspose.com/slides/java/password-protected-presentation/) when access to the content must be restricted.
**Is the PFX password the same as a presentation password?**
No. The PFX password unlocks the private key stored in the certificate package. It does not control who can open or edit the PPTX file.
**Can I use a self-signed certificate?**
Technically, a self-signed certificate can be used when it includes an accessible private key. Recipients will not automatically trust it, however, unless that certificate has been explicitly added to their trusted environment. Public or cross-organization workflows generally use a certificate issued by a trusted CA.
**What makes a signature invalid?**
Changing signed presentation content or the signature data after signing can invalidate the signature. File corruption can also cause validation to fail. If all signatures are removed, the presentation is unsigned rather than a file containing an invalid signature.
**Does a valid signature mean that I should trust the signer?**
Not by itself. Signature integrity and signer trust are separate decisions. A production validation policy should also check the certificate chain, validity period, revocation status, expected identity, key usage, and any trusted timestamp requirements.
**What happens when the certificate expires?**
Certificate expiration does not alter the presentation bytes, but it affects certificate-trust evaluation. Whether a signature remains acceptable depends on your policy and on whether a valid trusted timestamp proves that signing occurred while the certificate was valid. Do not rely on the displayed signing time alone as a trusted timestamp.
**Can a signed presentation still be edited?**
Yes. Signing does not lock the file. Editing signed content generally makes the existing signature invalid, so finish the presentation first and sign the final revision.
**Can a presentation contain more than one signature?**
Yes. Add each signature to the collection returned by [IPresentation.getDigitalSignatures](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentation/#getDigitalSignatures--) before saving. During validation, inspect every signature and confirm that all required signers are present.
**Which presentation formats support these operations?**
Aspose.Slides supports the digital-signature operations described here only for PPTX. PPT and OpenDocument presentation formats are not supported by this API workflow.
**Can I remove a signature without affecting the slides?**
Yes. You can remove one signature or clear the entire collection and then save the presentation. The slide content remains available, but the saved file no longer carries the removed signature evidence.
# Customize Doughnut Charts in Presentations Using Java
> Discover how to create and customize doughnut charts in Aspose.Slides for Java, supporting PowerPoint formats for dynamic presentations.
Source: https://docs.aspose.com/slides/java/doughnut-chart/
Updated: 2026-08-13
## **Overview**
This article shows how to work with a doughnut chart in Aspose.Slides by adding the chart to a slide, setting the size of its center hole, and saving the presentation. It focuses on the `setDoughnutHoleSize` method and demonstrates the basic steps required to customize this chart type in code.
It also includes a short FAQ covering related doughnut-chart scenarios, such as using multiple series to create multiple rings, working with exploded doughnut charts, and exporting a chart as a raster image or SVG.
## **Specify the Center Gap in a Doughnut Chart**
Aspose.Slides for Java now supports specifying the size of the hole in a doughnut chart. In this topic, we will see with example how to specify the size of the hole in a doughnut chart.
In order to specify the size of the hole in a doughnut chart, please follow the steps below:
1. Instantiate [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation) object.
1. Add doughnut chart on the slide.
1. Specify the size of the hole in a doughnut chart.
1. Write presentation to disk.
In the example given below, we have set the size of the hole in a doughnut chart.
```java
import com.aspose.slides.*;
// Create an instance of Presentation class
Presentation pres = new Presentation();
try {
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.Doughnut, 50, 50, 400, 400);
chart.getChartData().getSeriesGroups().get_Item(0).setDoughnutHoleSize((byte)90);
// Write presentation to disk
pres.save("DoughnutHoleSize_out.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
## **FAQ**
### Can I create a multi-level doughnut with multiple rings?
Yes. Add multiple series to a single doughnut chart—each series becomes a separate ring. The ring order is determined by the order of the series in the collection.
### Is an "exploded" doughnut (separated slices) supported?
Yes. There is an Exploded Doughnut [chart type](https://reference.aspose.com/slides/java/com.aspose.slides/charttype/) and an explosion property on data points; you can separate individual slices.
### How can I get an image of a doughnut chart (PNG/SVG) for a report?
A chart is a shape; you can render it to a [raster image](https://reference.aspose.com/slides/java/com.aspose.slides/shape/#getImage-int-float-float-) or export the chart to an [SVG image](https://reference.aspose.com/slides/java/com.aspose.slides/shape/#writeAsSvg-java.io.OutputStream-com.aspose.slides.ISVGOptions-).
# Manage Drawing Guides in Presentations in Java
> Add, access, and clear horizontal and vertical drawing guides in PowerPoint presentations using Aspose.Slides for Java.
Source: https://docs.aspose.com/slides/java/drawing-guides/
Updated: 2026-11-08
## **Overview**
Drawing guides are adjustable horizontal and vertical lines that help users align shapes consistently while editing a presentation in PowerPoint. They are especially useful when an application generates a presentation that will later be refined manually: the application can save the same alignment aids that authors should follow when adding or moving content.
Drawing guides are editing aids, not slide content. They do not appear in a slide show or rendered output. Aspose.Slides for Java exposes them through the [IDrawingGuidesCollection](https://reference.aspose.com/slides/java/com.aspose.slides/idrawingguidescollection/) interface. A guide is represented by [IDrawingGuide](https://reference.aspose.com/slides/java/com.aspose.slides/idrawingguide/) and has an orientation, a position, and a color.
The position is measured in points from the top-left corner of the relevant slide or master. A vertical guide uses a horizontal coordinate, typically between zero and the slide width. A horizontal guide uses a vertical coordinate, typically between zero and the slide height.
## **Add Guides to the Slide View**
Use [ICommonSlideViewProperties.getDrawingGuides](https://reference.aspose.com/slides/java/com.aspose.slides/icommonslideviewproperties/#getDrawingGuides--) to manage guides displayed while editing normal slides. Call [IDrawingGuidesCollection.add](https://reference.aspose.com/slides/java/com.aspose.slides/idrawingguidescollection/#add-byte-float-) with an [Orientation](https://reference.aspose.com/slides/java/com.aspose.slides/orientation/) value and a position in points.
The following example adds one vertical guide to the right of the slide center and one horizontal guide below it:
```java
import com.aspose.slides.*;
import java.awt.geom.Dimension2D;
Presentation presentation = new Presentation();
try {
Dimension2D slideSize = presentation.getSlideSize().getSize();
IDrawingGuidesCollection guides = presentation.getViewProperties().getSlideViewProperties().getDrawingGuides();
guides.add(Orientation.Vertical, (float) (slideSize.getWidth() / 2 + 12.5));
guides.add(Orientation.Horizontal, (float) (slideSize.getHeight() / 2 + 12.5));
presentation.save("drawing-guides.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
[](https://docs.aspose.com/slides/java/drawing-guides/visual-drawing-guides-7a8220358e23.svg)
*Conceptual editing overlay with coordinates verified in the saved .NET 26.11 fixture. The example adds guides at width/2 + 12.5 and height/2 + 12.5 points. Existing center guides may also be present. Guide visibility depends on the editor; static slide rendering does not draw them.*
## **Access Drawing Guides**
The [IDrawingGuidesCollection.getCount](https://reference.aspose.com/slides/java/com.aspose.slides/idrawingguidescollection/#getCount--) and [IDrawingGuidesCollection.get_Item](https://reference.aspose.com/slides/java/com.aspose.slides/idrawingguidescollection/#get_Item-int-) methods provide access to existing guides. The [IDrawingGuide.getOrientation](https://reference.aspose.com/slides/java/com.aspose.slides/idrawingguide/#getOrientation--), [IDrawingGuide.getPosition](https://reference.aspose.com/slides/java/com.aspose.slides/idrawingguide/#getPosition--), and [IDrawingGuide.getColor](https://reference.aspose.com/slides/java/com.aspose.slides/idrawingguide/#getColor--) methods return values that can also be changed through the corresponding setter methods.
The following example reads the slide-view guides from the presentation created above:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("drawing-guides.pptx");
try {
IDrawingGuidesCollection guides = presentation.getViewProperties().getSlideViewProperties().getDrawingGuides();
for (int index = 0; index < guides.getCount(); index++) {
IDrawingGuide guide = guides.get_Item(index);
System.out.println("Guide " + index + ": orientation = " + guide.getOrientation() + ", position = " + guide.getPosition() + ", color = " + guide.getColor());
}
} finally {
presentation.dispose();
}
```
## **Add Guides to Master and Layout Slides**
A slide master and each of its layout slides can have their own drawing-guide collections. Use [IMasterSlide.getDrawingGuides](https://reference.aspose.com/slides/java/com.aspose.slides/imasterslide/#getDrawingGuides--) for a master slide and [ILayoutSlide.getDrawingGuides](https://reference.aspose.com/slides/java/com.aspose.slides/ilayoutslide/#getDrawingGuides--) for a layout slide.
The following example adds a vertical guide to the first master slide and a horizontal guide to the first layout slide:
```java
import com.aspose.slides.*;
import java.awt.geom.Dimension2D;
Presentation presentation = new Presentation();
try {
Dimension2D slideSize = presentation.getSlideSize().getSize();
IDrawingGuidesCollection masterGuides = presentation.getMasters().get_Item(0).getDrawingGuides();
IDrawingGuidesCollection layoutGuides = presentation.getLayoutSlides().get_Item(0).getDrawingGuides();
masterGuides.add(Orientation.Vertical, (float) (slideSize.getWidth() / 2 - 20));
layoutGuides.add(Orientation.Horizontal, (float) (slideSize.getHeight() / 2 + 20));
presentation.save("master-layout-drawing-guides.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Add Guides to Notes and Handout Masters**
Notes masters and handout masters also support drawing guides. Use [IMasterNotesSlide.getDrawingGuides](https://reference.aspose.com/slides/java/com.aspose.slides/imasternotesslide/#getDrawingGuides--) and [IMasterHandoutSlide.getDrawingGuides](https://reference.aspose.com/slides/java/com.aspose.slides/imasterhandoutslide/#getDrawingGuides--) to access their collections. If a presentation does not contain one of these masters, [IMasterNotesSlideManager.setDefaultMasterNotesSlide](https://reference.aspose.com/slides/java/com.aspose.slides/imasternotesslidemanager/#setDefaultMasterNotesSlide--) or [IMasterHandoutSlideManager.setDefaultMasterHandoutSlide](https://reference.aspose.com/slides/java/com.aspose.slides/imasterhandoutslidemanager/#setDefaultMasterHandoutSlide--) creates the default master and returns it.
The following example adds a horizontal guide to a notes master and a vertical guide to a handout master:
```java
import com.aspose.slides.*;
import java.awt.geom.Dimension2D;
Presentation presentation = new Presentation();
try {
Dimension2D notesSize = presentation.getNotesSize().getSize();
IMasterNotesSlide notesMaster = presentation.getMasterNotesSlideManager().setDefaultMasterNotesSlide();
IMasterHandoutSlide handoutMaster = presentation.getMasterHandoutSlideManager().setDefaultMasterHandoutSlide();
notesMaster.getDrawingGuides().add(Orientation.Horizontal, (float) (notesSize.getHeight() / 2 + 50));
handoutMaster.getDrawingGuides().add(Orientation.Vertical, (float) (notesSize.getWidth() / 2 - 50));
presentation.save("notes-handout-drawing-guides.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Clear Drawing Guides**
Call [IDrawingGuidesCollection.clear](https://reference.aspose.com/slides/java/com.aspose.slides/idrawingguidescollection/#clear--) to remove every guide from a particular collection. Clearing one collection does not affect guides stored in another scope.
The following example clears the slide-view guides and all guides on slide masters, layout slides, the notes master, and the handout master without creating missing masters:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("presentation-with-guides.pptx");
try {
presentation.getViewProperties().getSlideViewProperties().getDrawingGuides().clear();
for (IMasterSlide masterSlide : presentation.getMasters()) {
masterSlide.getDrawingGuides().clear();
}
for (ILayoutSlide layoutSlide : presentation.getLayoutSlides()) {
layoutSlide.getDrawingGuides().clear();
}
IMasterNotesSlide notesMaster = presentation.getMasterNotesSlideManager().getMasterNotesSlide();
if (notesMaster != null) {
notesMaster.getDrawingGuides().clear();
}
IMasterHandoutSlide handoutMaster = presentation.getMasterHandoutSlideManager().getMasterHandoutSlide();
if (handoutMaster != null) {
handoutMaster.getDrawingGuides().clear();
}
presentation.save("presentation-without-guides.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **FAQ**
**Do drawing guides appear in a slide show or exported images?**
No. Drawing guides are alignment aids for editing and are not rendered as presentation content.
**Can a drawing guide be added directly to an individual normal slide?**
Normal-slide editing guides are stored in the presentation's slide-view properties. Separate guide collections are available for slide masters, layout slides, notes masters, and handout masters.
**Which units are used for guide positions?**
Positions are specified in points, where 72 points equal one inch. Vertical positions are measured from the left edge, and horizontal positions are measured from the top edge.
**Does clearing drawing guides remove shapes or change slide content?**
No. The [IDrawingGuidesCollection.clear](https://reference.aspose.com/slides/java/com.aspose.slides/idrawingguidescollection/#clear--) method removes only the guides in the selected collection. Shapes and other slide content remain unchanged.
# Edit PDF Documents in Java
> Edit PDF documents in Java by importing them into Aspose.Slides, replacing text, and saving the modified presentation back to PDF.
Source: https://docs.aspose.com/slides/java/edit-pdf/
Updated: 2026-09-21
## **Overview**
Aspose.Slides for Java lets you edit PDF content by importing its pages as slides, modifying the presentation, and exporting it back to PDF. This article shows a simple text replacement. The presentation stays in memory, so saving an intermediate PPTX file is optional.
## **Replace Text in a PDF**
Use [addFromPdf](https://reference.aspose.com/slides/java/com.aspose.slides/slidecollection/#addFromPdf-java.lang.String-) to import the pages, [replaceText](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#replaceText-java.lang.String-java.lang.String-com.aspose.slides.ITextSearchOptions-com.aspose.slides.IFindResultCallback-) to update the text, and [save](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#save-java.lang.String-int-) to export the result.
The following example expects `input.pdf` to contain the word "Draft" as editable text after import. It replaces that word with "Final" and writes `edited.pdf`. Clearing the initial slide before import prevents an extra blank page in the output. The search matches whole words with the same letter case; `null` means no result callback is needed.
```java
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
import com.aspose.slides.TextSearchOptions;
Presentation presentation = new Presentation();
try {
presentation.getSlides().removeAt(0);
presentation.getSlides().addFromPdf("input.pdf");
TextSearchOptions searchOptions = new TextSearchOptions();
searchOptions.setWholeWordsOnly(true);
searchOptions.setCaseSensitive(true);
presentation.replaceText("Draft", "Final", searchOptions, null);
presentation.save("edited.pdf", SaveFormat.Pdf);
} finally {
presentation.dispose();
}
```
For more options, see [Search and Replace Text](https://docs.aspose.com/slides/java/search-and-replace-text/) and [Convert PowerPoint to PDF](https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf/).
Text replacement works on imported text, not text inside scanned images. The conversion can affect layout and formatting, so review the output, especially when the replacement text is longer than the original.
## **FAQ**
**Do I need to save a PPTX file before exporting the PDF?**
No. You can edit and export the same presentation in memory. Save a PPTX copy only if you also want to continue editing it in PowerPoint; see [Save Presentations](https://docs.aspose.com/slides/java/save-presentation/).
**Why might some text remain unchanged?**
The example matches the whole word "Draft" with exact case. Text imported as an image or split across separate text frames will not necessarily match the search. Check the imported content and adjust the search for your document.
# Add Ellipses to Presentations in Java
> Learn how to create, format, and manipulate ellipse shapes in Aspose.Slides for Java across PPT and PPTX presentations—Java code examples included.
Source: https://docs.aspose.com/slides/java/ellipse/
Updated: 2026-08-05
## **Overview**
This article shows how to add ellipse shapes to PowerPoint slides by using Aspose.Slides. It covers creating a simple ellipse, creating a formatted ellipse, and saving the updated presentation as a PPTX file. It also touches on related questions such as working with ellipse position and size, controlling stacking order, and applying animation effects.
## **Create an Ellipse**
To add a simple ellipse to a selected slide of the presentation, please follow the steps below:
- Create an instance of [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation) class.
- Obtain the reference of a slide by using its Index.
- Add an AutoShape of Ellipse type using [addAutoShape](https://reference.aspose.com/slides/java/com.aspose.slides/IShapeCollection#addAutoShape-int-float-float-float-float-) method exposed by [IShapeCollection](https://reference.aspose.com/slides/java/com.aspose.slides/IShapeCollection) object.
- Write the modified presentation as a PPTX file.
In the example given below, we have added an ellipse to the first slide
```java
import com.aspose.slides.*;
// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
try {
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add AutoShape of ellipse type
sld.getShapes().addAutoShape(ShapeType.Ellipse, 50, 150, 150, 50);
// Write the PPTX file to disk
pres.save("EllipseShp1.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
## **Create a Formatted Ellipse**
To add a better formatted ellipse to a slide, please follow the steps below:
- Create an instance of [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation) class.
- Obtain the reference of a slide by using its Index.
- Add an AutoShape of Ellipse type using [addAutoShape](https://reference.aspose.com/slides/java/com.aspose.slides/IShapeCollection#addAutoShape-int-float-float-float-float-) method exposed by [IShapeCollection](https://reference.aspose.com/slides/java/com.aspose.slides/IShapeCollection) object.
- Set the Fill Type of the Ellipse to Solid.
- Set the Color of the Ellipse using SolidFillColor.Color property as exposed by [FillFormat](https://reference.aspose.com/slides/java/com.aspose.slides/IFillFormat) object associated with the [IShape](https://reference.aspose.com/slides/java/com.aspose.slides/IShape) object.
- Set the Color of the lines of the Ellipse.
- Set the Width of the lines of the Ellipse.
- Write the modified presentation as a PPTX file.
In the example given below, we have added a formatted ellipse to the first slide of the presentation.
```java
import com.aspose.slides.*;
import java.awt.Color;
// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
try {
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add AutoShape of ellipse type
IShape shp = sld.getShapes().addAutoShape(ShapeType.Ellipse, 50, 150, 150, 50);
// Apply some formatting to ellipse shape
shp.getFillFormat().setFillType(FillType.Solid);
shp.getFillFormat().getSolidFillColor().setPresetColor(PresetColor.Chocolate);
// Apply some formatting to the line of Ellipse
shp.getLineFormat().getFillFormat().setFillType(FillType.Solid);
shp.getLineFormat().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
shp.getLineFormat().setWidth(5);
// Write the PPTX file to disk
pres.save("EllipseShp1.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
## **FAQ**
### How do I set the exact position and size of an ellipse with respect to the slide's units?
Coordinates and sizes are typically specified **in points**. For predictable results, base your calculations on the slide size and convert required millimeters or inches to points before assigning values.
### How can I place an ellipse above or below other objects (control stacking order)?
Adjust the drawing order of the object by bringing it to front or sending it to back. This lets the ellipse overlap other objects or reveal those beneath it.
### How do I animate the appearance or emphasis of an ellipse?
[Apply](https://docs.aspose.com/slides/java/shape-animation/) entrance, emphasis, or exit effects to the shape, and configure triggers and timing to orchestrate when and how the animation plays.
# Embed Fonts in Presentations in Java
> Manage embedded fonts in PowerPoint with Aspose.Slides for Java. Add, retrieve, remove, and compress fonts to preserve text appearance and reduce file size.
Source: https://docs.aspose.com/slides/java/embedded-font/
Updated: 2026-09-03
## **Introduction**
Embedding fonts stores font data inside a PowerPoint presentation. When a viewer supports embedded fonts, it can display text using those fonts even if they are not installed on the target system. This helps preserve line breaks, text spacing, and slide layout.
Aspose.Slides for Java lets you retrieve, add, and remove embedded fonts through the [IFontsManager](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsmanager/) interface returned by [Presentation.getFontsManager](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#getFontsManager--). You can also reduce the size of embedded font data by removing characters that the presentation does not use.
The examples below work with PPTX files. Before embedding a font, make sure its font data is available to Aspose.Slides and its license permits embedding.
## **Get and Remove Embedded Fonts**
Use [getEmbeddedFonts](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsmanager/#getEmbeddedFonts--) to list the fonts stored in a presentation. To remove one, pass a font from that list to [removeEmbeddedFont](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsmanager/#removeEmbeddedFont-com.aspose.slides.IFontData-), then save the presentation.
The following example lists the embedded fonts in `EmbeddedFonts.pptx` and removes Calibri if it is present:
```java
import com.aspose.slides.IFontData;
import com.aspose.slides.IFontsManager;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
Presentation presentation = new Presentation("EmbeddedFonts.pptx");
try {
IFontsManager fontsManager = presentation.getFontsManager();
IFontData[] embeddedFonts = fontsManager.getEmbeddedFonts();
for (IFontData font : embeddedFonts) {
System.out.println(font.getFontName());
}
IFontData fontToRemove = null;
for (IFontData font : embeddedFonts) {
if ("Calibri".equalsIgnoreCase(font.getFontName())) {
fontToRemove = font;
break;
}
}
if (fontToRemove != null) {
fontsManager.removeEmbeddedFont(fontToRemove);
presentation.save("WithoutEmbeddedCalibri.pptx", SaveFormat.Pptx);
} else {
System.out.println("Calibri is not embedded. No output file was created.");
}
} finally {
presentation.dispose();
}
```
Removing an embedded font removes its stored font data; it does not change the font assigned to the text. If the font is installed on the target system, the text can still use it. Otherwise, rendering may require [font substitution](https://docs.aspose.com/slides/java/font-substitution/), which can affect the layout.
## **Inspect Font Data and Embedding Permissions**
Use the [IFontsManager](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsmanager/) interface to inspect fonts before embedding them. Call [IFontsManager.getFonts](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsmanager/#getFonts--) to retrieve the fonts used in the presentation. For each font, pass an [IFontData](https://reference.aspose.com/slides/java/com.aspose.slides/ifontdata/) object and the required [FontStyleType](https://reference.aspose.com/slides/java/com.aspose.slides/fontstyletype/) value to [IFontsManager.getFontBytes](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsmanager/#getFontBytes-com.aspose.slides.IFontData-int-). The method returns the binary data for that font style, or `null` when the requested font or style is unavailable. Do not pass a `null` result to [IFontsManager.getFontEmbeddingLevel](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsmanager/#getFontEmbeddingLevel-byte---java.lang.String-), because that method requires a byte array.
[EmbeddingLevel](https://reference.aspose.com/slides/java/com.aspose.slides/embeddinglevel/) is a flags enumeration that reports the embedding restrictions stored in the font:
- `Installable` permits embedding and permanent installation on another system, subject to the font license.
- `Restricted` prohibits embedding unless permission is obtained from the font's legal owner when it is the only usage-permission flag.
- `PreviewPrint` permits temporary use for viewing and printing; a document containing the font must be read-only.
- `Editable` permits temporary use and allows the document to be edited and saved.
- `NoSubsetting` is an additional restriction that prohibits embedding only a subset of the glyphs. Embed all characters when this flag is present.
- `BitmapOnly` is an additional restriction that permits only bitmap strikes to be embedded, not outline data. If the font has no bitmap strikes, it cannot be embedded.
The first four values describe usage permission, while `NoSubsetting` and `BitmapOnly` can be combined with them. Check the modifiers with bitwise operations. Because `Installable` is zero, mask the usage-permission bits and compare the result with `Installable` instead of checking it as a flag. Current fonts should set at most one usage-permission bit. For compatibility with older fonts that set more than one, the helper below selects the least restrictive permission: `Editable`, then `PreviewPrint`, then `Restricted`.
The following example audits the regular, bold, italic, and bold-italic data available for every font returned by `getFonts`. It skips unavailable styles, restricted fonts, bitmap-only fonts, fonts limited to preview and print because the output remains editable, and fonts that are already embedded. If any available style has `NoSubsetting`, it embeds all characters for that font family.
```java
import com.aspose.slides.EmbedFontCharacters;
import com.aspose.slides.EmbeddingLevel;
import com.aspose.slides.FontStyleType;
import com.aspose.slides.IFontData;
import com.aspose.slides.IFontsManager;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
class EmbeddingPermission {
int getUsagePermission(int level) {
int permissionMask = EmbeddingLevel.Restricted | EmbeddingLevel.PreviewPrint | EmbeddingLevel.Editable;
int permissions = level & permissionMask;
if ((permissions & EmbeddingLevel.Editable) != 0) {
return EmbeddingLevel.Editable;
}
if ((permissions & EmbeddingLevel.PreviewPrint) != 0) {
return EmbeddingLevel.PreviewPrint;
}
if ((permissions & EmbeddingLevel.Restricted) != 0) {
return EmbeddingLevel.Restricted;
}
return EmbeddingLevel.Installable;
}
}
Presentation presentation = new Presentation("Fonts.pptx");
try {
IFontsManager fontsManager = presentation.getFontsManager();
int[] fontStyles = {
FontStyleType.Regular,
FontStyleType.Bold,
FontStyleType.Italic,
FontStyleType.Bold | FontStyleType.Italic
};
Set embeddedFontNames = new HashSet();
for (IFontData embeddedFont : fontsManager.getEmbeddedFonts()) {
embeddedFontNames.add(embeddedFont.getFontName().toLowerCase(Locale.ROOT));
}
EmbeddingPermission permissionHelper = new EmbeddingPermission();
List fontsToEmbed = new ArrayList();
List embeddingRules = new ArrayList();
for (IFontData font : fontsManager.getFonts()) {
if (embeddedFontNames.contains(font.getFontName().toLowerCase(Locale.ROOT))) {
System.out.println(font.getFontName() + ": already embedded.");
continue;
}
boolean hasAvailableData = false;
boolean allAvailableStylesCanBeEmbedded = true;
boolean previewPrintOnly = false;
boolean requiresFullFont = false;
for (int fontStyle : fontStyles) {
byte[] fontBytes = fontsManager.getFontBytes(font, fontStyle);
if (fontBytes == null) {
System.out.println(font.getFontName() + " (" + fontStyle + "): font data is unavailable.");
continue;
}
hasAvailableData = true;
int embeddingLevel = fontsManager.getFontEmbeddingLevel(fontBytes, font.getFontName());
int usagePermission = permissionHelper.getUsagePermission(embeddingLevel);
boolean noSubsetting = (embeddingLevel & EmbeddingLevel.NoSubsetting) != 0;
boolean bitmapOnly = (embeddingLevel & EmbeddingLevel.BitmapOnly) != 0;
requiresFullFont |= noSubsetting;
previewPrintOnly |= usagePermission == EmbeddingLevel.PreviewPrint;
allAvailableStylesCanBeEmbedded &= usagePermission != EmbeddingLevel.Restricted && !bitmapOnly;
System.out.println(font.getFontName() + " (" + fontStyle + "): " + embeddingLevel + ".");
}
if (!hasAvailableData) {
System.out.println(font.getFontName() + ": skipped because no requested style is available.");
} else if (!allAvailableStylesCanBeEmbedded) {
System.out.println(font.getFontName() + ": skipped because at least one available style does not permit outline embedding.");
} else if (previewPrintOnly) {
System.out.println(font.getFontName() + ": skipped because this example produces an editable presentation.");
} else {
int rule = requiresFullFont ? EmbedFontCharacters.All : EmbedFontCharacters.OnlyUsed;
fontsToEmbed.add(font);
embeddingRules.add(rule);
}
}
for (int i = 0; i < fontsToEmbed.size(); i++) {
fontsManager.addEmbeddedFont(fontsToEmbed.get(i), embeddingRules.get(i));
}
presentation.save("WithAuditedFonts.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
This inspection reports the restrictions encoded in each font file. It does not grant a license, prove that you obtained the font legally, or replace checking the font's license agreement before distributing an embedded copy.
## **Add Embedded Fonts**
Use [addEmbeddedFont](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsmanager/#addEmbeddedFont-com.aspose.slides.IFontData-int-) to embed a font. Its overloads accept either an [IFontData](https://reference.aspose.com/slides/java/com.aspose.slides/ifontdata/) object or a byte array containing the font data. The [EmbedFontCharacters](https://reference.aspose.com/slides/java/com.aspose.slides/embedfontcharacters/) enumeration controls which characters are included:
- [All](https://reference.aspose.com/slides/java/com.aspose.slides/embedfontcharacters/) embeds all characters in the font. Use this option when recipients need to edit the presentation and enter new text.
- [OnlyUsed](https://reference.aspose.com/slides/java/com.aspose.slides/embedfontcharacters/) embeds only the characters used in the presentation to reduce file size. Choose this option for a finished presentation that is primarily intended for viewing.
The following example uses [getFonts](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsmanager/#getFonts--) to retrieve the fonts used in `Fonts.pptx` and embeds those that are not already embedded. The fonts to add must be available on the machine running the code. Existing embedded fonts retain their current character sets.
```java
import com.aspose.slides.EmbedFontCharacters;
import com.aspose.slides.IFontData;
import com.aspose.slides.IFontsManager;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
Presentation presentation = new Presentation("Fonts.pptx");
try {
IFontsManager fontsManager = presentation.getFontsManager();
IFontData[] allFonts = fontsManager.getFonts();
IFontData[] embeddedFonts = fontsManager.getEmbeddedFonts();
Set embeddedFontNames = new HashSet();
for (IFontData embeddedFont : embeddedFonts) {
embeddedFontNames.add(embeddedFont.getFontName().toLowerCase(Locale.ROOT));
}
for (IFontData font : allFonts) {
String fontName = font.getFontName().toLowerCase(Locale.ROOT);
if (!embeddedFontNames.contains(fontName)) {
fontsManager.addEmbeddedFont(font, EmbedFontCharacters.All);
embeddedFontNames.add(fontName);
}
}
presentation.save("WithEmbeddedFonts.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Compress Embedded Fonts**
[Compress.compressEmbeddedFonts](https://reference.aspose.com/slides/java/com.aspose.slides/compress/#compressEmbeddedFonts-com.aspose.slides.Presentation-) reduces embedded font data by removing unused characters. It operates on fonts that are already embedded, so the size reduction depends on how much unused font data the presentation contains.
The following example compresses the fonts in `EmbeddedFonts.pptx` and saves the result as a separate file:
```java
import com.aspose.slides.Compress;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
Presentation presentation = new Presentation("EmbeddedFonts.pptx");
try {
Compress.compressEmbeddedFonts(presentation);
presentation.save("CompressedEmbeddedFonts.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
Keep the original file if recipients may need to add text later. Characters removed during compression are no longer available from the embedded font, even if you originally embedded all characters.
## **FAQ**
**How can I check whether an embedded font will still be substituted during rendering?**
Call [getSubstitutions](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsmanager/#getSubstitutions--) in the environment where you render the presentation to see which fonts Aspose.Slides will replace. Also check [font substitution](https://docs.aspose.com/slides/java/font-substitution/) settings and [font fallback](https://docs.aspose.com/slides/java/fallback-font/) rules. Fallback handles missing characters, so embedding a font does not resolve characters that the font itself does not contain.
**Should I embed common fonts such as Arial and Calibri?**
Base the decision on the target environment. If the required fonts are available on every machine that opens or renders the presentation, embedding them may add unnecessary file size. If recipients or servers may lack those fonts, embedding them can help preserve the intended appearance, provided their licenses allow it.
# Customize Error Bars in Presentation Charts Using Java
> Learn how to add and customize error bars in charts with Aspose.Slides for Java—optimize data visuals in PowerPoint presentations.
Source: https://docs.aspose.com/slides/java/error-bar/
Updated: 2026-11-08
## **Overview**
This article explains how to work with error bars in presentation charts by using Aspose.Slides. It shows how to add error bars to a chart series, configure X and Y error bar settings, and apply different value types such as fixed, percentage, and custom values.
It also demonstrates how to assign custom error bar values for individual data points in a series by using the corresponding data point collection. In addition, the article includes brief notes about how error bars behave during export, their compatibility with markers and data labels, and where to find the related API reference classes and enums.
## **Add Error Bars**
Aspose.Slides for Java provides a simple API for managing error bar values. The sample code applies when using a custom value type. To specify a value, use the **ErrorBarCustomValues** property of a specific data point in the [**DataPoints**](https://reference.aspose.com/slides/java/com.aspose.slides/IChartSeriesCollection) collection of series:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class.
1. Add a bubble chart on desired slide.
1. Access the first chart series and set the error bar X format.
1. Access the first chart series and set the error bar Y format.
1. Setting bars values and format.
1. Write the modified presentation to a PPTX file.
```java
import com.aspose.slides.*;
// Create an instance of Presentation class
Presentation pres = new Presentation();
try {
// Creating a bubble chart
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.Bubble, 50, 50, 400, 300, true);
// Adding Error bars and setting its format
IErrorBarsFormat errBarX = chart.getChartData().getSeries().get_Item(0).getErrorBarsXFormat();
IErrorBarsFormat errBarY = chart.getChartData().getSeries().get_Item(0).getErrorBarsYFormat();
errBarX.setVisible(true);
errBarY.setVisible(true);
errBarX.setValueType(ErrorBarValueType.Fixed);
errBarX.setValue(0.1f);
errBarY.setValueType(ErrorBarValueType.Percentage);
errBarY.setValue(5);
errBarX.setType(ErrorBarType.Plus);
errBarY.getFormat().getLine().setWidth(2.0f);
errBarX.setEndCap(true);
// Saving presentation
pres.save("ErrorBars.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
## **Add Custom Error Bar Values**
Aspose.Slides for Java provides a simple API for managing custom error bar values. The sample code applies when the [**IErrorBarsFormat.ValueType**](https://reference.aspose.com/slides/java/com.aspose.slides/IErrorBarsFormat#getValue--) property is equal to **Custom**. To specify a value, use the **ErrorBarCustomValues** property of a specific data point in the [**DataPoints**](https://reference.aspose.com/slides/java/com.aspose.slides/IChartSeriesCollection) collection of series:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class.
1. Add a bubble chart on desired slide.
1. Access the first chart series and set the error bar X format.
1. Access the first chart series and set the error bar Y format.
1. Access the chart series individual data points and setting the Error Bar values for individual series data point.
1. Setting bars values and format.
1. Write the modified presentation to a PPTX file.
```java
import com.aspose.slides.*;
// Create an instance of Presentation class
Presentation pres = new Presentation();
try {
// Creating a bubble chart
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.Bubble, 50, 50, 400, 300, true);
// Adding custom Error bars and setting its format
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
IErrorBarsFormat errBarX = series.getErrorBarsXFormat();
IErrorBarsFormat errBarY = series.getErrorBarsYFormat();
errBarX.setVisible(true);
errBarY.setVisible(true);
errBarX.setValueType(ErrorBarValueType.Custom);
errBarY.setValueType(ErrorBarValueType.Custom);
// Accessing chart series data point and setting error bars values for
// individual point
IChartDataPointCollection points = series.getDataPoints();
points.getDataSourceTypeForErrorBarsCustomValues().setDataSourceTypeForXPlusValues((byte) DataSourceType.DoubleLiterals);
points.getDataSourceTypeForErrorBarsCustomValues().setDataSourceTypeForXMinusValues((byte) DataSourceType.DoubleLiterals);
points.getDataSourceTypeForErrorBarsCustomValues().setDataSourceTypeForYPlusValues((byte) DataSourceType.DoubleLiterals);
points.getDataSourceTypeForErrorBarsCustomValues().setDataSourceTypeForYMinusValues((byte) DataSourceType.DoubleLiterals);
// Setting error bars for chart series points
for (int i = 0; i < points.size(); i++) {
points.get_Item(i).getErrorBarsCustomValues().getXMinus().setAsLiteralDouble(i + 1);
points.get_Item(i).getErrorBarsCustomValues().getXPlus().setAsLiteralDouble(i + 1);
points.get_Item(i).getErrorBarsCustomValues().getYMinus().setAsLiteralDouble(i + 1);
points.get_Item(i).getErrorBarsCustomValues().getYPlus().setAsLiteralDouble(i + 1);
}
// Saving presentation
pres.save("ErrorBarsCustomValues.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
[](https://docs.aspose.com/slides/java/error-bar/visual-error-bar-bca0d6a2d53f.svg)
*Illustrative coordinates. The sample assigns the same offset to −X, +X, −Y and +Y at each point, using 1 for the first point and 2 for the second.*
## **FAQ**
### What happens to error bars when exporting a presentation to PDF or images?
They are rendered as part of the chart and preserved during conversion along with the rest of the chart formatting, assuming a compatible version or renderer.
### Can error bars be combined with markers and data labels?
Yes. Error bars are a separate element and are compatible with markers and data labels; if elements overlap, you may need to adjust formatting.
### Where can I find the list of properties and classes for working with error bars in the API?
In the API reference: the [ErrorBarsFormat](https://reference.aspose.com/slides/java/com.aspose.slides/errorbarsformat/) class and the related classes [ErrorBarType](https://reference.aspose.com/slides/java/com.aspose.slides/errorbartype/) and [ErrorBarValueType](https://reference.aspose.com/slides/java/com.aspose.slides/errorbarvaluetype/).
# Evaluate Aspose.Slides
> Evaluate Aspose.Slides for Java and explore API features for PowerPoint (PPT, PPTX) and OpenDocument (ODP) presentations—start your free trial.
Source: https://docs.aspose.com/slides/java/evaluate-aspose-slides/
Updated: 2026-09-29
## **Aspose.Slides Evaluation**
You can download Aspose.Slides for evaluation. The evaluation download is the same as the purchased download; it becomes licensed after you add a few lines of code to apply the license.
Without a license, Aspose.Slides provides its full functionality in evaluation mode, with two limitations: it adds an evaluation watermark text box to every slide of each presentation it saves, and text that your code reads through the API, including text it has just set, is truncated to its first few characters, followed by a notice about the evaluation limitation. Text that your code writes is saved in full. The [getPresentationText](https://reference.aspose.com/slides/java/com.aspose.slides/presentationfactory/#getPresentationText-java.lang.String-int-) method, which extracts text without loading the whole presentation, returns only evaluation notices and no slide text.

If you want to test Aspose.Slides without the evaluation version limitations, you can also request a 30-day Temporary License. Please refer to [How to get a Temporary License?](https://purchase.aspose.com/temporary-license)
## **FAQ**
### Can I test multiple presentations in parallel across different threads in evaluation mode?
Yes. You can process different documents in parallel; you should not share the same presentation object [across threads](https://docs.aspose.com/slides/java/multithreading/). Evaluation mode does not affect this.
### Do I need to install Microsoft PowerPoint to evaluate the library on a server or in CI?
No. Aspose.Slides is a standalone engine and does not require PowerPoint installed for either evaluation or production.
### Can I fully test conversion of PPT/PPTX to PDF and images in evaluation mode?
Yes. The [converters](https://docs.aspose.com/slides/java/convert-presentation/) work; the output will include a watermark.
### Can I use a temporary license for load testing without a watermark?
Yes. A 30-day temporary license removes evaluation-mode limitations and allows testing without a watermark.
## Related articles
- [Licensing](https://docs.aspose.com/slides/java/licensing/)
# Retrieve and Update Presentation Information in Java
> Explore slides, structure and metadata in PowerPoint and OpenDocument presentations using Java for faster insights and smarter content audits.
Source: https://docs.aspose.com/slides/java/examine-presentation/
Updated: 2026-09-22
## **Overview**
Aspose.Slides can identify a presentation's format and read its document metadata without creating a complete presentation object model. This is useful when you need to classify files, build an inventory, or inspect properties before deciding whether to load and process the presentation content.
This article demonstrates lightweight inspection through [PresentationFactory](https://reference.aspose.com/slides/java/com.aspose.slides/presentationfactory/) and [IPresentationInfo](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentationinfo/), as well as targeted updates through [IDocumentProperties](https://reference.aspose.com/slides/java/com.aspose.slides/idocumentproperties/).
## **Check a Presentation Format**
If you already have a loaded presentation, see [Determine the Original Presentation Format](https://docs.aspose.com/slides/java/detect-presentation-source-format/) for detection after loading and the limitations of legacy PPT, PPS, and POT streams.
Use [PresentationFactory.getPresentationInfo](https://reference.aspose.com/slides/java/com.aspose.slides/presentationfactory/#getPresentationInfo-java.lang.String-) to inspect a file without creating a [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) instance. The [IPresentationInfo.getLoadFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentationinfo/#getLoadFormat--) method reports the detected format, such as PPTX, PPT, or ODP.
```java
import com.aspose.slides.IPresentationInfo;
import com.aspose.slides.LoadFormat;
import com.aspose.slides.PresentationFactory;
String[] fileNames = { "pres.pptx", "pres.ppt", "pres.odp" };
for (String fileName : fileNames) {
IPresentationInfo presentationInfo = PresentationFactory.getInstance().getPresentationInfo(fileName);
int loadFormat = presentationInfo.getLoadFormat();
String formatName = "Other (" + loadFormat + ")";
if (loadFormat == LoadFormat.Pptx) {
formatName = "PPTX";
} else if (loadFormat == LoadFormat.Ppt) {
formatName = "PPT";
} else if (loadFormat == LoadFormat.Odp) {
formatName = "ODP";
}
System.out.println(fileName + ": " + formatName);
}
```
## **Build a Lightweight Presentation Inventory**
When you process many presentation files, you may need a compact inventory for validation, indexing, or a document-management system. In this scenario, use [PresentationFactory.getPresentationInfo](https://reference.aspose.com/slides/java/com.aspose.slides/presentationfactory/#getPresentationInfo-java.lang.String-) to obtain an [IPresentationInfo](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentationinfo/) object, and then call [IPresentationInfo.readDocumentProperties](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentationinfo/#readDocumentProperties--) to read the document metadata. This approach does not create a [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) instance or require you to traverse the complete presentation object model.
The extended properties exposed by [IDocumentProperties](https://reference.aspose.com/slides/java/com.aspose.slides/idocumentproperties/) provide the following inventory values:
| Method | Inventory value |
| --- | --- |
| [getSlides](https://reference.aspose.com/slides/java/com.aspose.slides/idocumentproperties/#getSlides--) | Total number of slides. |
| [getHiddenSlides](https://reference.aspose.com/slides/java/com.aspose.slides/idocumentproperties/#getHiddenSlides--) | Number of hidden slides. |
| [getNotes](https://reference.aspose.com/slides/java/com.aspose.slides/idocumentproperties/#getNotes--) | Number of slides that contain notes. |
| [getParagraphs](https://reference.aspose.com/slides/java/com.aspose.slides/idocumentproperties/#getParagraphs--) | Total number of paragraphs, when available. |
| [getWords](https://reference.aspose.com/slides/java/com.aspose.slides/idocumentproperties/#getWords--) | Total number of words. |
| [getMultimediaClips](https://reference.aspose.com/slides/java/com.aspose.slides/idocumentproperties/#getMultimediaClips--) | Total number of audio and video clips. |
The following example reads these values without creating a [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) object and prints a compact inventory. It also combines [getHeadingPairs](https://reference.aspose.com/slides/java/com.aspose.slides/idocumentproperties/#getHeadingPairs--) with [getTitlesOfParts](https://reference.aspose.com/slides/java/com.aspose.slides/idocumentproperties/#getTitlesOfParts--) to display content groups such as fonts, themes, and slide titles.
```java
import com.aspose.slides.IDocumentProperties;
import com.aspose.slides.IHeadingPair;
import com.aspose.slides.IPresentationInfo;
import com.aspose.slides.LoadFormat;
import com.aspose.slides.PresentationFactory;
import java.nio.file.Paths;
String filePath = "sample.pptx";
IPresentationInfo presentationInfo = PresentationFactory.getInstance().getPresentationInfo(filePath);
IDocumentProperties documentProperties = presentationInfo.readDocumentProperties();
int loadFormat = presentationInfo.getLoadFormat();
String formatName = "Other (" + loadFormat + ")";
if (loadFormat == LoadFormat.Pptx) {
formatName = "PPTX";
} else if (loadFormat == LoadFormat.Ppt) {
formatName = "PPT";
} else if (loadFormat == LoadFormat.Odp) {
formatName = "ODP";
}
System.out.println("File: " + Paths.get(filePath).getFileName());
System.out.println("Format: " + formatName);
System.out.println("Title: " + documentProperties.getTitle());
System.out.println("Author: " + documentProperties.getAuthor());
System.out.println("Statistics:");
System.out.println(" Slides: " + documentProperties.getSlides());
System.out.println(" Hidden slides: " + documentProperties.getHiddenSlides());
System.out.println(" Slides with notes: " + documentProperties.getNotes());
System.out.println(" Paragraphs: " + documentProperties.getParagraphs());
System.out.println(" Words: " + documentProperties.getWords());
System.out.println(" Multimedia clips: " + documentProperties.getMultimediaClips());
IHeadingPair[] headingPairs = documentProperties.getHeadingPairs();
String[] titlesOfParts = documentProperties.getTitlesOfParts();
headingPairs = headingPairs != null ? headingPairs : new IHeadingPair[0];
titlesOfParts = titlesOfParts != null ? titlesOfParts : new String[0];
int partIndex = 0;
if (headingPairs.length == 0 || titlesOfParts.length == 0) {
System.out.println("Content groups: not available");
} else {
System.out.println("Content groups:");
for (IHeadingPair headingPair : headingPairs) {
System.out.println(" " + headingPair.getName() + " (" + headingPair.getCount() + ")");
for (int partOffset = 0; partOffset < headingPair.getCount() && partIndex < titlesOfParts.length; partOffset++) {
System.out.println(" - " + titlesOfParts[partIndex]);
partIndex++;
}
}
if (partIndex < titlesOfParts.length) {
System.out.println(" Other parts:");
while (partIndex < titlesOfParts.length) {
System.out.println(" - " + titlesOfParts[partIndex]);
partIndex++;
}
}
}
```
Each [IHeadingPair](https://reference.aspose.com/slides/java/com.aspose.slides/iheadingpair/) supplies a group name and the number of items in that group. [IDocumentProperties.getTitlesOfParts](https://reference.aspose.com/slides/java/com.aspose.slides/idocumentproperties/#getTitlesOfParts--) returns a flat, ordered array, so consume the number of consecutive titles specified by each heading pair.
### **Stored Metadata and Format Limitations**
The inventory properties returned by [IPresentationInfo.readDocumentProperties](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentationinfo/#readDocumentProperties--) reflect metadata available in the source document. Aspose.Slides does not load and traverse the presentation object model to recalculate these values for this call. Missing properties are represented by default values, and stored values may be stale if the application that last saved the file did not update its document properties.
- **PPTX:** The format provides extended document properties for slide, note, hidden-slide, paragraph, word, and multimedia counts, as well as heading pairs and part titles. Availability depends on which properties were written by the document producer.
- **PPT:** The binary format can store corresponding document-summary properties. If a property is absent or was not refreshed by the document producer, Aspose.Slides returns its stored or default value rather than calculating it from the slides.
- **ODP:** OpenDocument metadata provides general document statistics, such as page, paragraph, and word counts, but these values do not map to every PowerPoint-specific extended property. Hidden-slide, notes-slide, multimedia, heading-pair, and part-title metadata may be unavailable, and the inventory properties may return default values. Do not treat a zero value or an empty array as authoritative proof that the corresponding content is absent.
Use the lightweight metadata approach for inventories and preliminary checks. Load the presentation and inspect its live object model when the result must reflect in-memory changes or when you need to verify the actual presentation content.
## **Update Presentation Properties**
The properties returned by [IPresentationInfo.readDocumentProperties](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentationinfo/#readDocumentProperties--) can also be changed without creating a [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) instance. Apply the changes with [IPresentationInfo.updateDocumentProperties](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentationinfo/#updateDocumentProperties-com.aspose.slides.IDocumentProperties-), and then write the bound presentation with [IPresentationInfo.writeBindedPresentation](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentationinfo/#writeBindedPresentation-java.io.OutputStream-).
The following image shows the original document properties.

The following example changes the title and last-saved time and writes the result to a new file:
```java
import com.aspose.slides.IDocumentProperties;
import com.aspose.slides.IPresentationInfo;
import com.aspose.slides.PresentationFactory;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.Date;
String sourceFile = "sample.pptx";
String outputFile = "sample_with_updated_properties.pptx";
IPresentationInfo presentationInfo = PresentationFactory.getInstance().getPresentationInfo(sourceFile);
IDocumentProperties documentProperties = presentationInfo.readDocumentProperties();
documentProperties.setTitle("Quarterly sales report");
documentProperties.setLastSavedTime(new Date());
presentationInfo.updateDocumentProperties(documentProperties);
try (OutputStream outputStream = new FileOutputStream(outputFile)) {
presentationInfo.writeBindedPresentation(outputStream);
}
```
The following image shows the updated document properties.

## **Useful Links**
For related security checks and protection settings, see the following articles:
- [Password-Protect Presentations](https://docs.aspose.com/slides/java/password-protected-presentation/)
- [Write-Protect Presentations](https://docs.aspose.com/slides/java/write-protected-presentation/)
## **FAQ**
**How can I check whether fonts are embedded and which ones they are?**
Load the presentation and use [Presentation.getFontsManager](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#getFontsManager--). Call [IFontsManager.getEmbeddedFonts](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsmanager/#getEmbeddedFonts--) to obtain the embedded fonts and [IFontsManager.getFonts](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsmanager/#getFonts--) to obtain the fonts used by the presentation. Compare the two results to find fonts that are required for rendering but are not embedded.
**How can I quickly tell if the file has hidden slides and how many?**
When stored document metadata is sufficient, read [IDocumentProperties.getHiddenSlides](https://reference.aspose.com/slides/java/com.aspose.slides/idocumentproperties/#getHiddenSlides--) through [PresentationFactory.getPresentationInfo](https://reference.aspose.com/slides/java/com.aspose.slides/presentationfactory/#getPresentationInfo-java.lang.String-) and [IPresentationInfo.readDocumentProperties](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentationinfo/#readDocumentProperties--). This is suitable for a lightweight inventory. If the presentation has been modified in memory, the stored metadata may be missing or stale, or you need to verify live values, iterate through [Presentation.getSlides](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#getSlides--) and inspect each slide's [ISlide.getHidden](https://reference.aspose.com/slides/java/com.aspose.slides/islide/#getHidden--) method instead.
**Can I detect whether custom slide size and orientation are used, and whether they differ from the defaults?**
Yes. Load the presentation and call [Presentation.getSlideSize](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#getSlideSize--). Use [ISlideSize.getType](https://reference.aspose.com/slides/java/com.aspose.slides/islidesize/#getType--), [ISlideSize.getSize](https://reference.aspose.com/slides/java/com.aspose.slides/islidesize/#getSize--), and [ISlideSize.getOrientation](https://reference.aspose.com/slides/java/com.aspose.slides/islidesize/#getOrientation--) to compare the current settings with the expected preset and dimensions.
**Is there a quick way to see if charts reference external data sources?**
Yes. Locate each [Chart](https://reference.aspose.com/slides/java/com.aspose.slides/chart/) and call [IChartData.getDataSourceType](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/#getDataSourceType--). For an external workbook, call [IChartData.getExternalWorkbookPath](https://reference.aspose.com/slides/java/com.aspose.slides/ichartdata/#getExternalWorkbookPath--). The data source type and path identify an external reference, but verifying whether the target is available requires a separate resource check.
**How can I assess 'heavy' slides that may slow rendering or PDF export?**
There is no single complexity property. Traverse [Presentation.getSlides](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#getSlides--) and each slide's [IBaseSlide.getShapes](https://reference.aspose.com/slides/java/com.aspose.slides/ibaseslide/#getShapes--) collection. Use shape counts and the presence of large images, effects, animations, or multimedia as screening signals, and measure a representative render or export before treating a slide as a confirmed performance bottleneck.
# Examples
> Explore Aspose.Slides for Java code examples with Java snippets for creating, editing, and converting presentations in PPT, PPTX, and ODP formats.
Source: https://docs.aspose.com/slides/java/examples/
Updated: 2026-02-19
---
lastmod: 2026-02-19T15:53:31+06:00
title: Examples
type: docs
weight: 40
url: /java/examples/
keywords:
- code example
- PowerPoint
- OpenDocument
- presentation
- Java
- Aspose.Slides
description: "Explore Aspose.Slides for Java code examples with Java snippets for creating, editing, and converting presentations in PPT, PPTX, and ODP formats."
---
# Elements
> Browse Aspose.Slides for Java elements examples: add, style, and animate shapes, text, images, charts, and tables in PowerPoint and OpenDocument presentations.
Source: https://docs.aspose.com/slides/java/examples/elements/
Updated: 2026-02-19
---
lastmod: 2026-02-19T15:53:31+06:00
title: Elements
type: docs
weight: 40
url: /java/examples/elements/
keywords:
- code example
- element
- PowerPoint
- OpenDocument
- presentation
- Java
- Aspose.Slides
description: "Browse Aspose.Slides for Java elements examples: add, style, and animate shapes, text, images, charts, and tables in PowerPoint and OpenDocument presentations."
---
# ActiveX
> See Aspose.Slides for Java ActiveX examples: insert, configure, and control ActiveX objects in PPT and PPTX presentations with clear Java code.
Source: https://docs.aspose.com/slides/java/examples/elements/activex/
Updated: 2026-08-05
This article demonstrates how to add, access, remove, and configure ActiveX controls in a presentation using **Aspose.Slides for Java**.
## **Add an ActiveX Control**
Insert a new ActiveX control and optionally set its properties.
```java
import com.aspose.slides.*;
static void addActiveX() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
// Add a new ActiveX control.
IControl control = slide.getControls().addControl(ControlType.WindowsMediaPlayer, 50, 50, 100, 50);
// Optionally set some properties.
control.getProperties().add("Value", "Default text");
presentation.save("add_activex.pptm", SaveFormat.Pptm);
} finally {
presentation.dispose();
}
}
```
## **Access an ActiveX Control**
Read information from the first ActiveX control on the slide.
```java
import com.aspose.slides.*;
static void accessActiveX() {
Presentation presentation = new Presentation("add_activex.pptm");
try {
ISlide slide = presentation.getSlides().get_Item(0);
if (slide.getControls().size() > 0) {
// Access the first ActiveX control.
IControl control = slide.getControls().get_Item(0);
System.out.println("Control Name: " + control.getName());
System.out.println("Value: " + control.getProperties().get_Item("Value"));
}
} finally {
presentation.dispose();
}
}
```
## **Remove an ActiveX Control**
Delete an existing ActiveX control from the slide.
```java
import com.aspose.slides.*;
public static void removeActiveX() {
Presentation presentation = new Presentation("add_activex.pptm");
try {
ISlide slide = presentation.getSlides().get_Item(0);
if (slide.getControls().size() > 0) {
// Remove the first ActiveX control.
slide.getControls().removeAt(0);
}
presentation.save("removed_activex.pptm", SaveFormat.Pptm);
} finally {
presentation.dispose();
}
}
```
## **Set ActiveX Properties**
Add a control and configure several ActiveX properties.
```java
import com.aspose.slides.*;
public static void setActiveXProperties() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
// Add a Windows Media Player control and configure properties.
IControl control = slide.getControls().addControl(ControlType.WindowsMediaPlayer, 50, 50, 150, 50);
control.getProperties().set_Item("Caption", "Click Me");
control.getProperties().set_Item("Enabled", "true");
presentation.save("set_activex_props.pptm", SaveFormat.Pptm);
} finally {
presentation.dispose();
}
}
```
## Related articles
- [Manage PowerPoint Shapes in Java](https://docs.aspose.com/slides/java/powerpoint-shapes/)
- [Manage ActiveX Controls in Presentations Using Java](https://docs.aspose.com/slides/java/activex/)
# Animation
> Explore Aspose.Slides for Java animation examples: add, sequence, and customize effects and transitions with Java for PPT, PPTX, and ODP presentations.
Source: https://docs.aspose.com/slides/java/examples/elements/animation/
Updated: 2026-08-05
This article demonstrates how to create simple animations and manage their sequence using **Aspose.Slides for Java**.
## **Add an Animation**
Create a rectangle shape and apply a fade effect triggered on click.
```java
import com.aspose.slides.*;
static void addAnimation() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 50, 50, 100, 100);
// Fade effect.
slide.getTimeline().getMainSequence().addEffect(
shape, EffectType.Fade, EffectSubtype.None, EffectTriggerType.OnClick
);
} finally {
presentation.dispose();
}
}
```
## **Access an Animation**
Retrieve the first animation effect from the slide timeline.
```java
import com.aspose.slides.*;
static void accessAnimation() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 50, 50, 100, 100);
slide.getTimeline().getMainSequence().addEffect(
shape, EffectType.Fade, EffectSubtype.None, EffectTriggerType.OnClick);
// Access the first animation effect.
IEffect effect = slide.getTimeline().getMainSequence().get_Item(0);
} finally {
presentation.dispose();
}
}
```
## **Remove an Animation**
Remove an animation effect from the sequence.
```java
import com.aspose.slides.*;
static void removeAnimation() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 50, 50, 100, 100);
IEffect effect = slide.getTimeline().getMainSequence().addEffect(
shape, EffectType.Fade, EffectSubtype.None, EffectTriggerType.OnClick);
// Remove the effect.
slide.getTimeline().getMainSequence().remove(effect);
} finally {
presentation.dispose();
}
}
```
## **Sequence Animations**
Add multiple effects and demonstrate the order in which animations occur.
```java
import com.aspose.slides.*;
static void sequenceAnimations() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape1 = slide.getShapes().addAutoShape(ShapeType.Rectangle, 50, 50, 100, 100);
IAutoShape shape2 = slide.getShapes().addAutoShape(ShapeType.Ellipse, 200, 50, 100, 100);
ISequence sequence = slide.getTimeline().getMainSequence();
sequence.addEffect(shape1, EffectType.Fly, EffectSubtype.Bottom, EffectTriggerType.OnClick);
sequence.addEffect(shape2, EffectType.Fly, EffectSubtype.Bottom, EffectTriggerType.OnClick);
} finally {
presentation.dispose();
}
}
```
## Related articles
- [Slide Transition](https://docs.aspose.com/slides/java/examples/elements/slide-transition/)
- [Animate PowerPoint Text in Java](https://docs.aspose.com/slides/java/animated-text/)
- [Enhance PowerPoint Presentations with Animations in Java](https://docs.aspose.com/slides/java/powerpoint-animation/)
# Audio
> Discover Aspose.Slides for Java audio examples: insert, play, trim, and extract sound in PPT, PPTX, and ODP presentations with clear Java code.
Source: https://docs.aspose.com/slides/java/examples/elements/audio/
Updated: 2026-08-05
This article demonstrates how to embed audio frames and control playback with **Aspose.Slides for Java**. The following examples show basic audio operations.
## **Add an Audio Frame**
Insert an empty audio frame that can later hold embedded sound data.
```java
import com.aspose.slides.*;
import java.io.ByteArrayInputStream;
static void addAudio() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
// Create an empty audio frame (audio will be embedded later).
IAudioFrame audioFrame = slide.getShapes().addAudioFrameEmbedded(
50, 50, 100, 100, new ByteArrayInputStream(new byte[0]));
} finally {
presentation.dispose();
}
}
```
## **Access an Audio Frame**
This code retrieves the first audio frame on a slide.
```java
import com.aspose.slides.*;
import java.io.ByteArrayInputStream;
static void accessAudio() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
slide.getShapes().addAudioFrameEmbedded(
50, 50, 100, 100, new ByteArrayInputStream(new byte[0]));
// Access the first audio frame on the slide.
IAudioFrame firstAudio = null;
for (IShape shape : slide.getShapes()) {
if (shape instanceof IAudioFrame) {
firstAudio = (IAudioFrame) shape;
break;
}
}
} finally {
presentation.dispose();
}
}
```
## **Remove an Audio Frame**
Delete a previously added audio frame.
```java
import com.aspose.slides.*;
import java.io.ByteArrayInputStream;
static void removeAudio() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAudioFrame audioFrame = slide.getShapes().addAudioFrameEmbedded(
50, 50, 100, 100, new ByteArrayInputStream(new byte[0]));
// Remove the audio frame.
slide.getShapes().remove(audioFrame);
} finally {
presentation.dispose();
}
}
```
## **Set Audio Playback**
Configure the audio frame to play automatically when the slide appears.
```java
import com.aspose.slides.*;
import java.io.ByteArrayInputStream;
static void setAudioPlayback() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAudioFrame audioFrame = slide.getShapes().addAudioFrameEmbedded(
50, 50, 100, 100, new ByteArrayInputStream(new byte[0]));
// Play automatically when the slide appears.
audioFrame.setPlayMode(AudioPlayModePreset.Auto);
} finally {
presentation.dispose();
}
}
```
## Related articles
- [Video](https://docs.aspose.com/slides/java/examples/elements/video/)
- [Manage Audio in Presentations Using Java](https://docs.aspose.com/slides/java/audio-frame/)
# Chart
> Master charts with Aspose.Slides for Java: create, format, bind data, and export charts in PPT, PPTX, and ODP with Java examples.
Source: https://docs.aspose.com/slides/java/examples/elements/chart/
Updated: 2026-08-05
Examples for adding, accessing, removing, and updating different chart types with **Aspose.Slides for Java**. The snippets below demonstrate basic chart operations.
## **Add a Chart**
This method adds a simple area chart to the first slide.
```java
import com.aspose.slides.*;
static void addChart() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
// Add a simple area chart to the first slide.
IChart chart = slide.getShapes().addChart(ChartType.Area, 50, 50, 400, 300);
} finally {
presentation.dispose();
}
}
```
## **Access a Chart**
After creating a chart, you can retrieve it through the shape collection.
```java
import com.aspose.slides.*;
static void accessChart() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Line, 50, 50, 400, 300);
// Access the first chart on the slide.
IChart firstChart = null;
for (IShape shape : slide.getShapes()) {
if (shape instanceof IChart) {
firstChart = (IChart) shape;
break;
}
}
} finally {
presentation.dispose();
}
}
```
## **Remove a Chart**
The following code removes a chart from a slide.
```java
import com.aspose.slides.*;
static void removeChart() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Pie, 50, 50, 400, 300);
// Remove the chart.
slide.getShapes().remove(chart);
} finally {
presentation.dispose();
}
}
```
## **Update Chart Data**
You can change chart properties such as the title.
```java
import com.aspose.slides.*;
static void updateChartData() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Column3D, 50, 50, 400, 300);
// Change the chart title.
chart.getChartTitle().addTextFrameForOverriding("Sales Report");
} finally {
presentation.dispose();
}
}
```
## Related articles
- [Create and Customize PowerPoint Charts in Java](https://docs.aspose.com/slides/java/powerpoint-charts/)
# Comment
> Work with slide comments in Aspose.Slides for Java: add, reply, edit, resolve, and export comments in PPT, PPTX, and ODP presentations with Java code examples.
Source: https://docs.aspose.com/slides/java/examples/elements/comment/
Updated: 2026-08-05
This article demonstrates adding, reading, removing, and replying to modern comments using **Aspose.Slides for Java**.
## **Add a Modern Comment**
Create a comment authored by a user and save the presentation.
```java
import com.aspose.slides.*;
import java.awt.geom.Point2D;
static void addModernComment() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
ICommentAuthor author = presentation.getCommentAuthors().addAuthor("User", "U1");
author.getComments().addModernComment(
"This is a modern comment", slide, null, new Point2D.Float(100, 100), new java.util.Date());
presentation.save("modern_comment.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
}
```
## **Access a Modern Comment**
Read a modern comment from an existing presentation.
```java
import com.aspose.slides.*;
static void accessModernComment() {
Presentation presentation = new Presentation("modern_comment.pptx");
try {
ICommentAuthor author = presentation.getCommentAuthors().get_Item(0);
IModernComment comment = (IModernComment) author.getComments().get_Item(0);
System.out.println("Author: " + author.getName() + ", Comment: " + comment.getText() + ", Position: " + comment.getPosition());
} finally {
presentation.dispose();
}
}
```
## **Remove a Modern Comment**
Remove a comment and save the updated file.
```java
import com.aspose.slides.*;
static void removeModernComment() {
Presentation presentation = new Presentation("modern_comment.pptx");
try {
ICommentAuthor author = presentation.getCommentAuthors().get_Item(0);
IComment comment = author.getComments().get_Item(0);
comment.remove();
presentation.save("modern_comment_removed.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
}
```
## **Reply to a Modern Comment**
Add replies to a parent modern comment.
```java
import com.aspose.slides.*;
import java.awt.geom.Point2D;
static void replyToModernComment() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
ICommentAuthor author = presentation.getCommentAuthors().addAuthor("User", "U1");
IModernComment parentComment = author.getComments().addModernComment(
"Parent comment", slide, null, new Point2D.Float(100, 100), new java.util.Date());
IModernComment reply1 = author.getComments().addModernComment(
"Reply 1", slide, null, new Point2D.Float(110, 100), new java.util.Date());
IModernComment reply2 = author.getComments().addModernComment(
"Reply 2", slide, null, new Point2D.Float(120, 100), new java.util.Date());
reply1.setParentComment(parentComment);
reply2.setParentComment(parentComment);
presentation.save("modern_comment_replies.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
}
```
## Related articles
- [Manage Presentation Comments in Java](https://docs.aspose.com/slides/java/presentation-comments/)
# Connector
> Learn how to add, route, and style connectors between shapes using Aspose.Slides for Java, with Java examples for PPT, PPTX, and ODP presentations.
Source: https://docs.aspose.com/slides/java/examples/elements/connector/
Updated: 2026-08-05
This article demonstrates how to connect shapes with connectors and change their targets using **Aspose.Slides for Java**.
## **Add a Connector**
Insert a connector shape between two points on the slide.
```java
import com.aspose.slides.*;
static void addConnector() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IConnector connector = slide.getShapes().addConnector(ShapeType.BentConnector2, 0, 0, 100, 100);
} finally {
presentation.dispose();
}
}
```
## **Access a Connector**
Retrieve the first connector shape added to a slide.
```java
import com.aspose.slides.*;
static void accessConnector() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
slide.getShapes().addConnector(ShapeType.BentConnector2, 0, 0, 100, 100);
// Access the first connector on the slide.
IConnector connector = null;
for (IShape shape : slide.getShapes()) {
if (shape instanceof IConnector) {
connector = (IConnector) shape;
break;
}
}
} finally {
presentation.dispose();
}
}
```
## **Remove a Connector**
Delete a connector from the slide.
```java
import com.aspose.slides.*;
static void removeConnector() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IConnector connector = slide.getShapes().addConnector(ShapeType.BentConnector2, 0, 0, 100, 100);
slide.getShapes().remove(connector);
} finally {
presentation.dispose();
}
}
```
## **Reconnect Shapes**
Attach a connector to two shapes by assigning start and end targets.
```java
import com.aspose.slides.*;
static void reconnectShapes() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape1 = slide.getShapes().addAutoShape(ShapeType.Rectangle, 0, 0, 50, 50);
IAutoShape shape2 = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 50, 50);
IConnector connector = slide.getShapes().addConnector(ShapeType.BentConnector2, 0, 0, 100, 100);
connector.setStartShapeConnectedTo(shape1);
connector.setEndShapeConnectedTo(shape2);
} finally {
presentation.dispose();
}
}
```
## Related articles
- [Shape Types in Aspose.Slides for Java](https://docs.aspose.com/slides/java/shape-types/)
# Group Shape
> Manage grouped shapes in Aspose.Slides for Java: create, nest, align, reorder, and style group shapes with Java examples in PPT, PPTX, and ODP presentations.
Source: https://docs.aspose.com/slides/java/examples/elements/group-shape/
Updated: 2026-08-05
Examples for creating groups of shapes, accessing them, ungrouping, and removal using **Aspose.Slides for Java**.
## **Add a Group Shape**
Create a group containing two basic shapes.
```java
import com.aspose.slides.*;
static void addGroupShape() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IGroupShape group = slide.getShapes().addGroupShape();
group.getShapes().addAutoShape(ShapeType.Rectangle, 0, 0, 50, 50);
group.getShapes().addAutoShape(ShapeType.Ellipse, 60, 0, 50, 50);
} finally {
presentation.dispose();
}
}
```
## **Access a Group Shape**
Retrieve the first group shape from a slide.
```java
import com.aspose.slides.*;
static void accessGroupShape() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IGroupShape group = slide.getShapes().addGroupShape();
group.getShapes().addAutoShape(ShapeType.Rectangle, 0, 0, 50, 50);
IGroupShape firstGroup = null;
for (IShape shape : slide.getShapes()) {
if (shape instanceof IGroupShape) {
firstGroup = (IGroupShape) shape;
break;
}
}
} finally {
presentation.dispose();
}
}
```
## **Remove a Group Shape**
Delete a group shape from the slide.
```java
import com.aspose.slides.*;
static void removeGroupShape() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IGroupShape group = slide.getShapes().addGroupShape();
slide.getShapes().remove(group);
} finally {
presentation.dispose();
}
}
```
## **Ungroup Shapes**
Move shapes out of a group container.
```java
import com.aspose.slides.*;
static void ungroupShapes() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IGroupShape group = slide.getShapes().addGroupShape();
IAutoShape rect = group.getShapes().addAutoShape(ShapeType.Rectangle, 0, 0, 50, 50);
// Move shape out of the group.
slide.getShapes().addClone(rect);
group.getShapes().remove(rect);
} finally {
presentation.dispose();
}
}
```
## Related articles
- [Group Presentation Shapes in Java](https://docs.aspose.com/slides/java/group/)
# Header Footer
> Control slide headers and footers with Aspose.Slides for Java: add dates, slide numbers, and custom text in PPT, PPTX, and ODP with Java examples.
Source: https://docs.aspose.com/slides/java/examples/elements/header-footer/
Updated: 2026-08-05
This article demonstrates how to add footers and update date and time placeholders using **Aspose.Slides for Java**.
## **Add a Footer**
Add text to the footer area of a slide and make it visible.
```java
import com.aspose.slides.*;
static void addHeaderFooter() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
slide.getHeaderFooterManager().setFooterText("My footer");
slide.getHeaderFooterManager().setFooterVisibility(true);
} finally {
presentation.dispose();
}
}
```
## **Update Date and Time**
Modify the date and time placeholder on a slide.
```java
import com.aspose.slides.*;
static void updateDateTime() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
slide.getHeaderFooterManager().setDateTimeText("01/01/2024");
slide.getHeaderFooterManager().setDateTimeVisibility(true);
} finally {
presentation.dispose();
}
}
```
## Related articles
- [Manage Presentation Headers and Footers in Java](https://docs.aspose.com/slides/java/presentation-header-and-footer/)
- [How to Add Headers & Footers to Presentations in Java](https://docs.aspose.com/slides/java/how-to-add-header-footer-in-a-presentation/)
# Hyperlink
> Add and manage hyperlinks in Aspose.Slides for Java: link text, shapes, and images, set targets and actions for PPT, PPTX, and ODP with Java examples.
Source: https://docs.aspose.com/slides/java/examples/elements/hyperlink/
Updated: 2026-08-05
This article demonstrates adding, accessing, removing, and updating hyperlinks on shapes using **Aspose.Slides for Java**.
## **Add a Hyperlink**
Create a rectangle shape with a hyperlink pointing to an external website.
```java
import com.aspose.slides.*;
static void addHyperlink() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 50, 50, 150, 50);
shape.getTextFrame().setText("Aspose");
IParagraph paragraph = shape.getTextFrame().getParagraphs().get_Item(0);
IPortion textPortion = paragraph.getPortions().get_Item(0);
textPortion.getPortionFormat().setHyperlinkClick(new Hyperlink("https://www.aspose.com"));
} finally {
presentation.dispose();
}
}
```
## **Access a Hyperlink**
Read hyperlink information from a shape's text portion.
```java
import com.aspose.slides.*;
static void accessHyperlink() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 50, 50, 150, 50);
shape.getTextFrame().setText("Aspose");
IParagraph paragraph = shape.getTextFrame().getParagraphs().get_Item(0);
IPortion textPortion = paragraph.getPortions().get_Item(0);
textPortion.getPortionFormat().setHyperlinkClick(new Hyperlink("https://www.aspose.com"));
IHyperlink hyperlink = textPortion.getPortionFormat().getHyperlinkClick();
} finally {
presentation.dispose();
}
}
```
## **Remove a Hyperlink**
Clear the hyperlink from a shape's text.
```java
import com.aspose.slides.*;
static void removeHyperlink() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 50, 50, 150, 50);
shape.getTextFrame().setText("Aspose");
IParagraph paragraph = shape.getTextFrame().getParagraphs().get_Item(0);
IPortion textPortion = paragraph.getPortions().get_Item(0);
textPortion.getPortionFormat().setHyperlinkClick(new Hyperlink("https://www.aspose.com"));
textPortion.getPortionFormat().setHyperlinkClick(null);
} finally {
presentation.dispose();
}
}
```
## **Update a Hyperlink**
Change the target of an existing hyperlink. Use `HyperlinkManager` to modify text that already contains a hyperlink, which mimics how PowerPoint updates hyperlinks safely.
```java
import com.aspose.slides.*;
static void updateHyperlink() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 50, 50, 150, 50);
shape.getTextFrame().setText("Aspose");
IParagraph paragraph = shape.getTextFrame().getParagraphs().get_Item(0);
IPortion textPortion = paragraph.getPortions().get_Item(0);
textPortion.getPortionFormat().setHyperlinkClick(new Hyperlink("https://old.example.com"));
// Changing a hyperlink inside existing text should be done via
// HyperlinkManager rather than setting the property directly.
// This mimics how PowerPoint safely updates hyperlinks.
textPortion.getPortionFormat().getHyperlinkManager().setExternalHyperlinkClick("https://new.example.com");
} finally {
presentation.dispose();
}
}
```
## Related articles
- [Manage Presentation Hyperlinks in Java](https://docs.aspose.com/slides/java/manage-hyperlinks/)
# Ink
> Work with Ink in Aspose.Slides for Java: draw, import, and edit strokes, adjust color and width, and export to PPT, PPTX, and ODP using Java examples.
Source: https://docs.aspose.com/slides/java/examples/elements/ink/
Updated: 2026-08-05
This article provides examples of accessing existing ink shapes and removing them using **Aspose.Slides for Java**.
> ❗ **Note:** Ink shapes represent user input from specialized devices. Aspose.Slides cannot create new ink strokes programmatically, but you can read and modify existing ink.
## **Access Ink**
Read the tags from the first ink shape on a slide.
```java
import com.aspose.slides.*;
static void accessInk() {
Presentation presentation = new Presentation("ink.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
IShape shape = slide.getShapes().get_Item(0);
if (shape instanceof IInk) {
IInk inkShape = (IInk) shape;
ITagCollection tags = inkShape.getCustomData().getTags();
if (tags.size() > 0) {
String tagName = tags.getNameByIndex(0);
// Use tagName as needed.
}
}
} finally {
presentation.dispose();
}
}
```
## **Remove Ink**
Delete an ink shape from the slide if one exists.
```java
import com.aspose.slides.*;
static void removeInk() {
Presentation presentation = new Presentation("ink.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
IInk ink = null;
for (IShape shape : slide.getShapes()) {
if (shape instanceof IInk) {
ink = (IInk) shape;
break;
}
}
if (ink != null) {
slide.getShapes().remove(ink);
}
} finally {
presentation.dispose();
}
}
```
# Layout Slide
> Master layout slides in Aspose.Slides for Java: choose, apply, and customize slide layouts, placeholders, and masters with Java examples for PPT, PPTX, and ODP presentations.
Source: https://docs.aspose.com/slides/java/examples/elements/layout-slide/
Updated: 2026-08-05
This article demonstrates how to work with **Layout Slides** in Aspose.Slides for Java. A layout slide defines the design and formatting inherited by normal slides. You can add, access, clone, and remove layout slides, as well as clean up unused ones to reduce presentation size.
## **Add a Layout Slide**
You can create a custom layout slide to define reusable formatting. For example, you might add a text box that appears on all slides using this layout.
```java
import com.aspose.slides.*;
static void addLayoutSlide() {
Presentation presentation = new Presentation();
try {
IMasterSlide masterSlide = presentation.getMasters().get_Item(0);
// Create a layout slide with a blank layout type and a custom name.
ILayoutSlide layoutSlide = presentation.getLayoutSlides().add(masterSlide, SlideLayoutType.Blank, "Main layout");
// Add a text box to the layout slide.
IAutoShape layoutTextBox = layoutSlide.getShapes().addAutoShape(ShapeType.Rectangle, 75, 75, 150, 150);
layoutTextBox.getTextFrame().setText("Layout Slide Text");
// Add two slides using this layout; both will inherit the text from the layout.
presentation.getSlides().addEmptySlide(layoutSlide);
presentation.getSlides().addEmptySlide(layoutSlide);
} finally {
presentation.dispose();
}
}
```
> 💡 **Note 1:** Layout slides act as templates for individual slides. You can define common elements once and reuse them across many slides.
> 💡 **Note 2:** When you add shapes or text to a layout slide, all slides based on that layout will display this shared content automatically.
> The screenshot below shows two slides, each inheriting a text box from the same layout slide.

## **Access a Layout Slide**
Layout slides can be accessed by index or by layout type (e.g., `Blank`, `Title`, `SectionHeader`, etc.).
```java
import com.aspose.slides.*;
static void accessLayoutSlide() {
Presentation presentation = new Presentation();
try {
// Access a layout slide by index.
ILayoutSlide firstLayoutSlide = presentation.getLayoutSlides().get_Item(0);
// Access a layout slide by type.
ILayoutSlide blankLayoutSlide = presentation.getLayoutSlides().getByType(SlideLayoutType.Blank);
} finally {
presentation.dispose();
}
}
```
## **Remove a Layout Slide**
You can remove a specific layout slide if it's no longer needed.
```java
import com.aspose.slides.*;
static void removeLayoutSlide() {
Presentation presentation = new Presentation();
try {
// Get a layout slide by type and remove it.
ILayoutSlide blankLayoutSlide = presentation.getLayoutSlides().getByType(SlideLayoutType.Custom);
presentation.getLayoutSlides().remove(blankLayoutSlide);
} finally {
presentation.dispose();
}
}
```
## **Remove Unused Layout Slides**
To reduce the presentation size, you may want to remove layout slides that are not used by any normal slides.
```java
import com.aspose.slides.*;
static void removeUnusedLayoutSlides() {
Presentation presentation = new Presentation();
try {
// Automatically removes all layout slides not referenced by any slide.
presentation.getLayoutSlides().removeUnused();
} finally {
presentation.dispose();
}
}
```
## **Clone a Layout Slide**
You can duplicate a layout slide using the `addClone` method.
```java
import com.aspose.slides.*;
static void cloneLayoutSlides() {
Presentation presentation = new Presentation();
try {
// Get an existing layout slide by type.
ILayoutSlide blankLayoutSlide = presentation.getLayoutSlides().getByType(SlideLayoutType.Blank);
// Clone the layout slide to the end of the layout slide collection.
ILayoutSlide clonedLayoutSlide = presentation.getLayoutSlides().addClone(blankLayoutSlide);
} finally {
presentation.dispose();
}
}
```
> ✅ **Summary:** Layout slides are powerful tools for managing consistent formatting across slides. Aspose.Slides allows full control over creating, managing, and optimizing layout slides.
## Related articles
- [Master Slide](https://docs.aspose.com/slides/java/examples/elements/master-slide/)
- [Manage Presentation Slide Masters in Java](https://docs.aspose.com/slides/java/slide-master/)
- [Apply or Change Slide Layouts in Java](https://docs.aspose.com/slides/java/slide-layout/)
# Master Slide
> Explore Aspose.Slides for Java master slide examples: create, edit, and style masters, placeholders, and themes in PPT, PPTX, and ODP with clear Java code.
Source: https://docs.aspose.com/slides/java/examples/elements/master-slide/
Updated: 2026-08-05
Master slides form the top level of the slide inheritance hierarchy in PowerPoint. A **master slide** defines common design elements such as backgrounds, logos, and text formatting. **Layout slides** inherit from master slides, and **normal slides** inherit from layout slides.
This article demonstrates how to create, modify, and manage master slides using Aspose.Slides for Java.
## **Add a Master Slide**
This example shows how to create a new master slide by cloning the default one. It then adds a company name banner to all slides through layout inheritance.
```java
import com.aspose.slides.*;
import java.awt.Color;
static void addMasterSlide() {
Presentation presentation = new Presentation();
try {
// Clone the default master slide.
IMasterSlide defaultMasterSlide = presentation.getMasters().get_Item(0);
IMasterSlide newMasterSlide = presentation.getMasters().addClone(defaultMasterSlide);
// Add a banner with company name to the top of the master slide.
IAutoShape textBox = newMasterSlide.getShapes().addAutoShape(ShapeType.Rectangle, 0, 0, 720, 25);
textBox.getTextFrame().setText("Company Name");
IParagraph paragraph = textBox.getTextFrame().getParagraphs().get_Item(0);
paragraph.getParagraphFormat().getDefaultPortionFormat().getFillFormat().setFillType(FillType.Solid);
paragraph.getParagraphFormat().getDefaultPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
textBox.getFillFormat().setFillType(FillType.NoFill);
// Assign the new master slide to a layout slide.
ILayoutSlide layoutSlide = presentation.getLayoutSlides().get_Item(0);
layoutSlide.setMasterSlide(newMasterSlide);
// Assign the layout slide to the first slide in the presentation.
presentation.getSlides().get_Item(0).setLayoutSlide(layoutSlide);
} finally {
presentation.dispose();
}
}
```
> 💡 **Note 1:** Master slides provide a way to apply consistent branding or shared design elements across all slides. Any changes made to the master will automatically reflect on dependent layout and normal slides.
> 💡 **Note 2:** Any shapes or formatting added to a master slide are inherited by layout slides and, in turn, all normal slides using those layouts.
> The image below illustrates how a text box added on a master slide is automatically rendered on the final slide.

## **Access a Master Slide**
You can access master slides using the presentation master collection. Here’s how to retrieve and work with them:
```java
import com.aspose.slides.*;
static void accessMasterSlide() {
Presentation presentation = new Presentation();
try {
IMasterSlide firstMasterSlide = presentation.getMasters().get_Item(0);
// Change the background type.
firstMasterSlide.getBackground().setType(BackgroundType.OwnBackground);
} finally {
presentation.dispose();
}
}
```
## **Remove a Master Slide**
Master slides can be removed either by index or by reference.
```java
import com.aspose.slides.*;
static void removeMasterSlide() {
Presentation presentation = new Presentation("sample.pptx");
try {
// Remove a master slide by index.
presentation.getMasters().removeAt(0);
// Remove a master slide by reference.
IMasterSlide firstMasterSlide = presentation.getMasters().get_Item(0);
presentation.getMasters().remove(firstMasterSlide);
} finally {
presentation.dispose();
}
}
```
## **Remove Unused Master Slides**
Some presentations contain master slides that are not in use. Removing these slides can help reduce file size.
```java
import com.aspose.slides.*;
static void removeUnusedMasterSlide() {
Presentation presentation = new Presentation();
try {
// Remove all unused master slides (even those marked as Preserve).
presentation.getMasters().removeUnused(true);
} finally {
presentation.dispose();
}
}
```
## Related articles
- [Layout Slide](https://docs.aspose.com/slides/java/examples/elements/layout-slide/)
- [Manage Presentation Slide Masters in Java](https://docs.aspose.com/slides/java/slide-master/)
# Math Text
> Explore Aspose.Slides for Java MathematicalText examples: create and format equations, fractions, matrices, and symbols with Java in PPT, PPTX, and ODP presentations.
Source: https://docs.aspose.com/slides/java/examples/elements/math-text/
Updated: 2026-08-05
This article demonstrates working with mathematical text shapes and formatting equations using **Aspose.Slides for Java**.
## **Add Math Text**
Create a math shape containing a fraction and the Pythagorean formula.
```java
import com.aspose.slides.*;
static void addMathText() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
// Add a Math shape to the slide.
IAutoShape mathShape = slide.getShapes().addMathShape(0, 0, 720, 150);
// Access the math paragraph.
IParagraph paragraph = mathShape.getTextFrame().getParagraphs().get_Item(0);
IPortion textPortion = paragraph.getPortions().get_Item(0);
IMathParagraph mathParagraph = ((MathPortion) textPortion).getMathParagraph();
// Add a simple fraction: x / y.
IMathElement fraction = new MathematicalText("x").divide("y");
mathParagraph.add(new MathBlock(fraction));
// Add equation: c² = a² + b².
IMathBlock mathBlock = new MathematicalText("c")
.setSuperscript("2")
.join("=")
.join(new MathematicalText("a").setSuperscript("2"))
.join("+")
.join(new MathematicalText("b").setSuperscript("2"));
mathParagraph.add(mathBlock);
} finally {
presentation.dispose();
}
}
```
## **Access Math Text**
Locate a shape that contains a math paragraph on the slide.
```java
import com.aspose.slides.*;
static void accessMathText() {
Presentation presentation = new Presentation("sample.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
// Find the first shape that contains a math paragraph.
IAutoShape mathShape = null;
for (IShape shape : slide.getShapes()) {
if (shape instanceof IAutoShape) {
IAutoShape autoShape = (IAutoShape) shape;
ITextFrame textFrame = autoShape.getTextFrame();
if (textFrame != null) {
boolean hasMath = false;
for (IParagraph paragraph : textFrame.getParagraphs()) {
for (IPortion portion : paragraph.getPortions()) {
if (portion instanceof MathPortion) {
hasMath = true;
break;
}
}
if (hasMath) break;
}
if (hasMath) {
mathShape = autoShape;
break;
}
}
}
}
if (mathShape != null) {
IParagraph paragraph = mathShape.getTextFrame().getParagraphs().get_Item(0);
IPortion textPortion = paragraph.getPortions().get_Item(0);
IMathParagraph mathParagraph = ((MathPortion) textPortion).getMathParagraph();
// Example: create a fraction (not added here).
IMathElement fraction = new MathematicalText("x").divide("y");
// Use mathParagraph or fraction as needed...
}
} finally {
presentation.dispose();
}
}
```
## **Remove Math Text**
Delete a math shape from the slide.
```java
import com.aspose.slides.*;
static void removeMathText() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape mathShape = slide.getShapes().addMathShape(50, 50, 100, 50);
IParagraph paragraph = mathShape.getTextFrame().getParagraphs().get_Item(0);
IPortion textPortion = paragraph.getPortions().get_Item(0);
IMathParagraph mathParagraph = ((MathPortion) textPortion).getMathParagraph();
IMathElement fraction = new MathematicalText("x").divide("y");
mathParagraph.add(new MathBlock(fraction));
// Remove the math shape.
slide.getShapes().remove(mathShape);
} finally {
presentation.dispose();
}
}
```
## **Format Math Text**
Set font properties for a math portion.
```java
import com.aspose.slides.*;
static void formatMathText() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape mathShape = slide.getShapes().addMathShape(50, 50, 100, 50);
IParagraph paragraph = mathShape.getTextFrame().getParagraphs().get_Item(0);
IPortion textPortion = paragraph.getPortions().get_Item(0);
IMathParagraph mathParagraph = ((MathPortion) textPortion).getMathParagraph();
IMathElement fraction = new MathematicalText("x").divide("y");
mathParagraph.add(new MathBlock(fraction));
textPortion.getPortionFormat().setFontHeight(20);
} finally {
presentation.dispose();
}
}
```
## Related articles
- [Add Math Equations to PowerPoint Presentations in Java](https://docs.aspose.com/slides/java/powerpoint-math-equations/)
# Note
> Work with slide notes in Aspose.Slides for Java: add, read, edit, and export speaker notes in PPT, PPTX, and ODP using clear Java examples.
Source: https://docs.aspose.com/slides/java/examples/elements/note/
Updated: 2026-08-05
This article demonstrates how to add, read, remove, and update notes slides using **Aspose.Slides for Java**.
## **Add a Notes Slide**
Create a notes slide and assign text to it.
```java
import com.aspose.slides.*;
static void addNote() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
INotesSlide notesSlide = slide.getNotesSlideManager().addNotesSlide();
slide.getNotesSlideManager().getNotesSlide().getNotesTextFrame().setText("My note");
} finally {
presentation.dispose();
}
}
```
## **Access a Notes Slide**
Read text from an existing notes slide.
```java
import com.aspose.slides.*;
static void accessNote() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
INotesSlide notesSlide = slide.getNotesSlideManager().addNotesSlide();
String notes = notesSlide.getNotesTextFrame().getText();
} finally {
presentation.dispose();
}
}
```
## **Remove a Notes Slide**
Remove the notes slide associated with a slide.
```java
import com.aspose.slides.*;
static void removeNote() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
INotesSlide notesSlide = slide.getNotesSlideManager().addNotesSlide();
slide.getNotesSlideManager().removeNotesSlide();
} finally {
presentation.dispose();
}
}
```
## **Update Notes Text**
Change the text of a notes slide.
```java
import com.aspose.slides.*;
static void updateNoteText() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
INotesSlide notesSlide = slide.getNotesSlideManager().addNotesSlide();
slide.getNotesSlideManager().getNotesSlide().getNotesTextFrame().setText("Old");
slide.getNotesSlideManager().getNotesSlide().getNotesTextFrame().setText("Updated");
} finally {
presentation.dispose();
}
}
```
## Related articles
- [Convert PowerPoint Presentations to PDF with Notes in Java](https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf-with-notes/)
# OLE Object
> Handle OLE objects in Aspose.Slides for Java: insert, link, update, and extract embedded content with Java in PPT, PPTX, and ODP presentations.
Source: https://docs.aspose.com/slides/java/examples/elements/ole-object/
Updated: 2026-08-05
This article demonstrates embedding a file as an OLE object and updating its data using **Aspose.Slides for Java**.
## **Add an OLE Object**
Embed a PDF file into the presentation.
```java
import com.aspose.slides.*;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
static void addOleObject() throws IOException {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
byte[] pdfData = Files.readAllBytes(Paths.get("doc.pdf"));
IOleEmbeddedDataInfo dataInfo = new OleEmbeddedDataInfo(pdfData, "pdf");
IOleObjectFrame oleFrame = slide.getShapes().addOleObjectFrame(20, 20, 50, 50, dataInfo);
} finally {
presentation.dispose();
}
}
```
## **Access an OLE Object**
Retrieve the first OLE object frame on a slide.
```java
import com.aspose.slides.*;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
static void accessOleObject() throws IOException {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
byte[] pdfData = Files.readAllBytes(Paths.get("doc.pdf"));
IOleEmbeddedDataInfo dataInfo = new OleEmbeddedDataInfo(pdfData, "pdf");
IOleObjectFrame oleFrame = slide.getShapes().addOleObjectFrame(20, 20, 50, 50, dataInfo);
IOleObjectFrame firstOleFrame = null;
for (IShape shape : slide.getShapes()) {
if (shape instanceof IOleObjectFrame) {
firstOleFrame = (IOleObjectFrame) shape;
break;
}
}
} finally {
presentation.dispose();
}
}
```
## **Remove an OLE Object**
Delete an embedded OLE object from the slide.
```java
import com.aspose.slides.*;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
static void removeOleObject() throws IOException {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
byte[] pdfData = Files.readAllBytes(Paths.get("doc.pdf"));
IOleEmbeddedDataInfo dataInfo = new OleEmbeddedDataInfo(pdfData, "pdf");
IOleObjectFrame oleFrame = slide.getShapes().addOleObjectFrame(20, 20, 50, 50, dataInfo);
slide.getShapes().remove(oleFrame);
} finally {
presentation.dispose();
}
}
```
## **Update OLE Object Data**
Replace the data embedded in an existing OLE object.
```java
import com.aspose.slides.*;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
static void updateOleObjectData() throws IOException {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
byte[] pdfData = Files.readAllBytes(Paths.get("doc.pdf"));
OleEmbeddedDataInfo dataInfo = new OleEmbeddedDataInfo(pdfData, "pdf");
IOleObjectFrame oleFrame = slide.getShapes().addOleObjectFrame(20, 20, 50, 50, dataInfo);
byte[] newData = Files.readAllBytes(Paths.get("Picture.png"));
OleEmbeddedDataInfo newDataInfo = new OleEmbeddedDataInfo(newData, "png");
oleFrame.setEmbeddedData(newDataInfo);
} finally {
presentation.dispose();
}
}
```
## Related articles
- [Manage OLE in Presentations Using Java](https://docs.aspose.com/slides/java/manage-ole/)
- [Create Excel Charts and Embed Them in Presentations as OLE Objects](https://docs.aspose.com/slides/java/creating-excel-chart-and-embedding-it-in-presentation-as-ole-object/)
# Picture
> Work with pictures in Aspose.Slides for Java: insert, crop, compress, recolor, and export images with Java examples for PPT, PPTX, and ODP presentations.
Source: https://docs.aspose.com/slides/java/examples/elements/picture/
Updated: 2026-08-05
This article demonstrates how to insert and access pictures from in-memory images using **Aspose.Slides for Java**. The examples below create an image in memory, place it on a slide, and then retrieve it.
## **Add a Picture**
This code generates a small bitmap, converts it to a stream, and inserts it as a picture frame on the first slide.
```java
import com.aspose.slides.*;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
public static void addPicture() throws IOException {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
// Create a simple in-memory image.
BufferedImage bitmap = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = bitmap.createGraphics();
try {
graphics.setPaint(new Color(144, 238, 144));
graphics.fillRect(0, 0, 100, 100);
} finally {
graphics.dispose();
}
// Convert the bitmap to a byte array.
ByteArrayOutputStream bitmapStream = new ByteArrayOutputStream();
ImageIO.write(bitmap, "png", bitmapStream);
byte[] pngBytes = bitmapStream.toByteArray();
// Add the image to the presentation.
IPPImage image = presentation.getImages().addImage(new ByteArrayInputStream(pngBytes));
// Insert a picture frame showing the image on the first slide.
slide.getShapes().addPictureFrame(ShapeType.Rectangle, 50, 50, bitmap.getWidth(), bitmap.getHeight(), image);
presentation.save("picture.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
}
```
## **Access a Picture**
This example ensures a slide contains a picture frame and then accesses the first one it finds.
```java
import com.aspose.slides.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
public static void accessPicture() throws IOException {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
BufferedImage bitmap = new BufferedImage(40, 40, BufferedImage.TYPE_INT_ARGB);
ByteArrayOutputStream bitmapStream = new ByteArrayOutputStream();
ImageIO.write(bitmap, "png", bitmapStream);
byte[] pngBytes = bitmapStream.toByteArray();
IPPImage image = presentation.getImages().addImage(new ByteArrayInputStream(pngBytes));
slide.getShapes().addPictureFrame(ShapeType.Rectangle, 0, 0, 40, 40, image);
IPictureFrame pictureFrame = null;
for (IShape shape : slide.getShapes()) {
if (shape instanceof IPictureFrame) {
pictureFrame = (IPictureFrame) shape;
break;
}
}
} finally {
presentation.dispose();
}
}
```
# Section
> Manage slide sections in Aspose.Slides for Java: create, rename, reorder, and group slides with Java examples for PPT, PPTX, and ODP.
Source: https://docs.aspose.com/slides/java/examples/elements/section/
Updated: 2026-08-05
Examples for managing presentation sections—add, access, remove, and rename them programmatically using **Aspose.Slides for Java**.
## **Add a Section**
Create a section that starts at a specific slide.
```java
import com.aspose.slides.*;
static void addSection() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
// Specify the slide that marks the beginning of the section.
presentation.getSections().addSection("New Section", slide);
} finally {
presentation.dispose();
}
}
```
## **Access a Section**
Read section information from a presentation.
```java
import com.aspose.slides.*;
static void accessSection() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
presentation.getSections().addSection("My Section", slide);
// Access a section by index.
ISection section = presentation.getSections().get_Item(0);
String sectionName = section.getName();
} finally {
presentation.dispose();
}
}
```
## **Remove a Section**
Delete a previously added section.
```java
import com.aspose.slides.*;
static void removeSection() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
ISection section = presentation.getSections().addSection("Temporary Section", slide);
// Remove the first section.
presentation.getSections().removeSection(section);
} finally {
presentation.dispose();
}
}
```
## **Rename a Section**
Change the name of an existing section.
```java
import com.aspose.slides.*;
static void renameSection() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
presentation.getSections().addSection("Old Name", slide);
ISection section = presentation.getSections().get_Item(0);
section.setName("New Name");
} finally {
presentation.dispose();
}
}
```
## Related articles
- [Manage Slide Sections in Presentations Using Java](https://docs.aspose.com/slides/java/slide-section/)
# Slide Transition
> Master slide transitions in Aspose.Slides for Java: add, customize, and sequence effects and durations with Java examples for PPT, PPTX, and ODP presentations.
Source: https://docs.aspose.com/slides/java/examples/elements/slide-transition/
Updated: 2026-08-05
This article demonstrates applying slide transition effects and timings with **Aspose.Slides for Java**.
## **Add a Slide Transition**
Apply a fade transition effect to the first slide.
```java
import com.aspose.slides.*;
static void addSlideTransition() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
// Apply a fade transition.
slide.getSlideShowTransition().setType(TransitionType.Fade);
} finally {
presentation.dispose();
}
}
```
## **Access a Slide Transition**
Read the transition type currently assigned to a slide.
```java
import com.aspose.slides.*;
static void accessSlideTransition() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
slide.getSlideShowTransition().setType(TransitionType.Push);
// Access the transition type.
int type = slide.getSlideShowTransition().getType();
} finally {
presentation.dispose();
}
}
```
## **Remove a Slide Transition**
Clear any transition effect by setting the type to `None`.
```java
import com.aspose.slides.*;
static void removeSlideTransition() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
slide.getSlideShowTransition().setType(TransitionType.Fade);
// Remove transition by setting none.
slide.getSlideShowTransition().setType(TransitionType.None);
} finally {
presentation.dispose();
}
}
```
## **Set Transition Duration**
Specify how long the slide is displayed before advancing automatically.
```java
import com.aspose.slides.*;
static void setTransitionDuration() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
slide.getSlideShowTransition().setAdvanceOnClick(true);
slide.getSlideShowTransition().setAdvanceAfterTime(2000); // in milliseconds.
} finally {
presentation.dispose();
}
}
```
## Related articles
- [Animation](https://docs.aspose.com/slides/java/examples/elements/animation/)
- [Manage Slide Transitions in Presentations Using Java](https://docs.aspose.com/slides/java/slide-transition/)
# Slide
> Control slides in Aspose.Slides for Java: create, clone, reorder, resize, set backgrounds, and apply transitions with Java for PPT, PPTX, and ODP presentations.
Source: https://docs.aspose.com/slides/java/examples/elements/slide/
Updated: 2026-08-05
This article provides a series of examples that demonstrate how to work with slides using **Aspose.Slides for Java**. You’ll learn how to add, access, clone, reorder, and remove slides using the `Presentation` class.
Each example below includes a brief explanation followed by a code snippet in Java.
## **Add a Slide**
To add a new slide, you must first select a layout. In this example, we use the `Blank` layout and add an empty slide to the presentation.
```java
import com.aspose.slides.*;
static void addSlide() {
Presentation presentation = new Presentation();
try {
ILayoutSlide blankLayout = presentation.getLayoutSlides().getByType(SlideLayoutType.Blank);
presentation.getSlides().addEmptySlide(blankLayout);
} finally {
presentation.dispose();
}
}
```
> 💡 **Note:** Each slide layout is derived from a master slide, which defines the overall design and placeholder structure. The image below illustrates how master slides and their associated layouts are organized in PowerPoint.

## **Access Slides by Index**
You can access slides using their index, or find a slide’s index based on a reference. This is useful for iterating through or modifying specific slides.
```java
import com.aspose.slides.*;
static void accessSlide() {
Presentation presentation = new Presentation();
try {
// Add another empty slide.
ILayoutSlide blankLayout = presentation.getLayoutSlides().getByType(SlideLayoutType.Blank);
presentation.getSlides().addEmptySlide(blankLayout);
// Access slides by index.
ISlide firstSlide = presentation.getSlides().get_Item(0);
ISlide secondSlide = presentation.getSlides().get_Item(1);
// Get slide index from a reference, then access it by index.
int secondSlideIndex = presentation.getSlides().indexOf(secondSlide);
ISlide secondSlideByIndex = presentation.getSlides().get_Item(secondSlideIndex);
} finally {
presentation.dispose();
}
}
```
## **Clone a Slide**
This example demonstrates how to clone an existing slide. The cloned slide is automatically added to the end of the slide collection.
```java
import com.aspose.slides.*;
static void cloneSlide() {
Presentation presentation = new Presentation();
try {
ISlide firstSlide = presentation.getSlides().get_Item(0);
ISlide clonedSlide = presentation.getSlides().addClone(firstSlide);
int clonedSlideIndex = presentation.getSlides().indexOf(clonedSlide);
} finally {
presentation.dispose();
}
}
```
## **Reorder Slides**
You can change the order of slides by moving one to a new index. In this case, we move a cloned slide to the first position.
```java
import com.aspose.slides.*;
static void reorderSlide() {
Presentation presentation = new Presentation();
try {
ISlide firstSlide = presentation.getSlides().get_Item(0);
ISlide clonedSlide = presentation.getSlides().addClone(firstSlide);
presentation.getSlides().reorder(0, clonedSlide);
} finally {
presentation.dispose();
}
}
```
## **Remove a Slide**
To remove a slide, simply reference it and call `remove`. This example adds a second slide and then removes the original, leaving only the new one.
```java
import com.aspose.slides.*;
static void removeSlide() {
Presentation presentation = new Presentation();
try {
ILayoutSlide blankLayout = presentation.getLayoutSlides().getByType(SlideLayoutType.Blank);
ISlide secondSlide = presentation.getSlides().addEmptySlide(blankLayout);
ISlide firstSlide = presentation.getSlides().get_Item(0);
presentation.getSlides().remove(firstSlide);
} finally {
presentation.dispose();
}
}
```
# SmartArt
> Work with SmartArt in Aspose.Slides for Java: create, edit, convert, and style diagrams with Java for PowerPoint and OpenDocument presentations.
Source: https://docs.aspose.com/slides/java/examples/elements/smart-art/
Updated: 2026-08-05
This article demonstrates how to add SmartArt graphics, access them, remove them, and change layouts using **Aspose.Slides for Java**.
## **Add SmartArt**
Insert a SmartArt graphic using one of the built-in layouts.
```java
import com.aspose.slides.*;
static void addSmartArt() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
ISmartArt smartArt = slide.getShapes().addSmartArt(50, 50, 400, 300, SmartArtLayoutType.BasicProcess);
} finally {
presentation.dispose();
}
}
```
## **Access SmartArt**
Retrieve the first SmartArt object on a slide.
```java
import com.aspose.slides.*;
static void accessSmartArt() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
ISmartArt smartArt = slide.getShapes().addSmartArt(50, 50, 400, 300, SmartArtLayoutType.BasicProcess);
ISmartArt firstSmartArt = null;
for (IShape shape : slide.getShapes()) {
if (shape instanceof ISmartArt) {
firstSmartArt = (ISmartArt) shape;
break;
}
}
} finally {
presentation.dispose();
}
}
```
## **Remove SmartArt**
Delete a SmartArt shape from the slide.
```java
import com.aspose.slides.*;
static void removeSmartArt() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
ISmartArt smartArt = slide.getShapes().addSmartArt(50, 50, 400, 300, SmartArtLayoutType.BasicProcess);
slide.getShapes().remove(smartArt);
} finally {
presentation.dispose();
}
}
```
## **Change SmartArt Layout**
Update the layout type of an existing SmartArt graphic.
```java
import com.aspose.slides.*;
static void changeSmartArtLayout() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
ISmartArt smartArt = slide.getShapes().addSmartArt(50, 50, 400, 300, SmartArtLayoutType.BasicBlockList);
smartArt.setLayout(SmartArtLayoutType.VerticalPictureList);
} finally {
presentation.dispose();
}
}
```
## Related articles
- [Create and Customize PowerPoint SmartArt in Java](https://docs.aspose.com/slides/java/powerpoint-smartart/)
- [Manage SmartArt Graphics in Presentations Using Java](https://docs.aspose.com/slides/java/manage-smartart-shape/)
# Table
> Work with tables in Aspose.Slides for Java: create, format, merge cells, apply styles, import data, and export with Java examples for PPT, PPTX, and ODP.
Source: https://docs.aspose.com/slides/java/examples/elements/table/
Updated: 2026-08-05
Examples for adding tables, accessing them, removing them, and merging cells using **Aspose.Slides for Java**.
## **Add a Table**
Create a simple table with two rows and two columns.
```java
import com.aspose.slides.*;
static void addTable() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
double[] widths = new double[] { 80, 80 };
double[] heights = new double[] { 30, 30 };
ITable table = slide.getShapes().addTable(50, 50, widths, heights);
} finally {
presentation.dispose();
}
}
```
## **Access a Table**
Retrieve the first table shape on the slide.
```java
import com.aspose.slides.*;
static void accessTable() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
double[] widths = new double[] { 80, 80 };
double[] heights = new double[] { 30, 30 };
ITable table = slide.getShapes().addTable(50, 50, widths, heights);
// Access first table on slide.
ITable firstTable = null;
for (IShape shape : slide.getShapes()) {
if (shape instanceof ITable) {
firstTable = (ITable) shape;
break;
}
}
} finally {
presentation.dispose();
}
}
```
## **Remove a Table**
Delete a table from a slide.
```java
import com.aspose.slides.*;
static void removeTable() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
double[] widths = new double[] { 80, 80 };
double[] heights = new double[] { 30, 30 };
ITable table = slide.getShapes().addTable(50, 50, widths, heights);
slide.getShapes().remove(table);
} finally {
presentation.dispose();
}
}
```
## **Merge Table Cells**
Merge adjacent cells of a table into a single cell.
```java
import com.aspose.slides.*;
static void mergeTableCells() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
double[] widths = new double[] { 80, 80 };
double[] heights = new double[] { 30, 30 };
ITable table = slide.getShapes().addTable(50, 50, widths, heights);
// Merge cells.
table.mergeCells(table.get_Item(0, 0), table.get_Item(1, 1), false);
} finally {
presentation.dispose();
}
}
```
## Related articles
- [Create and Customize PowerPoint Tables in Java](https://docs.aspose.com/slides/java/powerpoint-table/)
- [Manage Table Cells in Presentations Using Java](https://docs.aspose.com/slides/java/manage-cells/)
# Text Box
> Work with text boxes in Aspose.Slides for Java: add, format, align, wrap, autofit, and style text using Java for PPT, PPTX, and ODP presentations.
Source: https://docs.aspose.com/slides/java/examples/elements/text-box/
Updated: 2026-08-05
In Aspose.Slides, a **text box** is represented by an `AutoShape`. Nearly any shape can contain text, but a typical text box has no fill or border and displays only text.
This guide explains how to add, access, and remove text boxes programmatically.
## **Add a Text Box**
A text box is simply an `AutoShape` with no fill or border and some formatted text. Here's how to create one:
```java
import com.aspose.slides.*;
import java.awt.Color;
public static void addTextBox() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
// Create a rectangle shape (defaults to filled with border and no text).
IAutoShape textBox = slide.getShapes().addAutoShape(ShapeType.Rectangle, 50, 75, 150, 100);
// Remove fill and border to make it look like a typical text box.
textBox.getFillFormat().setFillType(FillType.NoFill);
textBox.getLineFormat().getFillFormat().setFillType(FillType.NoFill);
// Set text formatting.
IParagraph paragraph = textBox.getTextFrame().getParagraphs().get_Item(0);
IPortionFormat textFormat = paragraph.getParagraphFormat().getDefaultPortionFormat();
textFormat.getFillFormat().setFillType(FillType.Solid);
textFormat.getFillFormat().getSolidFillColor().setColor(Color.BLACK);
// Assign the actual text content.
textBox.getTextFrame().setText("Some text...");
} finally {
presentation.dispose();
}
}
```
> 💡 **Note:** Any `AutoShape` that contains a non-empty `TextFrame` can function as a text box.
## **Access Text Boxes by Content**
To find all text boxes containing a specific keyword (e.g. "Slide"), iterate through the shapes and check their text:
```java
import com.aspose.slides.*;
public static void accessTextBox() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
for (IShape shape : slide.getShapes()) {
// Only AutoShapes can contain editable text.
if (shape instanceof IAutoShape) {
IAutoShape autoShape = (IAutoShape) shape;
if (autoShape.getTextFrame().getText().contains("Slide")) {
// Do something with the matching text box.
}
}
}
} finally {
presentation.dispose();
}
}
```
## **Remove Text Boxes by Content**
This example finds and deletes all text boxes on the first slide that contain a specific keyword:
```java
import com.aspose.slides.*;
import java.util.ArrayList;
import java.util.List;
public static void removeTextBox() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
List shapesToRemove = new ArrayList();
for (IShape shape : slide.getShapes()) {
if (shape instanceof IAutoShape) {
IAutoShape autoShape = (IAutoShape) shape;
if (autoShape.getTextFrame().getText().contains("Slide")) {
shapesToRemove.add(shape);
}
}
}
for (IShape shape : shapesToRemove) {
slide.getShapes().remove(shape);
}
} finally {
presentation.dispose();
}
}
```
> 💡 **Tip:** Always create a copy of the shape collection before modifying it during iteration to avoid collection modification errors.
# VBA Macro
> Automate presentations with Aspose.Slides for Java: create, run, import, and secure VBA macros in PPT, PPTX, and ODP using clear Java examples.
Source: https://docs.aspose.com/slides/java/examples/elements/vba-macro/
Updated: 2026-08-05
This article demonstrates how to add, access, and remove VBA macros using **Aspose.Slides for Java**.
## **Add a VBA Macro**
Create a presentation with a VBA project and a simple macro module.
```java
import com.aspose.slides.*;
static void addVbaMacro() {
Presentation presentation = new Presentation();
try {
presentation.setVbaProject(new VbaProject());
IVbaModule module = presentation.getVbaProject().getModules().addEmptyModule("Module");
module.setSourceCode("Sub Test()\n MsgBox \"Hi\" \nEnd Sub");
} finally {
presentation.dispose();
}
}
```
## **Access a VBA Macro**
Retrieve the first module from the VBA project.
```java
import com.aspose.slides.*;
static void accessVbaMacro() {
Presentation presentation = new Presentation();
try {
presentation.setVbaProject(new VbaProject());
IVbaModule module = presentation.getVbaProject().getModules().addEmptyModule("Module");
module.setSourceCode("Sub Test()\n MsgBox \"Hi\" \nEnd Sub");
IVbaModule firstModule = presentation.getVbaProject().getModules().get_Item(0);
} finally {
presentation.dispose();
}
}
```
## **Remove a VBA Macro**
Delete a module from the VBA project.
```java
import com.aspose.slides.*;
static void removeVbaMacro() {
Presentation presentation = new Presentation();
try {
presentation.setVbaProject(new VbaProject());
IVbaModule module = presentation.getVbaProject().getModules().addEmptyModule("Module");
module.setSourceCode("Sub Test()\n MsgBox \"Hi\" \nEnd Sub");
presentation.getVbaProject().getModules().remove(module);
} finally {
presentation.dispose();
}
}
```
## Related articles
- [Manage VBA Projects in Presentations Using Java](https://docs.aspose.com/slides/java/presentation-via-vba/)
# Video
> Add and control videos with Aspose.Slides for Java: insert, play, trim, set poster frames, and export with Java examples for PPT, PPTX, and ODP presentations.
Source: https://docs.aspose.com/slides/java/examples/elements/video/
Updated: 2026-08-05
This article demonstrates how to embed video frames and set playback options using **Aspose.Slides for Java**.
## **Add a Video Frame**
Insert an empty video frame onto a slide.
```java
import com.aspose.slides.*;
static void addVideo() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
// Add a video.
IVideoFrame videoFrame = slide.getShapes().addVideoFrame(50, 50, 320, 240, "video.mp4");
} finally {
presentation.dispose();
}
}
```
## **Access a Video Frame**
Retrieve the first video frame added to a slide.
```java
import com.aspose.slides.*;
static void accessVideo() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IVideoFrame videoFrame = slide.getShapes().addVideoFrame(50, 50, 320, 240, "video.mp4");
// Access the first video frame on the slide.
IVideoFrame firstVideo = null;
for (IShape shape : slide.getShapes()) {
if (shape instanceof IVideoFrame) {
firstVideo = (IVideoFrame) shape;
break;
}
}
} finally {
presentation.dispose();
}
}
```
## **Remove a Video Frame**
Delete a video frame from the slide.
```java
import com.aspose.slides.*;
static void removeVideo() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IVideoFrame videoFrame = slide.getShapes().addVideoFrame(50, 50, 320, 240, "video.mp4");
// Remove the video frame.
slide.getShapes().remove(videoFrame);
} finally {
presentation.dispose();
}
}
```
## **Set Video Playback**
Configure the video to play automatically when the slide is displayed.
```java
import com.aspose.slides.*;
static void setVideoPlayback() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IVideoFrame videoFrame = slide.getShapes().addVideoFrame(50, 50, 320, 240, "video.mp4");
// Configure the video to play automatically.
videoFrame.setPlayMode(VideoPlayModePreset.Auto);
} finally {
presentation.dispose();
}
}
```
## Related articles
- [Audio](https://docs.aspose.com/slides/java/examples/elements/audio/)
- [Manage Video Frames in Presentations Using Java](https://docs.aspose.com/slides/java/video-frame/)
# Integrate Excel Data into PowerPoint Presentations
> Read data from Excel workbooks in Aspose.Slides using the ExcelDataWorkbook API. Load sheets and cells and use values to generate data-driven PowerPoint presentations.
Source: https://docs.aspose.com/slides/java/excel-integration/
Updated: 2026-08-12
## **Introduction**
PowerPoint presentations are a powerful way to display and communicate information. They are often used in conjunction with Excel workbooks, where Excel serves as an excellent source of structured data and PowerPoint excels at visualizing that data for an audience.
There are many practical scenarios where combining Excel and PowerPoint is essential: mail merges, populating data tables, generating one slide per data record (batch slide generation), creating training materials, and consolidating multiple Excel reports into a single presentation, to name a few.
Until now, implementing such features with the Aspose.Slides API required relying on third-party solutions like Aspose.Cells. While these tools are robust, they can be overly complex and costly for users who only need basic data integration functionality.
## **How It Works**
To make working with Excel data easier and more streamlined, Aspose.Slides has introduced new classes for reading data from Excel workbooks and importing content into a presentation. This feature opens up powerful new possibilities for API users who want to leverage Excel as a data source within their presentation workflows.
The new functionality is designed for general-purpose data access and is not integrated into the Presentation Document Object Model (DOM). That means *it does not allow editing or saving Excel files* — its sole purpose is to open workbooks and navigate through their content to retrieve cell data.
At the core of this feature is the new [IExcelDataWorkbook](https://reference.aspose.com/slides/java/com.aspose.slides/iexceldataworkbook/) interface, implemented by the [ExcelDataWorkbook](https://reference.aspose.com/slides/java/com.aspose.slides/exceldataworkbook/) class. This class allows you to load an Excel workbook from a local file or a stream. Once loaded, it provides several overloads of the [IExcelDataWorkbook.getCell](https://reference.aspose.com/slides/java/com.aspose.slides/iexceldataworkbook/#getCell-int-int-int-) method, which you can use to retrieve specific cells by their position (e.g., row and column indices or named ranges).
Each call to [IExcelDataWorkbook.getCell](https://reference.aspose.com/slides/java/com.aspose.slides/iexceldataworkbook/#getCell-int-int-int-) returns an object that implements the [IExcelDataCell](https://reference.aspose.com/slides/java/com.aspose.slides/iexceldatacell/) interface. This object represents a single cell in the Excel workbook and gives you access to its value in a simple and intuitive way.
#### **Import an Excel Chart**
The next step to extend functionality is the [ExcelWorkbookImporter](https://reference.aspose.com/slides/java/com.aspose.slides/excelworkbookimporter/) class. This utility class provides functionality for importing content from an Excel workbook into a presentation. It contains several overloads of the [ExcelWorkbookImporter.addChartFromWorkbook](https://reference.aspose.com/slides/java/com.aspose.slides/excelworkbookimporter/#addChartFromWorkbook-com.aspose.slides.IShapeCollection-float-float-com.aspose.slides.IExcelDataWorkbook-java.lang.String-int-boolean-) method, which help you to retrieve the selected chart from the specified Excel workbook and add it to the end of the given shape collection at the specified coordinates.
#### **Import an Excel Table**
The [ExcelWorkbookImporter](https://reference.aspose.com/slides/java/com.aspose.slides/excelworkbookimporter/) class also contains several overloads of the [ExcelWorkbookImporter.addTableFromWorkbook](https://reference.aspose.com/slides/java/com.aspose.slides/excelworkbookimporter/#addTableFromWorkbook-com.aspose.slides.IShapeCollection-float-float-java.lang.String-java.lang.String-java.lang.String-) method. These methods allow you to import a specified cell range from a specified worksheet and add it as a table to the end of the given shape collection at the specified coordinates.
In short, it's a lightweight and straightforward API for reading Excel data — exactly what many developers need without the overhead of a full spreadsheet processing library.
## **Let's Code**
### **Mail Merge Scenario Example**
In the following example, we'll implement a simple Mail Merge scenario by generating multiple presentations based on data stored in an Excel workbook.
To get started, we need two things:
1. An Excel workbook containing the data

2. PowerPoint presentation template

```java
import com.aspose.slides.*;
// Load the Excel workbook with employee data.
ExcelDataWorkbook workbook = new ExcelDataWorkbook("TemplateData.xlsx");
int worksheetIndex = 0;
// Load the presentation template.
Presentation templatePresentation = new Presentation("PresentationTemplate.pptx");
try {
// Loop through Excel rows (excluding header at row 0).
for (int rowIndex = 1; rowIndex <= 4; rowIndex++) {
// Create a new presentation for each employee record.
Presentation employeePresentation = new Presentation();
try {
// Remove the default blank slide.
employeePresentation.getSlides().removeAt(0);
// Clone the template slide into the new presentation.
ISlide slide = employeePresentation.getSlides().addClone(templatePresentation.getSlides().get_Item(0));
// Get paragraphs from the target shape (assumes shape index 1 is used).
IParagraphCollection paragraphs = ((IAutoShape)slide.getShapes().get_Item(1)).getTextFrame().getParagraphs();
// Replace the placeholders with data from Excel.
String employeeName = workbook.getCell(worksheetIndex, rowIndex, 0).getValue().toString();
IPortion namePortion = paragraphs.get_Item(0).getPortions().get_Item(0);
namePortion.setText(namePortion.getText().replace("{{EmployeeName}}", employeeName));
String department = workbook.getCell(worksheetIndex, rowIndex, 1).getValue().toString();
IPortion departmentPortion = paragraphs.get_Item(1).getPortions().get_Item(0);
departmentPortion.setText(departmentPortion.getText().replace("{{Department}}", department));
String yearsOfService = workbook.getCell(worksheetIndex, rowIndex, 2).getValue().toString();
IPortion yearsPortion = paragraphs.get_Item(2).getPortions().get_Item(0);
yearsPortion.setText(yearsPortion.getText().replace("{{YearsOfService}}", yearsOfService));
// Save the personalized presentation to a separate file.
employeePresentation.save(String.format("%s Report.pptx", employeeName), SaveFormat.Pptx);
} finally {
employeePresentation.dispose();
}
}
} finally {
templatePresentation.dispose();
}
```

### **Excel Table Example**
In the second example, we simply copy data from an Excel table and display it on a PowerPoint slide in a more visually appealing format.
In this example, we reuse the same Excel workbook from the first example, which contains a simple employee table.
```java
import com.aspose.slides.*;
// Load the Excel workbook containing the employee data.
ExcelDataWorkbook workbook = new ExcelDataWorkbook("TemplateData.xlsx");
int worksheetIndex = 0;
// Create a new PowerPoint presentation.
Presentation presentation = new Presentation();
try {
// Add a table shape to the first slide.
ITable table = presentation.getSlides().get_Item(0).getShapes().addTable(
50, 200,
new double[]{200, 200, 200},
new double[]{30, 30, 30, 30, 30}
);
// Fill the PowerPoint table with data from the Excel workbook.
for (int rowIndex = 0; rowIndex < 5; rowIndex++) {
for (int columnIndex = 0; columnIndex < 3; columnIndex++) {
String cellValue = workbook.getCell(worksheetIndex, rowIndex, columnIndex).getValue().toString();
table.getColumns().get_Item(columnIndex).get_Item(rowIndex).getTextFrame().setText(cellValue);
}
}
// Save the resulting presentation to a file.
presentation.save("Table.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```

### **Import an Excel Chart Example**
In this example, we import a chart from the first worksheet of the Excel workbook used in the previous example. The chart will link to the external workbook in the resulting presentation.
First, we add a Pie chart to the Excel workbook based on the employees table.

```java
import com.aspose.slides.*;
// Create a new PowerPoint presentation.
Presentation presentation = new Presentation();
try {
// Get the shapes collection of the first slide.
IShapeCollection shapes = presentation.getSlides().get_Item(0).getShapes();
// Import the chart named "Chart 1" from the first sheet of the workbook and add it to the shapes collection.
ExcelWorkbookImporter.addChartFromWorkbook(shapes, 10, 10, "TemplateData.xlsx", "Sheet1", "Chart 1", false);
// Save the resulting presentation to a file.
presentation.save("Chart.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```

### **Import All Excel Charts Example**
Let's imagine you have an Excel workbook full of charts and you need to import them all into a presentation. Each chart should be placed on a new slide.
The following code iterates through all worksheets in the source Excel file, extracts the charts from each worksheet, and adds each chart to a separate slide using a blank slide layout. In the resulting presentation, only the chart data will be embedded, not the entire workbook.
```java
import com.aspose.slides.*;
import com.aspose.slides.Collections.Generic.Dictionary;
import com.aspose.slides.Collections.Generic.KeyValuePair;
import java.util.List;
// Load the Excel workbook containing the employee data.
ExcelDataWorkbook workbook = new ExcelDataWorkbook("ExcelWithCharts.xlsx");
// Create a new PowerPoint presentation.
Presentation presentation = new Presentation();
try {
// Retrieve the blank slide layout.
ILayoutSlide blankLayout = presentation.getLayoutSlides().getByType(SlideLayoutType.Blank);
// Remove the default slide so that the result contains one slide per chart.
presentation.getSlides().removeAt(0);
// Get the names of all worksheets contained in the Excel workbook.
List worksheetNames = workbook.getWorksheetNames();
for (String name : worksheetNames) {
// Retrieve a map that maps chart indexes to chart names for the worksheet.
Dictionary worksheetCharts = workbook.getChartsFromWorksheet(name);
for (KeyValuePair chart : worksheetCharts) {
// Add a new slide using the blank layout.
ISlide slide = presentation.getSlides().addEmptySlide(blankLayout);
// Import the specified chart from the Excel workbook into the slide's shapes collection.
ExcelWorkbookImporter.addChartFromWorkbook(
slide.getShapes(), 10, 10, workbook, name, chart.getKey(), false);
}
}
// Save the resulting presentation to a file.
presentation.save("Charts.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
### **Import an Excel Table Example**
In this example, we import a formatted table from an Excel worksheet directly into a PowerPoint presentation.
The source Excel worksheet contains a formatted table with employee data:

```java
import com.aspose.slides.*;
// Create a new PowerPoint presentation.
Presentation presentation = new Presentation();
try {
// Get the first slide and its shapes collection.
ISlide slide = presentation.getSlides().get_Item(0);
IShapeCollection shapes = slide.getShapes();
// Import the table from the first sheet of the workbook and add it to the shapes collection.
ExcelWorkbookImporter.addTableFromWorkbook(
shapes, 10, 10, "TemplateData.xlsx", "Sheet1", "A1:C5");
// Save the resulting presentation to a file.
presentation.save("FormattedTable.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```

## **Summary**
This mechanism, available directly in Aspose.Slides, combines working with Excel data and presentations in one place. It allows you to create slides with visual charts and data presented as Excel tables - without any additional libraries or complex integrations.
# Export Presentation Charts in Java
> Learn how to export presentation charts with Aspose.Slides for Java, supporting PPT and PPTX formats, and streamline reporting into any workflow.
Source: https://docs.aspose.com/slides/java/export-chart/
Updated: 2026-08-05
## **Overview**
Aspose.Slides allows you to export a chart from a presentation as an image. This article shows how to get an image from a chart and save it, which is useful when you need to reuse chart visuals outside a PowerPoint presentation.
In addition to the basic image export workflow, the article also addresses common export-related questions, including saving chart content to SVG, controlling output size through rendering options, loading fonts to preserve label and legend appearance, and keeping the original presentation formatting such as themes, styles, fills, and effects during rendering.
## **Get a Chart Image**
Aspose.Slides for Java provides support for extracting image of specific chart. Below sample example is given.
```java
import com.aspose.slides.*;
Presentation pres = new Presentation();
try {
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 600, 400);
IImage slideImage = chart.getImage();
try {
slideImage.save("image.jpg", ImageFormat.Jpeg);
} finally {
if (slideImage != null) slideImage.dispose();
}
} finally {
if (pres != null) pres.dispose();
}
```
## **FAQ**
### Can I export a chart as a vector (SVG) instead of a raster image?
Yes. A chart is a shape, and its contents can be saved to SVG using the [shape-to-SVG saving method](https://reference.aspose.com/slides/java/com.aspose.slides/shape/#writeAsSvg-java.io.OutputStream-com.aspose.slides.ISVGOptions-).
### How can I set the exact size of the exported chart in pixels?
Use the image-rendering overloads that let you specify size or scale—the library supports rendering objects with given dimensions/scale.
### What should I do if fonts in labels and the legend look wrong after export?
[Load the required fonts](https://docs.aspose.com/slides/java/custom-font/) via [FontsLoader](https://reference.aspose.com/slides/java/com.aspose.slides/fontsloader/) so the chart rendering preserves metrics and text appearance.
### Does export honor the PowerPoint theme, styles, and effects?
Yes. Aspose.Slides’ renderer follows the presentation’s formatting (themes, styles, fills, effects), so the chart’s appearance is preserved.
### Where can I find available rendering/export capabilities beyond chart images?
See the [API](https://reference.aspose.com/slides/java/com.aspose.slides/)/[documentation](https://docs.aspose.com/slides/java/convert-powerpoint/) for output targets ([PDF](https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf/), [SVG](https://docs.aspose.com/slides/java/render-a-slide-as-an-svg-image/), [XPS](https://docs.aspose.com/slides/java/convert-powerpoint-to-xps/), [HTML](https://docs.aspose.com/slides/java/convert-powerpoint-to-html/), etc.) and related rendering options.
# Convert Presentations to HTML5 in Java
> Export PowerPoint & OpenDocument presentations to responsive HTML5 with Aspose.Slides for Java. Preserve formatting, animations, and interactivity.
Source: https://docs.aspose.com/slides/java/export-to-html5/
Updated: 2026-10-05
## **Overview**
This article explains how to convert PowerPoint presentations to HTML5 using Aspose.Slides for Java. It covers basic export, control of shape animations and slide transitions, and comment layout. It also compares HTML5 output with the SVG-based output of standard HTML export.
## **Export PowerPoint to HTML5**
The following example loads a presentation from the working directory and saves it in HTML5 format. It uses the default export settings; the next example shows how to control animation playback explicitly. Replace the input path with the path to your presentation.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("pres.pptx");
try {
presentation.save("pres.html", SaveFormat.Html5);
} finally {
presentation.dispose();
}
```
Besides the HTML document, the export writes supporting CSS and JavaScript files for slide styling, animations, effects, and navigation. Keep these files with the HTML document when moving or publishing the output. The generated page also loads jQuery and Anime.js from public CDNs; without them, slide navigation and animations do not run.
To export without playing shape animations or slide transitions, pass `false` to [setAnimateShapes](https://reference.aspose.com/slides/java/com.aspose.slides/html5options/#setAnimateShapes-boolean-) and [setAnimateTransitions](https://reference.aspose.com/slides/java/com.aspose.slides/html5options/#setAnimateTransitions-boolean-) in [Html5Options](https://reference.aspose.com/slides/java/com.aspose.slides/html5options/). These settings are independent, so you can enable one while disabling the other. The example exports the presentation with both types of animation disabled in the generated page.
```java
import com.aspose.slides.*;
Html5Options html5Options = new Html5Options();
html5Options.setAnimateShapes(false);
html5Options.setAnimateTransitions(false);
Presentation presentation = new Presentation("pres.pptx");
try {
presentation.save("pres5.html", SaveFormat.Html5, html5Options);
} finally {
presentation.dispose();
}
```
## **Export PowerPoint to HTML**
The standard HTML export uses a different rendering approach: slide content is represented by SVG inside an HTML page. The following example converts a presentation to an HTML document using this rendering approach.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("pres.pptx");
try {
presentation.save("pres.html", SaveFormat.Html);
} finally {
presentation.dispose();
}
```
The simplified markup below illustrates the structure of the generated page. The SVG element contains the rendered slide content; the placeholder text represents that content and is not literal export output.
```html
```
The SVG-based export does not expose PowerPoint shapes as individual HTML elements. Use HTML5 export when you need the shape-animation and slide-transition options demonstrated in this article.
## **Export PowerPoint to HTML5 Slide View**
HTML5 export produces a page for viewing and navigating the presentation slides in a browser. This example enables both [setAnimateShapes](https://reference.aspose.com/slides/java/com.aspose.slides/html5options/#setAnimateShapes-boolean-) and [setAnimateTransitions](https://reference.aspose.com/slides/java/com.aspose.slides/html5options/#setAnimateTransitions-boolean-) so that the exported slide view can play effects from the source presentation.
Use a presentation that already contains shape animations and slide transitions to see the effect of these settings. Enabling them does not add new effects to slides that have none. After export, open the generated HTML5 document in a browser with its supporting files available.
```java
import com.aspose.slides.*;
Html5Options html5Options = new Html5Options();
html5Options.setAnimateShapes(true);
html5Options.setAnimateTransitions(true);
Presentation presentation = new Presentation("pres.pptx");
try {
presentation.save("HTML5-slide-view.html", SaveFormat.Html5, html5Options);
} finally {
presentation.dispose();
}
```
## **Convert a Presentation to an HTML5 Document with Comments**
You can include existing slide comments in HTML5 output so that readers can see feedback alongside the slide content. The example in this section expects the source presentation to contain comments, as illustrated below. It exports those comments; it does not create new ones.

Pass a [NotesCommentsLayoutingOptions](https://reference.aspose.com/slides/java/com.aspose.slides/notescommentslayoutingoptions/) object to the [setSlidesLayoutOptions](https://reference.aspose.com/slides/java/com.aspose.slides/html5options/#setSlidesLayoutOptions-com.aspose.slides.ISlidesLayoutOptions-) method of [Html5Options](https://reference.aspose.com/slides/java/com.aspose.slides/html5options/). Use [setCommentsPosition](https://reference.aspose.com/slides/java/com.aspose.slides/notescommentslayoutingoptions/#setCommentsPosition-int-) to select `Right` from the [CommentsPositions](https://reference.aspose.com/slides/java/com.aspose.slides/commentspositions/) enumeration to place the comments to the right of each slide.
The following example exports the presentation to HTML5 with this comment layout. A presentation without comments will have no comment text to display.
```java
import com.aspose.slides.*;
NotesCommentsLayoutingOptions layoutOptions = new NotesCommentsLayoutingOptions();
layoutOptions.setCommentsPosition(CommentsPositions.Right);
Html5Options html5Options = new Html5Options();
html5Options.setSlidesLayoutOptions(layoutOptions);
Presentation presentation = new Presentation("sample.pptx");
try {
presentation.save("output.html", SaveFormat.Html5, html5Options);
} finally {
presentation.dispose();
}
```
The image below shows the exported HTML5 document with the comments displayed beside the slide.

## **Exclude JavaScript Hyperlinks During Export**
Suppose `hyperlinks.pptx` contains linked text with a `javascript:alert('Hello')` target and an ordinary `https://example.com/` link. To exclude the JavaScript hyperlink during export, pass `true` to [SaveOptions.setSkipJavaScriptLinks](https://reference.aspose.com/slides/java/com.aspose.slides/saveoptions/#setSkipJavaScriptLinks-boolean-). The default is `false`, so these links are not filtered unless you enable the option.
The following example loads the presentation from the working directory and exports it using [Html5Options](https://reference.aspose.com/slides/java/com.aspose.slides/html5options/):
```java
import com.aspose.slides.*;
Html5Options html5Options = new Html5Options();
html5Options.setSkipJavaScriptLinks(true);
Presentation presentation = new Presentation("hyperlinks.pptx");
try {
presentation.save("filtered-html5.html", SaveFormat.Html5, html5Options);
} finally {
presentation.dispose();
}
```
The exported file omits the JavaScript hyperlink while retaining its text and the ordinary HTTPS link. The source presentation is unchanged.
This option filters JavaScript hyperlinks; it does not remove all scripts or other active content, nor does it guarantee CSP compliance. For example, HTML5 output still includes scripts for slide navigation and animations.
## **FAQ**
**Can I control whether object animations and slide transitions will play in HTML5?**
Yes, HTML5 export provides separate options to enable or disable [shape animations](https://reference.aspose.com/slides/java/com.aspose.slides/html5options/#setAnimateShapes-boolean-) and [slide transitions](https://reference.aspose.com/slides/java/com.aspose.slides/html5options/#setAnimateTransitions-boolean-).
**Are comments supported, and where can they be placed relative to the slide?**
Yes, existing comments can be included in HTML5 output and positioned (for example, to the right of the slide) through [layout settings](https://reference.aspose.com/slides/java/com.aspose.slides/html5options/#setSlidesLayoutOptions-com.aspose.slides.ISlidesLayoutOptions-) for notes and comments.
**Can I skip links that invoke JavaScript for security or CSP reasons?**
Yes, the [setSkipJavaScriptLinks](https://reference.aspose.com/slides/java/com.aspose.slides/saveoptions/#setSkipJavaScriptLinks-boolean-) setting allows you to skip hyperlinks with JavaScript calls during saving. The default is `false`. See [Exclude JavaScript Hyperlinks During Export](https://docs.aspose.com/slides/java/export-to-html5/#exclude-javascript-hyperlinks-during-export) for an HTML5 export example and the scope of the filter. This setting does not remove the JavaScript used by the HTML5 viewer for navigation and animations.
# Export Presentations to XAML in Java
> Convert PowerPoint and OpenDocument slides to XAML in Java using Aspose.Slides—quick, Office-free solution that keeps your layout intact.
Source: https://docs.aspose.com/slides/java/export-to-xaml/
Updated: 2026-09-16
## **Overview**
This article explains how to export PowerPoint presentations to XAML using Aspose.Slides. It includes a brief introduction to XAML, shows how to save a presentation to XAML with default settings, and demonstrates how to customize the export through [XamlOptions](https://reference.aspose.com/slides/java/com.aspose.slides/xamloptions/), including exporting hidden slides. The article also answers a few common questions related to fallback fonts, XAML stack compatibility, and hidden slide export behavior.
## **About XAML**
XAML is an XML-based markup language used to describe user interfaces in frameworks such as WPF (Windows Presentation Foundation), UWP (Universal Windows Platform), and Xamarin.Forms.
You can work with XAML files in a visual designer or write and edit the markup directly.
## **Export Presentations to XAML With Default Options**
The following Java example shows how to export a presentation to XAML with default settings:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("pres.pptx");
try {
XamlOptions xamlOptions = new XamlOptions();
presentation.save(xamlOptions);
} finally {
presentation.dispose();
}
```
By default, the exported slides are saved in a `pres` subfolder of the process's current working directory, resolved from an empty path with [Paths.get](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Paths.html#get-java.lang.String-java.lang.String...-). The folder is created automatically, and any required images are saved there as well.
The output folder name is taken from the source file name without its extension. For `pres.pptx`, the output files are named `pres/Slide_1.xaml`, `pres/Slide_2.xaml`, and so on. Even if you pass an absolute path to the input presentation, the output folder is created relative to the current working directory, rather than alongside the input file.
## **Export Presentations to XAML With Custom Options**
Use the [IXamlOptions](https://reference.aspose.com/slides/java/com.aspose.slides/ixamloptions/) interface to control how Aspose.Slides exports a presentation to XAML.
To save the output to a custom location, implement [IXamlOutputSaver](https://reference.aspose.com/slides/java/com.aspose.slides/ixamloutputsaver/) and pass an instance of your implementation to the [setOutputSaver](https://reference.aspose.com/slides/java/com.aspose.slides/xamloptions/#setOutputSaver-com.aspose.slides.IXamlOutputSaver-) method of [XamlOptions](https://reference.aspose.com/slides/java/com.aspose.slides/xamloptions/).
To include hidden slides in the XAML output, call [setExportHiddenSlides](https://reference.aspose.com/slides/java/com.aspose.slides/xamloptions/#setExportHiddenSlides-boolean-) with `true`, as shown in the following Java example:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("pres.pptx");
try {
XamlOptions xamlOptions = new XamlOptions();
xamlOptions.setExportHiddenSlides(true);
presentation.save(xamlOptions);
} finally {
presentation.dispose();
}
```
## **Capture All Generated XAML Artifacts**
A XAML export can produce a XAML document for each exported slide plus separate images and supporting resources. Assign a custom [IXamlOutputSaver](https://reference.aspose.com/slides/java/com.aspose.slides/ixamloutputsaver/) to [XamlOptions.setOutputSaver](https://reference.aspose.com/slides/java/com.aspose.slides/xamloptions/#setOutputSaver-com.aspose.slides.IXamlOutputSaver-) to receive these artifacts instead of using the default file-system saver. Start the export with the XAML-specific [Presentation.save](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#save-com.aspose.slides.IXamlOptions-) overload that accepts XAML options.
### **Understand the Callback Lifecycle**
The exporter calls [IXamlOutputSaver.save](https://reference.aspose.com/slides/java/com.aspose.slides/ixamloutputsaver/#save-java.lang.String-byte:A-) separately for each generated artifact:
- `path` identifies the artifact and may include relative directories. Retain this information because XAML may reference resources using relative paths.
- `data` contains the artifact's bytes. Images and other binary resources must not be decoded as text.
- The saver is responsible for retaining or persisting the data before returning. The examples copy each byte array into application-owned memory.
- Treat export as successful only when the presentation save operation returns and every callback has completed successfully. Do not swallow storage errors or start unobserved background writes. If persistence happens afterward, report overall success only after that step also succeeds.
[XamlOptions.setExportHiddenSlides](https://reference.aspose.com/slides/java/com.aspose.slides/xamloptions/#setExportHiddenSlides-boolean-) also applies to a custom saver. The default setting, `false`, excludes hidden-slide XAML documents. Passing `true` includes them and any resources required for their export. Resource counts depend on the presentation; do not assume one callback per slide or a fixed callback order.
### **Export to Memory and Inspect the Artifacts**
This complete example loads `pres.pptx`, collects every artifact in a [Map](https://docs.oracle.com/javase/8/docs/api/java/util/Map.html), and prints its name, type, and byte count. It preserves the supplied names exactly. Duplicate names mark the collection as invalid instead of silently overwriting an artifact. The example checks this before using the results.
```java
import com.aspose.slides.*;
import java.util.LinkedHashMap;
import java.util.Map;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
class MemoryXamlSaver implements IXamlOutputSaver {
final Map artifacts = new LinkedHashMap<>();
boolean valid = true;
@Override
public void save(String path, byte[] data) {
if (artifacts.containsKey(path)) {
valid = false;
System.err.println("Export rejected: duplicate artifact name: " + path);
return;
}
byte[] retainedData = data.clone();
artifacts.put(path, retainedData);
}
}
MemoryXamlSaver saver = new MemoryXamlSaver();
Presentation presentation = new Presentation("pres.pptx");
try {
XamlOptions options = new XamlOptions();
options.setOutputSaver(saver);
options.setExportHiddenSlides(true);
presentation.save(options);
} finally {
presentation.dispose();
}
if (!saver.valid) {
System.err.println("Export rejected: the artifact collection is invalid.");
return;
}
boolean inspectXamlText = false;
for (Map.Entry artifact : saver.artifacts.entrySet()) {
String name = artifact.getKey().toLowerCase(Locale.ROOT);
boolean isXaml = name.endsWith(".xaml");
boolean isImage = name.matches(".*\\.(png|jpg|jpeg|gif|bmp|tif|tiff|svg)$");
String kind = isXaml ? "slide XAML" : isImage ? "image" : "supporting resource";
System.out.println(artifact.getKey() + ": " + artifact.getValue().length + " bytes (" + kind + ")");
// Decode only XAML, and only when textual inspection is needed.
if (isXaml && inspectXamlText) {
String markup = new String(artifact.getValue(), StandardCharsets.UTF_8);
System.out.println(markup);
}
}
```
Extension checks are useful for inspection; retain all artifacts, including unfamiliar resource types. Leave the bytes unchanged when storing or transmitting them. Use the [String constructor](https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#String-byte:A-java.nio.charset.Charset-) with UTF-8 only for XAML that needs textual processing.
### **Package Collected Artifacts in a ZIP Archive**
This independent example collects the export, validates its names, and writes the original bytes into a ZIP archive. A unique archive name separates concurrent export jobs. ZIP entries use forward slashes and retain relative directories. Unsafe names or names that collide after normalization reject the entire package before it is written.
```java
import com.aspose.slides.*;
import java.util.LinkedHashMap;
import java.util.Map;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Set;
import java.util.TreeSet;
import java.util.UUID;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
class MemoryXamlSaver implements IXamlOutputSaver {
final Map artifacts = new LinkedHashMap<>();
boolean valid = true;
@Override
public void save(String path, byte[] data) {
if (artifacts.containsKey(path)) {
valid = false;
System.err.println("Export rejected: duplicate artifact name: " + path);
return;
}
byte[] retainedData = data.clone();
artifacts.put(path, retainedData);
}
}
MemoryXamlSaver saver = new MemoryXamlSaver();
Presentation presentation = new Presentation("pres.pptx");
try {
XamlOptions options = new XamlOptions();
options.setOutputSaver(saver);
options.setExportHiddenSlides(false);
presentation.save(options);
} finally {
presentation.dispose();
}
if (!saver.valid) {
System.err.println("Export rejected: the artifact collection is invalid.");
return;
}
Map entries = new LinkedHashMap<>();
Set entryNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
for (Map.Entry artifact : saver.artifacts.entrySet()) {
String entryName = artifact.getKey().replace('\\', '/');
String[] segments = entryName.split("/", -1);
boolean unsafeName = entryName.startsWith("/") || entryName.contains(":");
for (String segment : segments) {
unsafeName |= segment.trim().isEmpty() || segment.equals(".") || segment.equals("..");
}
if (unsafeName || !entryNames.add(entryName)) {
System.err.println("Export rejected: unsafe or duplicate artifact name: " + artifact.getKey());
return;
}
entries.put(entryName, artifact.getValue());
}
Path archivePath = Paths.get("xaml-" + UUID.randomUUID() + ".zip");
try {
OutputStream output = Files.newOutputStream(archivePath, StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE);
try (OutputStream archiveOutput = output; ZipOutputStream archive = new ZipOutputStream(archiveOutput)) {
for (Map.Entry artifact : entries.entrySet()) {
ZipEntry entry = new ZipEntry(artifact.getKey());
archive.putNextEntry(entry);
archive.write(artifact.getValue());
archive.closeEntry();
}
}
// The ZIP directory has been finalized by closing before reporting success.
System.out.println("Saved " + entries.size() + " artifacts to " + archivePath);
} catch (IOException exception) {
System.err.println("Archive persistence failed: " + exception.getMessage());
}
```
The example uses [ZipOutputStream](https://docs.oracle.com/javase/8/docs/api/java/util/zip/ZipOutputStream.html) to write one local archive; the exporter itself does not write loose XAML or image files. For remote storage, replace the archive-writing stage with uploads of the collected byte arrays. Use an export-job identifier plus the full relative artifact name as a blob key, or store the job identifier, relative name, and binary data in a database row. Publish the job only after all uploads complete or the database transaction commits. Clean up partial output if persistence fails.
For large presentations, a custom saver can persist each artifact directly to application storage to avoid keeping an additional copy of the entire export in application memory. Keep each callback synchronous from the exporter's perspective: return only after the destination has accepted the bytes, and allow failures to reach the caller.
### **Preserve Resource Names and Verify References**
- Normalize path separators when the destination requires it, but preserve relative directories. Do not use only [Path.getFileName](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html#getFileName--) unless every generated name is known to be unique and resource references remain valid.
- Apply destination-specific name validation. When writing loose files, reject rooted paths and traversal segments, resolve the destination with [Path.toAbsolutePath](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html#toAbsolutePath--), and verify it stays beneath the intended export directory, including the directory separator in the containment check. Use an application-controlled directory without symbolic links that could redirect writes.
- Use a separate saver and storage namespace for each export job. Detect collisions after separator normalization and according to the destination's case-sensitivity rules.
- Before publishing, parse each XAML document as XML and inspect its file-based resource references, such as image `Source` or `ImageSource` attributes. Resolve each relative URI against the containing XAML artifact's directory, normalize the resulting storage name, and confirm that the corresponding map key, ZIP entry, or stored object exists. Treat external URIs and XAML markup expressions separately from relative file names.
For example, if `pres/Slide_1.xaml` references `images/image1.png`, the stored resource must be available as `pres/images/image1.png`. Keeping just `image1.png` would break that relationship. For object storage, preserve the same layout beneath the job prefix and make those resource URLs accessible to the XAML consumer. Reopen the completed ZIP to verify entry names and resource bytes, and load representative slides in the target XAML environment to confirm that images resolve correctly.
## **FAQ**
**How can I ensure predictable fonts if the original font is not available on the machine?**
Call [setDefaultRegularFont](https://reference.aspose.com/slides/java/com.aspose.slides/saveoptions/#setDefaultRegularFont-java.lang.String-) in [XamlOptions](https://reference.aspose.com/slides/java/com.aspose.slides/xamloptions/) — it is used as a fallback font during export when the original is missing. This does not guarantee that the generated XAML references the fallback font or that the font is available on the target machine. Ensure that the fonts referenced by the XAML are available in the environment where it is displayed.
**Is the exported XAML intended only for WPF, or can it be used in other XAML stacks as well?**
Aspose.Slides exports WPF XAML through its public API. Compatibility with other XAML stacks, such as UWP and Xamarin.Forms, is not guaranteed. Test the generated markup in your target environment.
**Are hidden slides supported, and how can I prevent them from being exported by default?**
By default, hidden slides are not included. You can control this behavior via [setExportHiddenSlides](https://reference.aspose.com/slides/java/com.aspose.slides/xamloptions/#setExportHiddenSlides-boolean-) in [XamlOptions](https://reference.aspose.com/slides/java/com.aspose.slides/xamloptions/) — keep it disabled if you do not need to export them.
# Export Math Equations from Presentations in Java
> Export math equations from PowerPoint presentations to LaTeX or MathML directly with Aspose.Slides for Java.
Source: https://docs.aspose.com/slides/java/exporting-math-equations/
Updated: 2026-08-13
## **Introduction**
Aspose.Slides allows you to export math equations from presentations. For example, you may need to extract the mathematical equations on slides (from a specific presentation) and use them in another program or platform.
You can export equations directly to LaTeX or to MathML, a popular standard for mathematical content used on the web and in many applications.
## **Export Math Equations to LaTeX**
Aspose.Slides can convert a PowerPoint math equation directly to LaTeX; an intermediate MathML file and an external converter are not required. A math equation is stored in a text frame as an [IMathPortion](https://reference.aspose.com/slides/java/com.aspose.slides/imathportion/). Use [IMathPortion.getMathParagraph](https://reference.aspose.com/slides/java/com.aspose.slides/imathportion/#getMathParagraph--) to get an [IMathParagraph](https://reference.aspose.com/slides/java/com.aspose.slides/imathparagraph/), and then call [IMathParagraph.toLatex](https://reference.aspose.com/slides/java/com.aspose.slides/imathparagraph/#toLatex--). The method returns a string that you can save, display, send to another application, or process further.
The following example examines every text frame on every slide, finds all math portions, and writes each equation to a separate `.tex` file:
```java
Presentation presentation = new Presentation("equations.pptx");
try {
int slideCount = presentation.getSlides().size();
for (int slideIndex = 0; slideIndex < slideCount; slideIndex++) {
ISlide slide = presentation.getSlides().get_Item(slideIndex);
int slideNumber = slideIndex + 1;
int equationNumber = 1;
ITextFrame[] textFrames = SlideUtil.getAllTextBoxes(slide);
for (ITextFrame textFrame : textFrames) {
for (IParagraph paragraph : textFrame.getParagraphs()) {
for (IPortion portion : paragraph.getPortions()) {
if (!(portion instanceof IMathPortion))
continue;
IMathPortion mathPortion = (IMathPortion) portion;
IMathParagraph mathParagraph = mathPortion.getMathParagraph();
String latexFileName = "slide_" + slideNumber + "_equation_" + equationNumber + ".tex";
String latexText = mathParagraph.toLatex();
Path latexPath = Paths.get(latexFileName);
byte[] latexBytes = latexText.getBytes(StandardCharsets.UTF_8);
Files.write(latexPath, latexBytes);
equationNumber++;
}
}
}
}
} finally {
presentation.dispose();
}
```
[SlideUtil.getAllTextBoxes](https://reference.aspose.com/slides/java/com.aspose.slides/slideutil/#getAllTextBoxes-com.aspose.slides.IBaseSlide-) returns all text frames found on a slide. The [IMathPortion](https://reference.aspose.com/slides/java/com.aspose.slides/imathportion/) type check separates genuine editable equations from ordinary text and images.
LaTeX engines and document templates do not all support the same commands, packages, or Unicode characters. Test the returned string with the LaTeX engine used by your application. If a symbol or Office Math element has no suitable representation in that environment, replace it in the returned string with a project-specific command or skip the equation and record the issue for review.
## **Save Math Equations as MathML**
While humans easily write the code for some equation formats like LaTeX, they struggle to write the code for MathML because the latter is meant to be generated automatically by apps. Programs read and parse MathML easily because its code is in XML, so MathML is commonly used as an output and printing format in many fields.
This sample code shows you how to export a math equation from a presentation to MathML:
```java
import com.aspose.slides.*;
import java.io.FileOutputStream;
import java.io.IOException;
Presentation pres = new Presentation();
try {
IAutoShape autoShape = pres.getSlides().get_Item(0).getShapes().addMathShape(0, 0, 500, 50);
IMathParagraph mathParagraph = ((MathPortion)autoShape.getTextFrame().getParagraphs().get_Item(0).
getPortions().get_Item(0)).getMathParagraph();
mathParagraph.add(new MathematicalText("a").
setSuperscript("2").
join("+").
join(new MathematicalText("b").setSuperscript("2")).
join("=").
join(new MathematicalText("c").setSuperscript("2")));
FileOutputStream stream = new FileOutputStream("mathml.xml");
mathParagraph.writeAsMathMl(stream);
} catch (IOException e) {
} finally {
if (pres != null) pres.dispose();
}
```
## **FAQ**
**What exactly is exported to MathML—a paragraph or an individual formula block?**
You can export either an entire math paragraph ([MathParagraph](https://reference.aspose.com/slides/java/com.aspose.slides/mathparagraph/)) or an individual block ([MathBlock](https://reference.aspose.com/slides/java/com.aspose.slides/mathblock/)) to MathML. Both types provide a method to write to MathML.
**How can I tell that an object on a slide is a math formula rather than regular text or an image?**
A formula lives in a [MathPortion](https://reference.aspose.com/slides/java/com.aspose.slides/mathportion/) and has a [MathParagraph](https://reference.aspose.com/slides/java/com.aspose.slides/mathparagraph/). Images and regular text portions without a [MathParagraph](https://reference.aspose.com/slides/java/com.aspose.slides/mathparagraph/) are not exportable formulas.
**Where does the MathML come from in a presentation—is it PowerPoint-specific or a standard?**
The export targets standard MathML (XML). Aspose uses Presentation MathML—the presentation subset of the standard—which is widely used across applications and the web.
**Is exporting formulas inside tables, SmartArt, groups, etc., supported?**
Yes, if those objects contain text portions with a [MathParagraph](https://reference.aspose.com/slides/java/com.aspose.slides/mathparagraph/) (i.e., genuine PowerPoint formulas), they are exported. If a formula is embedded as an image, it is not.
**Does exporting to MathML modify the original presentation?**
No. Writing MathML is a serialization of the formula’s content; it does not modify the presentation file.
## Related articles
- [Add Math Equations to PowerPoint Presentations in Java](https://docs.aspose.com/slides/java/powerpoint-math-equations/)
# Export Presentations to HTML with Externally Linked Images
> Export PowerPoint and OpenDocument presentations to HTML in Java using Aspose.Slides with images and other resources saved as external linked files.
Source: https://docs.aspose.com/slides/java/exporting-presentations-to-html-with-externally-linked-images/
Updated: 2026-08-02
## **Overview**
By default, Aspose.Slides exports a presentation to a self-contained HTML file. Images and other resources are written directly into the HTML, usually as Base64 data. This is convenient when you need one portable file, but it is not always the best format for a website, a CMS, or a server-side conversion pipeline.
Use externally linked resources when you want to:
- reduce the size of the HTML document;
- cache images, fonts, audio, or video separately in a browser or CDN;
- inspect, replace, compress, or post-process generated resources after export;
- keep the output structure closer to what a web application expects.
For the general HTML conversion workflow, see [Convert PowerPoint Presentations to HTML](https://docs.aspose.com/slides/java/convert-powerpoint-to-html/). This article focuses on the resource-linking part of the export.
## **How Linked Resource Export Works**
[ILinkEmbedController](https://reference.aspose.com/slides/java/com.aspose.slides/ilinkembedcontroller/) lets your application decide, resource by resource, whether the exporter embeds the data in the HTML or saves it externally and writes a link.
The interface has three methods:
- [ILinkEmbedController.getObjectStoringLocation](https://reference.aspose.com/slides/java/com.aspose.slides/ilinkembedcontroller/) decides whether a resource should be linked or embedded.
- [ILinkEmbedController.getUrl](https://reference.aspose.com/slides/java/com.aspose.slides/ilinkembedcontroller/) returns the URL that will be written to the generated HTML or to another linked resource.
- [ILinkEmbedController.saveExternal](https://reference.aspose.com/slides/java/com.aspose.slides/ilinkembedcontroller/) writes the linked resource data to disk or to another storage target.
The file system path and the browser URL are separate concerns. For example, the sample below writes resource files to `html-output/assets` on disk, while the HTML contains relative URLs such as `assets/resource-1.svg`. A browser resolves those URLs relative to the file that contains the link. Therefore, a link from `presentation.html` to an SVG file uses `assets/resource-1.svg`, while a link from that SVG file to an image saved in the same `assets` folder uses `resource-4.jpg`.
## **Export HTML with Linked Resources**
The following Java example creates an output directory, saves the HTML file there, and stores linked resources in an `assets` subdirectory. The controller links common image, font, audio, video, and CSS resources when Aspose.Slides provides or can infer a safe file extension. Resources that are not recognized remain embedded.
```java
import com.aspose.slides.HtmlFormatter;
import com.aspose.slides.HtmlOptions;
import com.aspose.slides.ILinkEmbedController;
import com.aspose.slides.LinkEmbedDecision;
import com.aspose.slides.Presentation;
import com.aspose.slides.SVGOptions;
import com.aspose.slides.SaveFormat;
import com.aspose.slides.SlideImageFormat;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
public class ExportToHtmlWithLinkedResources {
public static void main(String[] args) throws IOException {
Path inputFilePath = Paths.get("presentation.pptx");
Path outputDirectory = Paths.get("html-output");
String assetDirectoryName = "assets";
Path assetDirectory = outputDirectory.resolve(assetDirectoryName);
Files.createDirectories(outputDirectory);
Files.createDirectories(assetDirectory);
String assetUrlPrefix = assetDirectoryName + "/";
ExternalResourceController controller = new ExternalResourceController(assetDirectory, assetUrlPrefix);
SVGOptions svgOptions = new SVGOptions(controller);
SlideImageFormat slideImageFormat = SlideImageFormat.svg(svgOptions);
HtmlOptions htmlOptions = new HtmlOptions(controller);
htmlOptions.setHtmlFormatter(HtmlFormatter.createDocumentFormatter("", false));
htmlOptions.setSlideImageFormat(slideImageFormat);
Presentation presentation = new Presentation(inputFilePath.toString());
try {
Path htmlFilePath = outputDirectory.resolve("presentation.html");
presentation.save(htmlFilePath.toString(), SaveFormat.Html, htmlOptions);
} finally {
presentation.dispose();
}
}
private static final class ExternalResourceController implements ILinkEmbedController {
private static final Map EXTENSIONS_BY_CONTENT_TYPE = createExtensionsByContentType();
private final Path assetDirectory;
private final String assetUrlPrefix;
private final Map fileNamesByResourceId = new HashMap<>();
private ExternalResourceController(Path assetDirectory, String assetUrlPrefix) {
if (assetDirectory == null) {
throw new IllegalArgumentException("The asset output directory must not be null.");
}
this.assetDirectory = assetDirectory;
this.assetUrlPrefix = normalizeUrlPrefix(assetUrlPrefix);
}
@Override
public int getObjectStoringLocation(
int resourceId,
byte[] entityData,
String semanticName,
String contentType,
String recommendedExtension) {
String extension = resolveExtension(contentType, recommendedExtension);
if (extension == null) {
return LinkEmbedDecision.Embed;
}
fileNamesByResourceId.put(resourceId, "resource-" + resourceId + extension);
return LinkEmbedDecision.Link;
}
@Override
public String getUrl(int resourceId, int referrer) {
String fileName = fileNamesByResourceId.get(resourceId);
if (fileName == null) {
return null;
}
if (fileNamesByResourceId.containsKey(referrer)) {
return fileName;
}
return assetUrlPrefix + fileName;
}
@Override
public void saveExternal(int resourceId, byte[] entityData) {
String fileName = fileNamesByResourceId.get(resourceId);
if (fileName == null) {
throw new IllegalStateException(
"Resource " + resourceId + " was not registered for external storage.");
}
if (entityData == null || entityData.length == 0) {
throw new IllegalStateException(
"Resource " + resourceId + " contains no data and cannot be saved.");
}
try {
Files.createDirectories(assetDirectory);
Path filePath = assetDirectory.resolve(fileName);
Files.write(filePath, entityData);
} catch (IOException exception) {
throw new IllegalStateException("Failed to save external resource " + resourceId + ".", exception);
}
}
private static Map createExtensionsByContentType() {
Map extensionsByContentType = new HashMap<>();
extensionsByContentType.put("image/jpeg", ".jpg");
extensionsByContentType.put("image/png", ".png");
extensionsByContentType.put("image/gif", ".gif");
extensionsByContentType.put("image/bmp", ".bmp");
extensionsByContentType.put("image/svg+xml", ".svg");
extensionsByContentType.put("image/tiff", ".tiff");
extensionsByContentType.put("image/x-emf", ".emf");
extensionsByContentType.put("image/x-wmf", ".wmf");
extensionsByContentType.put("font/woff", ".woff");
extensionsByContentType.put("font/woff2", ".woff2");
extensionsByContentType.put("font/ttf", ".ttf");
extensionsByContentType.put("application/font-woff", ".woff");
extensionsByContentType.put("application/vnd.ms-fontobject", ".eot");
extensionsByContentType.put("application/x-font-ttf", ".ttf");
extensionsByContentType.put("text/css", ".css");
extensionsByContentType.put("audio/mpeg", ".mp3");
extensionsByContentType.put("audio/mp4", ".m4a");
extensionsByContentType.put("audio/wav", ".wav");
extensionsByContentType.put("video/mp4", ".mp4");
extensionsByContentType.put("video/webm", ".webm");
return extensionsByContentType;
}
private static String resolveExtension(String contentType, String recommendedExtension) {
if (contentType != null && !contentType.trim().isEmpty()) {
String mappedExtension = EXTENSIONS_BY_CONTENT_TYPE.get(contentType);
if (mappedExtension != null) {
return mappedExtension;
}
}
if (!isSupportedContentType(contentType)) {
return null;
}
return normalizeExtension(recommendedExtension);
}
private static boolean isSupportedContentType(String contentType) {
return contentType != null &&
(contentType.regionMatches(true, 0, "image/", 0, "image/".length()) ||
contentType.regionMatches(true, 0, "font/", 0, "font/".length()) ||
contentType.regionMatches(true, 0, "audio/", 0, "audio/".length()) ||
contentType.regionMatches(true, 0, "video/", 0, "video/".length()));
}
private static String normalizeExtension(String extension) {
if (extension == null || extension.trim().isEmpty()) {
return null;
}
String extensionCharacters = extension.trim();
while (extensionCharacters.startsWith(".")) {
extensionCharacters = extensionCharacters.substring(1);
}
if (extensionCharacters.isEmpty()) {
return null;
}
for (int index = 0; index < extensionCharacters.length(); index++) {
char character = extensionCharacters.charAt(index);
if (!Character.isLetterOrDigit(character)) {
return null;
}
}
return "." + extensionCharacters.toLowerCase(Locale.ROOT);
}
private static String normalizeUrlPrefix(String urlPrefix) {
if (urlPrefix == null || urlPrefix.isEmpty()) {
return "";
}
String normalizedUrlPrefix = urlPrefix.replace('\\', '/');
return normalizedUrlPrefix.endsWith("/")
? normalizedUrlPrefix
: normalizedUrlPrefix + "/";
}
}
}
```
After the export, the output folder has this structure:
```text
html-output/
presentation.html
assets/
resource-1.svg
resource-2.svg
resource-3.svg
resource-4.jpg
resource-5.png
```
The exact files depend on the presentation content and export options. For example, raster images are commonly exported as JPEG or PNG. Aspose.Slides may choose a different image codec than the one used in the source presentation when that produces a smaller or more suitable file. Images with transparency are exported as PNG.
## **Choosing URLs for Deployment**
The sample uses a relative URL prefix: `assets/`. If `presentation.html` is opened from `html-output/presentation.html`, the browser loads `html-output/assets/resource-1.svg`.
When one linked resource refers to another linked resource, the sample uses the `referrer` parameter in [ILinkEmbedController.getUrl](https://reference.aspose.com/slides/java/com.aspose.slides/ilinkembedcontroller/) and returns only the file name. For example, if `resource-1.svg` and `resource-4.jpg` are both in the `assets` folder, the SVG file should refer to `resource-4.jpg`, not to `assets/resource-4.jpg`.
Use a different URL prefix when the files are deployed elsewhere:
- Use `assets/` when the asset directory is next to the HTML file.
- Use `../assets/` when the asset directory is one level above the HTML file.
- Use `https://cdn.example.com/presentations/job-123/assets/` when the files are uploaded to a CDN or static file server.
The URL returned by [ILinkEmbedController.getUrl](https://reference.aspose.com/slides/java/com.aspose.slides/ilinkembedcontroller/) must match the final deployed location of the file written by [ILinkEmbedController.saveExternal](https://reference.aspose.com/slides/java/com.aspose.slides/ilinkembedcontroller/). In server applications, use a unique output directory or object-storage prefix for each conversion job to avoid overwriting files from another export.
## **When to Embed Instead**
Embedded Base64 HTML is still useful when the output must be a single file, such as an email attachment, an offline preview, or a document that will be moved without a supporting asset folder. Linked resources are a better fit when the HTML will be served by a web application, stored in a CMS, optimized by a build pipeline, or cached by browsers independently from the HTML.
## **FAQ**
### Can I externalize only images and keep other resources embedded?
Yes. In [ILinkEmbedController.getObjectStoringLocation](https://reference.aspose.com/slides/java/com.aspose.slides/ilinkembedcontroller/), return `LinkEmbedDecision.Link` only for the content types you want to save as separate files, and return `LinkEmbedDecision.Embed` for everything else.
### Why does the exported image extension differ from the source presentation?
Aspose.Slides may re-encode raster images during HTML export to improve size or browser compatibility. For example, an image from the source file may be written as JPEG or PNG depending on the rendered result.
### Do relative URLs work after I move the HTML file?
Relative URLs work only when the same relative folder structure is preserved. If the HTML references `assets/resource-1.png`, the `assets` folder must stay next to the HTML file unless you generate a different URL prefix.
### Should server applications reuse the same output folder?
No. Use a unique output directory or storage prefix for each conversion job. This avoids filename collisions and prevents one export from overwriting resources generated by another export.
## Related articles
- [Convert PowerPoint Presentations to HTML in Java](https://docs.aspose.com/slides/java/convert-powerpoint-to-html/)
# Advanced Text Extraction from Presentations in Java
> Quickly extract text from PowerPoint and OpenDocument presentations using Aspose.Slides for Java. Follow our simple, step-by-step guide to save time.
Source: https://docs.aspose.com/slides/java/extract-text-from-presentation/
Updated: 2026-08-05
## **Overview**
Extracting text from presentations is a common yet essential task for developers working with slide content. Whether you're dealing with Microsoft PowerPoint files in PPT or PPTX format, or OpenDocument presentations (ODP), accessing and retrieving textual data can be critical for analysis, automation, indexing, or content migration purposes.
This article provides a comprehensive guide on how to efficiently extract text from various presentation formats, including PPT, PPTX, and ODP, using Aspose.Slides for Java. You'll learn how to systematically iterate through presentation elements to accurately retrieve the text content you need.
## **Extract Text from a Slide**
Aspose.Slides for Java provides the [SlideUtil](https://reference.aspose.com/slides/java/com.aspose.slides/slideutil/) class. This class exposes several overloaded static methods for extracting all text from a presentation or slide. To extract text from a slide in a presentation, use the [SlideUtil.getAllTextBoxes](https://reference.aspose.com/slides/java/com.aspose.slides/slideutil/#getAllTextBoxes-com.aspose.slides.IBaseSlide-) method. This method accepts an object of type [IBaseSlide](https://reference.aspose.com/slides/java/com.aspose.slides/ibaseslide/) as a parameter. When executed, the method scans the entire slide for text and returns an array of objects of type [ITextFrame](https://reference.aspose.com/slides/java/com.aspose.slides/itextframe/), preserving any text formatting.
The following code snippet extracts all the text from the first slide of the presentation:
```java
import com.aspose.slides.*;
int slideIndex = 0;
Presentation presentation = new Presentation("demo.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(slideIndex);
ITextFrame[] textFrames = SlideUtil.getAllTextBoxes(slide);
for (ITextFrame textFrame : textFrames) {
for (IParagraph paragraph : textFrame.getParagraphs()) {
for (IPortion portion : paragraph.getPortions()) {
String portionText = portion.getText();
System.out.println(portionText);
IPortionFormat portionFormat = portion.getPortionFormat();
float fontHeight = portionFormat.getFontHeight();
System.out.println(fontHeight);
IFontData latinFont = portionFormat.getLatinFont();
if (latinFont != null) {
String fontName = latinFont.getFontName();
System.out.println(fontName);
}
}
}
}
} finally {
presentation.dispose();
}
```
## **Extract Text from a Presentation**
To scan text from the entire presentation, use the [SlideUtil.getAllTextFrames](https://reference.aspose.com/slides/java/com.aspose.slides/slideutil/#getAllTextFrames-com.aspose.slides.IPresentation-boolean-) static method exposed by the [SlideUtil](https://reference.aspose.com/slides/java/com.aspose.slides/slideutil/) class. It accepts two parameters:
1. First, an [IPresentation](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentation/) object representing a PowerPoint or OpenDocument presentation from which text will be extracted.
1. Second, a `boolean` value indicating whether the master slides should be included when scanning text from the presentation.
The method returns an array of objects of type [ITextFrame](https://reference.aspose.com/slides/java/com.aspose.slides/itextframe/), including text formatting information. The code below scans the text and formatting details from a presentation, including the master slides.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("demo.pptx");
try {
boolean includeMasterSlides = true;
ITextFrame[] textFrames = SlideUtil.getAllTextFrames(presentation, includeMasterSlides);
for (ITextFrame textFrame : textFrames) {
for (IParagraph paragraph : textFrame.getParagraphs()) {
for (IPortion portion : paragraph.getPortions()) {
String portionText = portion.getText();
System.out.println(portionText);
IPortionFormat portionFormat = portion.getPortionFormat();
float fontHeight = portionFormat.getFontHeight();
System.out.println(fontHeight);
IFontData latinFont = portionFormat.getLatinFont();
if (latinFont != null) {
String fontName = latinFont.getFontName();
System.out.println(fontName);
}
}
}
}
} finally {
presentation.dispose();
}
```
## **Categorized and Fast Text Extraction**
The [PresentationFactory](https://reference.aspose.com/slides/java/com.aspose.slides/presentationfactory/) class also provides methods for extracting all text from presentations:
```java
import com.aspose.slides.*;
import java.io.FileInputStream;
import java.io.InputStream;
int mode = TextExtractionArrangingMode.Unarranged;
ILoadOptions loadOptions = new LoadOptions();
// Extract the text from a file.
IPresentationText text1 = PresentationFactory.getInstance().getPresentationText("presentation.pptx", mode);
// Extract the text from a stream.
InputStream stream1 = new FileInputStream("presentation.pptx");
try {
IPresentationText text2 = PresentationFactory.getInstance().getPresentationText(stream1, mode);
} finally {
stream1.close();
}
// Extract the text from a stream using load options.
InputStream stream2 = new FileInputStream("presentation.pptx");
try {
IPresentationText text3 = PresentationFactory.getInstance().getPresentationText(stream2, mode, loadOptions);
} finally {
stream2.close();
}
```
The [TextExtractionArrangingMode](https://reference.aspose.com/slides/java/com.aspose.slides/textextractionarrangingmode/) enum argument indicates the mode for organizing the text extraction result and can be set to the following values:
- `Unarranged` - The raw text without regard to its position on the slide.
- `Arranged` - The text is arranged in the same order as on the slide.
The unarranged mode can be used when speed is critical; it's faster than the arranged mode.
[IPresentationText](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentationtext/) represents the raw text extracted from the presentation. Its `getSlidesText` method returns an array of objects of type [ISlideText](https://reference.aspose.com/slides/java/com.aspose.slides/islidetext/). Each object represents the text on the corresponding slide. The object of type [ISlideText](https://reference.aspose.com/slides/java/com.aspose.slides/islidetext/) has the following methods:
- `getText` - The text within the slide's shapes.
- `getMasterText` - The text within the master slide's shapes associated with this slide.
- `getLayoutText` - The text within the layout slide's shapes associated with this slide.
- `getNotesText` - The text within the notes slide's shapes associated with this slide.
- `getCommentsText` - The text within comments associated with this slide.
```java
import com.aspose.slides.*;
String presentationPath = "presentation.ppt";
int arrangingMode = TextExtractionArrangingMode.Unarranged;
IPresentationText presentationText = PresentationFactory.getInstance().getPresentationText(presentationPath, arrangingMode);
ISlideText firstSlideText = presentationText.getSlidesText()[0];
System.out.println(firstSlideText.getText());
System.out.println(firstSlideText.getLayoutText());
System.out.println(firstSlideText.getMasterText());
System.out.println(firstSlideText.getNotesText());
System.out.println(firstSlideText.getCommentsText());
```
## **FAQ**
### How fast does Aspose.Slides process large presentations during text extraction?
Aspose.Slides is optimized for high performance and can process even [large presentations](https://docs.aspose.com/slides/java/open-presentation/), making it suitable for real-time or bulk processing scenarios.
### Can Aspose.Slides extract text from tables and charts within presentations?
Yes. Aspose.Slides can extract text from many slide elements, including tables and chart-related objects, so you can access and analyze textual content in common presentation structures.
### Do I need a special Aspose.Slides license to extract text from presentations?
You can extract text using the free trial version of Aspose.Slides, although it will have [certain limitations](https://docs.aspose.com/slides/java/licensing/), such as processing only a limited number of slides. For unrestricted use and to handle larger presentations, purchasing a full license is recommended.
# Extract Images from Presentation Shapes in Java
> Extract images from shapes in PowerPoint and OpenDocument presentations with Aspose.Slides for Java - quick, code-friendly solution.
Source: https://docs.aspose.com/slides/java/extracting-images-from-presentation-shapes/
Updated: 2026-08-13
## **Overview**
Images in a presentation can appear in several shape types: as ordinary picture frames, as picture fills applied to shapes, as OLE object preview images, as video or audio frame thumbnails, as zoom images, or as images nested inside table, chart, and SmartArt shapes. Aspose.Slides stores those images in the presentation image collection, exposed through [IImageCollection](https://reference.aspose.com/slides/java/com.aspose.slides/iimagecollection/) and [IPPImage](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/) objects.
If you only need to export every image resource embedded in a presentation, iterate through `presentation.getImages()`. This article focuses on a different task: traversing shapes to find where images are used on slides, so the saved files can keep useful context such as the slide number, shape position, and source type (picture frame, fill image, media preview, OLE preview, or zoom image).
Use [IPPImage.getBinaryData](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/#getBinaryData--) to preserve the original encoded image data and file type. Use [IPPImage.getImage](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/#getImage--) with [IImage.save](https://reference.aspose.com/slides/java/com.aspose.slides/iimage/#save-java.lang.String-int-) when you want to normalize the output to a specific format such as PNG.
## **Shared Helper Methods**
The helper methods below keep the examples short. `saveOriginalImage` writes the original embedded bytes, chooses a safe extension from the MIME type, and skips duplicate image binaries by SHA-256 hash.
```java
import com.aspose.slides.*;
import java.io.File;
import java.io.FileOutputStream;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Set;
private static final class ShapeReference
{
private final IShape shape;
private final String namePart;
private ShapeReference(IShape shape, String namePart)
{
this.shape = shape;
this.namePart = namePart;
}
}
private static boolean saveOriginalImage(
IPPImage image,
String outputDirectory,
String fileNameBase,
Set savedImageHashes) throws Exception
{
byte[] imageData = image.getBinaryData();
String imageHash = getSha256Hash(imageData);
if (!savedImageHashes.add(imageHash))
{
return false;
}
String extension = getExtensionFromContentType(image.getContentType());
String fileName = fileNameBase + "." + extension;
File outputFile = new File(outputDirectory, fileName);
FileOutputStream outputStream = new FileOutputStream(outputFile);
try
{
outputStream.write(imageData);
}
finally
{
outputStream.close();
}
return true;
}
private static void saveImageAsPng(IPPImage image, String outputDirectory, String fileNameBase)
{
String fileName = fileNameBase + ".png";
File outputFile = new File(outputDirectory, fileName);
String outputPath = outputFile.getPath();
IImage outputImage = image.getImage();
try
{
outputImage.save(outputPath, ImageFormat.Png);
}
finally
{
if (outputImage != null)
{
outputImage.dispose();
}
}
}
private static IPPImage getPictureFillImage(IFillFormat fillFormat)
{
if (fillFormat == null || fillFormat.getFillType() != FillType.Picture)
{
return null;
}
return fillFormat.getPictureFillFormat().getPicture().getImage();
}
private static List enumerateShapes(
IShapeCollection shapes,
String prefix,
boolean includeGroupedShapes)
{
List shapeReferences = new ArrayList();
int shapeCount = shapes.size();
for (int shapeIndex = 0; shapeIndex < shapeCount; shapeIndex++)
{
IShape shape = shapes.get_Item(shapeIndex);
int displayIndex = shapeIndex + 1;
String shapeNamePart = prefix + "_shape_" + displayIndex;
ShapeReference shapeReference = new ShapeReference(shape, shapeNamePart);
shapeReferences.add(shapeReference);
if (includeGroupedShapes && shape instanceof IGroupShape)
{
IGroupShape groupShape = (IGroupShape)shape;
IShapeCollection childShapes = groupShape.getShapes();
List childReferences = enumerateShapes(
childShapes,
shapeNamePart,
includeGroupedShapes);
shapeReferences.addAll(childReferences);
}
}
return shapeReferences;
}
private static String getSha256Hash(byte[] data) throws Exception
{
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
byte[] hashBytes = messageDigest.digest(data);
StringBuilder hashBuilder = new StringBuilder();
for (byte hashByte : hashBytes)
{
String hexValue = Integer.toHexString(hashByte & 0xff);
if (hexValue.length() == 1)
{
hashBuilder.append('0');
}
hashBuilder.append(hexValue);
}
return hashBuilder.toString();
}
private static String getExtensionFromContentType(String contentType)
{
if (contentType == null || contentType.trim().length() == 0)
{
return "bin";
}
String mediaType = contentType.split(";")[0].trim().toLowerCase(Locale.ROOT);
if ("image/jpeg".equals(mediaType))
{
return "jpg";
}
if ("image/png".equals(mediaType))
{
return "png";
}
if ("image/gif".equals(mediaType))
{
return "gif";
}
if ("image/bmp".equals(mediaType))
{
return "bmp";
}
if ("image/tiff".equals(mediaType))
{
return "tiff";
}
if ("image/x-emf".equals(mediaType) || "image/emf".equals(mediaType))
{
return "emf";
}
if ("image/x-wmf".equals(mediaType) || "image/wmf".equals(mediaType))
{
return "wmf";
}
if ("image/svg+xml".equals(mediaType))
{
return "svg";
}
if (mediaType.startsWith("image/"))
{
String extension = mediaType.substring("image/".length());
return makeSafeFileNamePart(extension);
}
return "bin";
}
private static String makeSafeFileNamePart(String value)
{
return value.replaceAll("[^A-Za-z0-9._-]", "_");
}
```
## **Extract Images from Picture Frames**
Use this approach for pictures inserted as standalone objects. An [IPictureFrame](https://reference.aspose.com/slides/java/com.aspose.slides/ipictureframe/) stores its picture in `getPictureFormat().getPicture().getImage()`, which returns an [IPPImage](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/) object.
```java
import com.aspose.slides.*;
import java.io.File;
import java.util.Set;
import java.util.List;
String inputPath = "sample.pptx";
String currentDirectory = System.getProperty("user.dir");
File outputFolder = new File(currentDirectory, "extracted-images");
outputFolder.mkdirs();
String outputDirectory = outputFolder.getPath();
Set savedImageHashes = new java.util.HashSet();
Presentation presentation = new Presentation(inputPath);
try
{
int slideCount = presentation.getSlides().size();
for (int slideIndex = 0; slideIndex < slideCount; slideIndex++)
{
ISlide slide = presentation.getSlides().get_Item(slideIndex);
int slideNumber = slide.getSlideNumber();
String slidePrefix = "slide_" + slideNumber;
IShapeCollection shapes = slide.getShapes();
List shapeReferences = enumerateShapes(shapes, slidePrefix, false);
for (ShapeReference shapeReference : shapeReferences)
{
if (shapeReference.shape instanceof IPictureFrame)
{
IPictureFrame pictureFrame = (IPictureFrame)shapeReference.shape;
IPPImage image = pictureFrame.getPictureFormat().getPicture().getImage();
saveOriginalImage(image, outputDirectory, shapeReference.namePart, savedImageHashes);
}
}
}
}
finally
{
if (presentation != null)
{
presentation.dispose();
}
}
```
## **Extract Images from Picture-Filled Shapes**
Shapes can use a picture as their fill. Check the shape's fill type first: if it is not [FillType.Picture](https://reference.aspose.com/slides/java/com.aspose.slides/filltype/), there is no picture to extract from that fill. The example below handles [IAutoShape](https://reference.aspose.com/slides/java/com.aspose.slides/iautoshape/) objects and saves each image as PNG through [IPPImage.getImage](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/#getImage--).
```java
import com.aspose.slides.*;
import java.io.File;
import java.util.List;
String inputPath = "sample.pptx";
String currentDirectory = System.getProperty("user.dir");
File outputFolder = new File(currentDirectory, "shape-fill-images");
outputFolder.mkdirs();
String outputDirectory = outputFolder.getPath();
Presentation presentation = new Presentation(inputPath);
try
{
int slideCount = presentation.getSlides().size();
for (int slideIndex = 0; slideIndex < slideCount; slideIndex++)
{
ISlide slide = presentation.getSlides().get_Item(slideIndex);
int slideNumber = slide.getSlideNumber();
String slidePrefix = "slide_" + slideNumber;
IShapeCollection shapes = slide.getShapes();
List shapeReferences = enumerateShapes(shapes, slidePrefix, false);
for (ShapeReference shapeReference : shapeReferences)
{
if (shapeReference.shape instanceof IAutoShape)
{
IAutoShape autoShape = (IAutoShape)shapeReference.shape;
IFillFormat fillFormat = autoShape.getFillFormat();
IPPImage image = getPictureFillImage(fillFormat);
if (image != null)
{
saveImageAsPng(image, outputDirectory, shapeReference.namePart);
}
}
}
}
}
finally
{
if (presentation != null)
{
presentation.dispose();
}
}
```
## **Extract Preview Images from OLE Object Frames**
An [IOleObjectFrame](https://reference.aspose.com/slides/java/com.aspose.slides/ioleobjectframe/) can have a substitute picture that PowerPoint uses as the object's preview on a slide. This image is available through `getSubstitutePictureFormat().getPicture().getImage()`. Extracting this picture gives you the preview image, not the embedded OLE package contents.
```java
import com.aspose.slides.*;
import java.io.File;
import java.util.Set;
import java.util.List;
String inputPath = "sample.pptx";
String currentDirectory = System.getProperty("user.dir");
File outputFolder = new File(currentDirectory, "ole-preview-images");
outputFolder.mkdirs();
String outputDirectory = outputFolder.getPath();
Set savedImageHashes = new java.util.HashSet();
Presentation presentation = new Presentation(inputPath);
try
{
int slideCount = presentation.getSlides().size();
for (int slideIndex = 0; slideIndex < slideCount; slideIndex++)
{
ISlide slide = presentation.getSlides().get_Item(slideIndex);
int slideNumber = slide.getSlideNumber();
String slidePrefix = "slide_" + slideNumber;
IShapeCollection shapes = slide.getShapes();
List shapeReferences = enumerateShapes(shapes, slidePrefix, false);
for (ShapeReference shapeReference : shapeReferences)
{
if (shapeReference.shape instanceof IOleObjectFrame)
{
IOleObjectFrame oleObjectFrame = (IOleObjectFrame)shapeReference.shape;
IPPImage image = oleObjectFrame.getSubstitutePictureFormat().getPicture().getImage();
if (image != null)
{
String fileNameBase = shapeReference.namePart + "_ole_preview";
saveOriginalImage(image, outputDirectory, fileNameBase, savedImageHashes);
}
}
}
}
}
finally
{
if (presentation != null)
{
presentation.dispose();
}
}
```
## **Extract Preview Images from Video Frames**
An [IVideoFrame](https://reference.aspose.com/slides/java/com.aspose.slides/ivideoframe/) can also store a preview image in `getPictureFormat().getPicture().getImage()`. This is the poster or thumbnail shown on the slide, not a frame decoded from the video stream.
```java
import com.aspose.slides.*;
import java.io.File;
import java.util.Set;
import java.util.List;
String inputPath = "sample.pptx";
String currentDirectory = System.getProperty("user.dir");
File outputFolder = new File(currentDirectory, "video-preview-images");
outputFolder.mkdirs();
String outputDirectory = outputFolder.getPath();
Set savedImageHashes = new java.util.HashSet();
Presentation presentation = new Presentation(inputPath);
try
{
int slideCount = presentation.getSlides().size();
for (int slideIndex = 0; slideIndex < slideCount; slideIndex++)
{
ISlide slide = presentation.getSlides().get_Item(slideIndex);
int slideNumber = slide.getSlideNumber();
String slidePrefix = "slide_" + slideNumber;
IShapeCollection shapes = slide.getShapes();
List shapeReferences = enumerateShapes(shapes, slidePrefix, false);
for (ShapeReference shapeReference : shapeReferences)
{
if (shapeReference.shape instanceof IVideoFrame)
{
IVideoFrame videoFrame = (IVideoFrame)shapeReference.shape;
IPPImage image = videoFrame.getPictureFormat().getPicture().getImage();
if (image != null)
{
String fileNameBase = shapeReference.namePart + "_video_preview";
saveOriginalImage(image, outputDirectory, fileNameBase, savedImageHashes);
}
}
}
}
}
finally
{
if (presentation != null)
{
presentation.dispose();
}
}
```
## **Extract Preview Images from Audio Frames**
An [IAudioFrame](https://reference.aspose.com/slides/java/com.aspose.slides/iaudioframe/) can store a thumbnail in `getPictureFormat().getPicture().getImage()`. This is the image shown for the audio object on the slide.
```java
import com.aspose.slides.*;
import java.io.File;
import java.util.Set;
import java.util.List;
String inputPath = "sample.pptx";
String currentDirectory = System.getProperty("user.dir");
File outputFolder = new File(currentDirectory, "audio-preview-images");
outputFolder.mkdirs();
String outputDirectory = outputFolder.getPath();
Set savedImageHashes = new java.util.HashSet();
Presentation presentation = new Presentation(inputPath);
try
{
int slideCount = presentation.getSlides().size();
for (int slideIndex = 0; slideIndex < slideCount; slideIndex++)
{
ISlide slide = presentation.getSlides().get_Item(slideIndex);
int slideNumber = slide.getSlideNumber();
String slidePrefix = "slide_" + slideNumber;
IShapeCollection shapes = slide.getShapes();
List shapeReferences = enumerateShapes(shapes, slidePrefix, false);
for (ShapeReference shapeReference : shapeReferences)
{
if (shapeReference.shape instanceof IAudioFrame)
{
IAudioFrame audioFrame = (IAudioFrame)shapeReference.shape;
IPPImage image = audioFrame.getPictureFormat().getPicture().getImage();
if (image != null)
{
String fileNameBase = shapeReference.namePart + "_audio_preview";
saveOriginalImage(image, outputDirectory, fileNameBase, savedImageHashes);
}
}
}
}
}
finally
{
if (presentation != null)
{
presentation.dispose();
}
}
```
## **Extract Images from Zoom Objects**
[IZoomFrame](https://reference.aspose.com/slides/java/com.aspose.slides/izoomframe/) and [ISectionZoomFrame](https://reference.aspose.com/slides/java/com.aspose.slides/isectionzoomframe/) shapes can use custom images. Read `getZoomImage()` from the zoom frame.
```java
import com.aspose.slides.*;
import java.io.File;
import java.util.Set;
import java.util.List;
String inputPath = "sample.pptx";
String currentDirectory = System.getProperty("user.dir");
File outputFolder = new File(currentDirectory, "zoom-images");
outputFolder.mkdirs();
String outputDirectory = outputFolder.getPath();
Set savedImageHashes = new java.util.HashSet();
Presentation presentation = new Presentation(inputPath);
try
{
int slideCount = presentation.getSlides().size();
for (int slideIndex = 0; slideIndex < slideCount; slideIndex++)
{
ISlide slide = presentation.getSlides().get_Item(slideIndex);
int slideNumber = slide.getSlideNumber();
String slidePrefix = "slide_" + slideNumber;
IShapeCollection shapes = slide.getShapes();
List shapeReferences = enumerateShapes(shapes, slidePrefix, false);
for (ShapeReference shapeReference : shapeReferences)
{
if (shapeReference.shape instanceof IZoomFrame)
{
IZoomFrame zoomFrame = (IZoomFrame)shapeReference.shape;
IPPImage image = zoomFrame.getZoomImage();
if (image != null)
{
String fileNameBase = shapeReference.namePart + "_zoom";
saveOriginalImage(image, outputDirectory, fileNameBase, savedImageHashes);
continue;
}
}
if (shapeReference.shape instanceof ISectionZoomFrame)
{
ISectionZoomFrame sectionZoomFrame = (ISectionZoomFrame)shapeReference.shape;
IPPImage image = sectionZoomFrame.getZoomImage();
if (image != null)
{
String fileNameBase = shapeReference.namePart + "_section_zoom";
saveOriginalImage(image, outputDirectory, fileNameBase, savedImageHashes);
continue;
}
}
}
}
}
finally
{
if (presentation != null)
{
presentation.dispose();
}
}
```
## **Extract Images from Summary Zoom Frames**
An [ISummaryZoomFrame](https://reference.aspose.com/slides/java/com.aspose.slides/isummaryzoomframe/) is also a shape. Its section items can use custom images, exposed through each summary zoom section's `getZoomImage()` method.
```java
import com.aspose.slides.*;
import java.io.File;
import java.util.Set;
import java.util.List;
String inputPath = "sample.pptx";
String currentDirectory = System.getProperty("user.dir");
File outputFolder = new File(currentDirectory, "summary-zoom-images");
outputFolder.mkdirs();
String outputDirectory = outputFolder.getPath();
Set savedImageHashes = new java.util.HashSet();
Presentation presentation = new Presentation(inputPath);
try
{
int slideCount = presentation.getSlides().size();
for (int slideIndex = 0; slideIndex < slideCount; slideIndex++)
{
ISlide slide = presentation.getSlides().get_Item(slideIndex);
int slideNumber = slide.getSlideNumber();
String slidePrefix = "slide_" + slideNumber;
IShapeCollection shapes = slide.getShapes();
List shapeReferences = enumerateShapes(shapes, slidePrefix, false);
for (ShapeReference shapeReference : shapeReferences)
{
if (shapeReference.shape instanceof ISummaryZoomFrame)
{
ISummaryZoomFrame summaryZoomFrame = (ISummaryZoomFrame)shapeReference.shape;
int sectionCount = summaryZoomFrame.getSummaryZoomCollection().size();
for (int sectionIndex = 0; sectionIndex < sectionCount; sectionIndex++)
{
ISummaryZoomSection section = summaryZoomFrame.getSummaryZoomCollection().get_Item(sectionIndex);
IPPImage image = section.getZoomImage();
if (image != null)
{
int displayIndex = sectionIndex + 1;
String fileNameBase = shapeReference.namePart + "_summary_zoom_" + displayIndex;
saveOriginalImage(image, outputDirectory, fileNameBase, savedImageHashes);
}
}
}
}
}
}
finally
{
if (presentation != null)
{
presentation.dispose();
}
}
```
## **Extract Images from Table Shapes**
An [ITable](https://reference.aspose.com/slides/java/com.aspose.slides/itable/) is a shape. Images in a table are usually stored as picture fills in table cells.
```java
import com.aspose.slides.*;
import java.io.File;
import java.util.Set;
import java.util.List;
String inputPath = "sample.pptx";
String currentDirectory = System.getProperty("user.dir");
File outputFolder = new File(currentDirectory, "table-images");
outputFolder.mkdirs();
String outputDirectory = outputFolder.getPath();
Set savedImageHashes = new java.util.HashSet();
Presentation presentation = new Presentation(inputPath);
try
{
int slideCount = presentation.getSlides().size();
for (int slideIndex = 0; slideIndex < slideCount; slideIndex++)
{
ISlide slide = presentation.getSlides().get_Item(slideIndex);
int slideNumber = slide.getSlideNumber();
String slidePrefix = "slide_" + slideNumber;
IShapeCollection shapes = slide.getShapes();
List shapeReferences = enumerateShapes(shapes, slidePrefix, true);
for (ShapeReference shapeReference : shapeReferences)
{
if (shapeReference.shape instanceof ITable)
{
ITable table = (ITable)shapeReference.shape;
int rowCount = table.getRows().size();
int columnCount = table.getColumns().size();
for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
{
for (int columnIndex = 0; columnIndex < columnCount; columnIndex++)
{
ICell cell = table.get_Item(columnIndex, rowIndex);
IFillFormat fillFormat = cell.getCellFormat().getFillFormat();
IPPImage image = getPictureFillImage(fillFormat);
if (image != null)
{
int displayRow = rowIndex + 1;
int displayColumn = columnIndex + 1;
String fileNameBase = shapeReference.namePart + "_cell_" + displayRow + "_" + displayColumn;
saveOriginalImage(image, outputDirectory, fileNameBase, savedImageHashes);
}
}
}
}
}
}
}
finally
{
if (presentation != null)
{
presentation.dispose();
}
}
```
## **Extract Images from Chart Shapes**
An [IChart](https://reference.aspose.com/slides/java/com.aspose.slides/ichart/) is a shape. The example below extracts an image from the chart area's picture fill.
```java
import com.aspose.slides.*;
import java.io.File;
import java.util.Set;
import java.util.List;
String inputPath = "sample.pptx";
String currentDirectory = System.getProperty("user.dir");
File outputFolder = new File(currentDirectory, "chart-images");
outputFolder.mkdirs();
String outputDirectory = outputFolder.getPath();
Set savedImageHashes = new java.util.HashSet();
Presentation presentation = new Presentation(inputPath);
try
{
int slideCount = presentation.getSlides().size();
for (int slideIndex = 0; slideIndex < slideCount; slideIndex++)
{
ISlide slide = presentation.getSlides().get_Item(slideIndex);
int slideNumber = slide.getSlideNumber();
String slidePrefix = "slide_" + slideNumber;
IShapeCollection shapes = slide.getShapes();
List shapeReferences = enumerateShapes(shapes, slidePrefix, true);
for (ShapeReference shapeReference : shapeReferences)
{
if (shapeReference.shape instanceof IChart)
{
IChart chart = (IChart)shapeReference.shape;
IFillFormat fillFormat = chart.getFillFormat();
IPPImage image = getPictureFillImage(fillFormat);
if (image != null)
{
String fileNameBase = shapeReference.namePart + "_chart_area";
saveOriginalImage(image, outputDirectory, fileNameBase, savedImageHashes);
}
}
}
}
}
finally
{
if (presentation != null)
{
presentation.dispose();
}
}
```
## **Extract Images from SmartArt Shapes**
An [ISmartArt](https://reference.aspose.com/slides/java/com.aspose.slides/ismartart/) object is a shape. Depending on the SmartArt layout, images may be stored in node bullet fills or in the fill formats of node shapes.
```java
import com.aspose.slides.*;
import java.io.File;
import java.util.Set;
import java.util.List;
String inputPath = "sample.pptx";
String currentDirectory = System.getProperty("user.dir");
File outputFolder = new File(currentDirectory, "smartart-images");
outputFolder.mkdirs();
String outputDirectory = outputFolder.getPath();
Set savedImageHashes = new java.util.HashSet();
Presentation presentation = new Presentation(inputPath);
try
{
int slideCount = presentation.getSlides().size();
for (int slideIndex = 0; slideIndex < slideCount; slideIndex++)
{
ISlide slide = presentation.getSlides().get_Item(slideIndex);
int slideNumber = slide.getSlideNumber();
String slidePrefix = "slide_" + slideNumber;
IShapeCollection shapes = slide.getShapes();
List shapeReferences = enumerateShapes(shapes, slidePrefix, true);
for (ShapeReference shapeReference : shapeReferences)
{
if (shapeReference.shape instanceof ISmartArt)
{
ISmartArt smartArt = (ISmartArt)shapeReference.shape;
int nodeCount = smartArt.getAllNodes().size();
for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++)
{
ISmartArtNode node = smartArt.getAllNodes().get_Item(nodeIndex);
IFillFormat bulletFillFormat = node.getBulletFillFormat();
IPPImage bulletImage = getPictureFillImage(bulletFillFormat);
if (bulletImage != null)
{
int displayNode = nodeIndex + 1;
String fileNameBase = shapeReference.namePart + "_smartart_node_" + displayNode + "_bullet";
saveOriginalImage(bulletImage, outputDirectory, fileNameBase, savedImageHashes);
}
int nodeShapeCount = node.getShapes().size();
for (int nodeShapeIndex = 0; nodeShapeIndex < nodeShapeCount; nodeShapeIndex++)
{
ISmartArtShape nodeShape = node.getShapes().get_Item(nodeShapeIndex);
IFillFormat fillFormat = nodeShape.getFillFormat();
IPPImage image = getPictureFillImage(fillFormat);
if (image != null)
{
int displayNode = nodeIndex + 1;
int displayNodeShape = nodeShapeIndex + 1;
String fileNameBase = shapeReference.namePart + "_smartart_node_" + displayNode + "_shape_" + displayNodeShape;
saveOriginalImage(image, outputDirectory, fileNameBase, savedImageHashes);
}
}
}
}
}
}
}
finally
{
if (presentation != null)
{
presentation.dispose();
}
}
```
## **Include Images Inside Grouped Shapes**
Grouped shapes contain their own shape collections. The shared `enumerateShapes` helper has an `includeGroupedShapes` option. Set it to `true` when you want to inspect shapes inside [IGroupShape](https://reference.aspose.com/slides/java/com.aspose.slides/igroupshape/) objects. The example below extracts images from picture frames, picture-filled shapes, OLE object previews, video frame thumbnails, and audio frame thumbnails. To include table, chart, SmartArt, and summary zoom images as well, reuse the specialized extraction logic from the previous sections while keeping the same recursive shape traversal.
```java
import com.aspose.slides.*;
import java.io.File;
import java.util.Set;
import java.util.List;
String inputPath = "sample.pptx";
String currentDirectory = System.getProperty("user.dir");
File outputFolder = new File(currentDirectory, "all-shape-images");
outputFolder.mkdirs();
String outputDirectory = outputFolder.getPath();
Set savedImageHashes = new java.util.HashSet();
Presentation presentation = new Presentation(inputPath);
try
{
int slideCount = presentation.getSlides().size();
for (int slideIndex = 0; slideIndex < slideCount; slideIndex++)
{
ISlide slide = presentation.getSlides().get_Item(slideIndex);
int slideNumber = slide.getSlideNumber();
String slidePrefix = "slide_" + slideNumber;
IShapeCollection shapes = slide.getShapes();
List shapeReferences = enumerateShapes(shapes, slidePrefix, true);
for (ShapeReference shapeReference : shapeReferences)
{
if (shapeReference.shape instanceof IOleObjectFrame)
{
IOleObjectFrame oleObjectFrame = (IOleObjectFrame)shapeReference.shape;
IPPImage image = oleObjectFrame.getSubstitutePictureFormat().getPicture().getImage();
if (image != null)
{
String fileNameBase = shapeReference.namePart + "_ole_preview";
saveOriginalImage(image, outputDirectory, fileNameBase, savedImageHashes);
}
continue;
}
if (shapeReference.shape instanceof IVideoFrame)
{
IVideoFrame videoFrame = (IVideoFrame)shapeReference.shape;
IPPImage image = videoFrame.getPictureFormat().getPicture().getImage();
if (image != null)
{
String fileNameBase = shapeReference.namePart + "_video_preview";
saveOriginalImage(image, outputDirectory, fileNameBase, savedImageHashes);
}
continue;
}
if (shapeReference.shape instanceof IAudioFrame)
{
IAudioFrame audioFrame = (IAudioFrame)shapeReference.shape;
IPPImage image = audioFrame.getPictureFormat().getPicture().getImage();
if (image != null)
{
String fileNameBase = shapeReference.namePart + "_audio_preview";
saveOriginalImage(image, outputDirectory, fileNameBase, savedImageHashes);
}
continue;
}
if (shapeReference.shape instanceof IPictureFrame)
{
IPictureFrame pictureFrame = (IPictureFrame)shapeReference.shape;
IPPImage image = pictureFrame.getPictureFormat().getPicture().getImage();
saveOriginalImage(image, outputDirectory, shapeReference.namePart, savedImageHashes);
continue;
}
if (shapeReference.shape instanceof IAutoShape)
{
IAutoShape autoShape = (IAutoShape)shapeReference.shape;
IFillFormat fillFormat = autoShape.getFillFormat();
IPPImage image = getPictureFillImage(fillFormat);
if (image != null)
{
saveOriginalImage(image, outputDirectory, shapeReference.namePart, savedImageHashes);
}
}
}
}
}
finally
{
if (presentation != null)
{
presentation.dispose();
}
}
```
## **Edge Cases and Practical Notes**
- **Duplicate images:** Multiple shapes may reference the same image or separate images with identical bytes. Hash [IPPImage.getBinaryData](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/#getBinaryData--) before writing files if you want one output file per unique image.
- **Original data vs. converted output:** Saving [IPPImage.getBinaryData](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/#getBinaryData--) preserves the embedded JPEG, PNG, GIF, SVG, EMF, or WMF data. Saving [IPPImage.getImage](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/#getImage--) through [IImage.save](https://reference.aspose.com/slides/java/com.aspose.slides/iimage/#save-java.lang.String-int-) is useful when you want a consistent output format.
- **Unsupported fill types:** Solid, gradient, pattern, and no-fill shapes do not contain a picture fill. Check [FillType](https://reference.aspose.com/slides/java/com.aspose.slides/filltype/) before reading `getPictureFillFormat()`.
- **Grouped shapes:** The top-level slide shape collection does not flatten groups. Recursively inspect [IGroupShape.getShapes](https://reference.aspose.com/slides/java/com.aspose.slides/igroupshape/#getShapes--) when grouped content matters.
- **OLE object previews:** An [IOleObjectFrame](https://reference.aspose.com/slides/java/com.aspose.slides/ioleobjectframe/) may expose a preview image through `getSubstitutePictureFormat()`, but that image is only the slide preview. It is not the embedded file inside the OLE object.
- **Video frame thumbnails:** An [IVideoFrame](https://reference.aspose.com/slides/java/com.aspose.slides/ivideoframe/) may expose a preview image through `getPictureFormat()`, but that image is only the poster shown on the slide. It is not extracted from the video stream.
- **Audio frame thumbnails:** An [IAudioFrame](https://reference.aspose.com/slides/java/com.aspose.slides/iaudioframe/) may expose an icon or thumbnail through `getPictureFormat()`; it is not the embedded audio data.
- **Zoom images:** Slide zoom, section zoom, and summary zoom shapes may use custom [IPPImage](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/) objects through `getZoomImage()`.
- **Nested shape models:** Table, chart, and SmartArt objects implement [IShape](https://reference.aspose.com/slides/java/com.aspose.slides/ishape/), but their images are often stored in nested table cell, chart element, or SmartArt node formatting objects.
- **Cropped or transformed pictures:** Accessing [IPPImage](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/) gives you the stored image resource. It does not render cropping, transparency, recoloring, rotation, or other visual effects applied by the shape.
## **FAQ**
### Can I extract the original image without cropping, effects, or shape transformations?
Yes. Access the [IPPImage](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/) object and write [IPPImage.getBinaryData](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/#getBinaryData--) to disk. This preserves the original encoded image stored in the presentation, not the way the image is rendered on the slide.
### Can I export every extracted image as PNG?
Yes. Use [IPPImage.getImage](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/#getImage--) to get an [IImage](https://reference.aspose.com/slides/java/com.aspose.slides/iimage/) object, and then call [IImage.save](https://reference.aspose.com/slides/java/com.aspose.slides/iimage/#save-java.lang.String-int-) with [ImageFormat.Png](https://reference.aspose.com/slides/java/com.aspose.slides/imageformat/). This converts the output and may not preserve the original file type or vector data.
### How do I avoid saving the same image more than once?
Use a hash of [IPPImage.getBinaryData](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/#getBinaryData--) and keep the hashes in a set. If a new image has a hash that already exists, skip it or record another reference to the existing output file.
### Why do some shapes not produce an image?
Picture frames, picture-filled shapes, OLE object frames, media frames, zoom frames, tables, charts, and SmartArt objects can reference images. Some shape types expose images through nested formatting objects, so a simple `getPictureFormat()` or shape `getFillFormat()` check is not always enough.
### Can I extract the thumbnail shown for a video frame?
Yes. Use [IVideoFrame](https://reference.aspose.com/slides/java/com.aspose.slides/ivideoframe/) and read `getPictureFormat().getPicture().getImage()`. This extracts the poster image stored with the video frame, not a frame generated from the video file.
### How can I determine which shapes use a specific image from the presentation image collection?
Aspose.Slides does not store reverse links from [IPPImage](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/) to shapes. Build a mapping during traversal: whenever you find an image reference, record the slide number, shape path, and image hash or collection item.
### Can I extract images embedded inside OLE objects, such as attached documents?
You can extract the OLE object's slide preview from [IOleObjectFrame.getSubstitutePictureFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ioleobjectframe/#getSubstitutePictureFormat--). However, that preview is not the embedded document itself. To extract images from inside the embedded file, extract the OLE data and inspect it with tools for that file type.
# Extracting Text from PPT, PPTX, ODP
> Learn essential ways to extract and process slide text from PPT, PPTX and ODP on major cloud platforms, using Java tools to power search, analytics, and automation.
Source: https://docs.aspose.com/slides/java/extracting-text-from-ppt-pptx-odp-on-cloud-platforms/
Updated: 2025-11-18
---
lastmod: 2025-11-18T18:55:58+04:00
title: Extracting Text from PPT, PPTX, ODP
type: docs
weight: 40
url: /java/extracting-text-from-ppt-pptx-odp-on-cloud-platforms/
keywords:
- cloud platforms
- cloud integration
- extract text
- text extraction
- PPT
- PPTX
- ODP
- Open XML SDK
- PowerPoint
- OpenDocument
- presentation
- Java
- Aspose.Slides
description: "Learn essential ways to extract and process slide text from PPT, PPTX and ODP on major cloud platforms, using Java tools to power search, analytics, and automation."
---
## Related articles
- [Slides on Cloud Platforms](https://docs.aspose.com/slides/java/slides-on-cloud-platforms/)
- [Slide Text Extraction: PPT, PPTX, ODP Essentials](https://docs.aspose.com/slides/java/slide-text-extraction-ppt-pptx-odp-essentials/)
# Manage Fallback Fonts for Presentations in Java
> See how Aspose.Slides for Java uses fallback fonts to keep text readable in PowerPoint and OpenDocument presentations when original fonts aren’t available.
Source: https://docs.aspose.com/slides/java/fallback-font/
Updated: 2026-11-08
## **Introduction**
Fallback fonts are used when the font specified for text is available in the system but does not contain a required glyph. In this case, Aspose.Slides can use one of the specified fallback fonts to replace the missing glyph.
[](https://docs.aspose.com/slides/java/fallback-font/visual-font-glyph-fallback-7085020e9446.svg)
*In this illustrative render, Microsoft Himalaya draws the Latin words. Automatic fallback draws αβ in Courier New, and the explicit Greek range rule draws them in Arial.*
## **Fallback Font**
Aspose.Slides allows to create fallback fonts, add them to fallback fonts collection, set fallback font collection for a certain presentation, remove fallback fonts from presentation, specify the rules to apply fallback fonts and others.
To get familiar with these features, use the following links:
- [Create Fallback Font](https://docs.aspose.com/slides/java/create-fallback-font)
- [Create Fallback Fonts Collection](https://docs.aspose.com/slides/java/create-fallback-fonts-collection)
- [Render Presentation with Fallback Font](https://docs.aspose.com/slides/java/render-presentation-with-fallback-font)
## **FAQ**
### How do fallback fonts differ from font substitution?
Fallback is applied per character or per range of Unicode when the primary font lacks specific glyphs; it fills just the missing characters. [Substitution](https://docs.aspose.com/slides/java/font-substitution/) replaces a missing or unavailable font for an entire run or text portion with another font. They can be combined, but their scope and selection logic are different.
### Are fallback settings saved inside the presentation file?
No. Fallback configuration lives at processing/rendering time in the library and is not serialized into the PPTX. The presentation does not store your fallback rules.
### Does fallback affect elements created by PowerPoint objects (SmartArt, charts, WordArt)?
Yes. Text inside these objects goes through the same rendering pipeline, so the same fallback rules apply to it as to regular text.
## Related articles
- [Specify Fallback Fonts for Presentations in Java](https://docs.aspose.com/slides/java/create-fallback-font/)
- [Configure Fallback Font Collections in Java](https://docs.aspose.com/slides/java/create-fallback-fonts-collection/)
- [Master PowerPoint Fonts in Java](https://docs.aspose.com/slides/java/powerpoint-fonts/)
# FAQ
> Get answers to FAQ on Aspose.Slides for Java, covering PowerPoint and OpenDocument support, installation guidance, licensing, troubleshooting.
Source: https://docs.aspose.com/slides/java/faqs/
Updated: 2026-08-02
## **Overview**
This FAQ provides answers to common questions about Aspose.Slides. It covers supported file formats, handling exceptions when working with large presentations, changing slide sizes, previewing slides, retrieving text from presentations, formatting table borders, placing pictures, and resolving font-related issues when converting presentations to PDF or images.
## **Supported File Formats**
### Q: What file formats does Aspose.Slides for Java support?
**A**: Aspose.Slides for Java supports the file formats described in [Supported File Formats](https://docs.aspose.com/slides/java/supported-file-formats/).
## **Exceptions**
### Q: I am getting an out of memory exception while loading a large PPT file with images. Is there a limitation in Aspose.Slides regarding file size?
**A**: There is no specific formula for calculating the presentation size supported by Aspose.Slides. There should be enough space to accommodate the whole presentation structure and images in memory. Normally, images in the memory occupy more space than the hard disk, especially when images have additional effects.
In general, Aspose.Slides for Java can easily handle presentation files of around 300 MB on a server with 4 GB RAM.
## **Working with Slides**
### Q: Can I change the size of the slides in a presentation?
**A**: You can use the `getSlideSize` method exposed by the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class to define the size of the slides in a presentation.
### Q: Is there a way to define slides of different size in a presentation?
**A**: Since the size of slides is defined at presentation level in Microsoft PowerPoint documents, there is no way to do this.
### Q: Does Aspose.Slides for Java support previewing a slide before saving?
**A**: You can render the presentation slides to images and can use these images for previewing the slides.
## **Working with Text**
### Q: Is it possible to retrieve all the text from a presentation?
**A**: Aspose.Slides for Java provides the [SlideUtil](https://reference.aspose.com/slides/java/com.aspose.slides/slideutil/) class that provides various methods for retrieving whole text from the presentations.
### Q: Why are paragraph sizes different on Windows and Linux operating systems?
**A**: The calculation of paragraph sizes is based on the calculation of the text size representing the given paragraph. The text size calculation is based on the metrics of the font specified in the PowerPoint presentation. If the specified font is missing, it is replaced with the most similar font, but this font has metrics different from the original ones. As a result, the calculation of paragraph sizes in different systems will lead to different results depending on the set of installed fonts. To achieve the same result on different operating systems, you need to install the same fonts on the systems or load them at runtime as [external fonts](https://docs.aspose.com/slides/java/custom-font/).
## **Formatting and Images**
### Q: How can I set the color of a table border?
**A**: You can change the color of all table borders or just the border around the entire table. For changing all borders, please use the `getCellFormat` method from the [ICell](https://reference.aspose.com/slides/java/com.aspose.slides/icell/) interface. For the border of the entire table, you should iterate cells and change the color of the outer borders.
### Q: What measure does Aspose.Slides for Java use to place pictures?
**A**: The coordinates and sizes of all shapes on the slides are measured in points (72 dpi).
## **Working with Fonts**
### Q: When converting PPT to PDF or images, why are the fonts different in the output documents?
**A**: This issue might indicate that the fonts used in the presentation are missing from the operating system on which the code was executed. You should install the fonts on the operating system or load them as external fonts using the [FontsLoader](https://reference.aspose.com/slides/java/com.aspose.slides/fontsloader/) class as shown below:
```cs
var folders = new String[] { "path_to_a_folder_with_fonts" };
FontsLoader.loadExternalFonts(folders);
```
# Features Overview
> Review what Aspose.Slides for Java covers before you evaluate it: supported platforms, file formats, slide rendering, and the content you can create and edit.
Source: https://docs.aspose.com/slides/java/features-overview/
Updated: 2026-10-27
Browse the [features and support catalogue](https://docs.aspose.com/slides/features/) for short descriptions and links to the relevant guides.
## **Overview**
Aspose.Slides for Java is a class library for creating, reading, editing, converting, and rendering PowerPoint and OpenDocument presentations. It has no user interface of its own and does not require Microsoft PowerPoint or Microsoft Office. This article summarizes what the library covers and links to the articles that describe each area.
## **Supported Platforms**
Aspose.Slides for Java is a single JAR file, published in Aspose's Maven repository with the `jdk16` classifier. It is written in pure Java: the JAR contains no native libraries, and it does not depend on other packages.
- **Java:** Java 8 or later. Aspose.Slides for Java 26.9 and earlier versions also run on Java 6 and 7, which version 26.10 no longer supports; see the [26.9 release notes](https://releases.aspose.com/slides/java/release-notes/2026/aspose-slides-for-java-26-9-release-notes/).
- **Operating systems:** any operating system with a Java runtime, such as Windows, Linux, and macOS. On Linux, the fontconfig library and at least one font must be installed.
[Installation](https://docs.aspose.com/slides/java/installation/) shows how to add the library to a project and lists the Linux prerequisites. [System Requirements](https://docs.aspose.com/slides/java/system-requirements/) lists the supported platforms in detail.
## **File Formats and Conversions**
Aspose.Slides opens and saves PPT, PPTX, PPS, POT, PPSX, POTX, PPTM, PPSM, POTM, ODP, OTP, FODP, and PowerPoint XML presentations. It imports PDF and HTML content into slides, and it saves presentations as PDF, XPS, HTML, HTML5, TIFF, animated GIF, SWF, Markdown, and XAML. [Supported File Formats](https://docs.aspose.com/slides/java/supported-file-formats/) lists every format with the API that reads or writes it.
|**Feature**|**Description**|
| :- | :- |
|[PPT and PPTX](https://docs.aspose.com/slides/java/ppt-vs-pptx/)|Read and write both the binary PowerPoint 97-2003 format and the Office Open XML format.|
|[PPT to PPTX conversion](https://docs.aspose.com/slides/java/convert-ppt-to-pptx/)|Convert legacy PPT presentations to PPTX.|
|[ODP to PPTX conversion](https://docs.aspose.com/slides/java/convert-odp-to-pptx/)|Open and save ODP, OTP, and FODP presentations, and convert ODP presentations to PPTX.|
|[Portable Document Format (PDF)](https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf/)|Export presentations to PDF, including PDF/A and PDF/UA documents.|
|[XML Paper Specification (XPS)](https://docs.aspose.com/slides/java/convert-powerpoint-to-xps/)|Export presentations to XPS documents.|
|[Tagged Image File Format (TIFF)](https://docs.aspose.com/slides/java/convert-powerpoint-to-tiff/)|Export presentations to multi-page TIFF images, one page per slide.|
|[HTML](https://docs.aspose.com/slides/java/convert-powerpoint-to-html/)|Export presentations to HTML and HTML5.|
|[PDF and HTML import](https://docs.aspose.com/slides/java/import-presentation/)|Create slides from PDF pages and HTML content.|
## **Presentation Rendering**
Aspose.Slides renders slides and individual shapes as PNG, JPEG, BMP, GIF, TIFF, and SVG images, and slides as EMF metafiles. See [Convert Presentation Slides to Images](https://docs.aspose.com/slides/java/convert-slide/), [Render Presentation Slides as SVG Images](https://docs.aspose.com/slides/java/render-a-slide-as-an-svg-image/), and [Create Thumbnails of Presentation Shapes](https://docs.aspose.com/slides/java/create-shape-thumbnails/).
## **Content Features**
Aspose.Slides lets you create, read, and modify almost all the content of a presentation:
|**Area**|**What you can do**|
| :- | :- |
|[Slides](https://docs.aspose.com/slides/java/presentation-slide/)|Add, clone, reorder, and remove slides; apply layouts and masters; organize slides into sections; change the slide size.|
|[Design](https://docs.aspose.com/slides/java/presentation-design/)|Set backgrounds, theme colors, headers and footers, and fonts.|
|[Text](https://docs.aspose.com/slides/java/manage-text/)|Create and edit text frames, paragraphs, and portions; set fonts, colors, bullets, and alignment; find and replace text.|
|[Shapes](https://docs.aspose.com/slides/java/powerpoint-shapes/)|Create AutoShapes, lines, connectors, group shapes, and picture frames; set position, size, line, and solid, gradient, or pattern fill; find a shape by its alternative text.|
|[Tables](https://docs.aspose.com/slides/java/powerpoint-table/), [charts](https://docs.aspose.com/slides/java/powerpoint-charts/), and [SmartArt](https://docs.aspose.com/slides/java/powerpoint-smartart/)|Create and edit tables, Microsoft Office charts, and SmartArt diagrams.|
|[Media](https://docs.aspose.com/slides/java/manage-media-files/), [OLE objects](https://docs.aspose.com/slides/java/manage-ole/), and [ActiveX controls](https://docs.aspose.com/slides/java/activex/)|Add embedded or linked audio and video frames, embed OLE objects, and add, modify, or remove ActiveX controls.|
|[Notes](https://docs.aspose.com/slides/java/presentation-notes/) and [comments](https://docs.aspose.com/slides/java/presentation-comments/)|Add, read, and edit speaker notes and review comments.|
|[Animation](https://docs.aspose.com/slides/java/powerpoint-animation/) and [transitions](https://docs.aspose.com/slides/java/slide-transition/)|Apply animation effects to shapes, set slide transitions, and configure slide show settings.|
|[Security](https://docs.aspose.com/slides/java/presentation-security/)|Encrypt presentations with a password, set write protection, and work with [digital signatures](https://docs.aspose.com/slides/java/digital-signature-in-powerpoint/).|
|[VBA macros](https://docs.aspose.com/slides/java/presentation-via-vba/)|Add, extract, and remove VBA modules in macro-enabled presentations.|
|[Properties](https://docs.aspose.com/slides/java/presentation-properties/)|Read and edit document properties.|
## **FAQ**
**Do I need to install Microsoft PowerPoint on the server or PC for the library to work?**
No. PowerPoint is not required; Aspose.Slides is a standalone engine for creating, editing, converting, and rendering presentations.
**How does multithreading work? Can processing be parallelized?**
It is safe to process different documents in different threads; the same [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) object must not be used by [multiple threads](https://docs.aspose.com/slides/java/multithreading/) at the same time.
**Are file passwords and encryption supported?**
Yes. [You can](https://docs.aspose.com/slides/java/password-protected-presentation/) open encrypted presentations, set or remove an open and write password, and check the protection status.
**Do I need to care about fonts in Linux containers?**
Yes. On Linux, the fontconfig library and at least one font must be installed, and the fonts used in your presentations, or suitable substitutes, must be installed for text to render correctly. You can also [specify font directories](https://docs.aspose.com/slides/java/custom-font/) in your application. See [Installation](https://docs.aspose.com/slides/java/installation/#linux).
**Are there limitations in the evaluation version?**
Yes. Without a [license](https://docs.aspose.com/slides/java/licensing/), Aspose.Slides adds an evaluation watermark to every slide it saves and truncates text that your code reads through the API. A [30-day temporary license](https://purchase.aspose.com/temporary-license/) is available for full-feature testing.
**Is importing external formats into a presentation (PDF or HTML to PPTX) supported?**
Yes. You can add [PDF pages and HTML content](https://docs.aspose.com/slides/java/import-presentation/) to a presentation, turning them into slides.
## Related articles
- [Product Overview](https://docs.aspose.com/slides/java/product-overview/)
# File Formats and Conversions (Historical)
> Historical: older overviews of individual file formats, kept for existing links. The current list of supported formats is in Supported File Formats.
Source: https://docs.aspose.com/slides/java/file-formats-and-conversions/
Updated: 2026-09-29
The articles in this section are older overviews of individual file formats, kept for existing links. They do not describe the current version of Aspose.Slides for Java. For the formats that Aspose.Slides for Java loads, imports, saves, and renders, and the API for each one, see [Supported File Formats](https://docs.aspose.com/slides/java/supported-file-formats/). For conversion guides, see [Convert Presentations](https://docs.aspose.com/slides/java/convert-presentation/).
# Extract Flash Objects from Presentations in Java
> Learn how to extract Flash objects from PowerPoint and OpenDocument slides in Java with Aspose.Slides, complete code samples and best practices.
Source: https://docs.aspose.com/slides/java/flash/
Updated: 2026-08-05
## **Overview**
This article explains how to extract Flash objects from presentations by using Aspose.Slides. It shows how to find a Flash control by name in a slide’s controls collection and work with the embedded SWF object data.
## **Extract Flash Objects from Presentations**
Aspose.Slides for Java provides a facility for extracting flash objects from a presentation. You can access the flash control by name and extract it from the presentation and including store SWF object data.
```java
import com.aspose.slides.*;
// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
try {
IControlCollection controls = pres.getSlides().get_Item(0).getControls();
Control flashControl = null;
for (IControl control : controls)
{
if (control.getName() == "ShockwaveFlash1")
{
flashControl = (Control)control;
}
}
} finally {
if (pres != null) pres.dispose();
}
```
## **FAQ**
### What presentation formats are supported when extracting Flash content?
[Aspose.Slides supports](https://docs.aspose.com/slides/java/supported-file-formats/) the main PowerPoint formats such as PPT and PPTX, since it can load these containers and access their controls, including Flash-related ActiveX elements.
### Can I convert a presentation with Flash to HTML5 and preserve Flash interactivity?
No. Aspose.Slides does not execute SWF content or convert its interactivity. While export to [HTML](https://docs.aspose.com/slides/java/convert-powerpoint-to-html/)/[HTML5](https://docs.aspose.com/slides/java/export-to-html5/) is supported, Flash will not play in modern browsers due to end of support. The recommended path is to replace Flash with alternatives such as video or HTML5 animations before export.
### From a security perspective, does Aspose.Slides execute SWF files while reading a presentation?
No. Aspose.Slides treats Flash as binary data embedded in the file and does not execute SWF content during processing.
### How should I handle presentations that include Flash along with other embedded files via OLE?
Aspose.Slides supports [extracting embedded OLE objects](https://docs.aspose.com/slides/java/manage-ole/), so you can process all related embedded content in one pass, handling Flash controls and other OLE-embedded documents together.
## Related articles
- [Convert PowerPoint Presentations to SWF Flash in Java](https://docs.aspose.com/slides/java/convert-powerpoint-to-swf-flash/)
# Streamline Font Replacement in Presentations Using Java
> Seamlessly replace fonts in Aspose.Slides for Java to ensure consistent typography in PowerPoint and OpenDocument presentations.
Source: https://docs.aspose.com/slides/java/font-replacement/
Updated: 2026-08-05
## **Overview**
Aspose.Slides allows you to replace one font with another throughout a presentation. When a font is replaced, all instances of the original font are changed to the new font.
To perform font replacement, load the presentation, define the source font and the replacement font, call the font replacement method, and save the modified presentation as a PPTX file. This approach is useful when you intentionally want to switch from one font family to another across the presentation.
## **Replace Fonts**
If you change your mind about using a font, you can replace that font with another font. All instances of the old font will be replaced by the new font.
Aspose.Slides allows you to replace a font this way:
1. Load the relevant presentation.
2. Load the font that will be replaced.
3. Load the new font.
4. Replace the font.
5. Write the modified presentation as a PPTX file.
This Java code demonstrates font replacement:
```java
import com.aspose.slides.*;
// Loads a presentation
Presentation pres = new Presentation("Fonts.pptx");
try {
// Loads the source font that will be replaced
IFontData sourceFont = new FontData("Arial");
// Loads the new font
IFontData destFont = new FontData("Times New Roman");
// Replaces the fonts
pres.getFontsManager().replaceFont(sourceFont, destFont);
// Saves the presentation
pres.save("UpdatedFont_out.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
To set rules that determine what happens in certain conditions (if a font cannot be accessed, for example), see [**Font Substitution**](https://docs.aspose.com/slides/java/font-substitution/).
## **FAQ**
### What is the difference between "font replacement", "font substitution", and "fallback fonts"?
Replacement is an intentional switch from one family to another across the whole document. [Substitution](https://docs.aspose.com/slides/java/font-substitution/) is a rule like "if the font is unavailable, use X." [Fallback](https://docs.aspose.com/slides/java/fallback-font/) is applied surgically for individual missing glyphs when the base font is installed but does not contain the required characters.
### Does replacement apply to master slides, layouts, notes, and comments?
Yes. Replacement affects all presentation objects that use the original font, including master slides and notes; comments are also part of the document and are taken into account by the font engine.
### Will the font change inside embedded OLE objects (for example, Excel)?
No. [OLE content](https://docs.aspose.com/slides/java/manage-ole/) is controlled by its own application. Replacement in the presentation does not reformat the internal OLE data; it may be displayed as an image or as externally editable content.
### Can I replace a font only in part of the presentation (by slides or regions)?
Targeted replacement is possible if you change the font at the level of the required objects/ranges rather than applying a global replacement to the entire document. The overall font selection logic during rendering remains the same.
### How can I determine in advance which fonts the presentation uses at all?
Use the presentation’s [font manager](https://reference.aspose.com/slides/java/com.aspose.slides/fontsmanager/): it provides a list of the [families in use](https://reference.aspose.com/slides/java/com.aspose.slides/fontsmanager/#getFonts--) and information about [substitutions/"unknown" fonts](https://reference.aspose.com/slides/java/com.aspose.slides/fontsmanager/#getSubstitutions--), which helps plan the replacement.
### Does font replacement work when converting to PDF/images?
Yes. During export, Aspose.Slides applies the same [font selection/substitution sequence](https://docs.aspose.com/slides/java/font-selection-sequence/), so a replacement performed in advance will be honored during conversion.
### Do I need to install the target font in the system, or can I attach a fonts folder?
Installation is not required: the library allows [loading external fonts](https://docs.aspose.com/slides/java/custom-font/) from user folders for use during [rendering and export](https://docs.aspose.com/slides/java/convert-powerpoint/).
### Will replacement fix "tofu" (squares) instead of characters?
Only if the target font actually contains the required glyphs. If not, [configure fallback](https://docs.aspose.com/slides/java/fallback-font/) to cover the missing characters.
## Related articles
- [Font Selection Sequence in Aspose.Slides for Java](https://docs.aspose.com/slides/java/font-selection-sequence/)
- [Configure Font Substitution in Presentations Using Java](https://docs.aspose.com/slides/java/font-substitution/)
- [Manage Fallback Fonts for Presentations in Java](https://docs.aspose.com/slides/java/fallback-font/)
# Font Selection Sequence in Aspose.Slides for Java
> Discover how Aspose.Slides for Java selects fonts, ensuring crisp, consistent presentation of PPT, PPTX and ODP files—improve your slides now.
Source: https://docs.aspose.com/slides/java/font-selection-sequence/
Updated: 2026-10-27
## **Overview**
When a presentation is loaded, rendered, or converted to another format, Aspose.Slides checks whether the fonts used in the presentation are available in the operating system. If a required font is missing, Aspose.Slides selects a replacement font that is as close as possible to the one PowerPoint would use.
Aspose.Slides first searches for the selected font in the operating system. If the font is found, it is used. If it is not found, a suitable replacement is applied. When font substitution rules are defined through `FontSubstRule`, those rules are also taken into account.
You can also add fonts at application runtime, use embedded fonts from a presentation, or load external fonts for output documents such as PDF files.
## **Font Selection**
Text can reference a theme font, such as `+mn-lt`, rather than an explicit family name. See [Resolve Theme Font References](https://docs.aspose.com/slides/java/presentation-theme/#resolve-theme-font-references) to obtain the family specified by the applicable theme. Resolving that reference is separate from checking font availability and applying rendering-time substitution or glyph fallback; it does not identify the font file ultimately used to render the text.
Certain rules apply to fonts in a presentation when the presentation is loaded, rendered, or converted to another format. For example, when you try to convert a presentation (its slides) to images, the presentation's fonts are checked to verify that the chosen fonts are available in the operating system. If the fonts are confirmed to be missing, they are replaced — see [**Font Replacement**](https://docs.aspose.com/slides/java/font-replacement/) and [**Font Substitution**](https://docs.aspose.com/slides/java/font-substitution/).
This is the process Aspose.Slides follows when dealing with fonts:
1. Aspose.Slides searches for fonts in the operating system to find the font that matches the presentation's chosen font.
2. If the chosen font is found, Aspose.Slides uses it. Otherwise, Aspose.Slides uses a replacement font that is as close as possible to what PowerPoint would use.
3. If font replacement rules have been set through [FontSubstRule](https://reference.aspose.com/slides/java/com.aspose.slides/fontsubstrule/), they are applied.
Aspose.Slides allows you to add fonts at application runtime and then use those fonts. See [**Custom fonts**](https://docs.aspose.com/slides/java/custom-font/).
When additional fonts are placed within a presentation, they are called [**Embedded fonts**](https://docs.aspose.com/slides/java/embedded-font/).
Aspose.Slides allows you to add fonts that are applied to *only* output documents. For example, if a presentation you are looking to convert to PDF contains fonts missing from your system and embedded fonts, you can add or load the needed fonts as **external fonts**.
We do not distribute any fonts, either paid or free. Our API allows you to load external fonts and embed them in documents, but you do so with fonts at your discretion and responsibility.
## **FAQ**
**How can I determine which fonts are actually used in a presentation before conversion?**
Aspose.Slides lets you inspect the fonts used via the [font manager](https://reference.aspose.com/slides/java/com.aspose.slides/fontsmanager/), so you can decide whether to [embed](https://docs.aspose.com/slides/java/embedded-font/), [replace](https://docs.aspose.com/slides/java/font-replacement/), or add [external sources](https://docs.aspose.com/slides/java/custom-font/).This helps you prevent unwanted substitutions during rendering and export.
**Can I add extra font directories without installing them on the operating system?**
Yes. You can register [external font sources](https://docs.aspose.com/slides/java/custom-font/) such as folders or in-memory streams for rendering and export. This removes dependency on host system fonts and keeps layout predictable.
**How do I prevent a silent fallback to an unsuitable font when a glyph is missing?**
Define explicit [font replacement](https://docs.aspose.com/slides/java/font-replacement/) and font [fallback rules](https://docs.aspose.com/slides/java/fallback-font/) in advance. By analyzing used fonts and setting a controlled priority for substitutes, you ensure consistent typography and avoid unexpected results.
## Related articles
- [Configure Font Substitution in Presentations Using Java](https://docs.aspose.com/slides/java/font-substitution/)
- [Streamline Font Replacement in Presentations Using Java](https://docs.aspose.com/slides/java/font-replacement/)
- [Master PowerPoint Fonts in Java](https://docs.aspose.com/slides/java/powerpoint-fonts/)
# Configure Font Substitution in Presentations Using Java
> Configure font substitution rules and inspect substituted fonts in Aspose.Slides for Java when rendering or converting PowerPoint and OpenDocument presentations.
Source: https://docs.aspose.com/slides/java/font-substitution/
Updated: 2026-10-08
## **Overview**
Font substitution allows Aspose.Slides to use an available font in place of a font that cannot be accessed when a presentation is rendered or converted. The substitution affects the rendered output; it does not change the font assigned to the presentation content.
You can define the font to use when a particular font is unavailable, and you can inspect the substitutions that Aspose.Slides will make during rendering. This helps keep output consistent across environments with different installed fonts.
If a font is available but has no dedicated bold typeface, see [Handle Fonts Without a Dedicated Bold Typeface](https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf/#handle-fonts-without-a-dedicated-bold-typeface). That section explains how to rasterize the affected text during PDF export and the consequences for text selection, searching, and scaling.
## **Get Font Substitutions**
Use the [IFontsManager.getSubstitutions](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsmanager/#getSubstitutions--) method to determine which fonts will be substituted when the presentation is rendered. The method returns [FontSubstitutionInfo](https://reference.aspose.com/slides/java/com.aspose.slides/fontsubstitutioninfo/) objects that identify the original and substituted font names.
The following Java example lists all font substitutions for a presentation:
```java
import com.aspose.slides.FontSubstitutionInfo;
import com.aspose.slides.Presentation;
Presentation presentation = new Presentation("Presentation.pptx");
try {
for (FontSubstitutionInfo substitution : presentation.getFontsManager().getSubstitutions()) {
System.out.println(substitution.getOriginalFontName() + " -> " + substitution.getSubstitutedFontName());
}
} finally {
presentation.dispose();
}
```
## **Get Font Substitutions for Selected Slides**
Use the [IFontsManager.getSubstitutions](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsmanager/#getSubstitutions-int---) overload with an `int[] slides` argument to inspect only the substitutions required to render specific slides. This is useful when you are rendering or exporting part of a presentation, checking a large presentation incrementally, locating slides that depend on unavailable fonts, preparing a minimal font package for a server or container, or diagnosing rendering differences without processing unrelated slides.
The `slides` array contains one-based slide indexes: `1` identifies the first slide. By contrast, the [Presentation.getSlides](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#getSlides--) collection accessor uses zero-based indexing, so that same slide is accessed as `presentation.getSlides().get_Item(0)`. Keep this difference in mind when building the array to avoid off-by-one errors.
Call the overload through the [Presentation.getFontsManager](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#getFontsManager--) method. It returns only the substitutions determined while rendering the selected slides. Each result is a [FontSubstitutionInfo](https://reference.aspose.com/slides/java/com.aspose.slides/fontsubstitutioninfo/) object containing the original and substituted font names. The result reflects the current font environment, configured fallback rules, and [externally loaded fonts](https://docs.aspose.com/slides/java/custom-font/). Substitution rules stored in an [IFontSubstRuleCollection](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsubstrulecollection/) are applied when the presentation is rendered, but the result does not list them; check the fonts in the output file instead.
The same substitution can be required by more than one selected slide. Deduplicate the results when you create a font inventory or preflight report. The following example reports every returned substitution and then creates a sorted list of unique font mappings:
```java
import com.aspose.slides.FontSubstitutionInfo;
import com.aspose.slides.Presentation;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
Presentation presentation = new Presentation("Presentation.pptx");
try {
int[] selectedSlides = { 1, 3, 5 };
List substitutions = new ArrayList<>();
for (FontSubstitutionInfo substitution : presentation.getFontsManager().getSubstitutions(selectedSlides)) {
substitutions.add(substitution);
}
System.out.println("Substitutions for the selected slides:");
for (FontSubstitutionInfo substitution : substitutions) {
System.out.println(substitution.getOriginalFontName() + " -> " + substitution.getSubstitutedFontName());
}
Set sortedPreflightEntries = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
for (FontSubstitutionInfo substitution : substitutions) {
String entry = substitution.getOriginalFontName() + " -> " + substitution.getSubstitutedFontName();
sortedPreflightEntries.add(entry);
}
System.out.println("Deduplicated font preflight report:");
for (String entry : sortedPreflightEntries) {
System.out.println(entry);
}
} finally {
presentation.dispose();
}
```
The [IFontsManager](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsmanager/) interface provides both overloads. Choose one according to the scope of the rendering operation:
| Overload | Use it when |
|---|---|
| [getSubstitutions](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsmanager/#getSubstitutions--) with no arguments | You need substitutions for the entire presentation. |
| [getSubstitutions](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsmanager/#getSubstitutions-int---) with `int[] slides` | You need substitutions for a selected range, incremental check, or partial export. |
## **Set Font Substitution Rules**
To specify the font that Aspose.Slides should use when a source font is unavailable:
1. Load the presentation.
2. Create font definitions for the source and substitute fonts.
3. Create a [FontSubstRule](https://reference.aspose.com/slides/java/com.aspose.slides/fontsubstrule/) with the [WhenInaccessible](https://reference.aspose.com/slides/java/com.aspose.slides/fontsubstcondition/) condition.
4. Add the rule to a [FontSubstRuleCollection](https://reference.aspose.com/slides/java/com.aspose.slides/fontsubstrulecollection/).
5. Assign the collection by using the [FontsManager.setFontSubstRuleList](https://reference.aspose.com/slides/java/com.aspose.slides/fontsmanager/#setFontSubstRuleList-com.aspose.slides.IFontSubstRuleCollection-) method.
6. Render or convert the presentation.
The following Java example substitutes `Arial` for `SomeRareFont` when `SomeRareFont` is unavailable, and then renders the first slide to verify the result. The substitute font must be available to Aspose.Slides.
```java
import com.aspose.slides.FontData;
import com.aspose.slides.FontSubstCondition;
import com.aspose.slides.FontSubstRule;
import com.aspose.slides.FontSubstRuleCollection;
import com.aspose.slides.IFontData;
import com.aspose.slides.IFontSubstRule;
import com.aspose.slides.IFontSubstRuleCollection;
import com.aspose.slides.IImage;
import com.aspose.slides.ImageFormat;
import com.aspose.slides.Presentation;
Presentation presentation = new Presentation("Fonts.pptx");
try {
IFontData sourceFont = new FontData("SomeRareFont");
IFontData substituteFont = new FontData("Arial");
IFontSubstRule substitutionRule = new FontSubstRule(sourceFont, substituteFont, FontSubstCondition.WhenInaccessible);
IFontSubstRuleCollection substitutionRules = new FontSubstRuleCollection();
substitutionRules.add(substitutionRule);
presentation.getFontsManager().setFontSubstRuleList(substitutionRules);
IImage image = presentation.getSlides().get_Item(0).getImage(1f, 1f);
try {
image.save("slide.jpg", ImageFormat.Jpeg);
} finally {
image.dispose();
}
} finally {
presentation.dispose();
}
```
For an unconditional change to the fonts used throughout a presentation, see [Font Replacement](https://docs.aspose.com/slides/java/font-replacement/).
## **Limitations for Math Equation Fonts**
Font substitution rules are part of the standard font selection process used during rendering and conversion. They work for regular text when Aspose.Slides can replace an inaccessible font with the available font specified by a rule.
Office Math equations have an additional requirement. If an equation uses **Cambria Math**, Aspose.Slides may need that exact font to calculate and render the equation layout. A rule that substitutes another math font, such as **STIX Two Math**, cannot replace **Cambria Math** for this purpose, and rendering may still report that **Cambria Math** is required.
To render or convert such a presentation, make **Cambria Math** available to Aspose.Slides. Install it in the operating system or load it as an [external font](https://docs.aspose.com/slides/java/custom-font/).
This limitation applies to equation layout. The substitution rules described above still apply to regular presentation text.
## **FAQ**
**What is the difference between font replacement and font substitution?**
[Font replacement](https://docs.aspose.com/slides/java/font-replacement/) intentionally changes one font to another throughout the presentation. Font substitution selects a font for rendered output when the configured condition is met, such as when the original font is unavailable.
**When are substitution rules applied?**
The rules participate in the [font selection sequence](https://docs.aspose.com/slides/java/font-selection-sequence/) during rendering and conversion. With `WhenInaccessible`, a rule is used only when Aspose.Slides cannot access the source font.
**What happens when a font is missing and no substitution rule is configured?**
Aspose.Slides selects the closest available font according to its font selection process. The result depends on the fonts available in the runtime environment.
**Can I load external fonts to avoid substitution?**
Yes. You can [load external fonts](https://docs.aspose.com/slides/java/custom-font/) so Aspose.Slides can use them during rendering and conversion.
**Does Aspose distribute fonts with the library?**
No. You are responsible for providing fonts and complying with their licenses.
**Can substitution results differ between Windows, Linux, and macOS?**
Yes. Installed fonts and font search locations differ by operating system, so a font available on one machine may require substitution on another.
**How can I make font selection consistent in batch conversions?**
Use the same font files and versions on every machine or container, [load required external fonts](https://docs.aspose.com/slides/java/custom-font/), and [embed fonts](https://docs.aspose.com/slides/java/embedded-font/) when licensing permits. You can also call [IFontsManager.getSubstitutions](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsmanager/#getSubstitutions--) before export to identify unexpected substitutions.
## Related articles
- [Font Selection Sequence in Aspose.Slides for Java](https://docs.aspose.com/slides/java/font-selection-sequence/)
- [Streamline Font Replacement in Presentations Using Java](https://docs.aspose.com/slides/java/font-replacement/)
- [Manage Fallback Fonts for Presentations in Java](https://docs.aspose.com/slides/java/fallback-font/)
# Format Text Using VSTO and Aspose.Slides for Java
> Migrate from Microsoft Office automation to Aspose.Slides for Java and format text in PowerPoint (PPT, PPTX) presentations with precise control.
Source: https://docs.aspose.com/slides/java/format-text-using-vsto-and-aspose-slides-for-java/
Updated: 2026-08-13
Sometimes, you need to format the text on slides programmatically. This article shows how to read a sample presentation with some text on the first slide using either [VSTO](https://docs.aspose.com/slides/java/format-text-using-vsto-and-aspose-slides-for-java/) and [Aspose.Slides for Java](https://docs.aspose.com/slides/java/format-text-using-vsto-and-aspose-slides-for-java/). The code formats the text in the third textbox on the slide to look like the text in the last textbox.
## **Formatting Text**
Both the VSTO and Aspose.Slides methods take the following steps:
1. Open the source presentation.
1. Access the first slide.
1. Access the third text box.
1. Change the formatting of the text in the third text box.
1. Save the presentation to disk.
The screenshots below show the sample slide before and after the execution of the VSTO and Aspose.Slides for Java code.
**The input presentation**

### **VSTO Code Example**
The code below shows how to reformat text on a slide using VSTO.
**The text reformatted with VSTO**

```csharp
//Note: PowerPoint is a namespace which has been defined above like this
//using PowerPoint = Microsoft.Office.Interop.PowerPoint;
PowerPoint.Presentation pres = null;
//Open the presentation
pres = Globals.ThisAddIn.Application.Presentations.Open("c:\\source.ppt",
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoTrue);
//Access the first slide
PowerPoint.Slide slide = pres.Slides[1];
//Access the third shape
PowerPoint.Shape shp = slide.Shapes[3];
//Change its text's font to Verdana and height to 32
PowerPoint.TextRange txtRange = shp.TextFrame.TextRange;
txtRange.Font.Name = "Verdana";
txtRange.Font.Size = 32;
//Bolden it
txtRange.Font.Bold = Microsoft.Office.Core.MsoTriState.msoCTrue;
//Italicize it
txtRange.Font.Italic = Microsoft.Office.Core.MsoTriState.msoCTrue;
//Change text color
txtRange.Font.Color.RGB = 0x00CC3333;
//Change shape background color
shp.Fill.ForeColor.RGB = 0x00FFCCCC;
//Reposition it horizontally
shp.Left -= 70;
//Write the output to disk
pres.SaveAs("c:\\outVSTO.ppt",
PowerPoint.PpSaveAsFileType.ppSaveAsPresentation,
Microsoft.Office.Core.MsoTriState.msoFalse);
```
[Source: Examples-CSharp-VSTO-FormatTextUsingVSTO-FormatTextUsingVSTO.cs](https://gist.githubusercontent.com/aspose-com-gists/a56eda38c01ad33dc653116c7bae4293/raw/60f36b65dcdc5f7368b2d455fe1ae74076eeae08/Examples-CSharp-VSTO-FormatTextUsingVSTO-FormatTextUsingVSTO.cs)
### **Aspose.Slides for Java Example**
To format text with Aspose.Slides, add the font before formatting the text.
**The output presentation created with Aspose.Slides**

```java
//Open the presentation
Presentation pres = new Presentation("c:\\source.ppt");
//Access the first slide
ISlide slide = pres.getSlides().get_Item(0);
//Access the third shape
IShape shp = slide.getShapes().get_Item(2);
//Change its text's font to Verdana and height to 32
ITextFrame tf = ((IAutoShape)shp).getTextFrame();
IParagraph para = tf.getParagraphs().get_Item(0);
IPortion port = para.getPortions().get_Item(0);
port.getPortionFormat().setLatinFont(new FontData("Verdana"));
port.getPortionFormat().setFontHeight(32);
//Bolden it
port.getPortionFormat().setFontBold(NullableBool.True);
//Italicize it
port.getPortionFormat().setFontItalic(NullableBool.True);
//Change text color
//Set font color
port.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
port.getPortionFormat().getFillFormat().getSolidFillColor().setColor(new java.awt.Color(0x33, 0x33, 0xCC));
//Change shape background color
shp.getFillFormat().setFillType(FillType.Solid);
shp.getFillFormat().getSolidFillColor().setColor( new java.awt.Color(0xCC, 0xCC, 0xFF));
//Write the output to disk
pres.save("c:\\data\\outAsposeSlides.pptx",SaveFormat.Pptx);
```
[Source: Examples-src-main-java-com-aspose-slides-examples-Text-FormatText-FormatText.java](https://gist.githubusercontent.com/aspose-com-gists/1f55f0222bc39a382d831900e8de7400/raw/fa5f3d943772a7657d3f0d9cba4b39a80ae73f27/Examples-src-main-java-com-aspose-slides-examples-Text-FormatText-FormatText.java)
## Related articles
- [Creating Tables Using VSTO and Aspose.Slides for Java](https://docs.aspose.com/slides/java/creating-a-table-on-powerpoint-slide/)
- [Adding Text Dynamically Using VSTO and Aspose.Slides for Java](https://docs.aspose.com/slides/java/adding-text-dynamically-using-vsto-and-aspose-slides-for-java/)
- [Migration from Microsoft Office Automation to Aspose.Slides for Java](https://docs.aspose.com/slides/java/migration-from-microsoft-office-automation-to-aspose/)
# Get the Entire Slide Background from a Presentation as an Image
> Extract full slide backgrounds as images from PowerPoint and OpenDocument presentations using Aspose.Slides for Java, streamlining visual workflows.
Source: https://docs.aspose.com/slides/java/get-the-entire-presentation-slide-background-as-an-image/
Updated: 2026-08-05
## **Overview**
In PowerPoint presentations, a slide background may be formed from multiple elements, including the slide background image, presentation theme, color scheme, and objects placed on the master slide or layout slide.
This article shows how to extract the entire slide background as an image using Aspose.Slides for Java. Since there is no single method for this task, the approach involves cloning the selected slide into a temporary presentation, removing the slide shapes, and then converting the resulting slide background to an image.
## **Get the Entire Slide Background**
Aspose.Slides for Java does not provide a simple method to extract the entire presentation slide background as an image, but you can follow the steps below to do this:
1. Load the presentation using the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) class.
1. Get the slide size from the presentation.
1. Select a slide.
1. Create a temporary presentation.
1. Set the same slide size in the temporary presentation.
1. Clone the selected slide into the temporary presentation.
1. Delete the shapes from the cloned slide.
1. Convert the cloned slide to an image.
The following code example extracts the entire presentation slide background as an image.
```java
import com.aspose.slides.*;
var slideIndex = 0;
var imageScale = 1;
var presentation = new Presentation("sample.pptx");
var slideSize = presentation.getSlideSize().getSize();
var slide = presentation.getSlides().get_Item(slideIndex);
var tempPresentation = new Presentation();
var slideWidth = (float)slideSize.getWidth();
var slideHeight = (float)slideSize.getHeight();
tempPresentation.getSlideSize().setSize(slideWidth, slideHeight, SlideSizeScaleType.DoNotScale);
var clonedSlide = tempPresentation.getSlides().addClone(slide);
clonedSlide.getShapes().clear();
var background = clonedSlide.getImage(imageScale, imageScale);
background.save("output.png", ImageFormat.Png);
tempPresentation.dispose();
presentation.dispose();
```
## **FAQ**
### Will complex gradients, textures, or picture fills from a master slide be preserved in the resulting background image?
Yes. Aspose.Slides renders gradient, picture, and texture fills defined on the slide, layout, or master. If you need to isolate the look from inherited masters, [set an own background](https://docs.aspose.com/slides/java/presentation-background/) on the current slide before exporting.
### Can I add a watermark to the resulting background image before saving it?
Yes. You can [add a watermark](https://docs.aspose.com/slides/java/watermark/) shape or image on a working [copy of the slide](https://docs.aspose.com/slides/java/clone-slides/) (placed behind other content) and then export. This lets you generate a background image with the watermark baked in.
### Can I get the background for a specific layout or master without tying it to an existing slide?
Yes. Access the desired master or layout, apply it to a [temporary slide](https://docs.aspose.com/slides/java/clone-slides/) with the required size, and export that slide to obtain the background derived from that layout or master.
### Are there licensing limitations that affect image export?
Rendering features are fully available with a [valid license](https://docs.aspose.com/slides/java/licensing/). In evaluation mode, output may include limitations such as a watermark. Activate the license once per process before running batch exports.
# Getting Started
> The path from a new Java project to a first saved presentation with Aspose.Slides: check the requirements, add the library from Aspose's Maven repository, run a first program, and continue with common tasks.
Source: https://docs.aspose.com/slides/java/getting-started/
Updated: 2026-09-29
## **Overview**
Work through the four steps below in order. Each step names what to do and links the article with the details. Evaluation, licensing, and support are covered after the steps.
## **Step 1: Check the System Requirements**
Aspose.Slides for Java is a single JAR file with no native code, so it runs on any operating system that has a supported Java runtime. [System Requirements](https://docs.aspose.com/slides/java/system-requirements/) lists the supported operating systems and Java versions. The project and commands in the next steps need JDK 11 or later and, for the Maven route, [Apache Maven](https://maven.apache.org/install.html).
## **Step 2: Add the Library to Your Project**
Aspose.Slides for Java is published in Aspose's own Maven repository, not in Maven Central. Choose one of these routes:
- With Maven: declare the repository `https://releases.aspose.com/java/repo/` in your *pom.xml* and add the dependency `com.aspose:aspose-slides` with the `jdk16` classifier.
- Without Maven: download the JAR file whose name ends in *-jdk16.jar* from the repository and put it on the class path.
On Linux, also install the fontconfig library and at least one font. Without them, saving a presentation fails with the error "Fontconfig head is null, check your fonts or fonts configuration".
[Installation](https://docs.aspose.com/slides/java/installation/) gives the *pom.xml* entries, the JAR download, and the Linux command.
## **Step 3: Create Your First Presentation**
The [quick start on the Aspose.Slides for Java home page](https://docs.aspose.com/slides/java/#your-first-presentation) is a complete Maven project: a *pom.xml* file and a program that adds a cloud shape with text to a slide and saves the presentation as a PPTX file. You run it with `mvn compile exec:java`. [Create Presentations](https://docs.aspose.com/slides/java/create-presentation/) explains the same program step by step. To open an existing presentation and save it in another format, see [Open Presentations](https://docs.aspose.com/slides/java/open-presentation/) and [Save Presentations](https://docs.aspose.com/slides/java/save-presentation/).
## **Step 4: Continue with Common Tasks**
- [Open a presentation](https://docs.aspose.com/slides/java/open-presentation/)
- [Save a presentation](https://docs.aspose.com/slides/java/save-presentation/)
- [Convert a presentation to PDF](https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf/)
- [Render slides as images](https://docs.aspose.com/slides/java/convert-slide/)
- [Edit presentation text](https://docs.aspose.com/slides/java/manage-text/)
- [Examples by slide element](https://docs.aspose.com/slides/java/examples/)
## **Evaluate and License**
Without a license, Aspose.Slides runs in evaluation mode: it adds a watermark to every slide it saves and truncates text that your code reads from presentations.
- [Evaluate Aspose.Slides](https://docs.aspose.com/slides/java/evaluate-aspose-slides/) describes the evaluation limitations and how to request a temporary license.
- [Licensing](https://docs.aspose.com/slides/java/licensing/) shows how to apply a license from a file or a stream.
- [Metered Licensing](https://docs.aspose.com/slides/java/metered-licensing/) covers licensing that is billed by usage.
- [Supported File Formats](https://docs.aspose.com/slides/java/supported-file-formats/) lists the formats that Aspose.Slides can load and save.
## **Get Help**
[Technical Support](https://docs.aspose.com/slides/java/technical-support/) explains how to ask a question on the [free support forum](https://forum.aspose.com/c/slides/11) and what to include when you report a problem.
## **FAQ**
**Do I need Microsoft PowerPoint installed?**
No. Aspose.Slides reads and writes presentation files itself and does not use PowerPoint, so it also runs on servers and on Linux.
**Why does Maven not find Aspose.Slides for Java?**
The library is not in Maven Central. Declare Aspose's repository in your *pom.xml*, as shown in [Installation](https://docs.aspose.com/slides/java/installation/), and Maven downloads the library from there.
**Does the `jdk16` classifier mean that the library needs Java 16?**
No. The classifier selects the Java SE build of the library; the other build is for Android. The same build runs on current JDKs, such as JDK 21.
# Group Presentation Shapes in Java
> Learn to group and ungroup shapes in PowerPoint decks using Aspose.Slides for Java—fast, step-by-step guide with free Java code.
Source: https://docs.aspose.com/slides/java/group/
Updated: 2026-08-05
## **Overview**
This article explains how to work with group shapes in Aspose.Slides. It shows how to add a group shape to a slide, place shapes inside it, and save the updated presentation. It also demonstrates how to access shapes stored inside a group and read their `AlternativeText` values. In addition, the article briefly covers related group-shape capabilities such as nested groups, z-order, and locking options.
## **Add a Group Shape**
Aspose.Slides support working with group shapes on slides. This feature helps developers support richer presentations. Aspose.Slides for Java supports adding or accessing group shapes. It is possible to add shapes to an added group shape to populate it or access any property of group shape. To add a group shape to a slide using Aspose.Slides for Java:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class.
1. Obtain the reference of a slide by using its Index
1. Add a group shape to the slide.
1. Add the shapes to the added group shape.
1. Save the modified presentation as a PPTX file.
The example below adds a group shape to a slide.
```java
import com.aspose.slides.*;
// Instantiate Presentation class
Presentation pres = new Presentation();
try {
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Accessing the shape collection of slides
IShapeCollection slideShapes = sld.getShapes();
// Adding a group shape to the slide
IGroupShape groupShape = slideShapes.addGroupShape();
// Adding shapes inside Added group shape
groupShape.getShapes().addAutoShape(ShapeType.Rectangle, 300, 100, 100, 100);
groupShape.getShapes().addAutoShape(ShapeType.Rectangle, 500, 100, 100, 100);
groupShape.getShapes().addAutoShape(ShapeType.Rectangle, 300, 300, 100, 100);
groupShape.getShapes().addAutoShape(ShapeType.Rectangle, 500, 300, 100, 100);
// Adding group shape frame
groupShape.setFrame(new ShapeFrame(100, 300, 500, 40, NullableBool.False, NullableBool.False, 0));
// Write the PPTX file to disk
pres.save("GroupShape.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
## **Access the AltText Property**
This topic shows simple steps, complete with code examples, for adding a group shape and accessing AltText property of group shapes on slides. To access AltText of a group shape in a slide using Aspose.Slides for Java:
1. Instantiate [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class that represents PPTX file.
1. Obtain the reference of a slide by using its Index.
1. Accessing the shape collection of slides.
1. Accessing the group shape.
1. Accessing the [AlternativeText](https://reference.aspose.com/slides/java/com.aspose.slides/IShape#getAlternativeText--) property.
The example below accesses alternative text of group shape.
```java
import com.aspose.slides.*;
// Instantiate Presentation class that represents PPTX file
Presentation pres = new Presentation("AltText.pptx");
try {
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
for (int i = 0; i < sld.getShapes().size(); i++)
{
// Accessing the shape collection of slides
IShape shape = sld.getShapes().get_Item(i);
if (shape instanceof GroupShape)
{
// Accessing the group shape.
IGroupShape grphShape = (IGroupShape)shape;
for (int j = 0; j < grphShape.getShapes().size(); j++)
{
IShape shape2 = grphShape.getShapes().get_Item(j);
// Accessing the AltText property
System.out.println(shape2.getAlternativeText());
}
}
}
} finally {
if (pres != null) pres.dispose();
}
```
## **FAQ**
### Is nested grouping (a group inside a group) supported?
Yes. [GroupShape](https://reference.aspose.com/slides/java/com.aspose.slides/groupshape/) has a [getParentGroup](https://reference.aspose.com/slides/java/com.aspose.slides/shape/#getParentGroup--) method, which directly indicates hierarchy support (a group can be a child of another group).
### How do I control the group’s z-order relative to other objects on the slide?
Use the [GroupShape](https://reference.aspose.com/slides/java/com.aspose.slides/groupshape/)’s [getZOrderPosition](https://reference.aspose.com/slides/java/com.aspose.slides/shape/#getZOrderPosition--) method to inspect its position in the display stack.
### Can I prevent moving/editing/ungrouping?
Yes. The group’s lock section is exposed via [GroupShapeLock](https://reference.aspose.com/slides/java/com.aspose.slides/groupshape/#getGroupShapeLock--), which lets you restrict operations on the object.
## Related articles
- [Group Shape](https://docs.aspose.com/slides/java/examples/elements/group-shape/)
# How to Add Headers & Footers to Presentations in Java
> Learn how to add headers and footers in PowerPoint PPT, PPTX and ODP presentations in Java using both legacy and modern Aspose.Slides APIs.
Source: https://docs.aspose.com/slides/java/how-to-add-header-footer-in-a-presentation/
Updated: 2026-08-13
A new [Aspose.Slides for Java API](https://docs.aspose.com/slides/java/) has been released and now this single product supports the capability to generate PowerPoint documents from scratch and editing the existing ones.
## **Support for Legacy Code**
In order to use the legacy code developed with Aspose.Slides for Java versions earlier to 13.x, you need to make some minor changes in your code and the code will work as earlier. All the classes that were present in old Aspose.Slides for Java under Aspose.Slide and Aspose.Slides.Pptx namespaces are now merged in single Aspose.Slides namespace. Please take a look over the following simple code snippet for adding header footer in presentation in legacy Aspose.Slides API and follow the steps describing how to migrate to new merged API.
## **Legacy Aspose.Slides for Java Approach**
```java
PresentationEx sourcePres = new PresentationEx();
//Setting Header Footer visibility properties
sourcePres.setUpdateSlideNumberFields(true);
//Update the Date Time Fields
sourcePres.setUpdateDateTimeFields(true);
//Show date time placeholder
sourcePres.getHeaderFooterManager().isDateTimeVisible(true);
//Show the footer place holder
sourcePres.getHeaderFooterManager().isFooterVisible(true);
//Show Slide Number
sourcePres.getHeaderFooterManager().isSlideNumberVisible(true);
//Set the header footer visibility on Title Slide
sourcePres.getHeaderFooterManager().setVisibilityOnTitleSlide(true);
//Write the presentation to the disk
sourcePres.save("NewSource.pptx",SaveFormat.Pptx);
```
[Source: Examples-src-main-java-com-aspose-slides-examples-Presentation-Saving-SetPPTXFooter-SetPPTXFooter.java](https://gist.githubusercontent.com/aspose-com-gists/1f55f0222bc39a382d831900e8de7400/raw/f85b18f0303c32ea93bde3c6365a79169341867d/Examples-src-main-java-com-aspose-slides-examples-Presentation-Saving-SetPPTXFooter-SetPPTXFooter.java)
```java
//Create the presentation
Presentation pres = new Presentation();
//Get first slide
Slide sld = pres.getSlideByPosition(0);
//Access the Header / Footer of the slide
HeaderFooter hf = sld.getHeaderFooter();
//Set Page Number Visibility
hf.setPageNumberVisible(true);
//Set Footer Visibility
hf.setFooterVisible(true);
//Set Header Visibility
hf.setHeaderVisible(true);
//Set Date Time Visibility
hf.setDateTimeVisible(true);
//Set Date Time format
hf.setDateTimeFormat(DateTimeFormat.DateTime_dMMMMyyyy);
//Set Header Text
hf.setHeaderText("Header Text");
//Set Footer Text
hf.setFooterText("Footer Text");
//Write the presentation to the disk
pres.save("HeadFoot.ppt",SaveFormat.Ppt);
```
[Source: Examples-src-main-java-com-aspose-slides-examples-Presentation-Saving-SetPPTFooter-SetPPTFooter.java](https://gist.githubusercontent.com/aspose-com-gists/1f55f0222bc39a382d831900e8de7400/raw/7cda09560feafd3ba025078107beaf566847b969/Examples-src-main-java-com-aspose-slides-examples-Presentation-Saving-SetPPTFooter-SetPPTFooter.java)
## **New Aspose.Slides for Java 13.x Approach**
```java
Presentation sourcePres = new Presentation();
//Setting Header Footer visibility properties
sourcePres.UpdateSlideNumberFields = true;
//Update the Date Time Fields
sourcePres.UpdateDateTimeFields = true;
//Show date time placeholder
sourcePres.HeaderFooterManager.IsDateTimeVisible = true;
//Show the footer place holder
sourcePres.HeaderFooterManager.IsFooterVisible = true;
//Show Slide Number
sourcePres.HeaderFooterManager.IsSlideNumberVisible = true;
//Set the header footer visibility on Title Slide
sourcePres.HeaderFooterManager.SetVisibilityOnTitleSlide(true);
//Write the presentation to the disk
sourcePres.save("NewSource.pptx",SaveFormat.Pptx);
```
[Source: Examples-src-main-java-com-aspose-slides-examples-Presentation-Saving-SetPresentationFooter-SetPresentationFooter.java](https://gist.githubusercontent.com/aspose-com-gists/1f55f0222bc39a382d831900e8de7400/raw/46e0a21d85049a7b2db645f6b78a184df2682e1d/Examples-src-main-java-com-aspose-slides-examples-Presentation-Saving-SetPresentationFooter-SetPresentationFooter.java)
## Related articles
- [How to Create Charts in Presentations Using Java](https://docs.aspose.com/slides/java/how-to-create-charts-in-a-presentation/)
- [How to Create Hello World Presentations in Java](https://docs.aspose.com/slides/java/how-to-create-hello-world-presentation-document/)
- [Header Footer](https://docs.aspose.com/slides/java/examples/elements/header-footer/)
# How to Create Charts in Presentations Using Java
> Learn how to create charts in PowerPoint PPT, PPTX and ODP presentations in Java with Aspose.Slides using both legacy and modern chart APIs.
Source: https://docs.aspose.com/slides/java/how-to-create-charts-in-a-presentation/
Updated: 2026-08-13
A new [Aspose.Slides for Java API](https://docs.aspose.com/slides/java/) has been released and now this single product supports the capability to generate PowerPoint documents from scratch and editing the existing ones.
## **Support for Legacy Code**
In order to use the legacy code developed with Aspose.Slides for Java versions earlier to 14.x.x, you need to make some minor changes in your code and the code will work as earlier. All the classes that were present in old Aspose.Slides for Java under com.aspose.slides and com.aspose.slides.pptx namespaces are now merged in single com.aspose.slides namespace. Please take a look over the following simple code snippet for creating a normal chart from scratch in presentation using legacy Aspose.Slides API and follow the steps describing how to migrate to new merged API.
## **Legacy Aspose.Slides for Java Approach**
```java
//Instantiate PresentationEx class that represents PPTX file
PresentationEx pres = new PresentationEx();
//Access first slide
SlideEx sld = pres.getSlides().get_Item(0);
// Add chart with default data
ChartEx chart = sld.getShapes().addChart(ChartTypeEx.ClusteredColumn, 0, 0, 500, 500);
//Setting chart Title
chart.getChartTitle().getText().setText("Sample Title");
chart.getChartTitle().getText().setCenterText(true);
chart.getChartTitle().setHeight(20f);
chart.hasTitle(true);
//Set first series to Show Values
chart.getChartData().getSeries().get_Item(0).getLabels().setShowValue(true);
//Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
//Getting the chart data worksheet
ChartDataCellFactory fact = chart.getChartData().getChartDataCellFactory();
//Delete default generated series and categories
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
int s = chart.getChartData().getSeries().getCapacity();
//Adding new series
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 1, "Series 1"), chart.getType());
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 2, "Series 2"), chart.getType());
//Adding new categories
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 1, 0, "Caetegoty 1"));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 2, 0, "Caetegoty 2"));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 3, 0, "Caetegoty 3"));
//Take first chart series
ChartSeriesEx series = chart.getChartData().getSeries().get_Item(0);
//Now populating series data
series.getValues().add(fact.getCell(defaultWorksheetIndex, 1, 1, 20));
series.getValues().add(fact.getCell(defaultWorksheetIndex, 2, 1, 50));
series.getValues().add(fact.getCell(defaultWorksheetIndex, 3, 1, 30));
//Setting fill color for series
series.getFormat().getFill().setFillType(FillTypeEx.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(new java.awt.Color(com.aspose.slides.PresetColorEx.Red));
//Take second chart series
series = chart.getChartData().getSeries().get_Item(1);
//Now populating series data
series.getValues().add(fact.getCell(defaultWorksheetIndex, 1, 2, 30));
series.getValues().add(fact.getCell(defaultWorksheetIndex, 2, 2, 10));
series.getValues().add(fact.getCell(defaultWorksheetIndex, 3, 2, 60));
//Setting fill color for series
series.getFormat().getFill().setFillType(FillTypeEx.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(new java.awt.Color(PresetColorEx.Green));
//create custom lables for each of categories for new series
//first label will be show Category name
DataLabelEx lbl = new DataLabelEx(series);
lbl.setShowCategoryName( true);
lbl.setId (0);
series.getLabels().add(lbl);
//Show series name for second label
lbl = new DataLabelEx(series);
lbl.setShowSeriesName(true);
lbl.setId(1);
series.getLabels().add(lbl);
//show value for third label
lbl = new DataLabelEx(series);
lbl.setShowValue(true);
lbl.setShowSeriesName(true);
lbl.setSeparator("/");
lbl.setId( 2);
series.getLabels().add(lbl);
// show value and custom text
lbl = new DataLabelEx(series);
lbl.getTextFrame().setText( "My text");
lbl.setId( 3);
series.getLabels().add(lbl);
// Save presentation with chart
pres.write("D:\\Aspose Data\\AsposeChart.pptx");
```
[Source: Examples-src-main-java-com-aspose-slides-examples-Slides-Charts-CreateChartEx-CreateChartEx.java](https://gist.githubusercontent.com/aspose-com-gists/1f55f0222bc39a382d831900e8de7400/raw/8d440968b220c77ee6cfd7408dd06c15b0df9056/Examples-src-main-java-com-aspose-slides-examples-Slides-Charts-CreateChartEx-CreateChartEx.java)
## **New Aspose.Slides for Java 14.x.x Approach**
```java
//Instantiate Presentation class that represents PPTX file
Presentation pres = new Presentation();
//Access first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add chart with default data
IChart chart = sld.getShapes().addChart(ChartType.ClusteredColumn, 0, 0, 500, 500);
//Setting chart Title
//chart.getChartTitle().TextFrameForOverriding.Text = "Sample Title";
chart.getChartTitle().addTextFrameForOverriding("Sample Title");
chart.getChartTitle().getTextFrameForOverriding().getTextFrameFormat().setCenterText(NullableBool.True);
chart.getChartTitle().setHeight(20);
chart.hasTitle(true);
//Set first series to Show Values
chart.getChartData().getSeries().get_Item(0).getLabels().getDefaultDataLabelFormat().setShowValue(true);
//Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
//Getting the chart data worksheet
IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();
//Delete default generated series and categories
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
int s = chart.getChartData().getSeries().size();
s = chart.getChartData().getCategories().size();
//Adding new series
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 1, "Series 1"), chart.getType());
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 2, "Series 2"), chart.getType());
//Adding new categories
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 1, 0, "Caetegoty 1"));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 2, 0, "Caetegoty 2"));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 3, 0, "Caetegoty 3"));
//Take first chart series
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
//Now populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 1, 20));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 1, 50));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 1, 30));
//Setting fill color for series
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(java.awt.Color.RED);
//Take second chart series
series = chart.getChartData().getSeries().get_Item(1);
//Now populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 2, 30));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 2, 10));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 2, 60));
//Setting fill color for series
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(java.awt.Color.GREEN);
//create custom labels for each of categories for new series
//first label will be show Category name
IDataLabel lbl = series.getDataPoints().get_Item(0).getLabel();
lbl.getDataLabelFormat().setShowCategoryName(true);
lbl = series.getDataPoints().get_Item(1).getLabel();
lbl.getDataLabelFormat().setShowSeriesName(true);
//Show value for third label
lbl = series.getDataPoints().get_Item(2).getLabel();
lbl.getDataLabelFormat().setShowValue(true);
lbl.getDataLabelFormat().setShowSeriesName(true);
lbl.getDataLabelFormat().setSeparator("/");
//Save presentation with chart
pres.save("AsposeChart.pptx",SaveFormat.Pptx);
```
[Source: Examples-src-main-java-com-aspose-slides-examples-Slides-Charts-CreateAChart-CreateAChart.java](https://gist.githubusercontent.com/aspose-com-gists/1f55f0222bc39a382d831900e8de7400/raw/9ab0b94a2136f4b1610cdd24e665ab2697b86b27/Examples-src-main-java-com-aspose-slides-examples-Slides-Charts-CreateAChart-CreateAChart.java)
Please take a look over the following simple code snippet for creating a scatterd chart from scratch in presentation using legacy Aspose.Slides API and how to achieve it with new merged API.
## **Legacy Aspose.Slides for Java Approach**
```java
//Instantiate PresentationEx class that represents PPTX file
PresentationEx pres = new PresentationEx("D:\\AsposeChart.pptx");
//Access first slide
SlideEx sld = pres.getSlides().get_Item(0);
// Add chart with default data
ChartEx chart = (ChartEx)sld.getShapes().get_Item(0);
//Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
//Getting the chart data worksheet
ChartDataCellFactory fact = chart.getChartData().getChartDataCellFactory();
//Take first chart series
ChartSeriesEx series = chart.getChartData().getSeries().getItem(0);
//Now updating series data
fact.getCell(defaultWorksheetIndex, 0, 1, "New_Series1");//modifying series name
series.getValues().get_Item(0).setValue(90);
series.getValues().get_Item(1).setValue(123);
series.getValues().get_Item(2).setValue(44);
//Take Second chart series
series = chart.getChartData().getSeries().getItem(1);
//Now updating series data
fact.getCell(defaultWorksheetIndex, 0, 2, "New_Series2");//modifying series name
series.getValues().get_Item(0).setValue(23);
series.getValues().get_Item(1).setValue(67);
series.getValues().get_Item(2).setValue(99);
//Now, Adding a new series
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 3, "Series 3"), chart.getType());
//Take 3rd chart series
series = chart.getChartData().getSeries().getItem(2);
//Now populating series data
series.getValues().add(fact.getCell(defaultWorksheetIndex, 1, 3, 20));
series.getValues().add(fact.getCell(defaultWorksheetIndex, 2, 3, 50));
series.getValues().add(fact.getCell(defaultWorksheetIndex, 3, 3, 30));
chart.setType(ChartTypeEx.ClusteredCylinder);
// Save presentation with chart
pres.write("D:\\AsposeChartMoodified.pptx");
```
[Source: Examples-src-main-java-com-aspose-slides-examples-Slides-Charts-ExistingChart-ExistingChart.java](https://gist.githubusercontent.com/aspose-com-gists/1f55f0222bc39a382d831900e8de7400/raw/43d810038b5976a3ab16f246b59ed79592c1090d/Examples-src-main-java-com-aspose-slides-examples-Slides-Charts-ExistingChart-ExistingChart.java)
## **New Aspose.Slides for Java 14.x.x Approach**
```java
Presentation pres = new Presentation();
ISlide slide = pres.getSlides().get_Item(0);
//Creating the default chart
IChart chart = slide.getShapes().addChart(ChartType.ScatterWithSmoothLines, 0, 0, 400, 400);
//Getting the default chart data worksheet index
int defaultWorksheetIndex = 0;
//Accessing the chart data worksheet
IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();
//Delete demo series
chart.getChartData().getSeries().clear();
//Add new series
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 1, 1, "Series 1"), chart.getType());
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 1, 3, "Series 2"), chart.getType());
//Take first chart series
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
//Add new point (1:3) there.
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 2, 1, 1), fact.getCell(defaultWorksheetIndex, 2, 2, 3));
//Add new point (2:10)
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 3, 1, 2), fact.getCell(defaultWorksheetIndex, 3, 2, 10));
//Edit the type of series
series.setType (ChartType.ScatterWithStraightLinesAndMarkers);
//Changing the chart series marker
series.getMarker().setSize(10);
series.getMarker().setSymbol(MarkerStyleType.Star);
//Take second chart series
series = chart.getChartData().getSeries().get_Item(1);
//Add new point (5:2) there.
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 2, 3, 5), fact.getCell(defaultWorksheetIndex, 2, 4, 2));
//Add new point (3:1)
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 3, 3, 3), fact.getCell(defaultWorksheetIndex, 3, 4, 1));
//Add new point (2:2)
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 4, 3, 2), fact.getCell(defaultWorksheetIndex, 4, 4, 2));
//Add new point (5:1)
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 5, 3, 5), fact.getCell(defaultWorksheetIndex, 5, 4, 1));
//Changing the chart series marker
series.getMarker().setSize(10);
series.getMarker().setSymbol (MarkerStyleType.Circle);
pres.save("AsposeScatterChart.pptx",SaveFormat.Pptx);
```
[Source: Examples-src-main-java-com-aspose-slides-examples-Slides-Charts-CreateScatterChart-CreateScatterChart.java](https://gist.githubusercontent.com/aspose-com-gists/1f55f0222bc39a382d831900e8de7400/raw/07ca798e69d27754d6c4d1bb42bd9dc1aff217ce/Examples-src-main-java-com-aspose-slides-examples-Slides-Charts-CreateScatterChart-CreateScatterChart.java)
## Related articles
- [How to Add Headers & Footers to Presentations in Java](https://docs.aspose.com/slides/java/how-to-add-header-footer-in-a-presentation/)
- [How to Create Hello World Presentations in Java](https://docs.aspose.com/slides/java/how-to-create-hello-world-presentation-document/)
- [Migration from Earlier Versions](https://docs.aspose.com/slides/java/migration-from-earlier-versions-of-aspose-slides-for-java/)
# How to Create Hello World Presentations in Java
>
Source: https://docs.aspose.com/slides/java/how-to-create-hello-world-presentation-document/
Updated: 2026-08-13
A new [Aspose.Slides for Java API](https://docs.aspose.com/slides/java/) has been released and now this single product supports the capability to generate PowerPoint documents from scratch and editing the existing ones.
## **Support for Legacy Code**
In order to use the legacy code developed with Aspose.Slides for Java versions earlier to 13.x, you need to make some minor changes in your code and the code will work as earlier. All the classes that were present in old Aspose.Slides for Java under Aspose.Slide and Aspose.Slides.Pptx namespaces are now merged in single Aspose.Slides namespace. Please take a look over the following simple code snippet for creating a Hello World Presentation document in legacy Aspose.Slides API and follow the steps describing how to migrate to new merged API.
## **Legacy Aspose.Slides for Java Approach**
```java
//Instantiate a Presentation object that represents a PPT file
Presentation pres = new Presentation();
//Create a License object
License license = new License();
//Set the license of Aspose.Slides for Java to avoid the evaluation limitations
license.setLicense("Aspose.Slides.lic");
//Adding an empty slide to the presentation and getting the reference of
//that empty slide
Slide slide = pres.addEmptySlide();
//Adding a rectangle (X=2400, Y=1800, Width=1000 & Height=500) to the slide
com.aspose.slides.Rectangle rect = slide.getShapes().addRectangle(2400, 1800, 1000, 500);
//Hiding the lines of rectangle
rect.getLineFormat().setShowLines(false);
//Adding a text frame to the rectangle with "Hello World" as a default text
rect.addTextFrame("Hello World");
//Removing the first slide of the presentation which is always added by
//Aspose.Slides for Java by default while creating the presentation
pres.getSlides().removeAt(0);
//Writing the presentation as a PPT file
pres.write("C:\\hello.ppt");
```
[Source: Examples-src-main-java-com-aspose-slides-examples-Presentation-Creation-HelloWorldPresentation-HelloWorldPresentation.java](https://gist.githubusercontent.com/aspose-com-gists/1f55f0222bc39a382d831900e8de7400/raw/60a8dad2efa06999acbcf6470efe075ce9cfd8a1/Examples-src-main-java-com-aspose-slides-examples-Presentation-Creation-HelloWorldPresentation-HelloWorldPresentation.java)
## **New Aspose.Slides for Java 14.x.x Approach**
```java
// The path to the documents directory.
String dataDir = Utils.getDataDir(CreateAPresentation.class);
// Instantiate Presentation
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = (ISlide) pres.getSlides().get_Item(0);
// Add an AutoShape of Rectangle type
IAutoShape ashp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 150, 75, 150, 50);
// Add ITextFrame to the Rectangle
ashp.addTextFrame("Hello World");
// Change the text color to Black (which is White by default)
ashp.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().getFillFormat()
.setFillType(FillType.Solid);
ashp.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().getFillFormat()
.getSolidFillColor().setColor(java.awt.Color.BLACK);
// Change the line color of the rectangle to White
ashp.getShapeStyle().getLineColor().setColor(java.awt.Color.WHITE);
// Remove any fill formatting in the shape
ashp.getFillFormat().setFillType(FillType.NoFill);
// Save the presentation to disk
pres.save(dataDir + "HelloWorld.pptx", com.aspose.slides.SaveFormat.Pptx);
```
[Source: Examples-src-main-java-com-aspose-slides-examples-Presentation-Creation-CreateAPresentation-CreateAPresentation.java](https://gist.githubusercontent.com/aspose-com-gists/1f55f0222bc39a382d831900e8de7400/raw/9c5cc7c60db3f3783cd715fc97e65d8bad639efa/Examples-src-main-java-com-aspose-slides-examples-Presentation-Creation-CreateAPresentation-CreateAPresentation.java)
## Related articles
- [How to Create Charts in Presentations Using Java](https://docs.aspose.com/slides/java/how-to-create-charts-in-a-presentation/)
- [How to Add Headers & Footers to Presentations in Java](https://docs.aspose.com/slides/java/how-to-add-header-footer-in-a-presentation/)
- [Migration from Earlier Versions](https://docs.aspose.com/slides/java/migration-from-earlier-versions-of-aspose-slides-for-java/)
# Run Aspose.Slides for Java in Docker
> Build and run an Aspose.Slides for Java application in Docker: a multi-stage Dockerfile on the official Maven and Eclipse Temurin images, the Linux libraries and fonts that Aspose.Slides needs, and how to copy the generated files to your machine.
Source: https://docs.aspose.com/slides/java/how-to-run-aspose-slides-in-docker/
Updated: 2026-09-29
## **Overview**
This article shows how to run Aspose.Slides for Java in a Docker container. You build a small Maven project that creates a presentation with a text box and converts it to PDF, package it with a multi-stage Dockerfile on the official Maven and Eclipse Temurin images, run it, and copy the generated files to your machine. The article also explains what Aspose.Slides needs in a Linux image besides Java, and ends with variants for Alpine Linux and for images that install Java from the distribution's packages.
You only need Docker on your machine. The JDK and Maven are part of the build image, so you do not have to install them. To install Docker, see [Get Docker](https://docs.docker.com/get-started/get-docker/).
## **Choose the Base Images**
The Dockerfile in this article uses two official images from Docker Hub:
- [maven](https://hub.docker.com/_/maven) with the tag `3.9-eclipse-temurin-21` builds the application. It contains Apache Maven 3.9 and the Eclipse Temurin JDK 21.
- [eclipse-temurin](https://hub.docker.com/_/eclipse-temurin) with the tag `21-jre` runs it. It contains the Eclipse Temurin Java 21 runtime on Ubuntu, without the JDK and Maven.
Aspose.Slides for Java draws text with Java's font support, which on Linux needs the fontconfig and FreeType libraries and at least one installed font. The Eclipse Temurin images already contain fontconfig, FreeType, and the DejaVu fonts, so the Dockerfile in this article installs no packages. In an image without any font, saving a presentation stops with the error "Fontconfig head is null, check your fonts or fonts configuration". If you build on another base image, see [Use Another Base Image](https://docs.aspose.com/slides/java/how-to-run-aspose-slides-in-docker/#use-another-base-image).
## **Create the Project**
Create a folder named *hello-slides-docker* and add the following files to it.
*pom.xml* declares Aspose's Maven repository and the Aspose.Slides for Java dependency, as described in [Installation](https://docs.aspose.com/slides/java/installation/); Aspose.Slides for Java is not published in Maven Central, so the repository entry is required. The `finalName` element names the application JAR file *hello-slides.jar*, and the [maven-dependency-plugin](https://maven.apache.org/plugins/maven-dependency-plugin/) copies the dependencies of the application to *target/lib* when Maven packages it. Set the Aspose.Slides version to the latest one listed in the [repository](https://releases.aspose.com/java/repo/com/aspose/aspose-slides/).
```xml
4.0.0com.examplehello-slides1.011UTF-8AsposeJavaAPIAspose Java APIhttps://releases.aspose.com/java/repo/com.asposeaspose-slides26.9jdk16hello-slidesorg.apache.maven.pluginsmaven-compiler-plugin3.15.0org.apache.maven.pluginsmaven-dependency-plugin3.11.0packagecopy-dependencies${project.build.directory}/lib
```
*src/main/java/HelloSlides.java* creates a [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/), adds a rectangle with text to its first slide, and saves the presentation twice with the [save](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#save-java.lang.String-int-) method: as PPTX and as PDF. Both files go to the *output* folder under the working directory. The program then lists the fonts that Aspose.Slides replaces when it renders the presentation, using [IFontsManager.getSubstitutions](https://reference.aspose.com/slides/java/com.aspose.slides/ifontsmanager/#getSubstitutions--), so you can see whether the container has the fonts that the presentation uses.
```java
import com.aspose.slides.*;
import java.io.File;
public class HelloSlides {
public static void main(String[] args) {
File outputFolder = new File("output");
outputFolder.mkdirs();
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 50, 50, 400, 100);
shape.getTextFrame().setText("Hello from a Docker container!");
String pptxPath = new File(outputFolder, "hello.pptx").getPath();
String pdfPath = new File(outputFolder, "hello.pdf").getPath();
presentation.save(pptxPath, SaveFormat.Pptx);
presentation.save(pdfPath, SaveFormat.Pdf);
for (FontSubstitutionInfo substitution : presentation.getFontsManager().getSubstitutions()) {
System.out.println("Font substitution: " + substitution.getOriginalFontName() + " -> " + substitution.getSubstitutedFontName());
}
System.out.println("Saved " + pptxPath + " and " + pdfPath);
} finally {
presentation.dispose();
}
}
}
```
*.dockerignore* keeps the *target* folder of a local build, and the output of earlier runs, out of the Docker build context, so the image is built from the source files only.
```text
target/
output/
```
## **Write the Dockerfile**
Add a file named *Dockerfile* to the *hello-slides-docker* folder:
```dockerfile
FROM maven:3.9-eclipse-temurin-21 AS build
WORKDIR /src
COPY pom.xml .
RUN mvn -B dependency:go-offline
COPY src ./src
RUN mvn -B package
FROM eclipse-temurin:21-jre
WORKDIR /app
COPY --from=build /src/target/hello-slides.jar .
COPY --from=build /src/target/lib ./lib
RUN mkdir output && chown ubuntu output
USER ubuntu
ENTRYPOINT ["java", "-cp", "hello-slides.jar:lib/*", "HelloSlides"]
```
The file has two stages:
- **The build stage** starts from the Maven image. It copies *pom.xml* first and runs `mvn dependency:go-offline`, which downloads Aspose.Slides for Java and the Maven plugins, so Docker reuses that layer as long as *pom.xml* does not change. It then copies the source code and runs `mvn package`, which compiles the program into *target/hello-slides.jar* and copies the Aspose.Slides JAR file to *target/lib*. The `-B` option runs Maven in non-interactive (batch) mode.
- **The runtime stage** starts from the smaller Java runtime image and copies in only the application JAR file and the *lib* folder. It creates the *output* folder, gives it to `ubuntu`, the non-root user that the Ubuntu-based image defines, and runs the application as that user. The class path `hello-slides.jar:lib/*` contains the application and every JAR file in *lib*; Java expands the `*` itself.
The project is compiled for Java 11 (the `maven.compiler.release` property), so the runtime stage can use a newer Java version. For example, to run the application on Java 25, change the image of the runtime stage to `eclipse-temurin:25-jre`.
## **Build and Run the Container**
Open a terminal in the *hello-slides-docker* folder. Build the image, then run a container from it:
```bash
docker build -t hello-slides .
docker run --name hello-slides-run hello-slides
```
The first build downloads the base images, the Maven plugins, and Aspose.Slides for Java, so it takes several minutes; later builds reuse them. The container runs the application and stops. It prints:
```text
Font substitution: Calibri -> DejaVu Sans
Saved output/hello.pptx and output/hello.pdf
```
The first line shows that the text uses Calibri, the default font of a new presentation, and that Calibri is not installed in the image, so Aspose.Slides drew the text with DejaVu Sans. The text in the PDF is real, selectable text in that font. Without a license, Aspose.Slides also adds an evaluation watermark to every slide it saves; see [Licensing](https://docs.aspose.com/slides/java/licensing/).
## **Copy the Output to Your Machine**
The files are in the */app/output* folder of the stopped container. Copy them to an *output* folder on your machine, then remove the container:
```bash
docker cp hello-slides-run:/app/output/. ./output
docker rm hello-slides-run
```
These two commands work the same way in Bash, PowerShell, and the Windows Command Prompt.
On Linux, you can instead mount a folder of your machine into the container, so the application writes its files there directly:
```bash
mkdir -p output
docker run --rm --user "$(id -u):$(id -g)" -v "$(pwd)/output:/app/output" hello-slides
```
The `--user` option runs the application with your user and group IDs, so it can write to the folder you created and the files belong to you. `--rm` removes the container when it stops.
## **Run on Alpine Linux**
Eclipse Temurin is also available as an image based on Alpine Linux, which is smaller. It contains fontconfig, FreeType, and the DejaVu fonts as well, so the application needs no additional packages there either. To use it, replace the runtime stage in *Dockerfile* (everything from the second `FROM` line) with:
```dockerfile
FROM eclipse-temurin:21-jre-alpine
WORKDIR /app
COPY --from=build /src/target/hello-slides.jar .
COPY --from=build /src/target/lib ./lib
RUN adduser -D app && mkdir output && chown app output
USER app
ENTRYPOINT ["java", "-cp", "hello-slides.jar:lib/*", "HelloSlides"]
```
The Alpine image has no `ubuntu` user, so this stage creates a user named `app` with `adduser` and runs the application as that user. Build, run, and copy the output with the same commands as above. The application prints the same two lines.
## **Use Another Base Image**
If your image installs Java from the packages of the Linux distribution instead, install Java's font libraries and a font along with it. On Debian and Ubuntu, the `openjdk-21-jre-headless` package lists fontconfig, FreeType, and HarfBuzz only as recommended packages, so `apt-get install --no-install-recommends` leaves them out, and the application stops with an `UnsatisfiedLinkError` for `libfontmanager.so`. This runtime stage installs Java 21, the libraries, and the DejaVu fonts on Debian 13, and creates a non-root user named `app`:
```dockerfile
FROM debian:trixie
RUN apt-get update \
&& apt-get install -y --no-install-recommends openjdk-21-jre-headless libfontconfig1 libfreetype6 libharfbuzz0b fonts-dejavu-core \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=build /src/target/hello-slides.jar .
COPY --from=build /src/target/lib ./lib
RUN useradd --create-home app && mkdir output && chown app output
USER app
ENTRYPOINT ["java", "-cp", "hello-slides.jar:lib/*", "HelloSlides"]
```
The same stage works on Ubuntu 26.04 with `FROM ubuntu:26.04`.
## **FAQ**
**Saving the presentation stops with "Fontconfig head is null, check your fonts or fonts configuration". What is missing?**
A font. Java's font support found no installed font in the image. Install a font package, for example `fonts-dejavu-core` on Debian and Ubuntu, as in [Use Another Base Image](https://docs.aspose.com/slides/java/how-to-run-aspose-slides-in-docker/#use-another-base-image). [Deploy Fonts](https://docs.aspose.com/slides/java/deploy-fonts/) lists other font packages.
**The application stops with an UnsatisfiedLinkError for libfontmanager.so. What is missing?**
A native library of Java's font support; the message names the file that could not be loaded, for example `libharfbuzz.so.0`. This happens when Java is installed from the distribution's packages without their recommended packages. Install the libraries listed in [Use Another Base Image](https://docs.aspose.com/slides/java/how-to-run-aspose-slides-in-docker/#use-another-base-image).
**Why is the text in the PDF in a different font than in PowerPoint?**
The fonts that the presentation uses are not installed in the image, so Aspose.Slides draws the text with a substitute font. The application's output names each replaced font. [Deploy Fonts](https://docs.aspose.com/slides/java/deploy-fonts/) explains how to install fonts in the image or load them from the application folder.
**How much memory can the application use in the container?**
By default, Java limits its heap to a quarter of the memory available to the container, for example to about 250 MB when you start the container with `docker run -m 1g`. To process large presentations, raise the share with the `MaxRAMPercentage` option, for example `docker run --rm -m 1g -e JAVA_TOOL_OPTIONS=-XX:MaxRAMPercentage=75 hello-slides`. Java then prints a "Picked up JAVA_TOOL_OPTIONS" line before the output of the application.
**Do I need a JDK or Maven on my machine?**
No. The build stage compiles the application inside the Maven image. You need a JDK and Maven only if you also want to build and run the application outside Docker; see [Installation](https://docs.aspose.com/slides/java/installation/).
# How to Run Examples
> Run Aspose.Slides for Java examples fast: clone the repo, restore packages, then build and test features for PPT, PPTX and ODP.
Source: https://docs.aspose.com/slides/java/how-to-run-the-examples/
Updated: 2026-10-09
## **Download Aspose.Slides from GitHub**
All examples of Aspose.Slides for Java are hosted on [Github](https://github.com/aspose-slides/Aspose.Slides-for-Java). You can either clone the repository using your favorite Github client or download the ZIP file from [here](https://codeload.github.com/aspose-slides/Aspose.Slides-for-Java/zip/master).
Extract the contents of ZIP file to any folder on your computer. All examples are located in the **Examples** folder.

## **Import Examples into the IDE**
The project uses Maven build system. Any modern IDE can easily open or import the project and its dependencies. Below we show you how to use popular IDEs to build and run the examples.
### **IntelliJ IDEA**
Click on the **File** menu and choose **Open**. Browse to the project folder and select the **pom.xml** file.

It will open the project and download the dependencies automatically. From the Project tab, browse the examples in **src/main/java** folder. To run an example, just right click on the file and choose "Run ..", the example will be executed and the output will be shown in the built in console output window.

### **Eclipse**
Click on **File** menu and choose **Import**. Select **Maven** - Existing Maven Projects.

Browse to the folder that you cloned or downloaded from GitHub and select **pom.xml** file. It will open the project and download the dependencies automatically. From the Package Explorer tab, browse the examples in **src/main/java** folder. To run an example, just right click on the file and choose **Run As** - **Java Application**, the example will be executed and the output will be shown in the built in console output window.

### **NetBeans**
Click on the **File** menu and choose **Open Project**. Browse to the folder that you cloned or downloaded from GitHub. The icon of **Examples** folder will show that its a Maven project. Select Examples and open it.

It will open the project and download the dependencies automatically. From the Projects tab, browse the examples in **source packages**. To run an example, just right click on the file and choose **Run File**, the example will be executed and the output will be shown in the built in console output window.

## **Add Aspose.Slides Library into Maven Local Repository**
When you import **Aspose.Slides Examples** project into IDE, Maven automatically downloads aspose.slides JAR file from [Aspose Maven Repository](https://releases.aspose.com/java/repo/com/aspose/). In case you do not have access to internet, you can manually add JAR in your local repository.
### **mvn install**
Download the [aspose.slides](https://releases.aspose.com/java/repo/com/aspose/aspose-slides/), extract it and copy the aspose.slides-version.jar to somewhere else, for example, c drive. Issue following command:
```
mvn install:install-file
-Dfile=c:\aspose.slides-version.jar
-DgroupId=com.aspose
-DartifactId=aspose-slides
-Dversion={version}
-Dpackaging=jar
```
Now, the **aspose.slides** jar is copied to your Maven local repository.
### **pom.xml**
After installed, just declares the **aspose.slides** coordinate in pom.xml. Add following repository in repositories tab and dependency in dependencies tab.
``` xml
AsposeJavaAPIAspose Java APIhttps://releases.aspose.com/java/repo/com.asposeaspose-slides26.10jdk8
```
### **Done**
Build it, now the **aspose.slides** jar is able to retrieve from your Maven local repository.
## **Contribute**
If you like to add or improve an example, we encourage you to contribute to the project. All examples and showcase projects in this repository are open source and can be freely used in your own applications.
To contribute, you can fork the repository, edit the source code and can submit a Pull Request. We will review the changes and include it in the repository if found helpful.
## Related articles
- [Installation](https://docs.aspose.com/slides/java/installation/)
# Manage Image Transform Effects in Presentations with Java
> Apply, chain, inspect, remove, and verify image transform effects for picture frames with Aspose.Slides for Java.
Source: https://docs.aspose.com/slides/java/image-transform-effects/
Updated: 2026-11-17
## **Overview**
Aspose.Slides represents picture adjustments as an ordered collection of image transform operations. For a picture frame, start with the frame's [ISlidesPicture](https://reference.aspose.com/slides/java/com.aspose.slides/islidespicture/) and access [ISlidesPicture.getImageTransform](https://reference.aspose.com/slides/java/com.aspose.slides/islidespicture/#getImageTransform--). The returned [IImageTransformOperationCollection](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/) lets you append, enumerate, inspect, remove, and clear effects without rewriting the original image bytes.
This article demonstrates a complete workflow for brightness and contrast, color transformations, blur, transparency, ordered effect chains, effective values, removal, and PPTX round-trip verification.
## **Understand Effect Ownership and Image Reuse**
An image resource and the picture that displays it are different objects:
- [IPPImage](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/) stores or references the source image data owned by the presentation.
- [ISlidesPicture](https://reference.aspose.com/slides/java/com.aspose.slides/islidespicture/) belongs to a picture fill and refers to an image resource while storing the image transform collection.
- [IPictureFrame](https://reference.aspose.com/slides/java/com.aspose.slides/ipictureframe/) is the slide shape that owns the relevant picture fill, geometry, crop settings, and other frame-level formatting.
Therefore, image transform operations do not modify the bytes in [IPPImage](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/). When the same `IPPImage` is passed to [IShapeCollection.addPictureFrame](https://reference.aspose.com/slides/java/com.aspose.slides/ishapecollection/#addPictureFrame-int-float-float-float-float-com.aspose.slides.IPPImage-) more than once, each new picture frame receives its own `ISlidesPicture` and its own transform collection. Applying grayscale to one frame does not make the other frames grayscale, even though all of them reuse the same embedded image resource.
The same `ISlidesPicture.getImageTransform` model is also used by other picture fills, such as a shape or slide background. The examples below focus on picture frames.
## **Use Valid Parameter Ranges and Units**
The demonstrated methods use the following semantic ranges and units. Keep values in these ranges even if a particular library version does not reject every out-of-range value immediately; the target presentation format may normalize, omit, or reject invalid data during save or when PowerPoint opens the file.
| Operation | Parameters | Valid range and unit |
|---|---|---|
| [addBrightnessContrastEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addBrightnessContrastEffect-float-float-) | `brightness`, `contrast` | `-100` through `100`, percent; `0` leaves the component unchanged. |
| [addGrayScaleEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addGrayScaleEffect--) | None | No numeric parameters. Alpha is unchanged. |
| [addDuotoneEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addDuotoneEffect--) | `color1`, `color2` | Two colors for dark and light pixels. RGB and alpha channels in `java.awt.Color` use `0` through `255`. |
| [addTintEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addTintEffect-float-float-) | `hue`, `amount` | Hue is `0` inclusive through `360` exclusive, in degrees; amount is `-100` through `100`, percent. |
| [addHSLEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addHSLEffect-float-float-float-) | `hue`, `saturation`, `luminance` | Hue is `0` inclusive through `360` exclusive, in degrees; saturation and luminance are `-100` through `100`, percent. |
| [addColorReplaceEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addColorReplaceEffect--) | `color` | The replacement color uses channel values from `0` through `255`. Existing alpha values are unchanged. |
| [addBlurEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addBlurEffect-double-boolean-) | `radius`, `grow` | Radius is nonnegative and is measured in points; `grow` is a Boolean that controls whether blurred content may extend outside the original bounds. |
| [addAlphaModulateFixedEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addAlphaModulateFixedEffect-float-) | `amount` | Nonnegative percent. Use `0` through `100` for ordinary opacity scaling: `0` is fully transparent and `100` preserves the existing alpha. |
| [addAlphaReplaceEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addAlphaReplaceEffect-float-) | `alpha` | `0` through `100`, percent opacity. |
| [addAlphaBiLevelEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addAlphaBiLevelEffect-float-) | `threshold` | `0` through `100`, percent alpha threshold. Values below it become transparent; values at or above it become opaque. |
For fixed alpha modulation, transparency and opacity are complementary. For example, 35% transparency corresponds to an alpha modulation amount of 65%.
## **Apply Brightness and Contrast**
[IImageTransformOperationCollection.addBrightnessContrastEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addBrightnessContrastEffect-float-float-) returns an [IBrightnessContrast](https://reference.aspose.com/slides/java/com.aspose.slides/ibrightnesscontrast/) operation. Its scalar settings are supplied when the operation is created. [BrightnessContrast.getEffective](https://reference.aspose.com/slides/java/com.aspose.slides/brightnesscontrast/#getEffective--) returns calculated read-only values that can be inspected or logged.
The following example increases brightness by 15% and contrast by 20%, then renders a preview without modifying the embedded image:
```java
import com.aspose.slides.*;
import java.nio.file.Files;
import java.nio.file.Paths;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
byte[] imageData = Files.readAllBytes(Paths.get("photo.png"));
IPPImage image = presentation.getImages().addImage(imageData);
IPictureFrame pictureFrame = slide.getShapes().addPictureFrame(ShapeType.Rectangle, 50, 50, 400, 260, image);
IImageTransformOperationCollection imageTransform = pictureFrame.getPictureFormat().getPicture().getImageTransform();
IBrightnessContrast brightnessContrast = imageTransform.addBrightnessContrastEffect(15f, 20f);
IBrightnessContrastEffectiveData effectiveValues = brightnessContrast.getEffective();
System.out.println("Brightness: " + effectiveValues.getBrightness() + "%");
System.out.println("Contrast: " + effectiveValues.getContrast() + "%");
IImage preview = slide.getImage();
try {
preview.save("brightness-contrast-preview.png", ImageFormat.Png);
} finally {
preview.dispose();
}
} finally {
presentation.dispose();
}
```
[BrightnessContrast](https://reference.aspose.com/slides/java/com.aspose.slides/brightnesscontrast/) is an Office 2010 picture-effect extension and is less portable than the standard DrawingML luminance effect. When brightness and contrast must remain editable after a PPTX round trip, use [IImageTransformOperationCollection.addLuminanceEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addLuminanceEffect-float-float-) and verify the result after reopening the file. The format limitations section explains this distinction in more detail.
## **Apply Color Transformations**
Color effects can be applied independently to different picture frames that reuse one image resource. The following example creates five frames and applies grayscale, duotone, tint, HSL adjustment, and color replacement.
[IDuotone](https://reference.aspose.com/slides/java/com.aspose.slides/iduotone/) contains two independently editable color parameters: `color1` maps dark pixels, while `color2` maps light pixels. This makes it a useful example of an effect whose settings are more complex than a single scalar value.
```java
import com.aspose.slides.*;
import java.awt.Color;
import java.nio.file.Files;
import java.nio.file.Paths;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
byte[] imageData = Files.readAllBytes(Paths.get("photo.png"));
IPPImage image = presentation.getImages().addImage(imageData);
IPictureFrame grayFrame = slide.getShapes().addPictureFrame(ShapeType.Rectangle, 20, 20, 180, 120, image);
grayFrame.getPictureFormat().getPicture().getImageTransform().addGrayScaleEffect();
IPictureFrame duotoneFrame = slide.getShapes().addPictureFrame(ShapeType.Rectangle, 220, 20, 180, 120, image);
IDuotone duotone = duotoneFrame.getPictureFormat().getPicture().getImageTransform().addDuotoneEffect();
duotone.getColor1().setColor(new Color(0, 0, 128));
duotone.getColor2().setColor(new Color(255, 215, 0));
IPictureFrame tintFrame = slide.getShapes().addPictureFrame(ShapeType.Rectangle, 420, 20, 180, 120, image);
tintFrame.getPictureFormat().getPicture().getImageTransform().addTintEffect(210f, 35f);
IPictureFrame hslFrame = slide.getShapes().addPictureFrame(ShapeType.Rectangle, 120, 170, 180, 120, image);
hslFrame.getPictureFormat().getPicture().getImageTransform().addHSLEffect(30f, 20f, -10f);
IPictureFrame replacementFrame = slide.getShapes().addPictureFrame(ShapeType.Rectangle, 320, 170, 180, 120, image);
IColorReplace colorReplacement = replacementFrame.getPictureFormat().getPicture().getImageTransform().addColorReplaceEffect();
colorReplacement.getColor().setColor(new Color(100, 149, 237));
presentation.save("color-transformations.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
[addColorReplaceEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addColorReplaceEffect--) replaces every pixel's color with one fixed color while preserving alpha. It is different from [addColorChangeEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addColorChangeEffect--), which maps one source color to another and exposes both source and target color formats.
### **Apply a Luminance Threshold**
A luminance threshold can make faint marks on a scanned page easier to distinguish from the background. [addGrayScaleEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addGrayScaleEffect--) preserves intermediate shades of gray. [addBiLevelEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addBiLevelEffect-float-) maps luminance to black or white, while [addAlphaBiLevelEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addAlphaBiLevelEffect-float-) applies a threshold to opacity.
The luminance threshold ranges from 0% to 100%, inclusive. Pixels below the threshold become black. Pixels at or above it become white. Raising the threshold turns more shades black because more of them fall below the cutoff.
Download [grayscale-swatches.png](https://docs.aspose.com/slides/java/image-transform-effects/grayscale-swatches.png) to the working directory. Each label gives the original gray level on a scale from 0 to 255. The example places the original beside two copies and saves each copy's threshold in the presentation.
```java
import com.aspose.slides.*;
import java.nio.file.Files;
import java.nio.file.Paths;
Presentation presentation = new Presentation();
try {
presentation.getSlideSize().setSize(720, 150, SlideSizeScaleType.DoNotScale);
IShapeCollection shapes = presentation.getSlides().get_Item(0).getShapes();
byte[] imageData = Files.readAllBytes(Paths.get("grayscale-swatches.png"));
IPPImage image = presentation.getImages().addImage(imageData);
String[] captions = { "Original", "Threshold 20%", "Threshold 60%" };
IPictureFrame[] frames = new IPictureFrame[captions.length];
for (int i = 0; i < captions.length; i++) {
float x = 12 + 240 * i;
IAutoShape label = shapes.addAutoShape(ShapeType.Rectangle, x, 12, 216, 36);
label.getTextFrame().setText(captions[i]);
frames[i] = shapes.addPictureFrame(ShapeType.Rectangle, x, 60, 216, 72, image);
}
frames[1].getPictureFormat().getPicture().getImageTransform().addBiLevelEffect(20f);
frames[2].getPictureFormat().getPicture().getImageTransform().addBiLevelEffect(60f);
presentation.save("luminance-threshold.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
Open the output presentation in PowerPoint to compare the three frames. The swatch labeled 96 has about 38% luminance (96 out of 255). It turns white at the 20% threshold and black at the 60% threshold.

## **Add Blur, Transparency, and Alpha Effects**
[addBlurEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addBlurEffect-double-boolean-) affects all color channels, including alpha. Set `grow` to `true` when the blurred edge may extend beyond the original picture bounds.
For uniform transparency, use [addAlphaModulateFixedEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addAlphaModulateFixedEffect-float-). It multiplies every existing alpha value, so partially transparent pixels remain proportionally different. [addAlphaReplaceEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addAlphaReplaceEffect-float-) instead assigns one alpha value to all pixels. [addAlphaBiLevelEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addAlphaBiLevelEffect-float-) converts alpha to two levels based on a threshold.
```java
import com.aspose.slides.*;
import java.nio.file.Files;
import java.nio.file.Paths;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
byte[] imageData = Files.readAllBytes(Paths.get("photo.png"));
IPPImage image = presentation.getImages().addImage(imageData);
IPictureFrame blurredFrame = slide.getShapes().addPictureFrame(ShapeType.Rectangle, 20, 20, 200, 140, image);
IBlur blur = blurredFrame.getPictureFormat().getPicture().getImageTransform().addBlurEffect(4.5, true);
blur.setRadius(5);
IPictureFrame transparentFrame = slide.getShapes().addPictureFrame(ShapeType.Rectangle, 240, 20, 200, 140, image);
IAlphaModulateFixed alphaModulate = transparentFrame.getPictureFormat().getPicture().getImageTransform().addAlphaModulateFixedEffect(65f);
alphaModulate.setAmount(60f);
IPictureFrame uniformAlphaFrame = slide.getShapes().addPictureFrame(ShapeType.Rectangle, 20, 180, 200, 140, image);
uniformAlphaFrame.getPictureFormat().getPicture().getImageTransform().addAlphaReplaceEffect(55f);
IPictureFrame binaryAlphaFrame = slide.getShapes().addPictureFrame(ShapeType.Rectangle, 240, 180, 200, 140, image);
IAlphaBiLevel alphaBiLevel = binaryAlphaFrame.getPictureFormat().getPicture().getImageTransform().addAlphaBiLevelEffect(50f);
alphaBiLevel.setThreshold(45f);
binaryAlphaFrame.getPictureFormat().getPicture().getImageTransform().addAlphaInverseEffect();
presentation.save("blur-and-alpha-effects.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
Other parameter-free alpha operations include [addAlphaCeilingEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addAlphaCeilingEffect--), which makes every nonzero alpha fully opaque; [addAlphaFloorEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addAlphaFloorEffect--), which makes every alpha below 100% fully transparent; and [addAlphaInverseEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addAlphaInverseEffect--), which changes alpha to `100% - alpha`.
## **Build an Ordered Effect Chain**
Every `add...Effect` method appends a new operation to the end of the collection. The renderer uses the collection as an ordered pipeline: the output of operation 0 becomes the input of operation 1, and so on. Consequently, the same operations in a different order can produce a different image.
For example, grayscale followed by tint first removes chromatic information and then recolors the luminance result. Tint followed by grayscale removes the tint again. Similarly, alpha replacement can override alpha values calculated by earlier operations, while alpha modulation preserves their relative differences.
The following example builds a four-operation chain, saves it as PPTX, reopens the presentation, checks both the operation types and their order, and renders the reopened result:
```java
import com.aspose.slides.*;
import java.nio.file.Files;
import java.nio.file.Paths;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
byte[] imageData = Files.readAllBytes(Paths.get("photo.png"));
IPPImage image = presentation.getImages().addImage(imageData);
IPictureFrame pictureFrame = slide.getShapes().addPictureFrame(ShapeType.Rectangle, 50, 50, 400, 260, image);
IImageTransformOperationCollection imageTransform = pictureFrame.getPictureFormat().getPicture().getImageTransform();
imageTransform.addGrayScaleEffect();
imageTransform.addTintEffect(220f, 25f);
imageTransform.addBlurEffect(2.5, false);
imageTransform.addAlphaModulateFixedEffect(80f);
presentation.save("image-transform-chain.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
Presentation reopenedPresentation = new Presentation("image-transform-chain.pptx");
try {
IShape reopenedShape = reopenedPresentation.getSlides().get_Item(0).getShapes().get_Item(0);
if (reopenedShape instanceof IPictureFrame) {
IPictureFrame reopenedFrame = (IPictureFrame) reopenedShape;
IImageTransformOperationCollection reopenedTransform = reopenedFrame.getPictureFormat().getPicture().getImageTransform();
boolean orderIsPreserved = reopenedTransform.size() == 4 &&
reopenedTransform.get_Item(0) instanceof IGrayScale &&
reopenedTransform.get_Item(1) instanceof ITint &&
reopenedTransform.get_Item(2) instanceof IBlur &&
reopenedTransform.get_Item(3) instanceof IAlphaModulateFixed;
System.out.println(orderIsPreserved ? "The effect chain was preserved." : "The effect chain changed during the round trip.");
IImage renderedSlide = reopenedPresentation.getSlides().get_Item(0).getImage();
try {
renderedSlide.save("reopened-effect-chain.png", ImageFormat.Png);
} finally {
renderedSlide.dispose();
}
} else {
System.out.println("The reopened shape is not a picture frame.");
}
} finally {
reopenedPresentation.dispose();
}
```
The collection does not impose a compatibility matrix that restricts color, alpha, and blur operations to separate chains. They can be combined, but combinations are not always useful. A fixed color replacement removes RGB variation produced by earlier color effects; grayscale after duotone removes the two selected colors; and alpha ceiling, floor, replacement, or bi-level operations can discard alpha detail created earlier. Build the chain according to the desired pixel-processing sequence rather than treating its items as unordered formatting flags.
[](https://docs.aspose.com/slides/java/image-transform-effects/visual-image-transform-effects-49aa72211f3a.svg)
*In this illustrative Aspose.Slides for .NET 26.11 render, a 220° tint at 25% leaves the grayscale image unchanged. Applying the same tint before grayscale produces different tones.*
## **Inspect Editable and Effective Values**
An editable operation is the object stored in `ISlidesPicture.getImageTransform`. Depending on the effect, it may expose writable members directly. For example, [IBlur](https://reference.aspose.com/slides/java/com.aspose.slides/iblur/) exposes writable `radius` and `grow` values, [IAlphaModulateFixed](https://reference.aspose.com/slides/java/com.aspose.slides/ialphamodulatefixed/) exposes a writable `amount`, and [IAlphaBiLevel](https://reference.aspose.com/slides/java/com.aspose.slides/ialphabilevel/) exposes a writable `threshold`. Color effects such as [IDuotone](https://reference.aspose.com/slides/java/com.aspose.slides/iduotone/) expose mutable [IColorFormat](https://reference.aspose.com/slides/java/com.aspose.slides/icolorformat/) objects.
Some operation interfaces, including [IBrightnessContrast](https://reference.aspose.com/slides/java/com.aspose.slides/ibrightnesscontrast/), [IHSL](https://reference.aspose.com/slides/java/com.aspose.slides/ihsl/), [ITint](https://reference.aspose.com/slides/java/com.aspose.slides/itint/), and [IAlphaReplace](https://reference.aspose.com/slides/java/com.aspose.slides/ialphareplace/), do not expose their creation scalars as writable properties. To change those settings, remove the operation and add a replacement at the required position.
Effective data returned by `getEffective()` is calculated and read-only. It is useful for resolving theme-dependent colors and reading the normalized values that the renderer uses, but it is not another editing surface. The following example enumerates the chain and inspects effective values where the corresponding API provides them:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("image-transform-chain.pptx");
try {
IPictureFrame pictureFrame = null;
for (IShape shape : presentation.getSlides().get_Item(0).getShapes()) {
if (shape instanceof IPictureFrame) {
pictureFrame = (IPictureFrame) shape;
break;
}
}
if (pictureFrame != null) {
IImageTransformOperationCollection imageTransform = pictureFrame.getPictureFormat().getPicture().getImageTransform();
for (int index = 0; index < imageTransform.size(); index++) {
IImageTransformOperation operation = imageTransform.get_Item(index);
System.out.println(index + ": " + operation.getClass().getSimpleName());
if (operation instanceof IBrightnessContrast) {
IBrightnessContrastEffectiveData data = ((IBrightnessContrast) operation).getEffective();
System.out.println(" Brightness: " + data.getBrightness());
System.out.println(" Contrast: " + data.getContrast());
} else if (operation instanceof ILuminance) {
ILuminanceEffectiveData data = ((ILuminance) operation).getEffective();
System.out.println(" Brightness: " + data.getBrightness());
System.out.println(" Contrast: " + data.getContrast());
} else if (operation instanceof IDuotone) {
IDuotoneEffectiveData data = ((IDuotone) operation).getEffective();
System.out.println(" Dark color: " + data.getColor1());
System.out.println(" Light color: " + data.getColor2());
} else if (operation instanceof IColorReplace) {
IColorReplaceEffectiveData data = ((IColorReplace) operation).getEffective();
System.out.println(" Replacement color: " + data.getColor());
} else if (operation instanceof IHSL) {
IHSLEffectiveData data = ((IHSL) operation).getEffective();
System.out.println(" HSL: " + data.getHue() + ", " + data.getSaturation() + ", " + data.getLuminance());
} else if (operation instanceof ITint) {
ITintEffectiveData data = ((ITint) operation).getEffective();
System.out.println(" Tint: " + data.getHue() + ", " + data.getAmount());
} else if (operation instanceof IBlur) {
IBlurEffectiveData data = ((IBlur) operation).getEffective();
System.out.println(" Blur radius: " + data.getRadius() + " pt");
} else if (operation instanceof IAlphaModulateFixed) {
IAlphaModulateFixedEffectiveData data = ((IAlphaModulateFixed) operation).getEffective();
System.out.println(" Alpha amount: " + data.getAmount() + "%");
} else if (operation instanceof IAlphaReplace) {
IAlphaReplaceEffectiveData data = ((IAlphaReplace) operation).getEffective();
System.out.println(" Replacement alpha: " + data.getAlpha() + "%");
} else if (operation instanceof IAlphaBiLevel) {
IAlphaBiLevelEffectiveData data = ((IAlphaBiLevel) operation).getEffective();
System.out.println(" Alpha threshold: " + data.getThreshold() + "%");
}
}
}
} finally {
presentation.dispose();
}
```
Parameter-free effects such as grayscale, alpha ceiling, and alpha inverse still have an effective-data object, but there are no scalar settings to print. Their presence and position in the collection are the important information.
## **Remove or Clear Image Transforms**
Use [IImageTransformOperationCollection.removeAt](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#removeAt-int-) to remove one operation by index. Because indexes shift after removal, search for the target first and remove it after enumeration. Use [ImageTransformOperationCollection.clear](https://reference.aspose.com/slides/java/com.aspose.slides/imagetransformoperationcollection/#clear--) to remove the entire chain.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("image-transform-chain.pptx");
try {
IPictureFrame pictureFrame = null;
for (IShape shape : presentation.getSlides().get_Item(0).getShapes()) {
if (shape instanceof IPictureFrame) {
pictureFrame = (IPictureFrame) shape;
break;
}
}
if (pictureFrame != null) {
IImageTransformOperationCollection imageTransform = pictureFrame.getPictureFormat().getPicture().getImageTransform();
int blurIndex = -1;
for (int index = 0; index < imageTransform.size(); index++) {
if (imageTransform.get_Item(index) instanceof IBlur) {
blurIndex = index;
break;
}
}
if (blurIndex >= 0) {
imageTransform.removeAt(blurIndex);
System.out.println("The blur operation was removed.");
}
imageTransform.clear();
System.out.println("Remaining operations: " + imageTransform.size());
presentation.save("image-transforms-cleared.pptx", SaveFormat.Pptx);
}
} finally {
presentation.dispose();
}
```
Removing or clearing transforms changes only the picture formatting. It does not delete, recompress, or otherwise alter the reused [IPPImage](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/) resource.
## **Consider Presentation Formats and Export Targets**
Image transforms originate in DrawingML, so PPTX is the preferred editable format for effect chains. Even with PPTX, not every operation has identical portability:
- Standard DrawingML operations such as luminance, grayscale, duotone, tint, HSL, blur, and common alpha operations have the best chance of surviving a PPTX round trip. Always reopen the generated file and inspect the collection when preservation is a requirement.
- [BrightnessContrast](https://reference.aspose.com/slides/java/com.aspose.slides/brightnesscontrast/) is an Office 2010 extension rather than the standard DrawingML luminance operation. It can be used for in-memory rendering, but it is not guaranteed to remain as an editable [IBrightnessContrast](https://reference.aspose.com/slides/java/com.aspose.slides/ibrightnesscontrast/) after saving and reopening PPTX. Prefer [addLuminanceEffect](https://reference.aspose.com/slides/java/com.aspose.slides/iimagetransformoperationcollection/#addLuminanceEffect-float-float-) for persistent brightness and contrast adjustments.
- The binary PPT format predates the full DrawingML effect model. Saving to PPT can omit unsupported operations, reduce a chain to a supported subset, or approximate the appearance. Do not use PPT as the verification format for a complex editable chain.
- Rendering to PNG, JPEG, TIFF, PDF, SVG, HTML, or other visual output applies the supported chain to the rendered appearance. Those outputs do not contain an editable `IImageTransformOperationCollection`; raster formats flatten the result into pixels, and document/vector exports store their own rendering representation.
- Effects do not make a linked image self-contained. Rendering a linked picture still depends on the linked resource being available when the presentation is loaded.
Different presentation consumers may render edge cases differently, especially when several alpha or color-quantizing operations are combined. For critical output, test both the editable round trip and the final export format with the same Aspose.Slides version used in production.
## **FAQ**
**Do image transform effects modify the embedded image data?**
No. The operations belong to the `ISlidesPicture` used by the picture fill. The underlying `IPPImage` bytes remain unchanged.
**Will two picture frames that reuse the same image share their effects?**
No. Reusing an `IPPImage` avoids duplicate image data, but each picture frame normally has a separate `ISlidesPicture` and image transform collection.
**Can color, blur, and alpha effects be combined?**
Yes. The collection accepts them in one ordered chain. Consider what each operation does to the output of the previous one because replacement and threshold operations may discard earlier color or alpha detail.
**Why are effective values read-only?**
Effective data represents calculated values used for rendering, including resolved colors. Edit the operation stored in the transform collection where writable members exist; otherwise remove it and add a replacement with new creation parameters.
**Which format should I use to preserve a transform chain?**
Use PPTX and verify the file by reopening it. Legacy PPT cannot represent the full DrawingML effect model, and rendered export formats preserve appearance rather than editable transform operations.
# Optimize Image Management in Presentations Using Java
> Learn how to add, reuse, link, replace, and manage raster and SVG images in PowerPoint and OpenDocument presentations with Aspose.Slides for Java.
Source: https://docs.aspose.com/slides/java/image/
Updated: 2026-08-19
## **Introduction**
Aspose.Slides for Java provides several ways to work with images, and each one serves a different purpose. You can store an image in a presentation, display it in a picture frame, use it as a slide background, link to an external image, replace a shared image resource, or convert SVG content into editable shapes.
This article focuses on image resources and how they are used across a presentation. For cropping, transparency, effects, stretching, and other formatting applied to an individual picture frame, see [Picture Frame](https://docs.aspose.com/slides/java/picture-frame/).
## **Understand the Image Model**
The following API concepts are closely related but not interchangeable:
- The [presentation image collection](https://reference.aspose.com/slides/java/com.aspose.slides/iimagecollection/) stores image resources used by the presentation. Use [ImageCollection.addImage](https://reference.aspose.com/slides/java/com.aspose.slides/imagecollection/) to add image data and obtain an [IPPImage](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/) resource.
- A [picture frame](https://reference.aspose.com/slides/java/com.aspose.slides/ipictureframe/) is a shape that displays an image on a slide, layout, or master. Use [IShapeCollection.addPictureFrame](https://reference.aspose.com/slides/java/com.aspose.slides/ishapecollection/) to place an image resource on a slide.
- A slide background uses an image as part of the slide fill rather than as a shape. It therefore does not behave like a picture frame.
- [IPPImage.replaceImage](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/) replaces an image resource. If several presentation elements use that resource, they all use the replacement.
- Converting an SVG to shapes creates editable slide shapes. After conversion, the content is no longer managed as one picture resource.
A typical workflow is therefore: add image data to the image collection, receive an [IPPImage](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/), and then use that resource in one or more picture frames or fills.
## **Add an Embedded Image**
To insert a local image, load the file, add it to the image collection, and create a picture frame that uses the returned `IPPImage`.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
IPPImage image;
IImage sourceImage = Images.fromFile("photo.png");
try {
image = presentation.getImages().addImage(sourceImage);
} finally {
if (sourceImage != null) sourceImage.dispose();
}
ISlide slide = presentation.getSlides().get_Item(0);
slide.getShapes().addPictureFrame(ShapeType.Rectangle, 20, 20, 320, 180, image);
presentation.save("presentation.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The image added this way is embedded in the presentation, so the resulting file does not depend on the original image file remaining available.
### **Add an Image from the Web**
When an image is available through HTTP or HTTPS, download its bytes, add them to the presentation image collection, and use the returned image resource in the same way as a local image.
```java
import com.aspose.slides.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
Presentation presentation = new Presentation();
try {
URL imageUrl = URI.create("https://example.com/image.png").toURL();
HttpURLConnection connection = (HttpURLConnection) imageUrl.openConnection();
connection.setConnectTimeout(10000);
connection.setReadTimeout(10000);
try (InputStream inputStream = connection.getInputStream();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
byte[] buffer = new byte[8192];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) outputStream.write(buffer, 0, bytesRead);
IPPImage image = presentation.getImages().addImage(outputStream.toByteArray());
ISlide slide = presentation.getSlides().get_Item(0);
slide.getShapes().addPictureFrame(ShapeType.Rectangle, 20, 20, 320, 180, image);
}
presentation.save("presentation-from-web.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
In long-running applications, reuse an HTTP client or connection-management strategy appropriate to the application rather than repeatedly creating unnecessary networking infrastructure. Also validate remote URLs, response sizes, and content types when the source is not trusted.
## **Reuse Images Across Slides**
If the same image is needed more than once, add it to the presentation once and reuse the returned [IPPImage](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/) when creating additional picture frames. This avoids repeatedly loading the same source data and makes the relationship between the shared image resource and its uses explicit.
For graphics that should appear automatically on many slides, such as a company logo, consider placing the picture frame on a [slide master](https://docs.aspose.com/slides/java/slide-master/) or layout instead of adding an equivalent shape to every slide.
## **Use an Image as a Slide Background**
A background image is assigned to the slide fill; it is not added as a picture-frame shape. This is useful when the picture should cover the slide background and should not be manipulated as a normal slide object.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IPPImage image;
IImage sourceImage = Images.fromFile("background.jpg");
try {
image = presentation.getImages().addImage(sourceImage);
} finally {
if (sourceImage != null) sourceImage.dispose();
}
slide.getBackground().setType(BackgroundType.OwnBackground);
slide.getBackground().getFillFormat().setFillType(FillType.Picture);
slide.getBackground().getFillFormat().getPictureFillFormat().setPictureFillMode(PictureFillMode.Stretch);
slide.getBackground().getFillFormat().getPictureFillFormat().getPicture().setImage(image);
presentation.save("background-image.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
For additional background options, including master and layout backgrounds, see [Presentation Background](https://docs.aspose.com/slides/java/presentation-background/).
## **Embedded Images and Linked Images**
Embedded and linked images have different portability and file-size tradeoffs:
- **Embedded image:** the image data is stored inside the presentation. The presentation is self-contained, but the file size includes the image data.
- **Linked image:** the presentation stores a path or URL to an external image. This can reduce the presentation size, but the external resource must remain accessible when the presentation is opened or rendered.
A linked picture can be created by assigning the external path or URL through [ISlidesPicture.setLinkPathLong](https://reference.aspose.com/slides/java/com.aspose.slides/islidespicture/) rather than embedding the image data.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
IPictureFrame pictureFrame = slide.getShapes().addPictureFrame(ShapeType.Rectangle, 20, 20, 320, 180, null);
pictureFrame.getPictureFormat().getPicture().setLinkPathLong("https://example.com/image.png");
presentation.save("linked-image.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
Use linked images only when the deployment environment can reliably access the external resource. For presentations that must work offline or be moved between systems, embedded images are usually safer.
## **Work with SVG Images**
SVG is a vector format, so it can be useful for icons, diagrams, and other graphics that should scale without the same loss of detail as raster images. Aspose.Slides supports SVG both as an image resource and as a source for editable slide shapes.
### **Add an SVG as an Image**
Create an [SvgImage](https://reference.aspose.com/slides/java/com.aspose.slides/svgimage/), add it to the image collection, and place the resulting image resource in a picture frame.
```java
import com.aspose.slides.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
Presentation presentation = new Presentation();
try {
byte[] imageData = Files.readAllBytes(Paths.get("icon.svg"));
String svgContent = new String(imageData, StandardCharsets.UTF_8);
ISvgImage svgImage = new SvgImage(svgContent);
IPPImage image = presentation.getImages().addImage(svgImage);
ISlide slide = presentation.getSlides().get_Item(0);
slide.getShapes().addPictureFrame(ShapeType.Rectangle, 20, 20, 200, 200, image);
presentation.save("svg-image.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
### **SVG Files with External Resources**
An SVG can reference external images, stylesheets, or fonts. For these cases, [SvgImage](https://reference.aspose.com/slides/java/com.aspose.slides/svgimage/) provides constructors that accept an [IExternalResourceResolver](https://reference.aspose.com/slides/java/com.aspose.slides/iexternalresourceresolver/) and a base URI. The resolver can map a relative URI to an allowed absolute URI and return a stream for the requested resource.
The resolver makes external resources available while Aspose.Slides processes the SVG, but it does not rewrite the SVG into a self-contained document. If the SVG must remain portable, embed its required resources in the SVG itself, for example by using `data:` URIs for linked images.
When SVG files come from untrusted sources, restrict the schemes, file locations, and hosts that the resolver can access. Network resolvers should also apply timeouts, response-size limits, and content validation.
### **Convert SVG to Editable Shapes**
Aspose.Slides can convert an SVG into a group of editable slide shapes, similar to the corresponding PowerPoint command.

Use the [IShapeCollection.addGroupShape](https://reference.aspose.com/slides/java/com.aspose.slides/ishapecollection/) overload that accepts an [ISvgImage](https://reference.aspose.com/slides/java/com.aspose.slides/isvgimage/) to perform the conversion.
```java
import com.aspose.slides.*;
import java.awt.geom.Dimension2D;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
Presentation presentation = new Presentation();
try {
byte[] imageData = Files.readAllBytes(Paths.get("diagram.svg"));
String svgContent = new String(imageData, StandardCharsets.UTF_8);
ISvgImage svgImage = new SvgImage(svgContent);
Dimension2D slideSize = presentation.getSlideSize().getSize();
ISlide slide = presentation.getSlides().get_Item(0);
slide.getShapes().addGroupShape(svgImage, 0, 0, (float) slideSize.getWidth(), (float) slideSize.getHeight());
presentation.save("editable-svg-shapes.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
Use SVG-to-shapes conversion when individual vector elements need to be edited as PowerPoint shapes. If the SVG only needs to be displayed, keeping it as an image is simpler and avoids creating many separate shapes.
## **Replace an Existing Image Resource**
Use [IPPImage.replaceImage](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/) when you want to replace an existing image resource. This is especially useful for shared graphics such as logos.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("input.pptx");
try {
IPPImage imageToReplace = presentation.getImages().get_Item(0);
IImage replacementImage = Images.fromFile("new-logo.png");
try {
imageToReplace.replaceImage(replacementImage);
} finally {
if (replacementImage != null) replacementImage.dispose();
}
presentation.save("output.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
If multiple picture frames, backgrounds, masters, or layouts use the same image resource, replacing that resource updates all of those uses. If only one picture frame should change, assign a different image to that frame instead of replacing the shared resource.
`replaceImage` also provides overloads that accept a byte array or another [IPPImage](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/).
## **Practical Image Management Guidance**
### **Control Presentation Size**
Large raster images can make a presentation unnecessarily large. Use source images with dimensions appropriate for their intended display size, reuse shared image resources where possible, and avoid embedding repeated copies of the same full-resolution graphic.
For raster pictures that have already been placed in picture frames, [IPictureFillFormat.compressImage](https://reference.aspose.com/slides/java/com.aspose.slides/ipicturefillformat/) can reduce image data according to the selected resolution and crop settings. This is picture-frame processing rather than image-collection management, so see [Picture Frame](https://docs.aspose.com/slides/java/picture-frame/) for related formatting operations.
### **Choose Between Embedded and Linked Content**
Embedding makes the presentation portable because all required image data travels with the file. Linking can reduce file size, but it introduces an external dependency. Use links only when that dependency is acceptable and stable.
### **Reuse Shared Branding**
For repeated logos, watermarks, or decorative graphics, use one image resource and reuse it. If the graphic belongs to the presentation design rather than slide content, place it on a master or layout so it is inherited by the appropriate slides.
### **Keep SVG Resources Portable**
A self-contained SVG is easier to move and render consistently than an SVG that depends on external files or network resources. When possible, embed required resources before importing the SVG. Convert SVG to shapes only when the individual vector elements need to be edited.
### **Use the Modern Cross-Platform Image API**
For new Java code, use the Aspose.Slides [IImage](https://reference.aspose.com/slides/java/com.aspose.slides/iimage/) and [Images](https://reference.aspose.com/slides/java/com.aspose.slides/images/) APIs instead of the legacy public API based on `java.awt.image.BufferedImage`. See [Modern API](https://docs.aspose.com/slides/java/modern-api/) for migration guidance.
WMF and EMF require special consideration. When these formats are passed through an [IImage](https://reference.aspose.com/slides/java/com.aspose.slides/iimage/), [ImageCollection.addImage](https://reference.aspose.com/slides/java/com.aspose.slides/imagecollection/) converts the metafile to a raster PNG representation before insertion. If preserving the metafile data is important, use a stream-based [ImageCollection.addImage](https://reference.aspose.com/slides/java/com.aspose.slides/imagecollection/) overload instead. Generating EMF content from spreadsheets or other products is a separate integration workflow and is outside the scope of this article.
## **FAQ**
**What is the difference between the image collection and a picture frame?**
The image collection stores reusable image resources. A picture frame is a slide shape that displays one of those resources and provides picture-specific formatting such as cropping and effects.
**What is the best way to replace the same logo everywhere?**
If the logo is already shared as one image resource, replace that resource with [IPPImage.replaceImage](https://reference.aspose.com/slides/java/com.aspose.slides/ippimage/). For presentation-wide branding, placing the logo on a master or layout can also reduce duplicated slide content.
**Why does a linked image disappear on another computer?**
A linked picture depends on its external file or URL. If that resource cannot be reached from the other computer, the linked image may be unavailable. Embed the image when the presentation must be self-contained.
**Can an inserted SVG be edited as PowerPoint shapes?**
Yes. Convert the SVG with [IShapeCollection.addGroupShape](https://reference.aspose.com/slides/java/com.aspose.slides/ishapecollection/); the resulting group contains editable slide shapes rather than one SVG picture.
**How can I keep presentations with many images smaller?**
Reuse shared image resources, avoid unnecessarily large raster sources, compress suitable raster pictures when appropriate, keep repeated branding on masters or layouts, and use linked images only when an external dependency is acceptable.
# Import Presentations from PDF or HTML in Java
> Learn how to import PDF and HTML content into PowerPoint presentations in Java with Aspose.Slides and save the results as PPTX files.
Source: https://docs.aspose.com/slides/java/import-presentation/
Updated: 2026-11-08
## **Introduction**
Aspose.Slides for Java can turn PDF pages or HTML content into PowerPoint slides without Microsoft PowerPoint. The [SlideCollection](https://reference.aspose.com/slides/java/com.aspose.slides/slidecollection/) class provides [addFromPdf](https://reference.aspose.com/slides/java/com.aspose.slides/slidecollection/#addFromPdf-java.lang.String-) and [addFromHtml](https://reference.aspose.com/slides/java/com.aspose.slides/slidecollection/#addFromHtml-java.lang.String-) for appending imported content to a presentation.
For more control over HTML placement, [SlideCollection.insertFromHtml](https://reference.aspose.com/slides/java/com.aspose.slides/slidecollection/#insertFromHtml-int-java.lang.String-boolean-) can insert generated slides at a collection index or begin filling available space on an existing slide. Long HTML is paginated across additional slides automatically, the source can be supplied as a string or stream, and external assets can be loaded through [IExternalResourceResolver](https://reference.aspose.com/slides/java/com.aspose.slides/iexternalresourceresolver/) with a base URI. The returned [ISlide](https://reference.aspose.com/slides/java/com.aspose.slides/islide/) array identifies the affected and newly created slides.
## **Import from PDF**
To convert a PDF document to a PowerPoint presentation, import its content into the slide collection and save the result as a PPTX file.
1. Create a new [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) object.
2. Call [addFromPdf](https://reference.aspose.com/slides/java/com.aspose.slides/slidecollection/#addFromPdf-java.lang.String-) with the path to the PDF file.
3. Call [save](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#save-java.lang.String-int-) with [SaveFormat.Pptx](https://reference.aspose.com/slides/java/com.aspose.slides/saveformat/#Pptx) to write the presentation to a PPTX file.
The following Java example imports a PDF document and saves the generated slides as a PowerPoint presentation:
```java
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
Presentation presentation = new Presentation();
try {
presentation.getSlides().addFromPdf("document.pdf");
presentation.save("presentation.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The [addFromPdf](https://reference.aspose.com/slides/java/com.aspose.slides/slidecollection/#addFromPdf-java.lang.String-) method returns the slides it adds, which is useful when you need to process only the imported slides.
Try the free [PDF to PowerPoint](https://products.aspose.app/slides/import/pdf-to-powerpoint) web app to see this conversion workflow in action.
## **Import from HTML**
Aspose.Slides can also create slides from an HTML document. The source can be supplied as HTML text or a stream. The following steps use a file stream:
1. Create a new [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) object.
2. Open the HTML file for reading and pass the stream to [addFromHtml](https://reference.aspose.com/slides/java/com.aspose.slides/slidecollection/#addFromHtml-java.io.InputStream-).
3. Call [save](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#save-java.lang.String-int-) with [SaveFormat.Pptx](https://reference.aspose.com/slides/java/com.aspose.slides/saveformat/#Pptx) to write the result to a PPTX file.
The following Java example imports an HTML document and saves the generated slides as a PowerPoint presentation:
```java
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
Presentation presentation = new Presentation();
try {
try (InputStream htmlStream = Files.newInputStream(Paths.get("page.html"))) {
presentation.getSlides().addFromHtml(htmlStream);
}
presentation.save("presentation.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Insert HTML Content**
Use [SlideCollection.insertFromHtml](https://reference.aspose.com/slides/java/com.aspose.slides/slidecollection/#insertFromHtml-int-java.lang.String-boolean-) when HTML-generated slides must be placed at a specific position instead of appended. The index is zero-based and identifies the position at which the import starts. The method is also available through [ISlideCollection](https://reference.aspose.com/slides/java/com.aspose.slides/islidecollection/).
The `useSlideWithIndexAsStart` argument controls how the importer uses that position:
- When it is `false`, the importer creates new slides at the specified index and shifts the slides that follow them.
- When it is `true`, the importer starts placing content in the available space on the existing slide at that index. If the HTML does not fit, Aspose.Slides paginates it automatically and inserts additional slides immediately after the starting slide.
[SlideCollection.insertFromHtml](https://reference.aspose.com/slides/java/com.aspose.slides/slidecollection/#insertFromHtml-int-java.lang.String-boolean-) returns an array of [ISlide](https://reference.aspose.com/slides/java/com.aspose.slides/islide/) objects. When insertion starts on new slides, every returned item is newly created. When an existing slide is used as the start, the array includes that affected slide followed by any new overflow slides. You can inspect this array instead of calculating the affected range from the presentation's slide count.
### **Insert HTML as New Slides**
The following example supplies HTML as a string and inserts the generated slides at collection index `1`. Passing `false` leaves the existing slides unchanged except for shifting them to make room.
```java
import com.aspose.slides.ILayoutSlide;
import com.aspose.slides.ISlide;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
Presentation presentation = new Presentation();
try {
ILayoutSlide layoutSlide = presentation.getLayoutSlides().get_Item(0);
presentation.getSlides().addEmptySlide(layoutSlide);
presentation.getSlides().addEmptySlide(layoutSlide);
int insertIndex = 1;
String html = "
Quarterly update
This content is inserted before the slide that was at index 1.
";
ISlide[] insertedSlides = presentation.getSlides().insertFromHtml(insertIndex, html, false);
for (ISlide slide : insertedSlides) {
System.out.println("Inserted slide index: " + presentation.getSlides().indexOf(slide));
}
presentation.save("presentation-with-inserted-html.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
### **Start on an Existing Slide**
The next example supplies the HTML through a stream. It keeps a header shape on the existing template slide, starts importing below the occupied area, and lets the long body continue onto new slides.
The HTML also contains a relative image URL. An [IExternalResourceResolver](https://reference.aspose.com/slides/java/com.aspose.slides/iexternalresourceresolver/) obtains the resource, while the base URI tells the importer how to resolve `images/logo.png`. In this example, that file is expected at `html-assets/images/logo.png`.
```java
import com.aspose.slides.ExternalResourceResolver;
import com.aspose.slides.IAutoShape;
import com.aspose.slides.IExternalResourceResolver;
import com.aspose.slides.ISlide;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
import com.aspose.slides.ShapeType;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
Presentation presentation = new Presentation();
try {
ISlide templateSlide = presentation.getSlides().get_Item(0);
IAutoShape header = templateSlide.getShapes().addAutoShape(ShapeType.Rectangle, 20, 20, 680, 60);
header.getTextFrame().setText("Product roadmap");
StringBuilder htmlBuilder = new StringBuilder("
");
}
htmlBuilder.append("");
String html = htmlBuilder.toString();
byte[] htmlData = html.getBytes(StandardCharsets.UTF_8);
IExternalResourceResolver resolver = new ExternalResourceResolver();
Path baseDirectory = Paths.get("html-assets").toAbsolutePath();
String baseUri = baseDirectory.toUri().toString();
if (!baseUri.endsWith("/")) {
baseUri += "/";
}
try (InputStream htmlStream = new ByteArrayInputStream(htmlData)) {
ISlide[] affectedSlides = presentation.getSlides().insertFromHtml(0, htmlStream, resolver, baseUri, true);
for (ISlide slide : affectedSlides) {
System.out.println("Affected slide index: " + presentation.getSlides().indexOf(slide));
}
}
presentation.save("presentation-with-html-overflow.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
An unrestricted external resource resolver can read local or network resources referenced by the HTML. For untrusted input, implement [IExternalResourceResolver](https://reference.aspose.com/slides/java/com.aspose.slides/iexternalresourceresolver/) with an allowlist for permitted schemes, directories, and hosts, and reject all other URIs.
[](https://docs.aspose.com/slides/java/import-presentation/visual-import-presentation-2c09b3d2f9f0.svg)
*Crops from one .NET import with an existing target between two neighboring slides. The header survives, the relative logo and body start below it, and overflow creates six continuation slides before Summary.*
## **FAQ**
**Can Aspose.Slides detect tables when importing a PDF?**
Yes. Create a [PdfImportOptions](https://reference.aspose.com/slides/java/com.aspose.slides/pdfimportoptions/) object, call [setDetectTables](https://reference.aspose.com/slides/java/com.aspose.slides/pdfimportoptions/#setDetectTables-boolean-) with `true`, and pass the options to [addFromPdf](https://reference.aspose.com/slides/java/com.aspose.slides/slidecollection/#addFromPdf-java.lang.String-com.aspose.slides.PdfImportOptions-). The quality of table recognition depends on the structure and complexity of the source PDF.
You can also use Aspose.Slides to convert HTML content to other formats:
- [HTML to image](https://products.aspose.com/slides/java/conversion/html-to-image/)
- [HTML to JPG](https://products.aspose.com/slides/java/conversion/html-to-jpg/)
- [HTML to XML](https://products.aspose.com/slides/java/conversion/html-to-xml/)
- [HTML to TIFF](https://products.aspose.com/slides/java/conversion/html-to-tiff/)
# Installation
> Install Aspose.Slides for Java from Aspose's Maven repository or as a JAR file, set up the Linux prerequisites, and check the installation with a first program.
Source: https://docs.aspose.com/slides/java/installation/
Updated: 2026-10-09
## **Overview**
This article explains how to add Aspose.Slides for Java to a project. Aspose.Slides for Java is published in Aspose's own Maven repository, not in Maven Central, so a Maven project has to declare that repository. You can also download the JAR file and put it on the class path yourself. Both routes end with a short program that confirms the library works.
Aspose.Slides for Java does not require Microsoft PowerPoint. It programmatically generates the necessary presentation files. However, to view the generated presentations, you may need Microsoft PowerPoint or another presentation viewer.
## **Prerequisites**
- A Java Development Kit (JDK). The project and the commands in this article need JDK 11 or later. On JDK 11, the program that checks the installation prints a warning that begins with "WARNING: An illegal reflective access operation has occurred"; it does not affect the result and can be ignored.
- [Apache Maven](https://maven.apache.org/install.html), if you use the Maven route.
- On Linux, the fontconfig library and at least one installed font. See [Linux](https://docs.aspose.com/slides/java/installation/#linux).
## **Install from the Maven Repository**
Aspose hosts its Java libraries in its own [Maven repository](https://releases.aspose.com/java/repo/com/aspose/). To use [Aspose.Slides for Java](https://releases.aspose.com/java/repo/com/aspose/aspose-slides/) in a Maven project, add two entries to your *pom.xml*.
1. **Declare the Aspose Maven repository.**
```xml
AsposeJavaAPIAspose Java APIhttps://releases.aspose.com/java/repo/
```
2. **Add the Aspose.Slides for Java dependency.**
```xml
com.asposeaspose-slides26.10jdk8
```
The `jdk8` classifier is required: it selects the Java SE build of the library. Replace `26.10` with the latest version listed in the [repository](https://releases.aspose.com/java/repo/com/aspose/aspose-slides/). The repository publishes a SHA-1 checksum file next to each JAR, which Maven checks when it downloads the library.
### **Check the Installation**
To check the setup with a new project:
1. Create a folder for the project and save this *pom.xml* in it:
```xml
4.0.0com.examplehello-slides1.011UTF-8HelloSlidesAsposeJavaAPIAspose Java APIhttps://releases.aspose.com/java/repo/com.asposeaspose-slides26.10jdk8org.apache.maven.pluginsmaven-compiler-plugin3.15.0
```
Besides the repository and the dependency, this *pom.xml* sets the Java release to compile for, names the class that `mvn exec:java` runs, and pins the compiler plugin, because the older plugin that some Maven installations use by default ignores the `maven.compiler.release` setting.
2. Save the first example in [Create Presentations](https://docs.aspose.com/slides/java/create-presentation/) as *src/main/java/HelloSlides.java*.
3. In the project folder, run:
```bash
mvn compile exec:java
```
Maven downloads Aspose.Slides for Java, compiles the program, and runs it. The program saves *new_presentation.pptx* in the project folder.
## **Use the JAR File without Maven**
1. Download *aspose-slides-26.10-jdk8.jar* from the [version folder](https://releases.aspose.com/java/repo/com/aspose/aspose-slides/26.10/) in the repository. For another version, open its folder in the [repository](https://releases.aspose.com/java/repo/com/aspose/aspose-slides/) and download the file that ends in *-jdk8.jar*.
2. Save the first example in [Create Presentations](https://docs.aspose.com/slides/java/create-presentation/) as *HelloSlides.java* in the same folder as the JAR file.
3. In that folder, run:
```bash
java -cp aspose-slides-26.10-jdk8.jar HelloSlides.java
```
The JDK compiles and runs the single source file, and the program saves *new_presentation.pptx* in the folder. In your own application, add the JAR file to the class path in your build tool or IDE.
## **Linux**
Aspose.Slides for Java uses Java's font support, which on Linux needs the fontconfig library and at least one installed font. Without them, saving a presentation fails with the error "Fontconfig head is null, check your fonts or fonts configuration". Minimal server and container images can lack both; the official Ubuntu container image, for example, has neither.
On Debian and Ubuntu, this command installs a JDK, Maven, fontconfig, and the DejaVu fonts:
```bash
sudo apt-get update && sudo apt-get install -y default-jdk maven fontconfig fonts-dejavu-core
```
The fonts used in your presentations, or suitable substitutes, must also be installed for text to render correctly.
## **FAQ**
### How can I verify that Aspose.Slides is integrated correctly?
Build your project, instantiate a blank [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) and save it under a new name. If the file is created without throwing exceptions, the library has been integrated successfully.
### How can I limit memory consumption when processing large presentations?
Raise JVM memory limits only as high as needed, and call [dispose](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#dispose--) on each [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) instance in a `finally` block to release the cache promptly. This prevents out‑of‑memory errors and keeps overall memory usage predictable during batch operations.
### Can I exclude unwanted export formats to shrink the final JAR size?
Current Aspose.Slides releases are shipped as a single monolithic library, so you cannot disable specific exporters such as PDF or SVG at build time.
## Related features
- [Use Slides from Java](https://docs.aspose.com/slides/features/java-api/)
## Related articles
- [How to Run Examples](https://docs.aspose.com/slides/java/how-to-run-the-examples/)
# Known Issues in Aspose.Slides for Java 14.3.0 (Historical)
> Historical: the known issues published with Aspose.Slides for Java 14.3.0, kept for reference. It is not a list of issues in the current version.
Source: https://docs.aspose.com/slides/java/known-issues-in-aspose-slides-for-java-14-3-0/
Updated: 2026-09-29
This is a historical page. It lists the known issues published with Aspose.Slides for Java 14.3.0 and does not describe the current version. For the changes in each version, see the [release notes](https://releases.aspose.com/slides/java/release-notes/).
Aspose.Slides for Java 14.3.0 (14.4.0) provides completely new implementation of PPT processing. There are a lot of improvements, PPTX to PPT partial conversion. But there are some unimplemented features:
- Some shapes have wrong geometry in serialized PPT documents (Call outs)
- Not all PPTX text formatting features are supported in PPT serialization
- Info about text language and spelling settings is not present in serialized PPT documents
- Not all PPTX themes’ features are supported in PPT serialization
**There are some differences in comparison with Aspose.Slides for Java 8.6.0:**
- There are known issues in OLE/ActiveX PPT serialization to PPT
**There are some differences in comparison with Aspose.Slides for .NET 14.3.0:**
- Presentation printing support is at present unavailable in Aspose.Slides for Java
## Related articles
- [Known Issues in Aspose.Slides for Java 14.4.0](https://docs.aspose.com/slides/java/known-issues-in-aspose-slides-for-java-14-4-0/)
- [Known Issues](https://docs.aspose.com/slides/java/known-issues/)
# Known Issues in Aspose.Slides for Java 14.4.0 (Historical)
> Historical: the restrictions and known issues published with Aspose.Slides for Java 14.4.0, kept for reference. It is not a list of issues in the current version.
Source: https://docs.aspose.com/slides/java/known-issues-in-aspose-slides-for-java-14-4-0/
Updated: 2026-09-29
This is a historical page. It lists the restrictions and known issues published with Aspose.Slides for Java 14.4.0 and does not describe the current version. For the changes in each version, see the [release notes](https://releases.aspose.com/slides/java/release-notes/).
Aspose.Slides for Java 14.4.0 provides new decision for PowerPoint documents processing. There are some restrictions and known issues, which will be removed in coming releases:
- Some shapes have wrong geometry in serialized PPT documents (arc, circular arrow, callouts).
- Not all PPTX text formatting features are supported in PPT serialization (tabulation, indentation and paragraph formatting limitations).
- Info about text language and spelling settings is not present in serialized PPT documents.
- Not all PPTX theme features are supported in PPT serialization (only serialization of fill formats, line formats and font).
- There are known issues in OLE/ActiveX PPT serialization to PPT.
- WordArt serialization and rendering are not supported.
## Related articles
- [Known Issues in Aspose.Slides for Java 14.3.0](https://docs.aspose.com/slides/java/known-issues-in-aspose-slides-for-java-14-3-0/)
- [Known Issues](https://docs.aspose.com/slides/java/known-issues/)
# Known Issues and Behavior Notes
> A by-design note on OLE object previews and two historical known-issues lists from versions 14.3.0 and 14.4.0, with links to the current release notes and support.
Source: https://docs.aspose.com/slides/java/known-issues/
Updated: 2026-09-29
## **Overview**
This section does not contain a list of open issues in the current version. It contains three pages:
- [Object Preview Placeholder When Adding OleObjectFrame](https://docs.aspose.com/slides/java/object-preview-issue-when-adding-oleobjectframe/) explains why an OLE object added with Aspose.Slides shows an "EMBEDDED OLE OBJECT" image until its preview is updated, and how to set your own preview image. This is by-design behavior of the current version.
- [Known Issues in Aspose.Slides for Java 14.3.0 (Historical)](https://docs.aspose.com/slides/java/known-issues-in-aspose-slides-for-java-14-3-0/) and [Known Issues in Aspose.Slides for Java 14.4.0 (Historical)](https://docs.aspose.com/slides/java/known-issues-in-aspose-slides-for-java-14-4-0/) are lists published with those versions, kept for reference.
For the changes and fixes in each version, see the [release notes](https://releases.aspose.com/slides/java/release-notes/). The metadata fields that Aspose.Slides writes with fixed values are described in [Output Metadata Limitations](https://docs.aspose.com/slides/java/api-limitations/). To check whether a problem is already known, or to report one, use the [support forum](https://forum.aspose.com/c/slides/11).
## Related articles
- [Known Issues in Aspose.Slides for Java 14.4.0](https://docs.aspose.com/slides/java/known-issues-in-aspose-slides-for-java-14-4-0/)
- [Known Issues in Aspose.Slides for Java 14.3.0](https://docs.aspose.com/slides/java/known-issues-in-aspose-slides-for-java-14-3-0/)
# Licensing Bug in Versions 23.2 to 23.7 (Historical)
> Historical: a licensing bug in Aspose.Slides for Java 23.2 to 23.7 that switched perpetual licenses to evaluation mode after their subscription expired, and the fixed versions 23.2.1 to 23.7.1.
Source: https://docs.aspose.com/slides/java/licensing-bug/
Updated: 2026-09-29
This is a historical page. It describes a bug in Aspose.Slides for Java versions 23.2 to 23.7, which were released in 2023, and the versions that fixed it. It does not describe the current version. For licensing in the current version, see [Licensing](https://docs.aspose.com/slides/java/licensing/).
## **Overview**
This article describes a licensing bug encountered in Aspose.Slides for Java versions 23.2, 23.3, 23.4, 23.5, 23.6 and 23.7. This bug caused perpetual licenses to become temporarily unusable after their subscription expired.
## **Symptoms**
After your perpetual license subscription expires, Aspose.Slides for Java versions 23.2 - 23.7 may report the license as expired, transitioning all functions into evaluation mode.
This behavior is incorrect and does not affect versions prior to 23.2 and after 23.7.
## **Resolution**
Aspose.Slides for Java addressed this issue and released updated versions (23.2.1, 23.3.1, 23.4.1, 23.5.1, 23.6.1, 23.7.1) with the fix.
If you are using one of the affected versions of Aspose.Slides for Java in your project, please switch to using the corrected version.
List of versions with the fix:
| Repository link | Release notes link |
| :- | :- |
|[23.2.1](https://releases.aspose.com/java/repo/com/aspose/aspose-slides/23.2.1/) | [Release notes Aspose.Slides for Java 23.2.1](https://releases.aspose.com/slides/java/release-notes/2023/aspose-slides-for-java-23-2-1-release-notes/)|
|[23.3.1](https://releases.aspose.com/java/repo/com/aspose/aspose-slides/23.3.1/) | [Release notes Aspose.Slides for Java 23.3.1](https://releases.aspose.com/slides/java/release-notes/2023/aspose-slides-for-java-23-3-1-release-notes/)|
|[23.4.1](https://releases.aspose.com/java/repo/com/aspose/aspose-slides/23.4.1/) | [Release notes Aspose.Slides for Java 23.4.1](https://releases.aspose.com/slides/java/release-notes/2023/aspose-slides-for-java-23-4-1-release-notes/)|
|[23.5.1](https://releases.aspose.com/java/repo/com/aspose/aspose-slides/23.5.1/) | [Release notes Aspose.Slides for Java 23.5.1](https://releases.aspose.com/slides/java/release-notes/2023/aspose-slides-for-java-23-5-1-release-notes/)|
|[23.6.1](https://releases.aspose.com/java/repo/com/aspose/aspose-slides/23.6.1/) | [Release notes Aspose.Slides for Java 23.6.1](https://releases.aspose.com/slides/java/release-notes/2023/aspose-slides-for-java-23-6-1-release-notes/)|
|[23.7.1](https://releases.aspose.com/java/repo/com/aspose/aspose-slides/23.7.1/) | [Release notes Aspose.Slides for Java 23.7.1](https://releases.aspose.com/slides/java/release-notes/2023/aspose-slides-for-java-23-7-1-release-notes/)|
If you experience any licensing issues with Aspose.Slides for Java:
- Check the version you are using and ensure it's not affected by the bug described above.
- Refer to [Licensing](https://docs.aspose.com/slides/java/licensing/) for how to apply and validate a license.
- Contact [Aspose support](https://forum.aspose.com/c/slides/11) for further assistance.
## **Affected products and versions**
Please note that this bug only impacts Aspose.Slides for Java versions 23.2 through 23.7. **Other Aspose products and other versions of Aspose.Slides are not affected**.
# Licensing
> Apply, manage, and troubleshoot licenses in Aspose.Slides for Java. Ensure uninterrupted access to full features with our step-by-step licensing guide.
Source: https://docs.aspose.com/slides/java/licensing/
Updated: 2026-09-27
## **Overview**
Aspose.Slides can be used in evaluation mode or with a valid license. The evaluation version provides the same functionality as the licensed version, but it adds an evaluation watermark to every slide of each presentation it saves and truncates text that your code reads through the API.
This article explains how licensing works in Aspose.Slides and how to apply a license before using the library. A license can be loaded from a file, stream, or embedded resource by using the `License` class. The article also shows how to validate whether a license has been applied correctly.
## **Evaluate Aspose.Slides**
You can download an evaluation version of **Aspose.Slides for Java** from its [download page](https://releases.aspose.com/java/repo/com/aspose/aspose-slides/). The evaluation version provides the same functionalities as the licensed version of the product. The evaluation package is the same as the purchased package. The evaluation version simply becomes licensed after you add a few lines of code to it (to apply the license).
Once you are happy with your evaluation of **Aspose.Slides**, you can [purchase a license](https://purchase.aspose.com/pricing/slides/java/). We recommend you go through the different subscription types. If you have questions, contact the Aspose sales team.
Every Aspose license comes with a one-year subscription for free upgrades to new versions or fixes released within the subscription period. Users with licensed products (or even evaluation versions) get free and unlimited technical support.
**Evaluation version limitations**
* The evaluation version (without a license specified) provides full product functionality, but it adds an evaluation watermark text box to every slide of each presentation it saves.
* Text that your code reads through the API, including text it has just set, is truncated to its first few characters, followed by a notice about the evaluation limitation. Text that your code writes is saved in full.
To test Aspose.Slides without limitations, you can ask for a **30-Day Temporary License**. See the [How to get a Temporary License](https://purchase.aspose.com/temporary-license) page for more information.
## **Licensing in Aspose.Slides**
* An evaluation version becomes licensed after you purchase a license and add a couple of lines of code to it (to apply the license).
* The license is a plain-text XML file that contains details such as the product name, number of developers it is licensed to, subscription expiry date, and so on.
* The license file is digitally signed, so you must not modify the file. Even an inadvertent addition of an extra line break to the contents of the file will invalidate it.
* Aspose.Slides for Java typically tries to find the license in these locations:
* An explicit path
* The folder containing Aspose.Slides.jar
* To avoid the limitations associated with the evaluation version, you need to set a license before using **Aspose.Slides**. You only have to set a license once per application or process.
You may want to see [Metered Licensing](https://docs.aspose.com/slides/java/metered-licensing/).
## **Applying a License**
A license can be loaded from a **file** or **stream**.
Aspose.Slides provides the [License](https://reference.aspose.com/slides/java/com.aspose.slides/license/) class for licensing operations.
New licenses can activate Aspose.Slides only with version 21.4 or later. Earlier versions use a different licensing system and will not recognize these licenses.
### **File**
The easiest method of setting a license requires you to place the license file in the folder containing Aspose.Slides.jar or your applications' jar.
This Java code shows you how to set a license file:
``` java
// Instantiates the License class
com.aspose.slides.License license = new com.aspose.slides.License();
// Sets the license file path
license.setLicense("Aspose.Slides.Java.lic");
```
If you place the license file in a different directory, when you call the [setLicense](https://reference.aspose.com/slides/java/com.aspose.slides/license/#setLicense-java.lang.String-) method, the license file name at the end of the specified path must be the same as your license file name.
For example, you can change the license file name to *Aspose.Slides.Java.lic.xml*. Then, in your code, you have to pass the path to the file (ending with *Aspose.Slides.Java.lic.xml*) to the [setLicense](https://reference.aspose.com/slides/java/com.aspose.slides/license/#setLicense-java.lang.String-) method.
### **Stream**
You can load a license from a stream. This Java code shows you how to apply a license from a stream:
``` java
// Instantiates the License class
com.aspose.slides.License license = new com.aspose.slides.License();
// Sets the license through a stream
license.setLicense(new java.io.FileInputStream("Aspose.Slides.Java.lic"));
```
### **PHP/Java Bridge**
If you use Aspose.Slides for PHP via Java, you can set a license through a PHP/Java bridge. This bridge allows you to use Java classes in PHP syntax. For more information, see [License in PHP](https://docs.aspose.com/slides/php-java/licensing/).
## **Validating a License**
To check whether a license has been set properly, you can validate it. This Java code shows you how to validate a license:
```java
import com.aspose.slides.*;
License license = new License();
license.setLicense("Aspose.Slides.Java.lic");
if (license.isLicensed())
{
System.out.println("License is good!");
}
```
## **Thread Safety**
The [setLicense](https://reference.aspose.com/slides/java/com.aspose.slides/license/#setLicense-java.io.InputStream-) method is not thread-safe. If this method has to be called simultaneously from many threads, you may want to use synchronization primitives (like a lock) to avoid issues.
## **FAQ**
### Can I apply the license in a completely offline environment (no internet access)?
Yes. License validation is performed locally using the license file; no internet connection is required.
### What happens after the one-year subscription expires? Will the library stop working?
No. The license is perpetual: you can continue using versions released before your subscription end date; you just won’t be eligible to use newer releases without renewing.
## Related articles
- [Evaluate Aspose.Slides](https://docs.aspose.com/slides/java/evaluate-aspose-slides/)
# Add Line Shapes to Presentations in Java
> Learn to manipulate line formatting in PowerPoint presentations with Aspose.Slides for Java. Discover properties, methods, and examples.
Source: https://docs.aspose.com/slides/java/line/
Updated: 2026-08-05
## **Overview**
Aspose.Slides allows you to add line shapes to PowerPoint slides programmatically. This article shows how to create a simple line and how to customize a line so it appears as an arrow.
You will learn how to add a line shape to a slide, adjust its visual appearance, and save the updated presentation. The examples focus on practical line formatting settings such as style, width, dash pattern, arrowhead options, and fill color.
## **Create a Plain Line**
To add a simple plain line to a selected slide of the presentation, please follow the steps below:
- Create an instance of [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class.
- Obtain the reference of a slide by using its Index.
- Add an AutoShape of Line type using [addAutoShape](https://reference.aspose.com/slides/java/com.aspose.slides/IShapeCollection#addAutoShape-int-float-float-float-float-) method exposed by [IShapeCollection](https://reference.aspose.com/slides/java/com.aspose.slides/IShapeCollection) object.
- Write the modified presentation as a PPTX file.
In the example given below, we have added a line to the first slide of the presentation.
```java
import com.aspose.slides.*;
// Instantiate PresentationEx class that represents the PPTX file
Presentation pres = new Presentation();
try {
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add an AutoShape of type line
sld.getShapes().addAutoShape(ShapeType.Line, 50, 150, 300, 0);
// Write the PPTX to Disk
pres.save("LineShape.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
## **Create an Arrow-Shaped Line**
Aspose.Slides for Java also allows developers to configure some properties of the line to make it look more appealing. Let's try to configure few properties of a line to make it look like an arrow. Please follow the steps below to do so:
- Create an instance of [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation) class.
- Obtain the reference of a slide by using its Index.
- Add an AutoShape of Line type using [addAutoShape](https://reference.aspose.com/slides/java/com.aspose.slides/IShapeCollection#addAutoShape-int-float-float-float-float-) method exposed by [IShapeCollection](https://reference.aspose.com/slides/java/com.aspose.slides/IShapeCollection) object.
- Set the [Line Style](https://reference.aspose.com/slides/java/com.aspose.slides/LineStyle) to one of the styles as offered by Aspose.Slides for Java.
- Set the Width of the line.
- Set the [Dash Style](https://reference.aspose.com/slides/java/com.aspose.slides/LineDashStyle) of the line to one of the styles offered by Aspose.Slides for Java.
- Set the [Arrow Head Style](https://reference.aspose.com/slides/java/com.aspose.slides/LineArrowheadStyle) and [Length](https://reference.aspose.com/slides/java/com.aspose.slides/LineArrowheadLength) of the start point of the line.
- Set the [Arrow Head Style](https://reference.aspose.com/slides/java/com.aspose.slides/LineArrowheadStyle) and [Length](https://reference.aspose.com/slides/java/com.aspose.slides/LineArrowheadLength) of the end point of the line.
- Write the modified presentation as a PPTX file.
```java
import com.aspose.slides.*;
// Instantiate PresentationEx class that represents the PPTX file
Presentation pres = new Presentation();
try {
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add an AutoShape of type line
IAutoShape shp = sld.getShapes().addAutoShape(ShapeType.Line, 50, 150, 300, 0);
// Apply some formatting on the line
shp.getLineFormat().setStyle(LineStyle.ThickBetweenThin);
shp.getLineFormat().setWidth(10);
shp.getLineFormat().setDashStyle(LineDashStyle.DashDot);
shp.getLineFormat().setBeginArrowheadLength(LineArrowheadLength.Short);
shp.getLineFormat().setBeginArrowheadStyle(LineArrowheadStyle.Oval);
shp.getLineFormat().setEndArrowheadLength(LineArrowheadLength.Long);
shp.getLineFormat().setEndArrowheadStyle(LineArrowheadStyle.Triangle);
shp.getLineFormat().getFillFormat().setFillType(FillType.Solid);
shp.getLineFormat().getFillFormat().getSolidFillColor().setPresetColor(PresetColor.Maroon);
// Write the PPTX to Disk
pres.save("LineShape.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
## **FAQ**
### Can I convert a regular line into a connector so it "snaps" to shapes?
No. A regular line (an [AutoShape](https://reference.aspose.com/slides/java/com.aspose.slides/autoshape/) of type [Line](https://reference.aspose.com/slides/java/com.aspose.slides/shapetype/)) does not automatically become a connector. To make it snap to shapes, use the dedicated [Connector](https://reference.aspose.com/slides/java/com.aspose.slides/connector/) type and the [corresponding APIs](https://docs.aspose.com/slides/java/connector/) for connections.
### What should I do if a line’s properties are inherited from the theme and it’s hard to determine the final values?
[Read the effective properties](https://docs.aspose.com/slides/java/shape-effective-properties/) through the [ILineFormatEffectiveData](https://reference.aspose.com/slides/java/com.aspose.slides/ilineformateffectivedata/)/[ILineFillFormatEffectiveData](https://reference.aspose.com/slides/java/com.aspose.slides/ilinefillformateffectivedata/) interfaces—these already account for inheritance and theme styles.
### Can I lock a line against editing (moving, resizing)?
Yes. Shapes provide [lock objects](https://reference.aspose.com/slides/java/com.aspose.slides/autoshape/#getAutoShapeLock--) that let you [disallow editing operations](https://docs.aspose.com/slides/java/applying-protection-to-presentation/).
# Low-Code Presentation Operations in Java
> Use the Aspose.Slides low-code API in Java to convert and merge presentations, iterate through content, collect shapes, and reduce presentation size.
Source: https://docs.aspose.com/slides/java/low-code-presentation-operations/
Updated: 2026-08-25
## **Overview**
The [com.aspose.slides](https://reference.aspose.com/slides/java/com.aspose.slides/) package provides static helper classes for common presentation operations. These helpers wrap frequently used object-model workflows in focused methods, so you can convert or merge files, process presentation elements, collect shapes, and remove unused content with less code.
Low-code helpers are most useful when the operation applies to an entire file or presentation and the default workflow matches your requirements. Use the full [Aspose.Slides object model](https://reference.aspose.com/slides/java/com.aspose.slides/) when you need fine-grained control over individual slides, masters, layouts, shapes, export settings, or relationships between presentation elements.
The following table summarizes the available helpers:
| Helper | Use it for |
| --- | --- |
| [Convert](https://reference.aspose.com/slides/java/com.aspose.slides/convert/) | Converting a presentation to another format with a direct file-to-file call. |
| [Merger](https://reference.aspose.com/slides/java/com.aspose.slides/merger/) | Combining complete presentation files of the same format. |
| [ForEach](https://reference.aspose.com/slides/java/com.aspose.slides/foreach/) | Running an action for every slide, shape, paragraph, or text portion. |
| [Collect](https://reference.aspose.com/slides/java/com.aspose.slides/collect/) | Retrieving shapes from the entire presentation for repeated processing or analysis. |
| [Compress](https://reference.aspose.com/slides/java/com.aspose.slides/compress/) | Removing unused masters and layouts and reducing embedded font data. |
## **Convert a Presentation**
Use [Convert.autoByExtension](https://reference.aspose.com/slides/java/com.aspose.slides/convert/#autoByExtension-java.lang.String-java.lang.String-) when the output file extension is sufficient to select the export format. The method opens the source presentation, determines the required format from the output path, and writes the result.
```java
import com.aspose.slides.Convert;
Convert.autoByExtension("input.pptx", "output.pdf");
```
The [Convert](https://reference.aspose.com/slides/java/com.aspose.slides/convert/) class also provides dedicated methods for PDF, SVG, JPEG, PNG, and TIFF output. Use the full object model when you need to inspect or modify the presentation before export or configure an export option that is not exposed by the selected helper. See [Convert Presentation](https://docs.aspose.com/slides/java/convert-presentation/) for format-specific workflows and options.
## **Merge Presentations**
Use [Merger.process](https://reference.aspose.com/slides/java/com.aspose.slides/merger/#process-java.lang.String:A-java.lang.String-) to combine complete presentation files with one call. The input presentations must have the same file format.
```java
import com.aspose.slides.Merger;
String[] inputFiles = { "part-1.pptx", "part-2.pptx" };
Merger.process(inputFiles, "merged.pptx");
```
The helper is appropriate when all slides should be appended to one result without selecting or remapping them individually. Use the full object model when you need to merge selected slides, apply a destination master or layout, preserve sections explicitly, or reconcile different slide sizes. See [Merge Presentations](https://docs.aspose.com/slides/java/merge-presentation/) for those scenarios.
## **Iterate Through Presentation Elements**
The [ForEach](https://reference.aspose.com/slides/java/com.aspose.slides/foreach/) class invokes a callback for each requested type of presentation element. It avoids nested collection loops and is convenient for presentation-wide inspection or formatting changes.
The following example uses [ForEach.slide](https://reference.aspose.com/slides/java/com.aspose.slides/foreach/#slide-com.aspose.slides.Presentation-com.aspose.slides.ForEach.ForEachSlideCallback-), [ForEach.shape](https://reference.aspose.com/slides/java/com.aspose.slides/foreach/#shape-com.aspose.slides.Presentation-com.aspose.slides.ForEach.ForEachShapeCallback-), [ForEach.paragraph](https://reference.aspose.com/slides/java/com.aspose.slides/foreach/#paragraph-com.aspose.slides.Presentation-com.aspose.slides.ForEach.ForEachParagraphCallback-), and [ForEach.portion](https://reference.aspose.com/slides/java/com.aspose.slides/foreach/#portion-com.aspose.slides.Presentation-com.aspose.slides.ForEach.ForEachPortionCallback-) to inspect the corresponding elements:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("input.pptx");
try {
ForEach.slide(presentation, (slide, index) -> {
System.out.println(String.format("Slide %d: %d shapes", index, slide.getShapes().size()));
});
ForEach.shape(presentation, (shape, slide, index) -> {
System.out.println(String.format("Shape %d on %s: %s", index, slide.getClass().getSimpleName(), shape.getName()));
});
ForEach.paragraph(presentation, (paragraph, slide, index) -> {
System.out.println(String.format("Paragraph %d on %s: %s", index, slide.getClass().getSimpleName(), paragraph.getText()));
});
ForEach.portion(presentation, (portion, paragraph, slide, index) -> {
System.out.println(String.format("Portion %d on %s: %s", index, slide.getClass().getSimpleName(), portion.getText()));
});
} finally {
presentation.dispose();
}
```
By default, presentation-wide shape and text traversal includes normal, master, and layout slides. Overloads with an `includeNotes` parameter can also process notes slides. Use direct collection loops when traversal order, early exit, filtering before callback invocation, or detailed parent-child control is important.
## **Collect Shapes**
Use [Collect.shapes](https://reference.aspose.com/slides/java/com.aspose.slides/collect/#shapes-com.aspose.slides.Presentation-) when you need a collection of all shapes in a presentation rather than a callback for each shape. This is useful when the same set will be filtered, counted, or processed more than once.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("input.pptx");
try {
Iterable shapes = Collect.shapes(presentation);
for (Shape shape : shapes) {
System.out.println(String.format("%s: %s", shape.getName(), shape.getClass().getSimpleName()));
}
} finally {
presentation.dispose();
}
```
Use [ForEach.shape](https://reference.aspose.com/slides/java/com.aspose.slides/foreach/#shape-com.aspose.slides.Presentation-com.aspose.slides.ForEach.ForEachShapeCallback-) instead when each shape can be handled immediately and you do not need to retain the collected result.
## **Compress Presentation Content**
The [Compress](https://reference.aspose.com/slides/java/com.aspose.slides/compress/) class can remove unused structural elements and reduce embedded font data:
- [Compress.removeUnusedLayoutSlides](https://reference.aspose.com/slides/java/com.aspose.slides/compress/#removeUnusedLayoutSlides-com.aspose.slides.Presentation-) removes layout slides that no normal slide references.
- [Compress.removeUnusedMasterSlides](https://reference.aspose.com/slides/java/com.aspose.slides/compress/#removeUnusedMasterSlides-com.aspose.slides.Presentation-) removes master slides that are no longer used.
- [Compress.compressEmbeddedFonts](https://reference.aspose.com/slides/java/com.aspose.slides/compress/#compressEmbeddedFonts-com.aspose.slides.Presentation-) removes unused characters from embedded fonts.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("input.pptx");
try {
Compress.removeUnusedLayoutSlides(presentation);
Compress.removeUnusedMasterSlides(presentation);
Compress.compressEmbeddedFonts(presentation);
presentation.save("compressed.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
Remove unused layouts before unused masters so a master that becomes unreferenced after layout cleanup can also be removed. Save the optimized presentation to a new file if you may need the original masters, layouts, or complete embedded font data later. For more detail, see [Slide Master](https://docs.aspose.com/slides/java/slide-master/) and [Embedded Font](https://docs.aspose.com/slides/java/embedded-font/).
## **FAQ**
**When should I use the low-code API instead of the full object model?**
Use low-code helpers when a standard operation applies to a complete file or presentation and does not require detailed control over individual elements. Use the full object model when you need to select specific slides, control master and layout relationships, inspect intermediate state, or configure behavior that the helper does not expose.
**Can Merger combine presentations in different file formats?**
No. [Merger.process](https://reference.aspose.com/slides/java/com.aspose.slides/merger/#process-java.lang.String:A-java.lang.String-) requires input presentations in the same format. Convert the input files to a common format first, for example with [Convert.autoByExtension](https://reference.aspose.com/slides/java/com.aspose.slides/convert/#autoByExtension-java.lang.String-java.lang.String-), and then merge the converted files.
**Does ForEach process master, layout, and notes slides?**
[ForEach.slide](https://reference.aspose.com/slides/java/com.aspose.slides/foreach/#slide-com.aspose.slides.Presentation-com.aspose.slides.ForEach.ForEachSlideCallback-) iterates through normal presentation slides. Presentation-wide [ForEach.shape](https://reference.aspose.com/slides/java/com.aspose.slides/foreach/#shape-com.aspose.slides.Presentation-com.aspose.slides.ForEach.ForEachShapeCallback-), [ForEach.paragraph](https://reference.aspose.com/slides/java/com.aspose.slides/foreach/#paragraph-com.aspose.slides.Presentation-com.aspose.slides.ForEach.ForEachParagraphCallback-), and [ForEach.portion](https://reference.aspose.com/slides/java/com.aspose.slides/foreach/#portion-com.aspose.slides.Presentation-com.aspose.slides.ForEach.ForEachPortionCallback-) operations include normal, master, and layout slides by default. Use their overloads with `includeNotes` set to `true` to include notes slides.
**What is the difference between ForEach.shape and Collect.shapes?**
Use [ForEach.shape](https://reference.aspose.com/slides/java/com.aspose.slides/foreach/#shape-com.aspose.slides.Presentation-com.aspose.slides.ForEach.ForEachShapeCallback-) to process each shape immediately through a callback. Use [Collect.shapes](https://reference.aspose.com/slides/java/com.aspose.slides/collect/#shapes-com.aspose.slides.Presentation-) when you need an iterable result that can be retained, filtered, counted, or traversed multiple times.
**Does Compress always make the presentation file smaller?**
Not necessarily. The result depends on whether the presentation contains unused layouts, unused masters, or embedded fonts with unused characters. If none of those are present, the corresponding [Compress](https://reference.aspose.com/slides/java/com.aspose.slides/compress/) operations may not reduce the file size.
**Are changes made by ForEach or Compress saved automatically?**
No. These helpers operate on the loaded [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) object in memory. After changing elements in a [ForEach](https://reference.aspose.com/slides/java/com.aspose.slides/foreach/) callback or running [Compress](https://reference.aspose.com/slides/java/com.aspose.slides/compress/), call [Presentation.save](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#save-java.lang.String-int-) to write the result.
## **Related Articles**
- [Convert Presentation](https://docs.aspose.com/slides/java/convert-presentation/)
- [Merge Presentations](https://docs.aspose.com/slides/java/merge-presentation/)
- [Slide Master](https://docs.aspose.com/slides/java/slide-master/)
- [Manage Text Box](https://docs.aspose.com/slides/java/manage-textbox/)
- [Embedded Font](https://docs.aspose.com/slides/java/embedded-font/)
# Enhance Your Presentations with AutoFit in Java
> Learn how to manage AutoFit settings in Aspose.Slides for Java to optimize text display in your PowerPoint and OpenDocument presentations and improve content readability.
Source: https://docs.aspose.com/slides/java/manage-autofit-settings/
Updated: 2026-08-05
## **Introduction**
By default, when you add a textbox, Microsoft PowerPoint uses the **Resize shape to fix text** setting for the textbox—it automatically resizes the textbox to ensure its text always fits into it.

* When the text in the textbox becomes longer or bigger, PowerPoint automatically enlarges the textbox—increases its height—to allow it to hold more text.
* When the text in the textbox becomes shorter or smaller, PowerPoint automatically reduces the textbox—decreases its height—to clear redundant space.
In PowerPoint, these are the 4 important parameters or options that control the autofit behavior for a textbox:
* **Do not Autofit**
* **Shrink text on overflow**
* **Resize shape to fit text**
* **Wrap text in shape.**

Aspose.Slides for Java provides similar options—some properties under the [TextFrameFormat](https://reference.aspose.com/slides/java/com.aspose.slides/TextFrameFormat) class—that allow you to control the autofit behavior for textboxes in presentations.
## **Resize a Shape to Fit Text**
If you want the text in a box to always fit into that box after changes are made to the text, you have to use the **Resize shape to fix text** option. To specify this setting, set the [AutofitType](https://reference.aspose.com/slides/java/com.aspose.slides/TextFrameFormat#getAutofitType--) property (from the [TextFrameFormat](https://reference.aspose.com/slides/java/com.aspose.slides/TextFrameFormat) class) to `Shape`.

This Java code shows you how to specify that a text must always fit into its box in a PowerPoint presentation:
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation pres = new Presentation();
try {
ISlide slide = pres.getSlides().get_Item(0);
IAutoShape autoShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 30, 30, 350, 100);
Portion portion = new Portion("lorem ipsum...");
portion.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
portion.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
autoShape.getTextFrame().getParagraphs().get_Item(0).getPortions().add(portion);
ITextFrameFormat textFrameFormat = autoShape.getTextFrame().getTextFrameFormat();
textFrameFormat.setAutofitType(TextAutofitType.Shape);
pres.save("Output-presentation.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
If the text becomes longer or bigger, the textbox will be automatically resized (increase in height) to ensure all the text fits into it. If the text becomes shorter, the reverse occurs.
## **Do Not Autofit**
If you want a textbox or shape to retain its dimensions no matter the changes made to the text it contains, you have to use the **Do not Autofit** option. To specify this setting, set the [AutofitType](https://reference.aspose.com/slides/java/com.aspose.slides/TextFrameFormat#getAutofitType--) property (from the [TextFrameFormat](https://reference.aspose.com/slides/java/com.aspose.slides/TextFrameFormat) class) to `None`.

This Java code shows you how to specify that a textbox must always retain its dimensions in a PowerPoint presentation:
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation pres = new Presentation();
try {
ISlide slide = pres.getSlides().get_Item(0);
IAutoShape autoShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 30, 30, 350, 100);
Portion portion = new Portion("lorem ipsum...");
portion.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
portion.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
autoShape.getTextFrame().getParagraphs().get_Item(0).getPortions().add(portion);
ITextFrameFormat textFrameFormat = autoShape.getTextFrame().getTextFrameFormat();
textFrameFormat.setAutofitType(TextAutofitType.None);
pres.save("Output-presentation.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
When the text becomes too long for its box, it spills out.
## **Shrink Text on Overflow**
If a text becomes too long for its box, through the **Shrink text on overflow** option, you can specify that the text's size and spacing must be reduced to make it fit into its box. To specify this setting, set the [AutofitType](https://reference.aspose.com/slides/java/com.aspose.slides/TextFrameFormat#getAutofitType--) property (from the [TextFrameFormat](https://reference.aspose.com/slides/java/com.aspose.slides/TextFrameFormat) class) to `Normal`.

This Java code shows you how to specify that a text must be shrunk on overflow in a PowerPoint presentation:
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation pres = new Presentation();
try {
ISlide slide = pres.getSlides().get_Item(0);
IAutoShape autoShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 30, 30, 350, 100);
Portion portion = new Portion("lorem ipsum...");
portion.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
portion.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
autoShape.getTextFrame().getParagraphs().get_Item(0).getPortions().add(portion);
ITextFrameFormat textFrameFormat = autoShape.getTextFrame().getTextFrameFormat();
textFrameFormat.setAutofitType(TextAutofitType.Normal);
pres.save("Output-presentation.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
When the **Shrink text on overflow** option is used, the setting gets applied only when the text becomes too long for its box.
## **Wrap Text**
If you want the text in a shape to get wrapped inside that shape when the text goes beyond the shape's border (width only), you have to use the **Wrap text in shape** parameter. To specify this setting, you have to set the [WrapText](https://reference.aspose.com/slides/java/com.aspose.slides/TextFrameFormat#getWrapText--) property (from the [TextFrameFormat](https://reference.aspose.com/slides/java/com.aspose.slides/TextFrameFormat) class) to `true`.
This Java code shows you how to use the Wrap Text setting in a PowerPoint presentation:
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation pres = new Presentation();
try {
ISlide slide = pres.getSlides().get_Item(0);
IAutoShape autoShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 30, 30, 350, 100);
Portion portion = new Portion("lorem ipsum...");
portion.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
portion.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
autoShape.getTextFrame().getParagraphs().get_Item(0).getPortions().add(portion);
ITextFrameFormat textFrameFormat = autoShape.getTextFrame().getTextFrameFormat();
textFrameFormat.setWrapText(NullableBool.True);
pres.save("Output-presentation.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
If you set the `WrapText` property to `False` for a shape, when the text inside the shape becomes longer than the shape's width, the text gets extended beyond the shape's borders along a single line.
## **FAQ**
### Do the text frame’s internal margins affect AutoFit?
Yes. Padding (internal margins) reduces the usable area for text, so AutoFit will kick in earlier—shrinking the font or resizing the shape sooner. Check and adjust margins before tuning AutoFit.
### How does AutoFit interact with manual and soft line breaks?
Forced breaks remain in place, and AutoFit adapts font size and spacing around them. Removing unnecessary breaks often reduces how aggressively AutoFit needs to shrink the text.
### Does changing the theme font or triggering font substitution affect AutoFit results?
Yes. Substituting to a font with different glyph metrics changes text width/height, which can alter final font size and line wrapping. After any font change or substitution, re-check the slides.
# Manage Presentation BLOBs in Java for Efficient Memory Use
> Manage BLOB data in Aspose.Slides for Java to streamline PowerPoint and OpenDocument file operations for efficient presentation handling.
Source: https://docs.aspose.com/slides/java/manage-blob/
Updated: 2026-08-05
## **Overview**
Aspose.Slides provides BLOB-based handling for large binary data in presentations to help reduce memory consumption when working with large images, audio, video, and presentation files.
This article shows how to use BLOB-based processing to add large media to a presentation, export large media from a presentation, and load large presentations more efficiently. It also explains how temporary files can be used during processing and how to change the folder used to store them.
## **About BLOB**
**BLOB** (**Binary Large Object**) is usually a large item (photo, presentation, document, or media) saved in binary formats.
Aspose.Slides for Java allows you to use BLOBs for objects in a way that reduces memory consumption when large files are involved.
To circumvent certain limitations when interacting with streams, Aspose.Slides may copy the stream's content. Loading a large presentation through its stream will result in the copying of the presentation's contents and cause slow loading. Therefore, when you intend to load a large presentation, we strongly recommend that you use the presentation file path and not its stream.
## **Use BLOB to Reduce Memory Consumption**
### **Add a Large File through BLOB to a Presentation**
[Aspose.Slides](https://docs.aspose.com/slides/java/) for Java allows you to add large files (in this case, a large video file) through a process involving BLOBs to reduce memory consumption.
This Java shows you how to add a large video file through the BLOB process to a presentation:
```java
import com.aspose.slides.*;
import java.io.FileInputStream;
import java.io.IOException;
String pathToVeryLargeVideo = "veryLargeVideo.avi";
// Creates a new presentation to which the video will be added
Presentation pres = new Presentation();
try {
FileInputStream fileStream = new FileInputStream(pathToVeryLargeVideo);
try {
// Let's add the video to the presentation - we chose the KeepLocked behavior because we do
//not intend to access the "veryLargeVideo.avi" file.
IVideo video = pres.getVideos().addVideo(fileStream, LoadingStreamBehavior.KeepLocked);
pres.getSlides().get_Item(0).getShapes().addVideoFrame(0, 0, 480, 270, video);
// Saves the presentation. While a large presentation gets outputted, the memory consumption
// stays low through the pres object's lifecycle
pres.save("presentationWithLargeVideo.pptx", SaveFormat.Pptx);
} finally {
if (fileStream != null) fileStream.close();
}
} catch(IOException e) {
} finally {
if (pres != null) pres.dispose();
}
```
### **Export a Large File through BLOB from Presentation**
Aspose.Slides for Java allows you to export large files (in this case, an audio or video file) through a process involving BLOBs from presentations. For example, you may need to extract a large media file from a presentation but do not want the file to be loaded into your computer's memory. By exporting the file through the BLOB process, you get to keep memory consumption low.
This code in Java demonstrates the described operation:
```java
import com.aspose.slides.*;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
String hugePresentationWithAudiosAndVideosFile = "LargeVideoFileTest.pptx";
LoadOptions loadOptions = new LoadOptions();
// Locks the source file and does NOT load it into memory
loadOptions.getBlobManagementOptions().setPresentationLockingBehavior(PresentationLockingBehavior.KeepLocked);
// create the Presentation's instance, lock the "hugePresentationWithAudiosAndVideos.pptx" file.
Presentation pres = new Presentation(hugePresentationWithAudiosAndVideosFile, loadOptions);
try {
// Let's save each video to a file. To prevent high memory usage, we need a buffer that will be used
// to transfer the data from the presentation's video stream to a stream for a newly created video file.
byte[] buffer = new byte[8 * 1024];
// Iterates through the videos
for (int index = 0; index < pres.getVideos().size(); index++) {
IVideo video = pres.getVideos().get_Item(index);
// Opens the presentation video stream. Please, note that we intentionally avoided accessing properties
// like video.BinaryData - because this property returns a byte array containing a full video, which then
// causes bytes to be loaded into memory. We use video.GetStream, which will return Stream - and does NOT
// require us to load the whole video into the memory.
InputStream presVideoStream = video.getStream();
try {
OutputStream outputFileStream = new FileOutputStream("video" + index + ".avi");
try {
int bytesRead;
while ((bytesRead = presVideoStream.read(buffer, 0, buffer.length)) > 0) {
outputFileStream.write(buffer, 0, bytesRead);
}
} finally {
outputFileStream.close();
}
} finally {
presVideoStream.close();
}
// Memory consumption will remain low regardless of the size of the video or presentation.
}
// If necessary, you can apply the same steps for audio files.
} catch (IOException e) {
} finally {
pres.dispose();
}
```
### **Add an Image as BLOB to a Presentation**
With methods from the [**IImageCollection**](https://reference.aspose.com/slides/java/com.aspose.slides/IImageCollection) interface and [**ImageCollection** ](https://reference.aspose.com/slides/java/com.aspose.slides/ImageCollection) class, you can add a large image as a stream to get it treated as a BLOB.
This Java code shows you how to add a large image through the BLOB process:
```java
import com.aspose.slides.*;
import java.io.FileInputStream;
import java.io.IOException;
String pathToLargeImage = "large_image.jpg";
// creates a new presentation to which the image will be added.
Presentation pres = new Presentation();
try {
FileInputStream fileStream = new FileInputStream(pathToLargeImage);
try {
// Let's add the image to the presentation - we choose KeepLocked behavior because we do
// NOT intend to access the "large_image.jpg" file.
IPPImage img = pres.getImages().addImage(fileStream, LoadingStreamBehavior.KeepLocked);
pres.getSlides().get_Item(0).getShapes().addPictureFrame(ShapeType.Rectangle, 0, 0, 300, 200, img);
// Saves the presentation. While a large presentation gets outputted, the memory consumption
// stays low through the pres object's lifecycle
pres.save("presentationWithLargeImage.pptx", SaveFormat.Pptx);
} finally {
if (fileStream != null) fileStream.close();
}
} catch(IOException e) {
} finally {
if (pres != null) pres.dispose();
}
```
## **Memory and Large Presentations**
Typically, to load a large presentation, computers require a lot of temporary memory. All the presentation's content is loaded into the memory and the file (from which the presentation was loaded) stops being used.
Consider a large PowerPoint presentation (large.pptx) that contains a 1.5 GB video file. The standard method for loading the presentation is described in this Java code:
```java
import com.aspose.slides.*;
Presentation pres = new Presentation("large.pptx");
try {
pres.save("large.pdf", SaveFormat.Pdf);
} finally {
if (pres != null) pres.dispose();
}
```
But this method consumes around 1.6 GB of temporary memory.
### **Load a Large Presentation as BLOB**
Through the process involving a BLOB, you can load up a large presentation while using little memory. This Java code describes the implementation where the BLOB process is used to load up a large presentation file (large.pptx):
```java
import com.aspose.slides.*;
LoadOptions loadOptions = new LoadOptions();
loadOptions.getBlobManagementOptions().setPresentationLockingBehavior(PresentationLockingBehavior.KeepLocked);
loadOptions.getBlobManagementOptions().setTemporaryFilesAllowed(true);
Presentation pres = new Presentation("large.pptx", loadOptions);
try {
pres.save("large.pdf", SaveFormat.Pdf);
} finally {
if (pres != null) pres.dispose();
}
```
### **Change the Folder for Temporary Files**
When the BLOB process is used, your computer creates temporary files in the default folder for temporary files. If you want the temporary files to be kept in a different folder, you can change the settings for storage using `TempFilesRootPath`:
```java
import com.aspose.slides.*;
LoadOptions loadOptions = new LoadOptions();
loadOptions.getBlobManagementOptions().setPresentationLockingBehavior(PresentationLockingBehavior.KeepLocked);
loadOptions.getBlobManagementOptions().setTemporaryFilesAllowed(true);
loadOptions.getBlobManagementOptions().setTempFilesRootPath("temp");
```
When you use `TempFilesRootPath`, Aspose.Slides does not automatically create a folder to store temporary files. You have to create the folder manually.
### **Dispose Presentation Objects to Release Memory**
When processing large presentations, ensure that the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) instance is properly disposed so that the memory it occupied is released. Call `dispose()` after you have finished using the presentation to free unmanaged resources.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("large.pptx");
// ...process the presentation...
presentation.save("large.pdf", SaveFormat.Pdf);
// Explicitly release resources.
presentation.dispose();
```
## **FAQ**
### What data in an Aspose.Slides presentation is treated as BLOB and controlled by BLOB options?
Large binary objects such as images, audio, and video are treated as BLOB. The whole presentation file also involves BLOB handling when it’s loaded or saved. These objects are governed by BLOB policies that let you manage memory usage and spill to temporary files when needed.
### Where do I configure BLOB handling rules during presentation loading?
Use [LoadOptions](https://reference.aspose.com/slides/java/com.aspose.slides/loadoptions/) with [BlobManagementOptions](https://reference.aspose.com/slides/java/com.aspose.slides/blobmanagementoptions/). There you set the in-memory limit for BLOB, allow or disallow temporary files, choose the root path for temp files, and select source locking behavior.
### Do BLOB settings affect performance, and how do I balance speed vs memory?
Yes. Keeping BLOB in memory maximizes speed but increases RAM consumption; lowering the memory limit shifts more work to temporary files, reducing RAM at the cost of additional I/O. Use the [setMaxBlobsBytesInMemory](https://reference.aspose.com/slides/java/com.aspose.slides/blobmanagementoptions/#setMaxBlobsBytesInMemory-long-) method to reach the right balance for your workload and environment.
### Do BLOB options help when opening extremely large presentations (e.g., gigabytes)?
Yes. [BlobManagementOptions](https://reference.aspose.com/slides/java/com.aspose.slides/blobmanagementoptions/) are designed for such scenarios: enabling temporary files and using source locking can significantly reduce peak RAM use and stabilize processing for very large decks.
### Can I use BLOB policies when loading from streams instead of disk files?
Yes. The same rules apply to streams: the presentation instance can own and lock the input stream (depending on the chosen locking mode), and temporary files are used when allowed, keeping memory usage predictable during processing.
# Manage Table Cells in Presentations Using Java
> Manage PowerPoint table cells in Java: identify merged cells, remove borders, split cells, and set background colors and images with Aspose.Slides for Java.
Source: https://docs.aspose.com/slides/java/manage-cells/
Updated: 2026-11-17
## **Overview**
Aspose.Slides allows you to access and modify table cells in PowerPoint presentations. This article explains how to identify merged table cells, remove cell borders, work with cell numbering after merging or splitting cells, change a cell’s background color, and add an image inside a table cell. The examples show how to create or open a presentation, get a table from a slide, update cell formatting through cell properties, and save the modified presentation as a PPTX file.
Aspose.Slides uses zero-based indices to access table cells in the order `(column, row)`.
## **Identify a Merged Table Cell**
The example opens an existing presentation and accesses the first shape on the first slide as a table. It assumes that the slide and shape exist and that the shape is a table. It then iterates through all rows and columns and uses [isMergedCell](https://reference.aspose.com/slides/java/com.aspose.slides/icell/#isMergedCell--) to identify cells in merged regions. For each match, it prints the cell coordinates in `row;column` order, [getRowSpan](https://reference.aspose.com/slides/java/com.aspose.slides/icell/#getRowSpan--), [getColSpan](https://reference.aspose.com/slides/java/com.aspose.slides/icell/#getColSpan--), and the region's starting coordinates, [getFirstRowIndex](https://reference.aspose.com/slides/java/com.aspose.slides/icell/#getFirstRowIndex--) and [getFirstColumnIndex](https://reference.aspose.com/slides/java/com.aspose.slides/icell/#getFirstColumnIndex--).
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("presentation_with_table.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
ITable table = (ITable) slide.getShapes().get_Item(0);
int rowCount = table.getRows().size();
for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
{
int columnCount = table.getColumns().size();
for (int columnIndex = 0; columnIndex < columnCount; columnIndex++)
{
ICell cell = table.get_Item(columnIndex, rowIndex);
if (cell.isMergedCell())
{
System.out.printf("Cell %d;%d belongs to a merged region with RowSpan=%d and ColSpan=%d starting at %d;%d.%n", rowIndex, columnIndex, cell.getRowSpan(), cell.getColSpan(), cell.getFirstRowIndex(), cell.getFirstColumnIndex());
}
}
}
} finally {
presentation.dispose();
}
```
## **Remove Table Cell Borders**
Create a [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation/) and add a table to its first slide with [addTable](https://reference.aspose.com/slides/java/com.aspose.slides/ishapecollection/#addTable-float-float-double---double---). Column widths, row heights, and the table position are specified in points. The example sets all four cell borders to [FillType.NoFill](https://reference.aspose.com/slides/java/com.aspose.slides/filltype/), making them invisible.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
double[] columnWidths = { 50, 50, 50, 50 };
double[] rowHeights = { 50, 30, 30, 30, 30 };
ITable table = slide.getShapes().addTable(100, 50, columnWidths, rowHeights);
for (IRow row : table.getRows())
for (ICell cell : row)
{
cell.getCellFormat().getBorderTop().getFillFormat().setFillType(FillType.NoFill);
cell.getCellFormat().getBorderBottom().getFillFormat().setFillType(FillType.NoFill);
cell.getCellFormat().getBorderLeft().getFillFormat().setFillType(FillType.NoFill);
cell.getCellFormat().getBorderRight().getFillFormat().setFillType(FillType.NoFill);
}
presentation.save("table.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Add Diagonal Cell Borders**
Use [getBorderDiagonalDown](https://reference.aspose.com/slides/java/com.aspose.slides/icellformat/#getBorderDiagonalDown--) to draw a line from the top-left corner to the bottom-right, and [getBorderDiagonalUp](https://reference.aspose.com/slides/java/com.aspose.slides/icellformat/#getBorderDiagonalUp--) to draw a line from the bottom-left corner to the top-right. A diagonal can mark a corner header; both diagonals can form an X to mark a cell as not applicable.
Each diagonal is an [ILineFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ilineformat/). In its [getFillFormat](https://reference.aspose.com/slides/java/com.aspose.slides/ilineformat/#getFillFormat--), use [setFillType](https://reference.aspose.com/slides/java/com.aspose.slides/ifillformat/#setFillType-byte-) to select [FillType.Solid](https://reference.aspose.com/slides/java/com.aspose.slides/filltype/) and choose a color through [getSolidFillColor](https://reference.aspose.com/slides/java/com.aspose.slides/ifillformat/#getSolidFillColor--). Set the line's width in points with [setWidth](https://reference.aspose.com/slides/java/com.aspose.slides/ilineformat/#setWidth-double-).
The example creates three cells in one row: a red downward diagonal, a blue upward diagonal, and both diagonals. It leaves the top, bottom, left, and right cell borders unchanged.
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
double[] columnWidths = { 210, 210, 210 };
double[] rowHeights = { 160 };
ITable table = slide.getShapes().addTable(45, 130, columnWidths, rowHeights);
ILineFormat downwardBorder = table.get_Item(0, 0).getCellFormat().getBorderDiagonalDown();
downwardBorder.getFillFormat().setFillType(FillType.Solid);
downwardBorder.getFillFormat().getSolidFillColor().setColor(Color.RED);
downwardBorder.setWidth(3);
ILineFormat upwardBorder = table.get_Item(1, 0).getCellFormat().getBorderDiagonalUp();
upwardBorder.getFillFormat().setFillType(FillType.Solid);
upwardBorder.getFillFormat().getSolidFillColor().setColor(Color.BLUE);
upwardBorder.setWidth(5);
ILineFormat crossDownwardBorder = table.get_Item(2, 0).getCellFormat().getBorderDiagonalDown();
crossDownwardBorder.getFillFormat().setFillType(FillType.Solid);
crossDownwardBorder.getFillFormat().getSolidFillColor().setColor(Color.RED);
crossDownwardBorder.setWidth(3);
ILineFormat crossUpwardBorder = table.get_Item(2, 0).getCellFormat().getBorderDiagonalUp();
crossUpwardBorder.getFillFormat().setFillType(FillType.Solid);
crossUpwardBorder.getFillFormat().getSolidFillColor().setColor(Color.BLUE);
crossUpwardBorder.setWidth(5);
presentation.save("diagonal_cell_borders.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
A diagonal is a formatting property, not a cell split. Each cell retains a single text frame, accessed through [getTextFrame](https://reference.aspose.com/slides/java/com.aspose.slides/icell/#getTextFrame--); the regions on either side of a diagonal cannot be edited independently.
The saved table, rendered in Microsoft PowerPoint:

*Left to right: downward diagonal (red, 3 pt), upward diagonal (blue, 5 pt), and both diagonals.*
## **Merge Table Cells**
Use [mergeCells](https://reference.aspose.com/slides/java/com.aspose.slides/itable/#mergeCells-com.aspose.slides.ICell-com.aspose.slides.ICell-boolean-) to combine a rectangular range of table cells into one cell. Specify the cells at the top-left and bottom-right corners of the range. The final argument controls whether the merge may include cells outside the specified range; `false` keeps the merge within that range.
The example creates a 4-by-4 table with 70-point columns and rows, then merges the four central cells from `(1, 1)` through `(2, 2)`. The resulting cell spans two columns and two rows, while the table's underlying grid retains four columns and four rows. To access the merged cell's content or formatting, use its top-left position: `table.get_Item(1, 1)` in this example. The other positions in the merged range remain part of the table grid, so the indices of cells outside the range do not change.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
double[] columnWidths = { 70, 70, 70, 70 };
double[] rowHeights = { 70, 70, 70, 70 };
ITable table = slide.getShapes().addTable(100, 50, columnWidths, rowHeights);
table.mergeCells(table.get_Item(1, 1), table.get_Item(2, 2), false);
presentation.save("merged_cells.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Split Table Cells**
Merging cells in the previous example preserves the table's grid. Splitting a cell can introduce a new grid column and change the column indices of cells to its right. Aspose.Slides follows PowerPoint's table grid model.
This example creates a 4-by-4 table with 70-point columns and rows and calls [splitByWidth](https://reference.aspose.com/slides/java/com.aspose.slides/icell/#splitByWidth-double-) on cell `(1, 1)`. Half of the cell's 70-point width is passed to create two equal-width cells.
After this split, the two halves are accessed as `table.get_Item(1, 1)` and `table.get_Item(2, 1)`. The table grid now has five columns: cells originally in columns 2 and 3 move to columns 3 and 4, respectively. Row indices remain unchanged. Use these updated column indices when accessing cells after the split.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
double[] columnWidths = { 70, 70, 70, 70 };
double[] rowHeights = { 70, 70, 70, 70 };
ITable table = slide.getShapes().addTable(100, 50, columnWidths, rowHeights);
table.get_Item(1, 1).splitByWidth(table.get_Item(1, 1).getWidth() / 2);
presentation.save("split_cells.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
[](https://docs.aspose.com/slides/java/manage-cells/visual-manage-cells-04c40789d81c.svg)
*The width split affects cell (1, 1), using zero-based (column, row) indices. Other rows keep a cell spanning both new column positions.*
### **Split Merged Cells by Row or Column Span**
To prepare merged template cells for data population, use [splitByRowSpan](https://reference.aspose.com/slides/java/com.aspose.slides/icell/#splitByRowSpan-int-) to split along an existing row boundary, or [splitByColSpan](https://reference.aspose.com/slides/java/com.aspose.slides/icell/#splitByColSpan-int-) to split along a column boundary.
The `index` argument counts rows in the upper part or columns in the left part of the split; it is relative to the merged region:
- Row split: `0 < index <` [getRowSpan](https://reference.aspose.com/slides/java/com.aspose.slides/icell/#getRowSpan--).
- Column split: `0 < index <` [getColSpan](https://reference.aspose.com/slides/java/com.aspose.slides/icell/#getColSpan--).
The example expects a presentation to have a table as the first shape on the first slide, with `(1, 2)` and `(1, 3)` merged vertically. Starting from the lower position, it uses [getFirstColumnIndex](https://reference.aspose.com/slides/java/com.aspose.slides/icell/#getFirstColumnIndex--) and [getFirstRowIndex](https://reference.aspose.com/slides/java/com.aspose.slides/icell/#getFirstRowIndex--) to locate the origin and checks both spans. `splitByRowSpan(1)` then separates rows 2 and 3 for product names. For a horizontal two-column merge, use `splitByColSpan(1)` instead.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("table_template.pptx");
try {
ISlide slide = presentation.getSlides().get_Item(0);
ITable table = (ITable) slide.getShapes().get_Item(0);
ICell selectedCell = table.get_Item(1, 3);
int firstColumnIndex = selectedCell.getFirstColumnIndex();
int firstRowIndex = selectedCell.getFirstRowIndex();
ICell mergedCell = table.get_Item(firstColumnIndex, firstRowIndex);
if (mergedCell.isMergedCell() && mergedCell.getRowSpan() == 2 && mergedCell.getColSpan() == 1)
{
mergedCell.splitByRowSpan(1);
// Retrieve the resulting cells from the table after splitting.
ICell upperCell = table.get_Item(firstColumnIndex, firstRowIndex);
ICell lowerCell = table.get_Item(firstColumnIndex, firstRowIndex + 1);
System.out.println("Upper cell merged: " + upperCell.isMergedCell());
System.out.println("Lower cell merged: " + lowerCell.isMergedCell());
upperCell.getTextFrame().setText("Product A");
lowerCell.getTextFrame().setText("Product B");
presentation.save("split_template.pptx", SaveFormat.Pptx);
}
else
{
System.out.println("Select a merged region spanning exactly two rows and one column.");
}
} finally {
presentation.dispose();
}
```
The table grid and surrounding cell indices stay unchanged. Retrieve the resulting cells by their coordinates; here, both have spans of 1 and [isMergedCell](https://reference.aspose.com/slides/java/com.aspose.slides/icell/#isMergedCell--) prints `false`. Larger regions can remain partly merged after one split.
The original text and its formatting remain in the upper (or left) cell; the new cell is empty but inherits cell formatting such as fill, borders, and margins. Populate the cells after splitting and set any required text formatting explicitly.
The saved presentation contains separate "Product A" and "Product B" cells with the template's cell formatting retained. See the [Cell API Reference](https://reference.aspose.com/slides/java/com.aspose.slides/cell/) for details.
### **Split a Cell at a Specific Height**
[splitByHeight](https://reference.aspose.com/slides/java/com.aspose.slides/icell/#splitByHeight-double-) takes the height of the upper part in points. [splitByRowSpan](https://reference.aspose.com/slides/java/com.aspose.slides/icell/#splitByRowSpan-int-) takes the number of existing grid rows in the upper part. To center a 40-point cell in the right column, subtract 40 from the cell’s actual height and divide the remaining space equally above and below it.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
double[] columnWidths = { 160, 160 };
double[] rowHeights = { 140 };
ITable table = slide.getShapes().addTable(50, 50, columnWidths, rowHeights);
table.get_Item(0, 0).getTextFrame().setText("Left");
double height = table.get_Item(1, 0).getHeight();
double margin = (height - 40) / 2;
table.get_Item(1, 0).splitByHeight(margin);
table.get_Item(1, 1).splitByHeight(40);
table.get_Item(1, 1).getTextFrame().setText("Middle");
presentation.save("split_by_height.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
The first split adds a grid row and leaves the lower 90 points in cell `(1, 1)`. The second split divides that cell into a 40-point middle cell and a 50-point bottom cell. The right column now has three cells with heights of 50, 40, and 50 points from top to bottom. The left cell spans all three rows and retains its original height of 140 points.

## **Change the Table Cell Background Color**
This example creates a table with 150-point columns and 50-point rows. It uses [setFillType](https://reference.aspose.com/slides/java/com.aspose.slides/ifillformat/#setFillType-byte-) to select a solid fill and sets the color returned by [getSolidFillColor](https://reference.aspose.com/slides/java/com.aspose.slides/ifillformat/#getSolidFillColor--) to red for cell `(2, 3)`, in the third column and fourth row.
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
double[] columnWidths = { 150, 150, 150, 150 };
double[] rowHeights = { 50, 50, 50, 50, 50 };
ITable table = slide.getShapes().addTable(50, 50, columnWidths, rowHeights);
ICell cell = table.get_Item(2, 3);
cell.getCellFormat().getFillFormat().setFillType(FillType.Solid);
cell.getCellFormat().getFillFormat().getSolidFillColor().setColor(Color.RED);
presentation.save("cell_background_color.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Add an Image Inside a Table Cell**
Place the input image in the working directory before running this example. It loads the image with [Images.fromFile](https://reference.aspose.com/slides/java/com.aspose.slides/images/#fromFile-java.lang.String-) and adds it to the presentation's image collection with [addImage](https://reference.aspose.com/slides/java/com.aspose.slides/iimagecollection/#addImage-com.aspose.slides.IImage-). It then assigns the image to the picture fill of cell `(0, 0)`, the first cell in the table.
[PictureFillMode.Stretch](https://reference.aspose.com/slides/java/com.aspose.slides/picturefillmode/) stretches the image to fill the cell, which may change its aspect ratio. Column widths and row heights are in points. The loaded image is disposed in a `finally` block after it is added to the presentation.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
double[] columnWidths = { 150, 150, 150, 150 };
double[] rowHeights = { 100, 100, 100, 100, 90 };
ITable table = slide.getShapes().addTable(50, 50, columnWidths, rowHeights);
IPPImage ppImage;
IImage image = Images.fromFile("aspose_logo.jpg");
try {
ppImage = presentation.getImages().addImage(image);
} finally {
image.dispose();
}
table.get_Item(0, 0).getCellFormat().getFillFormat().setFillType(FillType.Picture);
table.get_Item(0, 0).getCellFormat().getFillFormat().getPictureFillFormat().setPictureFillMode(PictureFillMode.Stretch);
table.get_Item(0, 0).getCellFormat().getFillFormat().getPictureFillFormat().getPicture().setImage(ppImage);
presentation.save("table_cell_with_image.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **FAQ**
**Can I set different line thicknesses and styles for different sides of a single cell?**
Yes. The [top](https://reference.aspose.com/slides/java/com.aspose.slides/cellformat/#getBorderTop--)/[bottom](https://reference.aspose.com/slides/java/com.aspose.slides/cellformat/#getBorderBottom--)/[left](https://reference.aspose.com/slides/java/com.aspose.slides/cellformat/#getBorderLeft--)/[right](https://reference.aspose.com/slides/java/com.aspose.slides/cellformat/#getBorderRight--) borders have separate properties, so the thickness and style of each side can differ.
**What happens to the image if I change the column/row size after setting a picture as the cell’s background?**
The behavior depends on the [fill mode](https://reference.aspose.com/slides/java/com.aspose.slides/picturefillmode/) (stretch/tile). With stretching, the image adjusts to the new cell; with tiling, the tiles are recalculated.
**Can I assign a hyperlink to all the content of a cell?**
[Hyperlinks](https://docs.aspose.com/slides/java/manage-hyperlinks/) are set at the text (portion) level inside the cell’s text frame or at the level of the entire table/shape. In practice, you assign the link to a portion or to all the text in the cell.
**Can I set different fonts within a single cell?**
Yes. A cell’s text frame supports [portions](https://reference.aspose.com/slides/java/com.aspose.slides/portion/) (runs) with independent formatting—font family, style, size, and color.
## Related articles
- [Create and Customize PowerPoint Tables in Java](https://docs.aspose.com/slides/java/powerpoint-table/)
- [Manage Presentation Tables in Java](https://docs.aspose.com/slides/java/manage-table/)
- [Table](https://docs.aspose.com/slides/java/examples/elements/table/)
# Manage Fonts in Presentations Using Java
> Control fonts in Java with Aspose.Slides: embed, substitute, and load custom fonts to keep PPT, PPTX and ODP presentations clear, brand-safe, and consistent.
Source: https://docs.aspose.com/slides/java/manage-fonts/
Updated: 2026-08-13
## **Overview**
Aspose.Slides allows you to manage font properties in presentation text directly from your code. You can access text in slides through shapes, text frames, paragraphs, and portions, and then apply formatting to the selected text.
This article explains how to configure font-related properties for existing text in a presentation, including font family, bold and italic styles, paragraph alignment, and font color. It also shows how to create a text box, add text to it, and set font properties such as font family, bold, italic, underline, font size, and color before saving the result as a PPTX file.
## **Manage Font Related Properties**
Presentations usually contain both text and images. The text can be formatted in a various way, either to highlight specific sections and words or to conform with corporate styles. Text formatting helps users vary the look and feel of the presentation content. This article shows how to use Aspose.Slides for Java to configure the font properties of paragraphs of text on slides.
To manage font properties of a paragraph using Aspose.Slides for Java:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation) class.
1. Obtain a slide's reference by using its index.
1. Access the [Placeholder](https://reference.aspose.com/slides/java/com.aspose.slides/placeholder/) shapes in the slide and typecast them to [AutoShape](https://reference.aspose.com/slides/java/com.aspose.slides/autoshape/).
1. Get the [Paragraph](https://reference.aspose.com/slides/java/com.aspose.slides/paragraph/) from the [TextFrame](https://reference.aspose.com/slides/java/com.aspose.slides/textframe/) exposed by [AutoShape](https://reference.aspose.com/slides/java/com.aspose.slides/autoshape/).
1. Justify the paragraph.
1. Access a [Paragraph](https://reference.aspose.com/slides/java/com.aspose.slides/paragraph/)'s text [Portion](https://reference.aspose.com/slides/java/com.aspose.slides/portion/).
1. Define the font using [FontData](https://reference.aspose.com/slides/java/com.aspose.slides/fontdata/) and set the **Font** of the text [Portion](https://reference.aspose.com/slides/java/com.aspose.slides/portion/) accordingly.
1. Set the font to bold.
1. Set the font to italic.
1. Set the font color using the [FillFormat](https://reference.aspose.com/slides/java/com.aspose.slides/fillformat/) exposed by the [Portion](https://reference.aspose.com/slides/java/com.aspose.slides/portion/) object.
1. Save the modified presentation to a PPTX file.
The implementation of the above steps is given below. It takes an unadorned presentation and formats the fonts on one of the slides. The screenshots that follow show the input file and how the code snippets change it. The code changes the font, the color, and the font style.
||
| :- |
|**Figure: The text in the input file**|
||
| :- |
|**Figure: The same text with updated formatting**|
```java
import com.aspose.slides.*;
import java.awt.Color;
// Instantiate a Presentation object that represents a PPTX file
Presentation pres = new Presentation("FontProperties.pptx");
try {
// Accessing a slide using its slide position
ISlide slide = pres.getSlides().get_Item(0);
// Accessing the first and second placeholder in the slide and typecasting it as AutoShape
ITextFrame tf1 = ((IAutoShape) slide.getShapes().get_Item(0)).getTextFrame();
ITextFrame tf2 = ((IAutoShape) slide.getShapes().get_Item(1)).getTextFrame();
// Accessing the first Paragraph
IParagraph para1 = tf1.getParagraphs().get_Item(0);
IParagraph para2 = tf2.getParagraphs().get_Item(0);
// Justify the paragraph
para2.getParagraphFormat().setAlignment(TextAlignment.JustifyLow);
// Accessing the first portion
IPortion port1 = para1.getPortions().get_Item(0);
IPortion port2 = para2.getPortions().get_Item(0);
// Define new fonts
FontData fd1 = new FontData("Elephant");
FontData fd2 = new FontData("Castellar");
// Assign new fonts to portion
port1.getPortionFormat().setLatinFont(fd1);
port2.getPortionFormat().setLatinFont(fd2);
// Set font to Bold
port1.getPortionFormat().setFontBold(NullableBool.True);
port2.getPortionFormat().setFontBold(NullableBool.True);
// Set font to Italic
port1.getPortionFormat().setFontItalic(NullableBool.True);
port2.getPortionFormat().setFontItalic(NullableBool.True);
// Set font color
port1.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
port1.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.BLUE);
port2.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
port2.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.GREEN);
// Save the PPTX to disk
pres.save("WelcomeFont.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
## **Set Text Font Properties**
As mentioned in **Managing Font Related Properties**, a [Portion](https://reference.aspose.com/slides/java/com.aspose.slides/portion/) is used to hold text with similar formatting style in a paragraph. This article shows how to use Aspose.Slides for Java to create a textbox with some text and then define a particular font, and various other properties of the font family category.
To create a textbox and set font properties of the text in it:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/java/com.aspose.slides/presentation) class.
1. Obtain the reference of a slide by using its index.
1. Add an [AutoShape](https://reference.aspose.com/slides/java/com.aspose.slides/autoshape/) of the type **Rectangle** to the slide.
1. Remove the fill style associated with the [AutoShape](https://reference.aspose.com/slides/java/com.aspose.slides/autoshape/).
1. Access the of the [AutoShape](https://reference.aspose.com/slides/java/com.aspose.slides/autoshape/)'s [TextFrame](https://reference.aspose.com/slides/java/com.aspose.slides/textframe/).
1. Add some text to the [TextFrame](https://reference.aspose.com/slides/java/com.aspose.slides/textframe/).
1. Access the [Portion](https://reference.aspose.com/slides/java/com.aspose.slides/portion/) object associated with the [TextFrame](https://reference.aspose.com/slides/java/com.aspose.slides/textframe/).
1. Define the font to be used for the [Portion](https://reference.aspose.com/slides/java/com.aspose.slides/portion/).
1. Set other font properties like bold, italic, underline, color and height using the relevant properties as exposed by the [Portion](https://reference.aspose.com/slides/java/com.aspose.slides/portion/) object.
1. Write the modified presentation as a PPTX file.
The implementation of the above steps is given below.
||
| :- |
|**Figure: Text with some font properties set by Aspose.Slides for Java**|
```java
import com.aspose.slides.*;
import java.awt.Color;
// Instantiate a Presentation object that represents a PPTX file
Presentation pres = new Presentation();
try {
// Get first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add an AutoShape of Rectangle type
IAutoShape ashp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 50, 50, 200, 50);
// Remove any fill style associated with the AutoShape
ashp.getFillFormat().setFillType(FillType.NoFill);
// Access the TextFrame associated with the AutoShape
ITextFrame tf = ashp.getTextFrame();
tf.setText("Aspose TextBox");
// Access the Portion associated with the TextFrame
IPortion port = tf.getParagraphs().get_Item(0).getPortions().get_Item(0);
// Set the Font for the Portion
port.getPortionFormat().setLatinFont(new FontData("Times New Roman"));
// Set Bold property of the Font
port.getPortionFormat().setFontBold(NullableBool.True);
// Set Italic property of the Font
port.getPortionFormat().setFontItalic(NullableBool.True);
// Set Underline property of the Font
port.getPortionFormat().setFontUnderline(TextUnderlineType.Single);
// Set the Height of the Font
port.getPortionFormat().setFontHeight(25);
// Set the color of the Font
port.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
port.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.BLUE);
// Save the presentation to disk
pres.save("pptxFont.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
# Manage Presentation Hyperlinks in Java
> Add, format, update, and remove hyperlinks in PowerPoint and OpenDocument presentations with Aspose.Slides for Java, using Java examples.
Source: https://docs.aspose.com/slides/java/manage-hyperlinks/
Updated: 2026-11-02
## **Introduction**
A hyperlink connects presentation content to a website or a location within the presentation. In PowerPoint, hyperlinks commonly serve two purposes:
* Open a website from text, a shape, or a media frame.
* Navigate to another slide, for example, from a table of contents.
Aspose.Slides for Java lets you add these links, control their appearance and sound, update their properties, and remove them. The examples below show how to work with hyperlinks on individual elements and how to access hyperlinks at the presentation, slide, or text-frame level.
You can also edit presentations with the [free online Aspose PowerPoint editor](https://products.aspose.app/slides/editor).
## **Add URL Hyperlinks**
You can assign a website URL to text, a shape, or a media frame. The element to which you assign the hyperlink determines the clickable area: a text portion links the selected text, while a shape or frame links the slide object.
For presentations containing relative hyperlinks, see [Manage the Hyperlink Base](https://docs.aspose.com/slides/java/presentation-properties/#manage-the-hyperlink-base) to read, change, or clear the document-level base.
### **Add URL Hyperlinks to Text**
To link text to a website, pass a [Hyperlink](https://reference.aspose.com/slides/java/com.aspose.slides/hyperlink/) to the text portion's [setHyperlinkClick](https://reference.aspose.com/slides/java/com.aspose.slides/portionformat/#setHyperlinkClick-com.aspose.slides.IHyperlink-) method, as shown below. Only that portion of text becomes clickable.
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
IAutoShape textShape = presentation.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 600, 50, false);
textShape.addTextFrame("Aspose: File Format APIs");
IPortionFormat portionFormat = textShape.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat();
portionFormat.setHyperlinkClick(new Hyperlink("https://www.aspose.com/"));
portionFormat.getHyperlinkClick().setTooltip("Explore Aspose file format APIs");
portionFormat.setFontHeight(32);
presentation.save("presentation-out.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
### **Add URL Hyperlinks to Shapes and Media Frames**
To make a shape or frame clickable, call its [setHyperlinkClick](https://reference.aspose.com/slides/java/com.aspose.slides/shape/#setHyperlinkClick-com.aspose.slides.IHyperlink-) method. The hyperlink belongs to the object itself rather than to a text portion inside it.
The same approach applies to picture, audio, and video frames: assign the hyperlink to the frame and call [setTooltip](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlink/#setTooltip-java.lang.String-) if needed.
The following example makes a rectangle clickable:
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation();
try {
IAutoShape shape = presentation.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 600, 50);
shape.setHyperlinkClick(new Hyperlink("https://www.aspose.com/"));
shape.getHyperlinkClick().setTooltip("Explore Aspose file format APIs");
presentation.save("presentation-out.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Use Hyperlinks to Create a Table of Contents**
Internal hyperlinks let readers jump from a table of contents to a specific slide. The following example uses [setInternalHyperlinkClick](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlinkmanager/#setInternalHyperlinkClick-com.aspose.slides.ISlide-) to link the “Page 2” text on the first slide to the second slide.
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try {
ISlide firstSlide = presentation.getSlides().get_Item(0);
ISlide secondSlide = presentation.getSlides().addEmptySlide(firstSlide.getLayoutSlide());
IAutoShape tableOfContents = firstSlide.getShapes().addAutoShape(ShapeType.Rectangle, 40, 40, 300, 100);
tableOfContents.getFillFormat().setFillType(FillType.NoFill);
tableOfContents.getLineFormat().getFillFormat().setFillType(FillType.NoFill);
tableOfContents.getTextFrame().getParagraphs().clear();
Paragraph paragraph = new Paragraph();
paragraph.getParagraphFormat().getDefaultPortionFormat().getFillFormat().setFillType(FillType.Solid);
paragraph.getParagraphFormat().getDefaultPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
paragraph.setText("Title of slide 2 .......... ");
Portion linkPortion = new Portion();
linkPortion.setText("Page 2");
linkPortion.getPortionFormat().getHyperlinkManager().setInternalHyperlinkClick(secondSlide);
paragraph.getPortions().add(linkPortion);
tableOfContents.getTextFrame().getParagraphs().add(paragraph);
presentation.save("link_to_slide.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
## **Format Hyperlinks**
### **Color**
The [setColorSource](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlink/#setColorSource-int-) method of [IHyperlink](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlink/) determines whether a hyperlink uses the presentation's hyperlink color or the text portion's formatting. To apply a custom text color, select [HyperlinkColorSource.PortionFormat](https://reference.aspose.com/slides/java/com.aspose.slides/hyperlinkcolorsource/) and set the portion's fill color. This feature was introduced in PowerPoint 2019; older versions do not apply this setting.
The following example adds two text hyperlinks to the same slide. The first uses a red text fill, while the second retains the default hyperlink color.
```java
import com.aspose.slides.*;
import java.awt.Color;
Presentation presentation = new Presentation();
try {
IAutoShape coloredShape = presentation.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 450, 50, false);
coloredShape.addTextFrame("This hyperlink uses a custom color.");
IPortionFormat coloredPortionFormat = coloredShape.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat();
coloredPortionFormat.setHyperlinkClick(new Hyperlink("https://www.aspose.com/"));
coloredPortionFormat.getHyperlinkClick().setColorSource(HyperlinkColorSource.PortionFormat);
coloredPortionFormat.getFillFormat().setFillType(FillType.Solid);
coloredPortionFormat.getFillFormat().getSolidFillColor().setColor(Color.RED);
IAutoShape defaultShape = presentation.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 100, 200, 450, 50, false);
defaultShape.addTextFrame("This hyperlink uses the default color.");
defaultShape.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().setHyperlinkClick(new Hyperlink("https://www.aspose.com/"));
presentation.save("presentation-out-hyperlink.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
### **Sound**
A hyperlink can play a sound when activated or stop a sound that is already playing. Use the following methods to configure these behaviors:
- [IHyperlink.setSound](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlink/#setSound-com.aspose.slides.IAudio-) specifies the audio associated with the hyperlink.
- [IHyperlink.setStopSoundOnClick](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlink/#setStopSoundOnClick-boolean-) controls whether activating the hyperlink stops the previous sound.
#### **Add a Hyperlink Sound**
The following example loads `sampleaudio.wav` and associates it with a button on the first slide. Clicking the button plays the sound and navigates to the next slide. A second shape on that slide stops the previous sound when clicked, without performing a navigation action.
```java
import com.aspose.slides.*;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
Presentation presentation = new Presentation();
try {
byte[] audioData = Files.readAllBytes(Paths.get("sampleaudio.wav"));
IAudio hyperlinkSound = presentation.getAudios().addAudio(audioData);
ISlide firstSlide = presentation.getSlides().get_Item(0);
IAutoShape playButton = firstSlide.getShapes().addAutoShape(ShapeType.SoundButton, 100, 100, 100, 50);
playButton.setHyperlinkClick(Hyperlink.getNextSlide());
if (!playButton.getHyperlinkClick().getStopSoundOnClick() && playButton.getHyperlinkClick().getSound() == null)
{
playButton.getHyperlinkClick().setSound(hyperlinkSound);
}
ISlide secondSlide = presentation.getSlides().addEmptySlide(firstSlide.getLayoutSlide());
IAutoShape stopButton = secondSlide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 100, 50);
stopButton.setHyperlinkClick(Hyperlink.getNoAction());
stopButton.getHyperlinkClick().setStopSoundOnClick(true);
presentation.save("hyperlink-sound.pptx", SaveFormat.Pptx);
} catch (IOException exception) {
System.out.println("Unable to read the audio file: " + exception.getMessage());
} finally {
presentation.dispose();
}
```
#### **Extract a Hyperlink Sound**
The following example opens the presentation created above and reads the first shape's hyperlink audio into memory through [getSound](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlink/#getSound--) and [getBinaryData](https://reference.aspose.com/slides/java/com.aspose.slides/iaudio/#getBinaryData--).
```java
import com.aspose.slides.*;
Presentation presentation = new Presentation("hyperlink-sound.pptx");
try {
if (presentation.getSlides().size() > 0 && presentation.getSlides().get_Item(0).getShapes().size() > 0) {
IHyperlink hyperlink = presentation.getSlides().get_Item(0).getShapes().get_Item(0).getHyperlinkClick();
IAudio sound = hyperlink == null ? null : hyperlink.getSound();
if (sound != null) {
byte[] audioData = sound.getBinaryData();
System.out.println("Extracted " + audioData.length + " bytes of hyperlink audio.");
} else {
System.out.println("The first shape has no hyperlink sound.");
}
} else {
System.out.println("The presentation has no first slide or shape to inspect.");
}
} finally {
presentation.dispose();
}
```
### **Tooltip and Interaction Settings**
You can call the following [IHyperlink](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlink/) methods after assigning a hyperlink to text or a shape:
- [setTooltip](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlink/#setTooltip-java.lang.String-) sets the text that a viewer can display as a hint for the link.
- [setTargetFrame](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlink/#setTargetFrame-java.lang.String-) specifies the target frame within a parent HTML frameset, when applicable.
- [setHistory](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlink/#setHistory-boolean-) controls whether activating the link adds its destination to the list of viewed hyperlinks.
- [setHighlightClick](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlink/#setHighlightClick-boolean-) controls whether the hyperlink is highlighted when clicked.
## **Remove Hyperlinks from Presentations**
Use [getAnyHyperlinks](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlinkqueries/#getAnyHyperlinks--) to collect hyperlink containers, including text-portion links, before changing them. The following example removes both activation types from the first slide. To remove only one type, call only [removeHyperlinkClick](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlinkmanager/#removeHyperlinkClick--) or [removeHyperlinkMouseOver](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlinkmanager/#removeHyperlinkMouseOver--); removing a click action does not remove its mouse-over counterpart.
```java
import com.aspose.slides.*;
import java.util.ArrayList;
import java.util.List;
Presentation presentation = new Presentation("pres.pptx");
try {
if (presentation.getSlides().size() > 0) {
List containers = new ArrayList<>();
for (IHyperlinkContainer container : presentation.getSlides().get_Item(0).getHyperlinkQueries().getAnyHyperlinks()) {
containers.add(container);
}
for (IHyperlinkContainer container : containers) {
container.getHyperlinkManager().removeHyperlinkClick();
container.getHyperlinkManager().removeHyperlinkMouseOver();
}
presentation.save("pres-removed-hyperlinks.pptx", SaveFormat.Pptx);
} else {
System.out.println("The presentation has no slides to process.");
}
} finally {
presentation.dispose();
}
```
For unconditional removal, [removeAllHyperlinks](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlinkqueries/#removeAllHyperlinks--) removes both activation types in the selected scope in one call. For selective cleanup and coverage of masters, layouts, and notes, see [Report, Sanitize, and Verify Hyperlinks](https://docs.aspose.com/slides/java/manage-hyperlinks/#report-sanitize-and-verify-hyperlinks).
## **Build a Complete Hyperlink Inventory**
Before distributing a presentation, inventory its interactive actions as well as its web links. [getAnyHyperlinks](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlinkqueries/#getAnyHyperlinks--) returns [IHyperlinkContainer](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlinkcontainer/) objects, not a flat list of URL strings. Inspect both [getHyperlinkClick](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlinkcontainer/#getHyperlinkClick--) and [getHyperlinkMouseOver](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlinkcontainer/#getHyperlinkMouseOver--) on each container. They are independent: the same container can expose both actions, so a complete report needs up to two rows per container.
Scanning only shape-level hyperlinks can miss links attached to text portions. Query the appropriate scope instead, and retain the returned containers so that you can later update or remove their actions.
### **Query Presentation, Slide, and Text-Frame Scopes**
The [IHyperlinkQueries](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlinkqueries/) interface is available through [IPresentation.getHyperlinkQueries](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentation/#getHyperlinkQueries--), [IBaseSlide.getHyperlinkQueries](https://reference.aspose.com/slides/java/com.aspose.slides/ibaseslide/#getHyperlinkQueries--), and [ITextFrame.getHyperlinkQueries](https://reference.aspose.com/slides/java/com.aspose.slides/itextframe/#getHyperlinkQueries--). Each scope supports the same queries:
- [getHyperlinkClicks](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlinkqueries/#getHyperlinkClicks--) returns containers with a click action.
- [getHyperlinkMouseOvers](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlinkqueries/#getHyperlinkMouseOvers--) returns containers with a mouse-over action.
- [getAnyHyperlinks](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlinkqueries/#getAnyHyperlinks--) returns containers with either or both actions.
The following example creates `hyperlink-audit-input.pptx` with an external click link, a file mouse-over link, internal slide navigation, a text mouse-over link, and a macro action. It does not execute any of these actions. The same three queries work at every scope; the counts describe containers, not action totals. The text-frame scope excludes the enclosing shape's own links.
```java
import com.aspose.slides.*;
class QueryCounts {
void print(String scope, IHyperlinkQueries queries) {
int clickCount = queries.getHyperlinkClicks().size();
int mouseOverCount = queries.getHyperlinkMouseOvers().size();
int anyCount = queries.getAnyHyperlinks().size();
System.out.println(scope + ": click=" + clickCount + ", mouse-over=" + mouseOverCount + ", any=" + anyCount);
}
}
QueryCounts counts = new QueryCounts();
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
ISlide destination = presentation.getSlides().addEmptySlide(slide.getLayoutSlide());
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 20, 20, 400, 60);
shape.getTextFrame().setText("Click the text to go to slide 2");
shape.getHyperlinkManager().setExternalHyperlinkClick("https://example.com/");
shape.getHyperlinkClick().setTooltip("Public website");
shape.getHyperlinkManager().setExternalHyperlinkMouseOver("file:///C:/private/report.xlsx");
IPortionFormat portionFormat = shape.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat();
portionFormat.getHyperlinkManager().setInternalHyperlinkClick(destination);
portionFormat.getHyperlinkManager().setExternalHyperlinkMouseOver("https://example.com/help");
IAutoShape macroButton = slide.getShapes().addAutoShape(ShapeType.Rectangle, 20, 120, 200, 60);
macroButton.getHyperlinkManager().setMacroHyperlinkClick("ReviewPresentation");
counts.print("Presentation", presentation.getHyperlinkQueries());
counts.print("Slide 1", slide.getHyperlinkQueries());
counts.print("Text frame", shape.getTextFrame().getHyperlinkQueries());
presentation.save("hyperlink-audit-input.pptx", SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
For this example, presentation and slide queries each report three click containers, two mouse-over containers, and three containers with either action. The text-frame query reports one container in each category.
### **Classify Actions and Destinations**
Use [IHyperlink.getActionType](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlink/#getActionType--) to interpret an action before interpreting its destination. The [HyperlinkActionType](https://reference.aspose.com/slides/java/com.aspose.slides/hyperlinkactiontype/) values cover more than web navigation:
| Values | Meaning for an audit |
| --- | --- |
| `Hyperlink` | External hyperlink; inspect the URL and its scheme. |
| `JumpSpecificSlide` | Internal navigation to a particular slide. |
| `JumpFirstSlide`, `JumpPreviousSlide`, `JumpNextSlide`, `JumpLastSlide`, `JumpLastViewedSlide` | Built-in slideshow navigation, resolved in slideshow context. |
| `JumpEndShow`, `StartCustomSlideShow` | End the current show or start a custom show. |
| `StartMacro` | Execute a macro. |
| `StartProgram` | Launch a program. |
| `OpenFile`, `OpenPresentation` | Open a file or another presentation; review separately from web URLs. |
| `StartStopMedia` | Start or stop media playback. |
| `NoAction`, `Unknown` | No navigation action, or an unrecognized action requiring review. |
Read external destinations from [getExternalUrl](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlink/#getExternalUrl--) and specific internal destinations from [getTargetSlide](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlink/#getTargetSlide--). Internal actions and built-in commands may have no external URL; an empty URL does not mean that the container has no action. Preserve the value returned by [getExternalUrlOriginal](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlink/#getExternalUrlOriginal--) when it differs from the normalized URL, and include the tooltip returned by [getTooltip](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlink/#getTooltip--) when available.
### **Report, Sanitize, and Verify Hyperlinks**
The following Java example reads an existing presentation (use the file created above), writes `hyperlink-audit.json`, applies a policy, saves `hyperlink-sanitized.pptx`, and reopens it to check both activation types again. It collects containers before changing them and uses reference equality to avoid processing the same container twice. Presentation queries cover ordinary slides; for a package-wide inventory, it also explicitly queries masters, layouts, notes, and the notes and handout masters when present.
The report records a one-based slide index and [getSlideId](https://reference.aspose.com/slides/java/com.aspose.slides/ibaseslide/#getSlideId--) where available. [ISlideComponent.getSlide](https://reference.aspose.com/slides/java/com.aspose.slides/islidecomponent/#getSlide--) supplies the owning slide for supported containers. Masters, layouts, and notes have no ordinary slide index and are identified by their scope. Shape containers and text-portion formatting containers are labeled separately; other container types retain their runtime type name. Each container gets a report-local ID so its two actions can be correlated. The report stores action types as the integer constants defined by the Java enumeration.
This deliberately restrictive application policy allows only absolute HTTPS URLs and valid internal slide targets. It rejects macros, programs, file actions, other slideshow actions, unknown actions, and other URL schemes. These rejections are policy decisions, not an Aspose.Slides safety verdict. HTTPS alone does not establish trust: add host allowlists and other checks for your application. Both original and normalized external URLs are checked. The example audits metadata without following links or running actions.
For remediation, the container's [getHyperlinkManager](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlinkcontainer/#getHyperlinkManager--) supports [setExternalHyperlinkClick](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlinkmanager/#setExternalHyperlinkClick-java.lang.String-), [removeHyperlinkClick](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlinkmanager/#removeHyperlinkClick--), and [removeHyperlinkMouseOver](https://reference.aspose.com/slides/java/com.aspose.slides/ihyperlinkmanager/#removeHyperlinkMouseOver--). Here, prohibited external click links are replaced with a fixed HTTPS landing page; other prohibited clicks and prohibited mouse-over actions are removed independently. Set `replaceExternalClicks` to `false` to remove all policy violations instead. Choose an application-owned replacement page before deployment.
The report's export flag uses a conservative PDF review policy: flag mouse-over actions and anything other than an external link or specific slide jump as potentially unsupported. It is a review hint, not a capability test or a guarantee that unflagged links will survive export. Supported [PDF](https://docs.aspose.com/slides/java/convert-powerpoint-to-pdf/) and [HTML](https://docs.aspose.com/slides/java/convert-powerpoint-to-html/) exports may preserve hyperlinks, depending on the action, export options, and viewer. Raster [images](https://docs.aspose.com/slides/java/convert-powerpoint-to-png/) and [video](https://docs.aspose.com/slides/java/convert-powerpoint-to-video/) cannot preserve interactive hyperlinks; flag every action when auditing for those outputs.
```java
import com.aspose.slides.*;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
class HyperlinkAudit {
Integer slideIndex(IPresentation presentation, IBaseSlide slide) {
for (int index = 0; index < presentation.getSlides().size(); index++) {
if (presentation.getSlides().get_Item(index) == slide) return index + 1;
}
return null;
}
boolean isHttps(String value) {
if (value == null || value.isEmpty()) return false;
try {
URI uri = new URI(value);
return uri.isAbsolute() && "https".equalsIgnoreCase(uri.getScheme()) && uri.getHost() != null;
} catch (URISyntaxException exception) {
return false;
}
}
String policyViolation(IHyperlink link) {
if (link == null) return null;
if (link.getActionType() == HyperlinkActionType.JumpSpecificSlide) {
return link.getTargetSlide() == null ? "Missing target slide" : null;
}
if (link.getActionType() != HyperlinkActionType.Hyperlink) return "Action is not allowed";
if (!isHttps(link.getExternalUrl())) return "Normalized URL is not absolute HTTPS";
String original = link.getExternalUrlOriginal();
if (original != null && !original.isEmpty() && !isHttps(original)) return "Original URL is not absolute HTTPS";
return null;
}
void addScope(List found, IBaseSlide slide) {
if (slide != null) {
for (IHyperlinkContainer container : slide.getHyperlinkQueries().getAnyHyperlinks()) {
found.add(container);
}
}
}
List collectContainers(IPresentation presentation) {
List found = new ArrayList<>();
for (IHyperlinkContainer container : presentation.getHyperlinkQueries().getAnyHyperlinks()) {
found.add(container);
}
for (IMasterSlide master : presentation.getMasters()) addScope(found, master);
for (ILayoutSlide layout : presentation.getLayoutSlides()) addScope(found, layout);
for (ISlide slide : presentation.getSlides()) addScope(found, slide.getNotesSlideManager().getNotesSlide());
addScope(found, presentation.getMasterNotesSlideManager().getMasterNotesSlide());
addScope(found, presentation.getMasterHandoutSlideManager().getMasterHandoutSlide());
Set seen = Collections.newSetFromMap(new IdentityHashMap());
List unique = new ArrayList<>();
for (IHyperlinkContainer container : found) {
if (seen.add(container)) unique.add(container);
}
return unique;
}
void addRow(List