# Aspose.Slides for PHP via Java
> Complete English documentation. Each page retains its canonical source URL.
# Aspose.Slides for PHP via Java
> Start here: install Aspose.Slides for PHP via Java, create a first presentation, and find the guides for common tasks, the API reference and support.
Source: https://docs.aspose.com/slides/php-java/
Updated: 2026-10-27
Aspose.Slides for PHP via Java is a class library for creating, reading, editing and converting PowerPoint and OpenDocument presentations in PHP applications, without Microsoft PowerPoint or Office Automation.
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 PHP via Java runs on Java inside Apache Tomcat, and your PHP scripts reach it through PHP/Java Bridge. [Installation](https://docs.aspose.com/slides/php-java/installation/) sets up PHP 8.3 or earlier, Java, Tomcat and the bridge, and then installs the package from Packagist in a project folder:
```bash
composer require aspose/slides
```
Then copy the package's JAR file into the bridge and restart Tomcat, as in step 4 of [Install on Linux](https://docs.aspose.com/slides/php-java/installation/#install-on-linux) or step 6 of [Install on Windows](https://docs.aspose.com/slides/php-java/installation/#install-on-windows). With Tomcat running, save this script as *hello.php* in the project folder and run `php hello.php`:
```php
getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 400, 100);
$shape->getTextFrame()->setText("Hello, Aspose.Slides!");
$presentation->save(__DIR__ . "/hello.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The script saves *hello.pptx* next to itself, with one slide holding a text box. Without a license, the saved file carries an evaluation watermark — see [Licensing](https://docs.aspose.com/slides/php-java/licensing/). For more ways to create and fill a presentation, see [Create Presentations](https://docs.aspose.com/slides/php-java/create-presentation/).
## Related articles
- [API Reference](https://docs.aspose.com/slides/php-java/api-reference/)
- [Resources](https://docs.aspose.com/slides/php-java/resources/)
- [Product Overview](https://docs.aspose.com/slides/php-java/product-overview/)
# Customize 3D Charts in Presentations Using PHP
> Create 3D charts in PowerPoint presentations with Aspose.Slides for PHP via Java. Adjust rotation, height proportions, chart depth, and spacing between series with PHP examples.
Source: https://docs.aspose.com/slides/php-java/3d-chart/
Updated: 2026-11-09
## **Overview**
Aspose.Slides for PHP via Java lets you customize the view of a 3D chart through the [Chart::getRotation3D](https://reference.aspose.com/slides/php-java/aspose.slides/chart/#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/php-java/aspose.slides/presentation/) and uses [ShapeCollection::addChart](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/#addChart) 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/php-java/aspose.slides/rotation3d/#setRotationX) and [setRotationY](https://reference.aspose.com/slides/php-java/aspose.slides/rotation3d/#setRotationY) methods set the chart's rotation to 40 and 270 degrees, respectively. [setDepthPercents](https://reference.aspose.com/slides/php-java/aspose.slides/rotation3d/#setDepthPercents) sets its depth to 150% of its width, while [setRightAngleAxes](https://reference.aspose.com/slides/php-java/aspose.slides/rotation3d/#setRightAngleAxes) enables right-angle axes instead of perspective. The resulting presentation contains the populated chart with these 3D view settings.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::StackedColumn3D, 0, 0, 500, 500);
$chart->getChartData()->getSeries()->clear();
$chart->getChartData()->getCategories()->clear();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$worksheetIndex = 0;
$values = [[20, 50, 30], [30, 10, 60]];
for ($categoryIndex = 0; $categoryIndex < 3; $categoryIndex++) {
$categoryCell = $workbook->getCell($worksheetIndex, $categoryIndex + 1, 0, "Category " . ($categoryIndex + 1));
$chart->getChartData()->getCategories()->add($categoryCell);
}
for ($seriesIndex = 0; $seriesIndex < 2; $seriesIndex++) {
$seriesCell = $workbook->getCell($worksheetIndex, 0, $seriesIndex + 1, "Series " . ($seriesIndex + 1));
$series = $chart->getChartData()->getSeries()->add($seriesCell, $chart->getType());
for ($categoryIndex = 0; $categoryIndex < 3; $categoryIndex++) {
$valueCell = $workbook->getCell($worksheetIndex, $categoryIndex + 1, $seriesIndex + 1, $values[$seriesIndex][$categoryIndex]);
$series->getDataPoints()->addDataPointForBarSeries($valueCell);
}
}
$chart->getRotation3D()->setRightAngleAxes(true);
$chart->getRotation3D()->setRotationX(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 [Rotation3D::setHeightPercents](https://reference.aspose.com/slides/php-java/aspose.slides/rotation3d/#setHeightPercents) 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/php-java/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.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::Column3D, 40, 30, 620, 460);
$chart->getRotation3D()->setRotationX(20);
$chart->getRotation3D()->setRotationY(30);
$chart->getRotation3D()->setRightAngleAxes(true);
$chart->getRotation3D()->setDepthPercents(100);
$chart->getChartData()->getSeries()->get_Item(0)->getParentSeriesGroup()->setGapDepth(150);
foreach ([50, 100, 200] as $heightPercent) {
$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 |
| --- | --- |
| [Rotation3D::setHeightPercents](https://reference.aspose.com/slides/php-java/aspose.slides/rotation3d/#setHeightPercents) | Height of the 3D scene as a percentage of its width. |
| [Chart::setHeight](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#setHeight) | Height of the chart object on the slide, in points. |
| [Rotation3D::setDepthPercents](https://reference.aspose.com/slides/php-java/aspose.slides/rotation3d/#setDepthPercents) | Depth of the 3D scene as a percentage of its width. |
| [ChartSeriesGroup::setGapDepth](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/#setGapDepth) | 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/php-java/aspose.slides/charttype/) class. For other chart appearance settings, see [Chart Formatting](https://docs.aspose.com/slides/php-java/chart-formatting/).
## **Adjust the Gap Between Series**
Use [ChartSeriesGroup::setGapDepth](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/#setGapDepth) 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 [ChartSeries::getParentSeriesGroup](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/#getParentSeriesGroup). The setting applies to every series in that group, not just the series used to access it. [ChartSeries::getGapDepth](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/#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/php-java/aspose.slides/charttype/) class.
These methods control different aspects of the chart:
| Method | Effect |
| --- | --- |
| [ChartSeriesGroup::setGapDepth](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/#setGapDepth) | Spacing between series along the depth axis, as a percentage of the marker width. |
| [ChartSeriesGroup::setGapWidth](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/#setGapWidth) | Spacing between adjacent bar or column clusters, as a percentage of the bar or column width. |
| [setDepthPercents](https://reference.aspose.com/slides/php-java/aspose.slides/rotation3d/#setDepthPercents) | 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.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::Column3D, 40, 30, 620, 230);
$chart->getRotation3D()->setRotationX(20);
$chart->getRotation3D()->setRotationY(30);
$chart->getRotation3D()->setDepthPercents(100);
$series = $chart->getChartData()->getSeries()->get_Item(0);
$group = $series->getParentSeriesGroup();
$group->setGapWidth(150);
foreach ([0, 500] as $gapDepth) {
$group->setGapDepth($gapDepth);
$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/php-java/aspose.slides/charttype/) class. For an exact, up-to-date list, check the [ChartType](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/shape/#getImage) or [render the entire slide](https://docs.aspose.com/slides/php-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 PHP
> Apply and render 3D effects for PowerPoint shapes and text in PHP with Aspose.Slides. Configure camera, lighting, material, extrusion, fills, and 3D text.
Source: https://docs.aspose.com/slides/php-java/3d-presentation/
Updated: 2026-09-25
## **Overview**
Aspose.Slides for PHP via 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 [Shape::getThreeDFormat](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#getThreeDFormat--) method to apply 3D formatting to a shape. The method returns [ThreeDFormat](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/), which controls the 3D scene for that shape.
For text, use the [TextFrameFormat::getThreeDFormat](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#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/php-java/aspose.slides/threedformat/#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/php-java/aspose.slides/threedformat/#getLightRig--) | Light preset, direction, and light rotation. | Change how highlights and shadows appear on the 3D surface. |
| [getMaterial](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/#getMaterial--) and [setMaterial](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/#setMaterial-byte-) | 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/php-java/aspose.slides/threedformat/#getExtrusionHeight--) and [setExtrusionHeight](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/#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/php-java/aspose.slides/threedformat/#getExtrusionColor--) | Color of the extruded sides. | Make depth visible or coordinate the side color with the front fill. |
| [getDepth](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/#getDepth--) and [setDepth](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/#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/php-java/aspose.slides/threedformat/#getBevelTop--) and [getBevelBottom](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/#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/php-java/aspose.slides/threedformat/#getContourColor--) and [getContourWidth](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/#getContourWidth--) and [setContourWidth](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/#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.
```php
use aspose\slides\CameraPresetType;
use aspose\slides\FillType;
use aspose\slides\ImageFormat;
use aspose\slides\LightingDirection;
use aspose\slides\LightRigPresetType;
use aspose\slides\MaterialPresetType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$imageScale = 2;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$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 Java("java.awt.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(java("java.awt.Color")->BLUE);
$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 [ThreeDFormat::getCamera](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/#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:
```php
use aspose\slides\CameraPresetType;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$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 [ThreeDFormat::setExtrusionHeight](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/#setExtrusionHeight-double-) to set the thickness and [ThreeDFormat::getExtrusionColor](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/#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:
```php
use aspose\slides\CameraPresetType;
use aspose\slides\LightingDirection;
use aspose\slides\LightRigPresetType;
use aspose\slides\MaterialPresetType;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 200, 150, 200, 200);
$extrusionColor = new Java("java.awt.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 [ThreeDFormat::setDepth](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/#setDepth-double-) method sets the depth of a 3D shape. The [setExtrusionHeight](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/#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:
```php
use aspose\slides\CameraPresetType;
use aspose\slides\FillType;
use aspose\slides\ImageFormat;
use aspose\slides\LightingDirection;
use aspose\slides\LightRigPresetType;
use aspose\slides\MaterialPresetType;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$imageScale = 2;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$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, java("java.awt.Color")->BLUE);
$shape->getFillFormat()->getGradientFormat()->getGradientStops()->add(100, new Java("java.awt.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);
$extrusionColor = new Java("java.awt.Color", 255, 140, 0);
$shape->getThreeDFormat()->setExtrusionHeight(150);
$shape->getThreeDFormat()->getExtrusionColor()->setColor($extrusionColor);
$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:
```php
use aspose\slides\CameraPresetType;
use aspose\slides\FillType;
use aspose\slides\Images;
use aspose\slides\LightingDirection;
use aspose\slides\LightRigPresetType;
use aspose\slides\MaterialPresetType;
use aspose\slides\PictureFillMode;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 200, 150, 250, 250);
$sourceImage = Images::fromFile("image.jpg");
try {
$image = $presentation->getImages()->addImage($sourceImage);
} finally {
$sourceImage->dispose();
}
$shape->getFillFormat()->setFillType(FillType::Picture);
$shape->getFillFormat()->getPictureFillFormat()->getPicture()->setImage($image);
$shape->getFillFormat()->getPictureFillFormat()->setPictureFillMode(PictureFillMode::Stretch);
$extrusionColor = new Java("java.awt.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 [TextFrameFormat::getThreeDFormat](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#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:
```php
use aspose\slides\CameraPresetType;
use aspose\slides\FillType;
use aspose\slides\ImageFormat;
use aspose\slides\LightingDirection;
use aspose\slides\LightRigPresetType;
use aspose\slides\MaterialPresetType;
use aspose\slides\PatternStyle;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\TextShapeType;
$imageScale = 2;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$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");
$portion = $shape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
$portion->getPortionFormat()->getFillFormat()->setFillType(FillType::Pattern);
$patternColor = new Java("java.awt.Color", 255, 140, 0);
$portion->getPortionFormat()->getFillFormat()->getPatternFormat()->getForeColor()->setColor($patternColor);
$portion->getPortionFormat()->getFillFormat()->getPatternFormat()->getBackColor()->setColor(java("java.awt.Color")->WHITE);
$portion->getPortionFormat()->getFillFormat()->getPatternFormat()->setPatternStyle(PatternStyle::LargeGrid);
$shape->getTextFrame()->getParagraphs()->get_Item(0)->getParagraphFormat()->getDefaultPortionFormat()->setFontHeight(128);
$textFrameFormat = $shape->getTextFrame()->getTextFrameFormat();
$textFrameFormat->setTransform(TextShapeType::ArchUp);
$textFrameFormat->getThreeDFormat()->setExtrusionHeight(3.5);
$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);
$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 [TextFrameFormat::setKeepTextFlat](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#setKeepTextFlat-boolean-) through [TextFrame::getTextFrameFormat](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#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 [Shape::getThreeDFormat](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#getThreeDFormat--). It is also different from ordinary rotation. [Shape::setRotation](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#setRotation-float-) rotates the shape in the slide plane, while [TextFrameFormat::setRotationAngle](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#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.
```php
use aspose\slides\CameraPresetType;
use aspose\slides\FillType;
use aspose\slides\ImageFormat;
use aspose\slides\LightingDirection;
use aspose\slides\LightRigPresetType;
use aspose\slides\MaterialPresetType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\TextAlignment;
use aspose\slides\TextAnchorType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$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 Java("java.awt.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 Java("java.awt.Color", 65, 105, 225));
$shape->getTextFrame()->getTextFrameFormat()->setKeepTextFlat(false);
$flatTextShape = $slide->getShapes()->addClone($shape, 400, 160);
$flatTextShape->getTextFrame()->getTextFrameFormat()->setKeepTextFlat(true);
$presentation->save("keep_text_flat.pptx", SaveFormat::Pptx);
$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/php-java/convert-powerpoint-to-png/), export to [PDF](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-pdf/), export to [HTML](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-html/), or generate frames for [video conversion](https://docs.aspose.com/slides/php-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/php-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 [Shape::getThreeDFormat](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#getThreeDFormat--) for the shape body and [TextFrameFormat::getThreeDFormat](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#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/php-java/shape-effective-properties/) to read final camera, light rig, bevel, and related 3D values.
# Access Presentation Slides in PHP
> Learn how to access and manage slides in PowerPoint and OpenDocument presentations with Aspose.Slides for PHP via Java. Boost productivity with code examples.
Source: https://docs.aspose.com/slides/php-java/access-slide-in-presentation/
Updated: 2026-08-02
## **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 [SlideCollection](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/) collection (collection of [Slide](https://reference.aspose.com/slides/php-java/aspose.slides/slide/) objects). This PHP code shows you how to access a slide through its index:
```php
# Instantiates a Presentation object that represents a presentation file
$pres = new Presentation("demo.pptx");
try {
# Accesses a slide using its slide index
$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/php-java/aspose.slides/presentation/#getSlideById-long-) method (exposed by the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class) to target that ID. This PHP code shows you how to provide a valid slide ID and access that slide through the [getSlideById](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getSlideById-long-) method:
```php
# Instantiates a Presentation object that represents a presentation file
$pres = new Presentation("demo.pptx");
try {
# Gets a slide ID
$id = $pres->getSlides()->get_Item(0)->getSlideId();
# Accesses the slide through its ID
$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/php-java/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/php-java/aspose.slides/slide/#setSlideNumber) method.
1. Save the modified presentation.
This PHP code demonstrates an operation in which the slide in position 1 is moved to position 2:
```php
# Instantiates a Presentation object that represents a presentation file
$pres = new Presentation("Presentation.pptx");
try {
# Gets the slide whose position will be changed
$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/php-java/aspose.slides/presentation/#setFirstSlideNumber-int-) method (exposed by the [Presentation](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/presentation/) class.
1. Get the slide number.
1. Set the slide number.
1. Save the modified presentation.
This PHP code demonstrates an operation where the first slide number is set to 10:
```php
# Instantiates a Presentation object that represents a presentation file
$pres = new Presentation("HelloWorld.pptx");
try {
# Gets the slide number
$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:
```php
$presentation = new Presentation();
try {
$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 (!java_is_null($presentation)) {
$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/php-java/aspose.slides/presentation/setfirstslidenumber/) 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 PHP
> Learn how Aspose.Slides for PHP via Java leverages ActiveX to automate and enhance PowerPoint presentations, giving developers powerful control over slides.
Source: https://docs.aspose.com/slides/php-java/activex/
Updated: 2026-08-13
## **Introduction**
ActiveX controls are used in presentations. Aspose.Slides for PHP via 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 [ShapeCollection](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/). They are part of the separate [ControlCollection](https://reference.aspose.com/slides/php-java/aspose.slides/controlcollection/) 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/php-java/aspose.slides/presentation) class and generate an empty presentation instance.
1. Access the target slide in [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation).
1. Add the Media Player ActiveX control using the [addControl](https://reference.aspose.com/slides/php-java/aspose.slides/controlcollection/addcontrol/) method exposed by [ControlCollection](https://reference.aspose.com/slides/php-java/aspose.slides/controlcollection/).
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:
```php
# Create empty presentation instance
$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 (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Modify an ActiveX Control**
Aspose.Slides for PHP via 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/php-java/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 [ControlCollection](https://reference.aspose.com/slides/php-java/aspose.slides/controlcollection/).
1. Access the TextBox1 ActiveX control using the [Control](https://reference.aspose.com/slides/php-java/aspose.slides/control/) 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:
```php
# Accessing the presentation with ActiveX controls
$pres = new Presentation("ActiveX.pptm");
try {
# java.awt classes are reached through the PHP/Java bridge
$bufferedImageClass = new JavaClass("java.awt.image.BufferedImage");
$fontClass = new JavaClass("java.awt.Font");
$systemColor = new JavaClass("java.awt.SystemColor");
# Accessing the first slide in presentation
$slide = $pres->getSlides()->get_Item(0);
# changing TextBox text
$control = $slide->getControls()->get_Item(0);
if (!java_is_null($control->getName()->equalsIgnoreCase("TextBox1") && $control->getProperties())) {
$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.
$image = new Java("java.awt.image.BufferedImage", $control->getFrame()->getWidth(), $control->getFrame()->getHeight(), $bufferedImageClass->TYPE_INT_ARGB);
$graphics = $image->getGraphics();
$graphics->setColor($systemColor->window);
$graphics->fillRect(0, 0, $image->getWidth(), $image->getHeight());
$font = new Java("java.awt.Font", $control->getProperties()->get_Item("FontName"), $fontClass->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();
$baos = new Java("java.io.ByteArrayOutputStream");
Java("javax.imageio.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 (!java_is_null($control->getName()->equalsIgnoreCase("CommandButton1") && $control->getProperties())) {
$newCaption = "Show MessageBox";
$control->getProperties()->set_Item("Caption", $newCaption);
# Changing substitute
$image = new Java("java.awt.image.BufferedImage", $control->getFrame()->getWidth(), $control->getFrame()->getHeight(), $bufferedImageClass->TYPE_INT_ARGB);
$graphics = $image->getGraphics();
$graphics->setColor($systemColor->control);
$graphics->fillRect(0, 0, $image->getWidth(), $image->getHeight());
$font = new Java("java.awt.Font", $control->getProperties()->get_Item("FontName"), $fontClass->PLAIN, 16);
$graphics->setColor($systemColor->windowText);
$graphics->setFont($font);
$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();
$baos = new Java("java.io.ByteArrayOutputStream");
Java("javax.imageio.ImageIO")->write($image, "PNG", $baos);
$control->getSubstitutePictureFormat()->getPicture()->setImage($pres->getImages()->addImage($baos->toByteArray()));
}
# moving 100 points down
foreach($pres->getSlides()->get_Item(0)->getControls() as $ctl) {
$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 (JavaException $e) {
} finally {
if (!java_is_null($pres)) {
$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/php-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/php-java/examples/elements/activex/)
# Add Slides to Presentations in PHP
> Easily add slides to your PowerPoint and OpenDocument presentations using Aspose.Slides for PHP via Java — seamless, efficient slide insertion in seconds.
Source: https://docs.aspose.com/slides/php-java/add-slide-to-presentation/
Updated: 2026-08-02
## **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 PHP via 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 PHP via 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/php-java/aspose.slides/presentation) class.
- Get the [SlideCollection](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/) object by using the [getSlides](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation#getSlides--) (collection of content Slide objects) method exposed by the [Presentation](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/slidecollection/#addEmptySlide) methods exposed by [SlideCollection](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/) object.
- Do some work with the newly added empty slide.
- Finally, write the presentation file using the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation) object.
```php
# Instantiate Presentation class that represents the presentation file
$pres = new Presentation();
try {
# Instantiate SlideCollection calss
$slds = $pres->getSlides();
for($i = 0; $i < java_values($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/php-java/aspose.slides/slidecollection/insertemptyslide/)/[clone](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/insertclone/) 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/php-java/aspose.slides/layoutslide/) that matches the required structure ([Title and Content, Two Content, etc.](https://reference.aspose.com/slides/php-java/aspose.slides/slidelayouttype/)). If such a layout is missing, you can [add it to the master](https://docs.aspose.com/slides/php-java/slide-layout/) and then use it.
# AI Features in Aspose.Slides
> Explore AI features in Aspose.Slides for PHP to generate, analyze, and enhance presentations in PHP, with guides for PowerPoint and OpenDocument formats.
Source: https://docs.aspose.com/slides/php-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: /php-java/ai/
keywords:
- AI features
- AI presentation translator
- AI presentation generator
- AI slide translator
- AI slide generator
- multilingual presentation
- multilingual slide
- PowerPoint
- OpenDocument
- presentation
- PHP
- Aspose.Slides
description: "Explore AI features in Aspose.Slides for PHP to generate, analyze, and enhance presentations in PHP, with guides for PowerPoint and OpenDocument formats."
---
## Related articles
- [Customize Presentation Charts in PHP](https://docs.aspose.com/slides/php-java/chart-types/)
# AI-Powered Presentation Translator
> Translate PowerPoint slides with AI using Aspose.Slides for PHP. Localize PPT, PPTX and ODP while preserving layout—fast and developer-friendly. Try it.
Source: https://docs.aspose.com/slides/php-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/php-java/aspose.slides/slidesaiagent/) class to communicate with AI services.
You can use the built-in [OpenAIWebClient](https://reference.aspose.com/slides/php-java/aspose.slides/openaiwebclient/) to connect to OpenAI’s API.
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/php-java/aspose.slides/openaiwebclient/).
## **Example**
In this example, we translate a PowerPoint presentation into Japanese using the built-in [OpenAIWebClient](https://reference.aspose.com/slides/php-java/aspose.slides/openaiwebclient/) with a specified OpenAI [model](https://platform.openai.com/docs/models).
```php
// Load a presentation to translate.
$presentation = new Presentation("sample.pptx");
// Create an AI client with OpenAIWebClient, specifying your model and API key.
$aiWebClient = new OpenAIWebClient("gpt-4o-mini", "apiKey", null);
try {
// Initialize SlidesAIAgent with the AI client.
$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/php-java/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/php-java/aspose.slides/openaiwebclient/).
```php
// Create and pre-configure your own HttpURLConnection instance (custom timeouts, proxy settings, etc.).
$url = new Java("java.net.URL", "https://api.openai.com/v1/chat/completions");
$urlConnection = $url->openConnection();
$urlConnection->setConnectTimeout(10000);
$urlConnection->setReadTimeout(60000);
// Pass the connection to the AI client.
$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/php-java/aspose.slides/openaicompatiblewebclient/).
```php
use aspose\slides\OpenAICompatibleWebClient;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SlidesAIAgent;
$model = "your-azure-deployment-name";
$apiKey = "your-azure-api-key";
$baseUrl = "https://your-resource.openai.azure.com/openai/v1/";
$aiWebClient = new OpenAICompatibleWebClient($model, $apiKey, $baseUrl);
try {
$aiAgent = new SlidesAIAgent($aiWebClient);
$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.
# Animate PowerPoint Charts in PHP
> Create stunning animated charts with Aspose.Slides for PHP via Java. Boost presentations with dynamic visuals in PPT and PPTX files — get started now.
Source: https://docs.aspose.com/slides/php-java/animated-charts/
Updated: 2026-11-08
## **Introduction**
Aspose.Slides for PHP via Java supports animating the chart elements. **Series**, **Categories**, **Series Elements**, **Categories Elements** can be animated with [Sequence::addEffect](https://reference.aspose.com/slides/php-java/aspose.slides/sequence/#addEffect) method and two enums [EffectChartMajorGroupingType](https://reference.aspose.com/slides/php-java/aspose.slides/EffectChartMajorGroupingType) and [EffectChartMinorGroupingType](https://reference.aspose.com/slides/php-java/aspose.slides/EffectChartMinorGroupingType).
[](https://docs.aspose.com/slides/php-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.
```php
# Instantiate Presentation class that represents a presentation file
$pres = new Presentation("ExistingChart.pptx");
try {
# Get reference of the chart object
$slide = $pres->getSlides()->get_Item(0);
$shapes = $slide->getShapes();
$chart = $shapes->get_Item(0);
# Animate the series
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectType::Fade, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMajorGroupingType::BySeries, 0, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMajorGroupingType::BySeries, 1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMajorGroupingType::BySeries, 2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMajorGroupingType::BySeries, 3, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
# Write the modified presentation to disk
$pres->save("AnimatingSeries_out.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Chart Category 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 Category.
1. Write the presentation file to disk.
In the example given below, we animated chart category.
```php
# Instantiate Presentation class that represents a presentation file
$pres = new Presentation("ExistingChart.pptx");
try {
$slide = $pres->getSlides()->get_Item(0);
$shapes = $slide->getShapes();
$chart = $shapes->get_Item(0);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectType::Fade, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMajorGroupingType::ByCategory, 0, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMajorGroupingType::ByCategory, 1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMajorGroupingType::ByCategory, 2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMajorGroupingType::ByCategory, 3, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$pres->save("Sample_Animation_C.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$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.
```php
# Instantiate Presentation class that represents a presentation file
$pres = new Presentation("ExistingChart.pptx");
try {
# Get reference of the chart object
$slide = $pres->getSlides()->get_Item(0);
$shapes = $slide->getShapes();
$chart = $shapes->get_Item(0);
# Animate series elements
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectType::Fade, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInSeries, 0, 0, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInSeries, 0, 1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInSeries, 0, 2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInSeries, 0, 3, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInSeries, 1, 0, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInSeries, 1, 1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInSeries, 1, 2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInSeries, 1, 3, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInSeries, 2, 0, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInSeries, 2, 1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInSeries, 2, 2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$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 (!java_is_null($pres)) {
$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.
```php
# Instantiate Presentation class that represents a presentation file
$pres = new Presentation("ExistingChart.pptx");
try {
# Get reference of the chart object
$slide = $pres->getSlides()->get_Item(0);
$shapes = $slide->getShapes();
$chart = $shapes->get_Item(0);
# Animate categories' elements
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectType::Fade, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInCategory, 0, 0, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInCategory, 0, 1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInCategory, 0, 2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInCategory, 0, 3, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInCategory, 1, 0, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInCategory, 1, 1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInCategory, 1, 2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInCategory, 1, 3, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInCategory, 2, 0, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInCategory, 2, 1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$slide->getTimeline()->getMainSequence()->addEffect($chart, EffectChartMinorGroupingType::ByElementInCategory, 2, 2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$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 (!java_is_null($pres)) {
$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/php-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/php-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/php-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 PHP](https://docs.aspose.com/slides/php-java/animated-text/)
- [Enhance PowerPoint Presentations with Animations in PHP](https://docs.aspose.com/slides/php-java/powerpoint-animation/)
- [Animation](https://docs.aspose.com/slides/php-java/examples/elements/animation/)
# Animate PowerPoint Text in PHP
> Create dynamic animated text in PowerPoint and OpenDocument presentations using Aspose.Slides for PHP via Java, with easy-to-follow, optimized code examples.
Source: https://docs.aspose.com/slides/php-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/php-java/aspose.slides/Sequence#addEffect-com.aspose.slides.IParagraph-int-int-int-) method to the [**Sequence**](https://reference.aspose.com/slides/php-java/aspose.slides/Sequence) class. 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:
```php
$presentation = new Presentation("Presentation.pptx");
try {
# select paragraph to add effect
$autoShape = $presentation->getSlides()->get_Item(0)->getShapes()->get_Item(0);
$paragraph = $autoShape->getTextFrame()->getParagraphs()->get_Item(0);
# add Fly animation effect to selected paragraph
$effect = $presentation->getSlides()->get_Item(0)->getTimeline()->getMainSequence()->addEffect($paragraph, EffectType::Fly, EffectSubtype::Left, EffectTriggerType::OnClick);
$presentation->save("AnimationEffectinParagraph.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$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 PHP via 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:
```php
$pres = new Presentation("Presentation.pptx");
$Array = new java_class("java.lang.reflect.Array");
try {
$sequence = $pres->getSlides()->get_Item(0)->getTimeline()->getMainSequence();
$autoShape = $pres->getSlides()->get_Item(0)->getShapes()->get_Item(0);
foreach($autoShape->getTextFrame()->getParagraphs() as $paragraph) {
$effects = $sequence->getEffectsByParagraph($paragraph);
if (java_values($Array->getLength($effects)) > 0) {
echo("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/php-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/php-java/convert-powerpoint-to-video/) or [HTML](https://docs.aspose.com/slides/php-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/php-java/examples/elements/animation/)
- [Animate PowerPoint Charts in PHP](https://docs.aspose.com/slides/php-java/animated-charts/)
- [Apply Shape Animations in Presentations Using PHP](https://docs.aspose.com/slides/php-java/shape-animation/)
# API Limitations
> Know Aspose.Slides for PHP limits: exports set fixed Application/Producer metadata in PPT, PPTX, ODP, and PDF—helping you plan integrations without surprises.
Source: https://docs.aspose.com/slides/php-java/api-limitations/
Updated: 2026-05-15
## **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`, and `Producer` metadata fields in PPTX and PDF files.
## **Application and Producer**
When you create or export presentations with Aspose.Slides for PHP via 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 PHP via Java, this value is fixed and shows the library vendor rather than your app name, even if you use [DocumentProperties::setNameOfApplication](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/setnameofapplication/).
**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 PHP via 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 PHP via Java". For **PDF**, the Creator and Producer properties are written as "Aspose.Slides for PHP via Java x.x.x." 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/php-java/aspose.slides/documentproperties/setnameofapplication/).
# API Reference
> Create, edit, and convert presentations in PHP — no PowerPoint needed. Aspose.Slides for PHP via Java supports PPT, PPTX, and ODP with fast SVG/PDF export.
Source: https://docs.aspose.com/slides/php-java/api-reference/
Updated: 2026-08-13
Aspose.Slides for PHP via Java is a class library that enables PHP applications to read and write presentation documents without using Microsoft PowerPoint® or others. Aspose.Slides for PHP via 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 PHP via Java API Reference](https://reference.aspose.com/slides/php-java/).
## Related articles
- [Aspose.Slides for PHP via Java](https://docs.aspose.com/slides/php-java/)
- [Convert PowerPoint Presentations in PHP | HTML, PNG, PDF, Word, TIFF](https://docs.aspose.com/slides/php-java/convert-powerpoint/)
# Restrict Presentation Edits with Shape Locks in PHP
> Learn how to lock and unlock shapes in PPTX presentations with Aspose.Slides for PHP via Java to restrict selection, movement, resizing, and grouping.
Source: https://docs.aspose.com/slides/php-java/applying-protection-to-presentation/
Updated: 2026-10-20
## **Overview**
A common use for Aspose.Slides for PHP via 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 PHP via Java, each element on a slide is represented by an object that inherits from the [Shape](https://reference.aspose.com/slides/php-java/aspose.slides/shape/) class.
Different shape types expose different locking options. The [BaseShapeLock](https://reference.aspose.com/slides/php-java/aspose.slides/baseshapelock/) class is the base class for shape locks. Aspose.Slides for PHP via Java provides the following lock classes:
- [AutoShapeLock](https://reference.aspose.com/slides/php-java/aspose.slides/autoshapelock/) locks autoshapes.
- [ConnectorLock](https://reference.aspose.com/slides/php-java/aspose.slides/connectorlock/) locks connector shapes.
- [GraphicalObjectLock](https://reference.aspose.com/slides/php-java/aspose.slides/graphicalobjectlock/) locks graphical objects.
- [GroupShapeLock](https://reference.aspose.com/slides/php-java/aspose.slides/groupshapelock/) locks group shapes.
- [PictureFrameLock](https://reference.aspose.com/slides/php-java/aspose.slides/pictureframelock/) locks picture frames.
To apply locks across a [Presentation](https://reference.aspose.com/slides/php-java/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 PHP via Java provides the [Shape](https://reference.aspose.com/slides/php-java/aspose.slides/shape/) class to work with shapes on a slide.
The example calls [setSelectLocked](https://reference.aspose.com/slides/php-java/aspose.slides/autoshapelock/#setSelectLocked), [setPositionLocked](https://reference.aspose.com/slides/php-java/aspose.slides/autoshapelock/#setPositionLocked), and [setSizeLocked](https://reference.aspose.com/slides/php-java/aspose.slides/autoshapelock/#setSizeLocked) with `true` for autoshapes, with equivalent locks for group shapes, connectors, and picture frames. Connectors use [setPositionMove](https://reference.aspose.com/slides/php-java/aspose.slides/connectorlock/#setPositionMove) for movement; groups also use [setGroupingLocked](https://reference.aspose.com/slides/php-java/aspose.slides/groupshapelock/#setGroupingLocked) 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.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("Sample.pptx");
try {
foreach ($presentation->getSlides()->toArray() as $slide) {
foreach ($slide->getShapes()->toArray() as $shape) {
if (java_instanceof($shape, new JavaClass("com.aspose.slides.AutoShape"))) {
$shapeLock = $shape->getShapeLock();
$shapeLock->setPositionLocked(true);
$shapeLock->setSelectLocked(true);
$shapeLock->setSizeLocked(true);
} elseif (java_instanceof($shape, new JavaClass("com.aspose.slides.GroupShape"))) {
$shapeLock = $shape->getShapeLock();
$shapeLock->setGroupingLocked(true);
$shapeLock->setPositionLocked(true);
$shapeLock->setSelectLocked(true);
$shapeLock->setSizeLocked(true);
} elseif (java_instanceof($shape, new JavaClass("com.aspose.slides.Connector"))) {
$shapeLock = $shape->getShapeLock();
$shapeLock->setPositionMove(true);
$shapeLock->setSelectLocked(true);
$shapeLock->setSizeLocked(true);
} elseif (java_instanceof($shape, new JavaClass("com.aspose.slides.PictureFrame"))) {
$shapeLock = $shape->getShapeLock();
$shapeLock->setPositionLocked(true);
$shapeLock->setSelectLocked(true);
$shapeLock->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 [AutoShapeLock](https://reference.aspose.com/slides/php-java/aspose.slides/autoshapelock/), [GroupShapeLock](https://reference.aspose.com/slides/php-java/aspose.slides/groupshapelock/), [ConnectorLock](https://reference.aspose.com/slides/php-java/aspose.slides/connectorlock/), and [PictureFrameLock](https://reference.aspose.com/slides/php-java/aspose.slides/pictureframelock/). It also removes the grouping restriction by passing `false` to [GroupShapeLock::setGroupingLocked](https://reference.aspose.com/slides/php-java/aspose.slides/groupshapelock/#setGroupingLocked) and saves a copy of the presentation. Other lock settings are left unchanged.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("ProtectedSample.pptx");
try {
foreach ($presentation->getSlides()->toArray() as $slide) {
foreach ($slide->getShapes()->toArray() as $shape) {
if (java_instanceof($shape, new JavaClass("com.aspose.slides.AutoShape"))) {
$shapeLock = $shape->getShapeLock();
$shapeLock->setPositionLocked(false);
$shapeLock->setSelectLocked(false);
$shapeLock->setSizeLocked(false);
} elseif (java_instanceof($shape, new JavaClass("com.aspose.slides.GroupShape"))) {
$shapeLock = $shape->getShapeLock();
$shapeLock->setGroupingLocked(false);
$shapeLock->setPositionLocked(false);
$shapeLock->setSelectLocked(false);
$shapeLock->setSizeLocked(false);
} elseif (java_instanceof($shape, new JavaClass("com.aspose.slides.Connector"))) {
$shapeLock = $shape->getShapeLock();
$shapeLock->setPositionMove(false);
$shapeLock->setSelectLocked(false);
$shapeLock->setSizeLocked(false);
} elseif (java_instanceof($shape, new JavaClass("com.aspose.slides.PictureFrame"))) {
$shapeLock = $shape->getShapeLock();
$shapeLock->setPositionLocked(false);
$shapeLock->setSelectLocked(false);
$shapeLock->setSizeLocked(false);
}
}
}
$presentation->save("RemovedProtectionSample.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Conclusion**
Aspose.Slides for PHP via 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/php-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/php-java/aspose.slides/groupshape/#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.
# Manage Audio in Presentations Using PHP
> Create and control audio frames in Aspose.Slides for PHP—code examples to embed, trim, loop, and configure playback across PPT, PPTX, and ODP presentations.
Source: https://docs.aspose.com/slides/php-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 PHP via 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/php-java/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/php-java/aspose.slides/AudioPlayModePreset) and `Volume` exposed by the [AudioFrame](https://reference.aspose.com/slides/php-java/aspose.slides/audioframe/) object.
6. Save the modified presentation.
This PHP code shows you how to add an embedded audio frame to a slide:
```php
// Instantiates a Presentation class that represents a presentation file
$pres = new Presentation();
try {
# Gets the first slide
$sld = $pres->getSlides()->get_Item(0);
# Loads the wav sound file to stream
$fstr = new Java("java.io.FileInputStream", new Java("java.io.File", "audio.wav"));
# Adds the Audio Frame
$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);
} finally {
if (!java_is_null($pres)) {
$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 PHP code shows you how to change an audio frame's thumbnail or preview image:
```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
# Adds an audio frame to the slide with a specified position and size.
$audioStream = new Java("java.io.FileInputStream", "sample2.mp3");
$audioFrame = $slide->getShapes()->addAudioFrameEmbedded(150, 100, 50, 50, $audioStream);
$audioStream->close();
# Adds an image to presentation resources.
$picture;
$image = Images->fromFile("eagle.jpeg");
try {
$picture = $presentation->getImages()->addImage($image);
} finally {
if (!java_is_null($image)) {
$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 (JavaException $e) {
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
## **Change Audio Play Options**
Aspose.Slides for PHP via 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/php-java/aspose.slides/audioframe/) properties:
- **Start** drop-down list matches the [AudioFrame::setPlayMode](https://reference.aspose.com/slides/php-java/aspose.slides/audioframe/#setPlayMode) method
- **Volume** matches the [AudioFrame::setVolume](https://reference.aspose.com/slides/php-java/aspose.slides/audioframe/#setVolume) method
- **Play Across Slides** matches the [AudioFrame::setPlayAcrossSlides](https://reference.aspose.com/slides/php-java/aspose.slides/audioframe/#setPlayAcrossSlides) method
- **Loop until Stopped** matches the [AudioFrame::setPlayLoopMode](https://reference.aspose.com/slides/php-java/aspose.slides/audioframe/#setPlayLoopMode) method
- **Hide During Show** matches the [AudioFrame::setHideAtShowing](https://reference.aspose.com/slides/php-java/aspose.slides/audioframe/#setHideAtShowing) method
- **Rewind after Playing** matches the [AudioFrame::setRewindAudio](https://reference.aspose.com/slides/php-java/aspose.slides/audioframe/#setRewindAudio) method
PowerPoint **Editing** options that correspond to Aspose.Slides [AudioFrame](https://reference.aspose.com/slides/php-java/aspose.slides/audioframe/) properties:
- **Fade In** matches the [AudioFrame::setFadeInDuration](https://reference.aspose.com/slides/php-java/aspose.slides/audioframe/#setFadeInDuration) method
- **Fade Out** matches the [AudioFrame::setFadeOutDuration](https://reference.aspose.com/slides/php-java/aspose.slides/audioframe/#setFadeOutDuration) method
- **Trim Audio Start Time** matches the [AudioFrame::setTrimFromStart](https://reference.aspose.com/slides/php-java/aspose.slides/audioframe/#setTrimFromStart) method
- **Trim Audio End Time** value equals the audio duration minus the value of [AudioFrame::setTrimFromEnd](https://reference.aspose.com/slides/php-java/aspose.slides/audioframe/#setTrimFromEnd) method
The PowerPoint **Volume controll** on the audio control panel corresponds to the [AudioFrame::setVolumeValue](https://reference.aspose.com/slides/php-java/aspose.slides/audioframe/#setVolumeValue) 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/php-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 PHP code demonstrates an operation in which an audio's options are adjusted:
```php
$pres = new Presentation("AudioFrameEmbed_out.pptx");
try {
# Gets the AudioFrame shape
$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 (!java_is_null($pres)) {
$pres->dispose();
}
}
```
This PHP example shows how to add a new audio frame with embedded audio, trim it, and set the fade durations:
```php
$pres = new Presentation();
try {
$slide = $pres->getSlides()->get_Item(0);
$audioData = file_get_contents("sampleaudio.mp3");
$audio = $pres->getAudios()->addAudio($audioData);
$audioFrame = $slide->getShapes()->addAudioFrameEmbedded(50, 50, 100, 100, $audio);
// Sets the trimming start offset to 1.5 seconds
$audioFrame->setTrimFromStart(1500);
// Sets the trimming end offset to 2 seconds
$audioFrame->setTrimFromEnd(2000);
// Sets the fade-in duration to 200 ms
$audioFrame->setFadeInDuration(200);
// Sets the fade-out duration to 500 ms
$audioFrame->setFadeOutDuration(500);
$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%:
```php
$pres = new Presentation("AudioFrameEmbed_out.pptx");
try {
$slide = $pres->getSlides()->get_Item(0);
// Gets an audio frame shape
$audioFrame = $slide->getShapes()->get_Item(0);
// Sets the audio volume to 85%
$audioFrame->setVolumeValue(85);
$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/php-java/aspose.slides/audioframe/#getCaptionTracks) method. This method returns an [CaptionsCollection](https://reference.aspose.com/slides/php-java/aspose.slides/captionscollection/), 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/php-java/aspose.slides/audioframe/#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.
```php
$presentation = new Presentation();
try {
$audioData = file_get_contents("audio.mp3");
$audio = $presentation->getAudios()->addAudio($audioData);
$slide = $presentation->getSlides()->get_Item(0);
$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.
```php
$presentation = new Presentation("audio_with_captions.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapeCount = java_values($slide->getShapes()->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $slide->getShapes()->get_Item($shapeIndex);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.AudioFrame"))) {
$audioFrame = $shape;
$trackCount = java_values($audioFrame->getCaptionTracks()->getCount());
for ($trackIndex = 0; $trackIndex < $trackCount; $trackIndex++) {
$captionTrack = $audioFrame->getCaptionTracks()->get_Item($trackIndex);
// Save each caption track as a .vtt file.
$filePath = $captionTrack->getCaptionId() . ".vtt";
file_put_contents($filePath, $captionTrack->getBinaryData());
}
}
}
} finally {
$presentation->dispose();
}
```
**Remove Audio Captions**
To remove captions from an audio frame, use the methods provided by [CaptionsCollection](https://reference.aspose.com/slides/php-java/aspose.slides/captionscollection/), such as [clear](https://reference.aspose.com/slides/php-java/aspose.slides/captionscollection/#clear), [remove](https://reference.aspose.com/slides/php-java/aspose.slides/captionscollection/#remove), or [removeAt](https://reference.aspose.com/slides/php-java/aspose.slides/captionscollection/#removeAt). The following example removes all caption tracks from an audio frame.
```php
$presentation = new Presentation("audio_with_captions.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$audioFrame = $slide->getShapes()->get_Item(0); // type: AudioFrame
// 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 PHP via 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/php-java/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/php-java/aspose.slides/baseslide/#getSlideShowTransition) for the slide.
4. Extract the sound in byte data.
This code shows you how to extract the audio used in a slide:
```php
# Instantiates a Presentation class that represents a presentation file
$pres = new Presentation("AudioSlide.pptx");
$Array = new java_class("java.lang.reflect.Array");
try {
# Accesses the desired slide
$slide = $pres->getSlides()->get_Item(0);
# Gets the slideshow transition effects for the slide
$transition = $slide->getSlideShowTransition();
# Extracts the sound in byte array
$audio = $transition->getSound()->getBinaryData();
echo("Length: " . $Array->getLength($audio));
} finally {
if (!java_is_null($pres)) {
$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/php-java/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/php-java/aspose.slides/audioframe/setlinkpathlong/) to point to the new file. For an embedded sound, swap the [embedded audio](https://reference.aspose.com/slides/php-java/aspose.slides/audioframe/setembeddedaudio/) object with another one from the presentation’s [audio collection](https://reference.aspose.com/slides/php-java/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/php-java/examples/elements/audio/)
- [Manage Video Frames in Presentations Using PHP](https://docs.aspose.com/slides/php-java/video-frame/)
# Automating PowerPoint Generation in PHP: Create Dynamic Presentations Easily
> Automate slide creation on cloud platforms with Aspose.Slides for PHP—generate, edit, and convert PowerPoint and OpenDocument files fast and reliably.
Source: https://docs.aspose.com/slides/php-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 PHP 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 PHP 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 PHP**
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 PHP](https://products.aspose.com/slides/php-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/php-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.
```php
$presentation = new Presentation();
$slide0 = $presentation->getSlides()->get_Item(0);
$layoutSlide = $presentation->getLayoutSlides()->getByType(SlideLayoutType::Title);
$slide0->setLayoutSlide($layoutSlide);
$titleShape = $slide0->getShapes()->get_Item(0);
$subtitleShape = $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.
```php
$presentation = new Presentation();
$layoutSlide1 = $presentation->getLayoutSlides()->getByType(SlideLayoutType::Blank);
$slide1 = $presentation->getSlides()->addEmptySlide($layoutSlide1);
$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);
$workbook = $chart->getChartData()->getChartDataWorkbook();
$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"));
$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.
```php
$presentation = new Presentation();
$layoutSlide2 = $presentation->getLayoutSlides()->getByType(SlideLayoutType::Blank);
$slide2 = $presentation->getSlides()->addEmptySlide($layoutSlide2);
$columnWidths = [200, 100];
$rowHeights = [40, 40, 40, 40, 40];
$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.
```php
function createBulletParagraph($text) {
$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(java("java.awt.Color")->BLACK);
$paragraph->setText($text);
return $paragraph;
}
```
```php
$presentation = new Presentation();
$layoutSlide3 = $presentation->getLayoutSlides()->getByType(SlideLayoutType::Blank);
$slide3 = $presentation->getSlides()->addEmptySlide($layoutSlide3);
$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:
```php
$presentation = new Presentation();
$presentation->save("presentation.pptx", SaveFormat::Pptx);
```
## **Conclusion**
Automating PowerPoint generation in PHP 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, PHP developers can efficiently automate PowerPoint creation, enhancing productivity and ensuring consistency across presentations.
# Customize Bubble Charts in Presentations Using PHP
> Create and customize powerful bubble charts in PowerPoint with Aspose.Slides for PHP via Java to enhance your data visualization easily.
Source: https://docs.aspose.com/slides/php-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 PHP via Java provides support for Bubble chart size scaling. In Aspose.Slides for PHP via Java [**ChartSeries.getBubbleSizeScale**](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/getbubblesizescale/), [**ChartSeriesGroup.getBubbleSizeScale**](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/getbubblesizescale/) and [**ChartSeriesGroup.setBubbleSizeScale**](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/setbubblesizescale/) methods have been added. Below sample example is given.
```php
$pres = new Presentation();
try {
$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 (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Represent Data as Bubble Chart Sizes**
Methods [**setBubbleSizeRepresentation**](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/setbubblesizerepresentation/) and [**getBubbleSizeRepresentation**](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/getbubblesizerepresentation/) have been added to [ChartSeries](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/), [ChartSeriesGroup](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/) classes, 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/php-java/aspose.slides/BubbleSizeRepresentationType#Area) and [**BubbleSizeRepresentationType::Width**](https://reference.aspose.com/slides/php-java/aspose.slides/BubbleSizeRepresentationType#Width). Accordingly, [**BubbleSizeRepresentationType**](https://reference.aspose.com/slides/php-java/aspose.slides/BubbleSizeRepresentationType) enum has been added to specify the possible ways to represent data as bubble chart sizes. Sample code is given below.
```php
$pres = new Presentation();
try {
$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 (!java_is_null($pres)) {
$pres->dispose();
}
}
```
[](https://docs.aspose.com/slides/php-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/php-java/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 PHP
> Create and style callouts in Aspose.Slides for PHP via Java with concise code examples, compatible with PPT and PPTX to automate presentation workflows.
Source: https://docs.aspose.com/slides/php-java/callout/
Updated: 2026-08-02
## **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/php-java/aspose.slides/datalabelformat/getshowlabelasdatacallout/) and [**setShowLabelAsDataCallout()**](https://reference.aspose.com/slides/php-java/aspose.slides/datalabelformat/setshowlabelasdatacallout/) have been added to [DataLabelFormat](https://reference.aspose.com/slides/php-java/aspose.slides/datalabelformat) class. These methods determine either specified chart's data label will be displayed as data callout or as data label.
```php
$pres = new Presentation();
try {
$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 (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Set a Callout for a Doughnut Chart**
Aspose.Slides for PHP via Java provides support for setting series data label callout shape for a Doughnut chart. Below sample example is given.
```php
$pres = new Presentation();
try {
$slide = $pres->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::Doughnut, 10, 10, 500, 500, false);
$workBook = $chart->getChartData()->getChartDataWorkbook();
$chart->getChartData()->getSeries()->clear();
$chart->getChartData()->getCategories()->clear();
$chart->setLegend(false);
$seriesIndex = 0;
while ($seriesIndex < 15) {
$series = $chart->getChartData()->getSeries()->add($workBook->getCell(0, 0, $seriesIndex + 1, "SERIES " . $seriesIndex), $chart->getType());
$series->setExplosion(0);
$series->getParentSeriesGroup()->setDoughnutHoleSize(20);
$series->getParentSeriesGroup()->setFirstSliceAngle(351);
$seriesIndex++;
}
$categoryIndex = 0;
while ($categoryIndex < 15) {
$chart->getChartData()->getCategories()->add($workBook->getCell(0, $categoryIndex + 1, 0, "CATEGORY " . $categoryIndex));
$i = 0;
while ($i < java_values($chart->getChartData()->getSeries()->size())) {
$iCS = $chart->getChartData()->getSeries()->get_Item($i);
$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("java.awt.Color")->WHITE);
$dataPoint->getFormat()->getLine()->setWidth(1);
$dataPoint->getFormat()->getLine()->setStyle(LineStyle->Single);
$dataPoint->getFormat()->getLine()->setDashStyle(LineDashStyle->Solid);
if ($i == java_values($chart->getChartData()->getSeries()->size()) - 1) {
$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("java.awt.Color")->LIGHT_GRAY);
$lbl->getDataLabelFormat()->getFormat()->getLine()->getFillFormat()->getSolidFillColor()->setColor(java("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($lbl->getX() + 0.5);
$lbl->setY($lbl->getY() + 0.5);
}
$i++;
}
$categoryIndex++;
}
$pres->save("chart.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$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/php-java/convert-powerpoint-to-pdf/), [HTML5](https://docs.aspose.com/slides/php-java/export-to-html5/), [SVG](https://docs.aspose.com/slides/php-java/render-a-slide-as-an-svg-image/), or [raster images](https://docs.aspose.com/slides/php-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/php-java/embedded-font/) into the presentation and controls font embedding during exports such as [PDF](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-pdf/), ensuring the callouts look the same across different systems.
# Customize Chart Axes in Presentations Using PHP
> Discover how to use Aspose.Slides for PHP via Java to customize chart axes in PowerPoint presentations for reports and visualizations.
Source: https://docs.aspose.com/slides/php-java/chart-axis/
Updated: 2026-10-30
## **Overview**
This article explains how to customize chart axes with Aspose.Slides for PHP via 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/php-java/aspose.slides/presentation/) and add an area chart with default data. Call [validateChartLayout](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/axis/getactualmaxvalue/) and [getActualMinValue](https://reference.aspose.com/slides/php-java/aspose.slides/axis/getactualminvalue/) for the axis limits, and [getActualMajorUnit](https://reference.aspose.com/slides/php-java/aspose.slides/axis/getactualmajorunit/) and [getActualMinorUnit](https://reference.aspose.com/slides/php-java/aspose.slides/axis/getactualminorunit/) for the tick intervals. [getActualMajorUnitScale](https://reference.aspose.com/slides/php-java/aspose.slides/axis/getactualmajorunitscale/) and [getActualMinorUnitScale](https://reference.aspose.com/slides/php-java/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.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::Area, 100, 100, 500, 350);
$chart->validateChartLayout();
$maxValue = $chart->getAxes()->getVerticalAxis()->getActualMaxValue();
$minValue = $chart->getAxes()->getVerticalAxis()->getActualMinValue();
$majorUnit = $chart->getAxes()->getVerticalAxis()->getActualMajorUnit();
$minorUnit = $chart->getAxes()->getVerticalAxis()->getActualMinorUnit();
$majorUnitScale = $chart->getAxes()->getVerticalAxis()->getActualMajorUnitScale();
$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/php-java/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/php-java/aspose.slides/chartdata/setrange/) 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.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$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/php-java/aspose.slides/axis/setplotorderreversed/) 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/php-java/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.
```php
use aspose\slides\ChartType;
use aspose\slides\CrossesType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredBar, 50, 40, 620, 320);
$chart->setLegend(false);
$chart->getChartData()->getCategories()->clear();
$chart->getChartData()->getSeries()->clear();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$workbook->clear(0);
$series = $chart->getChartData()->getSeries()->add(ChartType::ClusteredBar);
$stages = ["Planning", "Development", "Testing"];
$values = [10, 30, 20];
for ($i = 0; $i < count($stages); $i++) {
$categoryCell = $workbook->getCell(0, $i + 1, 0, $stages[$i]);
$chart->getChartData()->getCategories()->add($categoryCell);
$valueCell = $workbook->getCell(0, $i + 1, 1, $values[$i]);
$series->getDataPoints()->addDataPointForBarSeries($valueCell);
}
// Slide 2: display the first category at the top.
$categorySlide = $presentation->getSlides()->addClone($slide);
$categoryChart = $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.
$valueSlide = $presentation->getSlides()->addClone($slide);
$valueChart = $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/php-java/aspose.slides/axis/setcrosstype/) 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/php-java/aspose.slides/axis/setcrossat/). 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/php-java/aspose.slides/axis/setvisible/) 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.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$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/php-java/aspose.slides/axis/setvisible/) 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.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$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/php-java/aspose.slides/axis/setcategoryaxistype/) 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/php-java/aspose.slides/axis/setautomaticmajorunit/) with `false`, [setMajorUnit](https://reference.aspose.com/slides/php-java/aspose.slides/axis/setmajorunit/) with `1`, and [setMajorUnitScale](https://reference.aspose.com/slides/php-java/aspose.slides/axis/setmajorunitscale/) with `TimeUnitType::Months` places major ticks at one-month intervals.
```php
use aspose\slides\CategoryAxisType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TimeUnitType;
$presentation = new Presentation("ExistingChart.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $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/php-java/aspose.slides/axis/setcategoryaxistypeautomatically/) after populating the categories, then read [getCategoryAxisType](https://reference.aspose.com/slides/php-java/aspose.slides/axis/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/php-java/aspose.slides/chartdatacell/setcustomnumberformat/) 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/php-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/php-java/aspose.slides/axis/setcategoryaxistype/) to match the intended meaning. Numeric values alone do not establish that the categories represent dates.
```php
use aspose\slides\CategoryAxisType;
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 30, 40, 660, 320);
$chart->getChartData()->getCategories()->clear();
$chart->getChartData()->getSeries()->clear();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$workbook->clear(0);
$seriesName = $workbook->getCell(0, 0, 1, "Sales");
$series = $chart->getChartData()->getSeries()->add($seriesName, $chart->getType());
$labels = ["First", "Second", "Third"];
for ($i = 0; $i < count($labels); $i++) {
$categoryCell = $workbook->getCell(0, $i + 1, 0, $labels[$i]);
$chart->getChartData()->getCategories()->add($categoryCell);
$valueCell = $workbook->getCell(0, $i + 1, 1, ($i + 1) * 10);
$series->getDataPoints()->addDataPointForBarSeries($valueCell);
}
$axis = $chart->getAxes()->getHorizontalAxis();
$axis->setCategoryAxisTypeAutomatically();
echo (java_values($axis->getCategoryAxisType()) == CategoryAxisType::Text ? "true" : "false") . PHP_EOL;
$baseDate = gmmktime(0, 0, 0, 12, 30, 1899);
$dates = [gmmktime(0, 0, 0, 1, 1, 2026), gmmktime(0, 0, 0, 1, 2, 2026), gmmktime(0, 0, 0, 2, 1, 2026)];
for ($i = 0; $i < count($dates); $i++) {
$categoryCell = $workbook->getCell(0, $i + 1, 0);
$categoryCell->setValue((float)(($dates[$i] - $baseDate) / 86400));
$categoryCell->setCustomNumberFormat("yyyy-mm-dd");
}
$axis->setCategoryAxisTypeAutomatically();
echo (java_values($axis->getCategoryAxisType()) == CategoryAxisType::Date ? "true" : "false") . PHP_EOL;
$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/php-java/aspose.slides/axis/setautomaticticklabelspacing/) with `false`, then pass the desired category interval to [setTickLabelSpacing](https://reference.aspose.com/slides/php-java/aspose.slides/axis/setticklabelspacing/). 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/php-java/aspose.slides/axis/setautomatictickmarksspacing/) with `false` and use [setTickMarksSpacing](https://reference.aspose.com/slides/php-java/aspose.slides/axis/settickmarksspacing/) 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/php-java/aspose.slides/axis/setmajortickmark/) 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.
```php
use aspose\slides\CategoryAxisType;
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TickMarkType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 30, 40, 660, 320);
$chart->setLegend(false);
$chart->getChartData()->getCategories()->clear();
$chart->getChartData()->getSeries()->clear();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$workbook->clear(0);
$series = $chart->getChartData()->getSeries()->add(ChartType::ClusteredColumn);
for ($i = 0; $i < 24; $i++) {
$categoryCell = $workbook->getCell(0, $i + 1, 0, "Category " . ($i + 1));
$chart->getChartData()->getCategories()->add($categoryCell);
$valueCell = $workbook->getCell(0, $i + 1, 1, 10 + $i % 6 * 5);
$series->getDataPoints()->addDataPointForBarSeries($valueCell);
}
$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.
$manualSlide = $presentation->getSlides()->addClone($slide);
$manualChart = $manualSlide->getShapes()->get_Item(0);
$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.
$restoredSlide = $presentation->getSlides()->addClone($manualSlide);
$restoredChart = $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/php-java/aspose.slides/axesmanager/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/php-java/aspose.slides/axis/setmajorunit/) 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/php-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/php-java/aspose.slides/axis/setcategoryaxistype/) with `CategoryAxisType::Date`, call [setNumberFormatLinkedToSource](https://reference.aspose.com/slides/php-java/aspose.slides/axis/setnumberformatlinkedtosource/) with `false`, and pass `yyyy` to [setNumberFormat](https://reference.aspose.com/slides/php-java/aspose.slides/axis/setnumberformat/) so the category labels display four-digit years independently of the cell formatting.
```php
use aspose\slides\CategoryAxisType;
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::Line, 50, 50, 450, 300);
$chart->getChartData()->getCategories()->clear();
$chart->getChartData()->getSeries()->clear();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$workbook->clear(0);
$baseDate = gmmktime(0, 0, 0, 12, 30, 1899);
$series = $chart->getChartData()->getSeries()->add(ChartType::Line);
for ($i = 0; $i < 4; $i++) {
$date = gmmktime(0, 0, 0, 1, 1, 2015 + $i);
$serialDate = ($date - $baseDate) / 86400;
$categoryCell = $workbook->getCell(0, $i + 1, 0, $serialDate);
$chart->getChartData()->getCategories()->add($categoryCell);
$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/php-java/aspose.slides/axis/settitle/) 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.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$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/php-java/aspose.slides/axis/setaxisbetweencategories/) 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.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$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/php-java/aspose.slides/axis/setdisplayunit/) to scale the labels on a value axis without changing the underlying data. With [DisplayUnitType](https://reference.aspose.com/slides/php-java/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.
```php
use aspose\slides\ChartType;
use aspose\slides\DisplayUnitType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$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/php-java/aspose.slides/axis/setlogarithmic/) with `true` on the value axis and use [setLogBase](https://reference.aspose.com/slides/php-java/aspose.slides/axis/setlogbase/) 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/php-java/aspose.slides/axesmanager/getverticalaxis/). For a horizontal bar chart, it is returned by [getHorizontalAxis](https://reference.aspose.com/slides/php-java/aspose.slides/axesmanager/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.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::Line, 30, 40, 660, 200);
$chart->setLegend(false);
$chart->getChartData()->getCategories()->clear();
$chart->getChartData()->getSeries()->clear();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$workbook->clear(0);
$series = $chart->getChartData()->getSeries()->add(ChartType::Line);
$values = [10, 100, 1000, 10000, 100000];
for ($i = 0; $i < count($values); $i++) {
$categoryCell = $workbook->getCell(0, $i + 1, 0, "Period " . ($i + 1));
$chart->getChartData()->getCategories()->add($categoryCell);
$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.
$logarithmicSlide = $presentation->getSlides()->addClone($slide);
$logarithmicChart = $logarithmicSlide->getShapes()->get_Item(0);
$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/php-java/aspose.slides/axis/setcrosstype/) to select the crossing behavior. To specify a numeric crossing value, use [setCrossAt](https://reference.aspose.com/slides/php-java/aspose.slides/axis/setcrossat/). 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/php-java/aspose.slides/axis/setticklabelposition/) using [TickLabelPositionType](https://reference.aspose.com/slides/php-java/aspose.slides/ticklabelpositiontype/): `Low`, `High`, `NextTo`, or `None`. To control the tick marks themselves, use [setMajorTickMark](https://reference.aspose.com/slides/php-java/aspose.slides/axis/setmajortickmark/) or [setMinorTickMark](https://reference.aspose.com/slides/php-java/aspose.slides/axis/setminortickmark/); these are separate from label positioning.
## Related articles
- [Format Presentation Charts in PHP](https://docs.aspose.com/slides/php-java/chart-formatting/)
# Optimize Chart Calculations for Presentations in PHP
> Understand chart calculations, data updates, and precision control in Aspose.Slides for PHP via Java for PPT and PPTX, with practical code examples.
Source: https://docs.aspose.com/slides/php-java/chart-calculations/
Updated: 2026-08-02
## **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 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 PHP via Java provides a simple API for getting these properties. Methods of the [Axis](https://reference.aspose.com/slides/php-java/aspose.slides/axis/) class provide information about actual position of axis chart element ([getActualMaxValue](https://reference.aspose.com/slides/php-java/aspose.slides/axis/getactualmaxvalue/), [getActualMinValue](https://reference.aspose.com/slides/php-java/aspose.slides/axis/getactualminvalue/), [getActualMajorUnit](https://reference.aspose.com/slides/php-java/aspose.slides/axis/getactualmajorunit/), [getActualMinorUnit](https://reference.aspose.com/slides/php-java/aspose.slides/axis/getactualminorunit/), [getActualMajorUnitScale](https://reference.aspose.com/slides/php-java/aspose.slides/axis/getactualmajorunitscale/), [getActualMinorUnitScale](https://reference.aspose.com/slides/php-java/aspose.slides/axis/getactualminorunitscale/)). It is necessary to call method [Chart.validateChartLayout](https://reference.aspose.com/slides/php-java/aspose.slides/chart/validatechartlayout/) previously to fill properties with actual values.
```php
$pres = new Presentation();
try {
$chart = $pres->getSlides()->get_Item(0)->getShapes()->addChart(ChartType::Area, 100, 100, 500, 350);
$chart->validateChartLayout();
$maxValue = $chart->getAxes()->getVerticalAxis()->getActualMaxValue();
$minValue = $chart->getAxes()->getVerticalAxis()->getActualMinValue();
$majorUnit = $chart->getAxes()->getHorizontalAxis()->getActualMajorUnit();
$minorUnit = $chart->getAxes()->getHorizontalAxis()->getActualMinorUnit();
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Calculate Actual Position of Parent Chart Elements**
Aspose.Slides for PHP via Java provides a simple API for getting these properties. Methods of the `ActualLayout` class provide information about actual position of parent chart element (`getActualX`, `getActualY`, `getActualWidth`, `getActualHeight`). It is necessary to call method [Chart.validateChartLayout](https://reference.aspose.com/slides/php-java/aspose.slides/chart/validatechartlayout/) previously to fill properties with actual values.
```php
$pres = new Presentation();
try {
$chart = $pres->getSlides()->get_Item(0)->getShapes()->addChart(ChartType::ClusteredColumn, 100, 100, 500, 350);
$chart->validateChartLayout();
$x = $chart->getPlotArea()->getActualX();
$y = $chart->getPlotArea()->getActualY();
$w = $chart->getPlotArea()->getActualWidth();
$h = $chart->getPlotArea()->getActualHeight();
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Hide Chart Elements**
This topic helps you to understand how to hide information from chart. Using Aspose.Slides for PHP via Java you can hide **Title, Vertical Axis, Horizontal Axis** and **Grid Lines** from chart. Below code example shows how to use these properties.
```php
$pres = new Presentation();
try {
$slide = $pres->getSlides()->get_Item(0);
$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);
for($i = 0; $i < java_values($chart->getChartData()->getSeries()->size()) ; $i++) {
$chart->getChartData()->getSeries()->removeAt($i);
}
$series = $chart->getChartData()->getSeries()->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(java("java.awt.Color")->MAGENTA);
$series->getFormat()->getLine()->setDashStyle(LineDashStyle->Solid);
$pres->save("HideInformationFromChart.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$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/php-java/aspose.slides/chartdata/setexternalworkbook/) path and manage the linked data.
### Can I compute and display trendlines without implementing regression myself?
Yes. [Trendlines](https://docs.aspose.com/slides/php-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/php-java/aspose.slides/chartdata/setexternalworkbook/), or you can create/replace an external workbook per chart independently of the others.
# Manage Chart Data Labels in Presentations Using PHP
> Learn to add and format chart data labels in PowerPoint presentations using Aspose.Slides for PHP via Java for more engaging slides.
Source: https://docs.aspose.com/slides/php-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/php-java/aspose.slides/datalabelcollection/getcountofvisibledatalabels/) to check how many data labels are enabled for display before publishing a presentation. Unlike [getCount](https://reference.aspose.com/slides/php-java/aspose.slides/datalabelcollection/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/php-java/aspose.slides/chartseries/getlabels/) and prints the visible count as the settings change: **0, 3, 2, 3**. The total count remains **3**.
```php
use aspose\slides\Presentation;
use aspose\slides\ChartType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 50, 50, 500, 300);
$chart->getChartData()->getSeries()->clear();
$chart->getChartData()->getCategories()->clear();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$seriesCell = $workbook->getCell(0, 0, 1, "Values");
$series = $chart->getChartData()->getSeries()->add($seriesCell, $chart->getType());
for ($i = 0; $i < 3; $i++) {
$categoryCell = $workbook->getCell(0, $i + 1, 0, "Category " . ($i + 1));
$chart->getChartData()->getCategories()->add($categoryCell);
$valueCell = $workbook->getCell(0, $i + 1, 1, ($i + 1) * 10);
$series->getDataPoints()->addDataPointForBarSeries($valueCell);
}
$labels = $series->getLabels();
echo "Total: " . java_values($labels->getCount()) . "; visible: " . java_values($labels->getCountOfVisibleDataLabels()) . PHP_EOL; // Total: 3; visible: 0
$labels->getDefaultDataLabelFormat()->setShowValue(true);
echo "Visible: " . java_values($labels->getCountOfVisibleDataLabels()) . PHP_EOL; // Visible: 3
$labels->get_Item(1)->getDataLabelFormat()->setShowValue(false);
echo "Visible: " . java_values($labels->getCountOfVisibleDataLabels()) . PHP_EOL; // Visible: 2
$labels->get_Item(1)->getDataLabelFormat()->setShowLegendKey(true);
echo "Visible: " . java_values($labels->getCountOfVisibleDataLabels()) . PHP_EOL; // Visible: 3
} finally {
$presentation->dispose();
}
```
The series' [getDefaultDataLabelFormat](https://reference.aspose.com/slides/php-java/aspose.slides/datalabelcollection/getdefaultdatalabelformat/) supplies the default settings. Passing `true` to [setShowValue](https://reference.aspose.com/slides/php-java/aspose.slides/datalabelformat/setshowvalue/) there displays values for all three labels. Passing `false` through one label's [getDataLabelFormat](https://reference.aspose.com/slides/php-java/aspose.slides/datalabel/getdatalabelformat/) overrides that setting for the selected label. Passing `true` to [setShowLegendKey](https://reference.aspose.com/slides/php-java/aspose.slides/datalabelformat/setshowlegendkey/) 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/php-java/aspose.slides/chartseries/setnumberformatofvalues/) 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.
```php
use aspose\slides\Presentation;
use aspose\slides\ChartType;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::Line, 50, 50, 450, 300);
$chart->setDataTable(true);
$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/php-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/php-java/aspose.slides/datalabel/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.
```php
use aspose\slides\Presentation;
use aspose\slides\ChartType;
use aspose\slides\Portion;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::StackedColumn, 20, 20, 400, 400);
$categoryCount = java_values($chart->getChartData()->getCategories()->size());
$categoryTotals = array_fill(0, $categoryCount, 0.0);
for ($k = 0; $k < $categoryCount; $k++) {
for ($i = 0; $i < java_values($chart->getChartData()->getSeries()->size()); $i++) {
$series = $chart->getChartData()->getSeries()->get_Item($i);
$pointValue = java_values($series->getDataPoints()->get_Item($k)->getValue()->getData());
$categoryTotals[$k] += $pointValue;
}
}
for ($x = 0; $x < java_values($chart->getChartData()->getSeries()->size()); $x++) {
$series = $chart->getChartData()->getSeries()->get_Item($x);
$series->getLabels()->getDefaultDataLabelFormat()->setShowLegendKey(false);
for ($j = 0; $j < java_values($series->getDataPoints()->size()); $j++) {
$label = $series->getDataPoints()->get_Item($j)->getLabel();
if ($categoryTotals[$j] == 0) {
continue;
}
$pointValue = java_values($series->getDataPoints()->get_Item($j)->getValue()->getData());
$dataPointPercent = ($pointValue / $categoryTotals[$j]) * 100;
$portion = new Portion();
$portion->setText(sprintf("%.2F %%", $dataPointPercent));
$portion->getPortionFormat()->setFontHeight(8);
$label->getTextFrameForOverriding()->setText("");
$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/php-java/aspose.slides/datalabelformat/setnumberformat/) to display percentages. Pass `false` to [setNumberFormatLinkedToSource](https://reference.aspose.com/slides/php-java/aspose.slides/datalabelformat/setnumberformatlinkedtosource/) 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.
```php
use aspose\slides\Presentation;
use aspose\slides\ChartType;
use aspose\slides\FillType;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$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();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$worksheetIndex = 0;
for ($i = 0; $i < 4; $i++) {
$categoryCell = $workbook->getCell($worksheetIndex, $i + 1, 0, "Category " . ($i + 1));
$chart->getChartData()->getCategories()->add($categoryCell);
}
$colors = java("java.awt.Color");
$seriesNames = [ "Reds", "Blues" ];
$seriesColors = [ $colors->RED, $colors->BLUE ];
$values = [ [ 0.30, 0.50, 0.80, 0.65 ], [ 0.70, 0.50, 0.20, 0.35 ] ];
for ($i = 0; $i < count($seriesNames); $i++) {
$seriesCell = $workbook->getCell($worksheetIndex, 0, $i + 1, $seriesNames[$i]);
$series = $chart->getChartData()->getSeries()->add($seriesCell, $chart->getType());
for ($j = 0; $j < 4; $j++) {
$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]);
$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($colors->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/php-java/aspose.slides/datalabel/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/php-java/aspose.slides/datalabelformat/) 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/php-java/aspose.slides/datalabel/gettextframeforoverriding/).
```php
use aspose\slides\Presentation;
use aspose\slides\ChartType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 20, 20, 500, 300);
$chart->getChartData()->getSeries()->clear();
$chart->getChartData()->getCategories()->clear();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$firstCategoryCell = $workbook->getCell(0, 1, 0, "Q1");
$chart->getChartData()->getCategories()->add($firstCategoryCell);
$secondCategoryCell = $workbook->getCell(0, 2, 0, "Q2");
$chart->getChartData()->getCategories()->add($secondCategoryCell);
$northSeriesCell = $workbook->getCell(0, 0, 1, "North");
$north = $chart->getChartData()->getSeries()->add($northSeriesCell, $chart->getType());
$northFirstValueCell = $workbook->getCell(0, 1, 1, 0.25);
$north->getDataPoints()->addDataPointForBarSeries($northFirstValueCell);
$northSecondValueCell = $workbook->getCell(0, 2, 1, 0.75);
$north->getDataPoints()->addDataPointForBarSeries($northSecondValueCell);
$southSeriesCell = $workbook->getCell(0, 0, 2, "South");
$south = $chart->getChartData()->getSeries()->add($southSeriesCell, $chart->getType());
$southFirstValueCell = $workbook->getCell(0, 1, 2, 0.40);
$south->getDataPoints()->addDataPointForBarSeries($southFirstValueCell);
$southSecondValueCell = $workbook->getCell(0, 2, 2, 0.60);
$south->getDataPoints()->addDataPointForBarSeries($southSecondValueCell);
for ($i = 0; $i < java_values($chart->getChartData()->getSeries()->size()); $i++) {
$series = $chart->getChartData()->getSeries()->get_Item($i);
$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 ($i = 0; $i < java_values($chart->getChartData()->getSeries()->size()); $i++) {
$series = $chart->getChartData()->getSeries()->get_Item($i);
for ($j = 0; $j < java_values($series->getDataPoints()->size()); $j++) {
$point = $series->getDataPoints()->get_Item($j);
$label = $point->getLabel();
if (!java_values($label->isVisible())) {
continue;
}
echo "Value: " . java_values($point->getValue()->getData()) . "; label: " . java_values($label->getActualLabelText()) . PHP_EOL;
}
}
} 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/php-java/aspose.slides/datalabel/getactuallabeltext/) returns the resulting label string in either case. Check [isVisible](https://reference.aspose.com/slides/php-java/aspose.slides/datalabel/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/php-java/aspose.slides/chart/setshowdatalabelsovermaximum/) 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/php-java/aspose.slides/axis/setautomaticmaxvalue/) and sets the maximum to 100 with [setMaxValue](https://reference.aspose.com/slides/php-java/aspose.slides/axis/setmaxvalue/) 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/php-java/aspose.slides/datalabelformat/setshowvalue/). 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/php-java/aspose.slides/datalabelformat/setposition/) to place labels at the outside end of each column.
```php
use aspose\slides\Presentation;
use aspose\slides\ChartType;
use aspose\slides\LegendDataLabelPosition;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 50, 50, 600, 400);
$chart->setLegend(false);
$chart->getChartData()->getSeries()->clear();
$chart->getChartData()->getCategories()->clear();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$firstCategory = $workbook->getCell(0, 1, 0, "Within range");
$secondCategory = $workbook->getCell(0, 2, 0, "Above maximum");
$chart->getChartData()->getCategories()->add($firstCategory);
$chart->getChartData()->getCategories()->add($secondCategory);
$seriesName = $workbook->getCell(0, 0, 1, "Values");
$series = $chart->getChartData()->getSeries()->add($seriesName, $chart->getType());
$firstValue = $workbook->getCell(0, 1, 1, 60);
$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);
$secondSlide = $presentation->getSlides()->addClone($slide);
$secondChart = $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/php-java/aspose.slides/axis/setlabeloffset/) 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.
```php
use aspose\slides\Presentation;
use aspose\slides\ChartType;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$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/php-java/aspose.slides/datalabel/setx/) and [setY](https://reference.aspose.com/slides/php-java/aspose.slides/datalabel/sety/). These offsets are relative to the chart width and height, respectively.
```php
use aspose\slides\Presentation;
use aspose\slides\ChartType;
use aspose\slides\LegendDataLabelPosition;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::Pie, 50, 50, 200, 200);
$series = $chart->getChartData()->getSeries();
$label = $series->get_Item(0)->getLabels()->get_Item(0);
$label->getDataLabelFormat()->setShowValue(true);
$label->getDataLabelFormat()->setPosition(LegendDataLabelPosition::OutsideEnd);
$label->setX(0.71);
$label->setY(0.04);
$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/php-java/aspose.slides/datalabelcollection/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/php-java/aspose.slides/datalabelformat/setshowleaderlines/). It moves two labels farther from their slices using [setX](https://reference.aspose.com/slides/php-java/aspose.slides/datalabel/setx/) and [setY](https://reference.aspose.com/slides/php-java/aspose.slides/datalabel/sety/) offsets, expressed as fractions of the chart width and height. No input presentation is required.
The line's [getFillFormat](https://reference.aspose.com/slides/php-java/aspose.slides/lineformat/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/php-java/aspose.slides/lineformat/setwidth/) sets the thickness to 2 points, and [setDashStyle](https://reference.aspose.com/slides/php-java/aspose.slides/lineformat/setdashstyle/) makes the line dashed.
```php
use aspose\slides\Presentation;
use aspose\slides\ChartType;
use aspose\slides\LegendDataLabelPosition;
use aspose\slides\FillType;
use aspose\slides\LineDashStyle;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::Pie, 80, 50, 560, 400);
$chart->setLegend(false);
$series = $chart->getChartData()->getSeries()->get_Item(0);
$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.10);
$series->getLabels()->get_Item(0)->setY(-0.05);
$series->getLabels()->get_Item(1)->setX(-0.10);
$series->getLabels()->get_Item(1)->setY(0.05);
$line = $series->getLabels()->getLeaderLinesFormat()->getLine();
$line->getFillFormat()->setFillType(FillType::Solid);
$lineColor = new Java("java.awt.Color", 30, 90, 160, 191);
$line->getFillFormat()->getSolidFillColor()->setColor($lineColor);
$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/php-java/aspose.slides/chartseriesgroup/setoverlap/) method aligns all three series with the same category centers.
The [ChartPlotArea](https://reference.aspose.com/slides/php-java/aspose.slides/chartplotarea/) settings reserve space for the label rows. After [Chart::validateChartLayout](https://reference.aspose.com/slides/php-java/aspose.slides/chart/validatechartlayout/) calculates the default positions, [DataLabel::setX](https://reference.aspose.com/slides/php-java/aspose.slides/datalabel/setx/) and [DataLabel::setY](https://reference.aspose.com/slides/php-java/aspose.slides/datalabel/sety/) 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.
```php
use aspose\slides\Presentation;
use aspose\slides\ChartType;
use aspose\slides\FillType;
use aspose\slides\LegendDataLabelPosition;
use aspose\slides\LayoutTargetType;
use aspose\slides\ShapeType;
use aspose\slides\SaveFormat;
$colors = java("java.awt.Color");
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$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();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$workbook->clear(0);
$categories = [ "North", "South", "East", "West" ];
$seriesNames = [ "Series A", "Series B", "Series C" ];
$seriesValues = [
[ 35, 42, 28, 47 ],
[ 22, 31, 19, 26 ],
[ 12, 16, 14, 18 ]
];
for ($categoryIndex = 0; $categoryIndex < count($categories); $categoryIndex++) {
$categoryCell = $workbook->getCell(0, $categoryIndex + 1, 0, $categories[$categoryIndex]);
$chart->getChartData()->getCategories()->add($categoryCell);
}
for ($seriesIndex = 0; $seriesIndex < count($seriesNames); $seriesIndex++) {
$seriesCell = $workbook->getCell(0, 0, $seriesIndex + 1, $seriesNames[$seriesIndex]);
$series = $chart->getChartData()->getSeries()->add($seriesCell, ChartType::ClusteredColumn);
for ($categoryIndex = 0; $categoryIndex < count($categories); $categoryIndex++) {
$valueCell = $workbook->getCell(0, $categoryIndex + 1, $seriesIndex + 1, $seriesValues[$seriesIndex][$categoryIndex]);
$series->getDataPoints()->addDataPointForBarSeries($valueCell);
}
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);
$labelFormat = $series->getLabels()->getDefaultDataLabelFormat();
$labelFormat->setShowValue(true);
$labelFormat->getTextFormat()->getPortionFormat()->setFontHeight(12);
$labelFill = $labelFormat->getTextFormat()->getPortionFormat()->getFillFormat();
$labelFill->setFillType(FillType::Solid);
$labelFill->getSolidFillColor()->setColor($colors->BLACK);
$labelFormat->setPosition(LegendDataLabelPosition::InsideBase);
}
}
// Align all three series with the same category centers.
$chart->getChartData()->getSeries()->get_Item(0)->getParentSeriesGroup()->setOverlap(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.15);
$chart->getPlotArea()->setY(0.32);
$chart->getPlotArea()->setWidth(0.80);
$chart->getPlotArea()->setHeight(0.48);
$chart->validateChartLayout();
$chartX = java_values($chart->getX());
$chartY = java_values($chart->getY());
$chartHeight = java_values($chart->getHeight());
for ($seriesIndex = 1; $seriesIndex < count($seriesNames); $seriesIndex++) {
$series = $chart->getChartData()->getSeries()->get_Item($seriesIndex);
$rowTop = $seriesIndex == 1 ? 0.15 : 0.03;
for ($categoryIndex = 0; $categoryIndex < count($categories); $categoryIndex++) {
$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.
$actualY = java_values($dataLabel->getActualY());
$dataLabel->setX(0);
$dataLabel->setY($rowTop - $actualY / $chartHeight);
}
// Only the row heading is a separate text shape.
$rowHeading = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, $chartX, $chartY + $rowTop * $chartHeight, 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);
$headingFormat = $rowHeading->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0)->getPortionFormat();
$headingFormat->setFontHeight(12);
$headingFormat->getFillFormat()->setFillType(FillType::Solid);
$headingFormat->getFillFormat()->getSolidFillColor()->setColor($colors->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 PHP
> Learn how to customize chart data markers in Aspose.Slides for PHP, boosting presentation impact across PPT and PPTX formats with clear code examples.
Source: https://docs.aspose.com/slides/php-java/chart-data-marker/
Updated: 2026-08-02
## **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/php-java/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.
```php
# Creating empty presentation
$pres = new Presentation();
try {
# Access first slide
$slide = $pres->getSlides()->get_Item(0);
# Creating the default chart
$chart = $slide->getShapes()->addChart(ChartType::LineWithMarkers, 0, 0, 400, 400);
# Getting the default chart data WorkSheet index
$defaultWorksheetIndex = 0;
# Getting the chart data WorkSheet
$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
$imgx1 = $pres->getImages()->addImage(new Java("java.io.FileInputStream", new Java("java.io.File", "Desert.jpg")));
# Load the picture 2
$imgx2 = $pres->getImages()->addImage(new Java("java.io.FileInputStream", new Java("java.io.File", "Tulips.jpg")));
# Take first chart series
$series = $chart->getChartData()->getSeries()->get_Item(0);
# Add new point (1:3) there.
$point = $series->getDataPoints()->addDataPointForLineSeries($fact->getCell($defaultWorksheetIndex, 1, 1, 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, 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, 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, 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("ScatterChart.pptx", SaveFormat::Pptx);
} catch (JavaException $e) {
} finally {
if (!java_is_null($pres)) {
$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/php-java/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/php-java/convert-powerpoint-to-png/) or saving [shapes as SVG](https://docs.aspose.com/slides/php-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 PHP
> Customize chart data table fonts, borders, and legend keys in PowerPoint presentations using Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/chart-data-table/
Updated: 2026-09-24
## **Overview**
Aspose.Slides for PHP via 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/php-java/aspose.slides/chart/setdatatable/). Use [getChartDataTable](https://reference.aspose.com/slides/php-java/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/php-java/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/php-java/aspose.slides/baseportionformat/#setFontBold) and pass `20` to [setFontHeight](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setFontHeight) 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.
```php
use aspose\slides\ChartType;
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("test.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 50, 50, 600, 400);
$chart->setDataTable(true);
$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 [Chart::setDataTable](https://reference.aspose.com/slides/php-java/aspose.slides/chart/setdatatable/) and access it through [Chart::getChartDataTable](https://reference.aspose.com/slides/php-java/aspose.slides/chart/getchartdatatable/). You can control three types of borders independently:
- [setBorderHorizontal](https://reference.aspose.com/slides/php-java/aspose.slides/datatable/setborderhorizontal/) controls horizontal cell borders.
- [setBorderVertical](https://reference.aspose.com/slides/php-java/aspose.slides/datatable/setbordervertical/) controls vertical cell borders.
- [setBorderOutline](https://reference.aspose.com/slides/php-java/aspose.slides/datatable/setborderoutline/) 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.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 50, 50, 600, 400);
$chart->setDataTable(true);
$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/php-java/aspose.slides/datatable/setshowlegendkey/) to show these markers or `false` to hide them.
The chart's separate legend is controlled by [Chart::setLegend](https://reference.aspose.com/slides/php-java/aspose.slides/chart/setlegend/). 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/php-java/aspose.slides/datatable/setshowlegendkey/).
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 50, 50, 600, 400);
$chart->setDataTable(true);
$chart->setLegend(false);
$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/php-java/aspose.slides/datatable/setshowlegendkey/) 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/php-java/convert-powerpoint-to-pdf/), [HTML](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-html/), or [images](https://docs.aspose.com/slides/php-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/php-java/aspose.slides/chart/hasdatatable/) and [setDataTable](https://reference.aspose.com/slides/php-java/aspose.slides/chart/setdatatable/) 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/php-java/aspose.slides/chart/hasdatatable/) method. A value of `true` indicates that the data table is enabled.
# Customize Presentation Chart Entities in PHP
> Understand chart entities in Aspose.Slides for PHP via Java and learn to manage series, categories, data points and axes in PowerPoint PPT and PPTX.
Source: https://docs.aspose.com/slides/php-java/chart-entities/
Updated: 2025-11-30
---
lastmod: 2025-11-30T13:47:17+04:00
title: Customize Presentation Chart Entities in PHP
linktitle: Chart Entities
type: docs
weight: 30
url: /php-java/chart-entities/
keywords:
- callout
- axis
- data label
- data marker
- data table
- legend
- plot area
- data series
- error bar
- trend line
- PowerPoint
- presentation
- PHP
- Aspose.Slides
description: "Understand chart entities in Aspose.Slides for PHP via Java and learn to manage series, categories, data points and axes in PowerPoint PPT and PPTX."
---
## Related articles
- [Create and Customize PowerPoint Charts in PHP](https://docs.aspose.com/slides/php-java/powerpoint-charts/)
- [Format Presentation Charts in PHP](https://docs.aspose.com/slides/php-java/chart-formatting/)
- [Chart](https://docs.aspose.com/slides/php-java/examples/elements/chart/)
# Format Presentation Charts in PHP
> Learn chart formatting in Aspose.Slides for PHP via Java and elevate your PowerPoint presentation with custom axes, fonts, number formats, and rounded chart borders.
Source: https://docs.aspose.com/slides/php-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/php-java/create-chart/#create-stock-charts).
## **Format Chart Entities**
Use [Chart](https://reference.aspose.com/slides/php-java/aspose.slides/chart/) 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/php-java/aspose.slides/axis/setnumberformat/) 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/php-java/aspose.slides/axis/setdisplayunit/) 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/php-java/aspose.slides/legend/setoverlay/) is called with `false`. Back-wall and floor fills are configured through [getBackWall](https://reference.aspose.com/slides/php-java/aspose.slides/chart/getbackwall/) and [getFloor](https://reference.aspose.com/slides/php-java/aspose.slides/chart/getfloor/), but these surfaces are only visible in 3D charts.
```php
use aspose\slides\ChartType;
use aspose\slides\DisplayUnitType;
use aspose\slides\FillType;
use aspose\slides\FontData;
use aspose\slides\LineDashStyle;
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\PresetColor;
use aspose\slides\SaveFormat;
use aspose\slides\TickLabelPositionType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::LineWithMarkers, 50, 50, 500, 400);
$chart->setTitle(true);
$chart->getChartTitle()->addTextFrameForOverriding("");
$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(java("java.awt.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(java("java.awt.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(java("java.awt.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(15);
$chart->getAxes()->getVerticalAxis()->setMinValue(-2);
$chart->getAxes()->getVerticalAxis()->setMinorUnit(0.5);
$chart->getAxes()->getVerticalAxis()->setMajorUnit(2.0);
$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("");
$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(java("java.awt.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 Java("java.awt.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(java("java.awt.Color")->YELLOW);
$chart->getAxes()->getHorizontalAxis()->getMinorGridLinesFormat()->getLine()->setWidth(3);
$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(java("java.awt.Color")->BLUE);
$categoryAxisText->setLatinFont(new FontData("Arial"));
$chart->getAxes()->getHorizontalAxis()->setTitle(true);
$chart->getAxes()->getHorizontalAxis()->getTitle()->addTextFrameForOverriding("");
$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(java("java.awt.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);
$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 Java("java.awt.Color", 255, 165, 0));
$chart->getFloor()->getFormat()->getFill()->setFillType(FillType::Solid);
$chart->getFloor()->getFormat()->getFill()->getSolidFillColor()->setColor(java("java.awt.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/php-java/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/php-java/aspose.slides/datalabelformat/setshowvalue/). Text elements with their own explicit font settings can override the chart default.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$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 [ChartDataCell::setPresetNumberFormat](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatacell/setpresetnumberformat/) 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.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 50, 50, 500, 400);
$series = $chart->getChartData()->getSeries();
for ($i = 0; $i < java_values($series->size()); $i++) {
$chartSeries = $series->get_Item($i);
$dataPoints = $chartSeries->getDataPoints();
for ($j = 0; $j < java_values($dataPoints->size()); $j++) {
$dataPoint = $dataPoints->get_Item($j);
$dataPoint->getValue()->getAsCell()->setPresetNumberFormat(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 [Chart::setRoundedCorners](https://reference.aspose.com/slides/php-java/aspose.slides/chart/setroundedcorners/) 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/php-java/aspose.slides/shape/getlineformat/) to give its outline a solid gray color and a single-line style before saving the presentation.
```php
use aspose\slides\ChartType;
use aspose\slides\FillType;
use aspose\slides\LineStyle;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 20, 100, 600, 400);
$chart->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$chart->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.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 [Chart::getUserShapes](https://reference.aspose.com/slides/php-java/aspose.slides/chart/getusershapes/). The collection returned by [getShapes](https://reference.aspose.com/slides/php-java/aspose.slides/groupshape/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/php-java/aspose.slides/slide/) 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/php-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 [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/) with a non-null text frame returned by [getTextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/gettextframe/) and the expected text.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("chart-annotations.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$chartType = new JavaClass("com.aspose.slides.IChart");
$autoShapeType = new JavaClass("com.aspose.slides.IAutoShape");
$chart = null;
for ($i = 0; $i < java_values($slide->getShapes()->size()); $i++) {
$shape = $slide->getShapes()->get_Item($i);
if (java_instanceof($shape, $chartType)) {
$chart = $shape;
break;
}
}
if ($chart === null || java_values($chart->getUserShapes()->getShapes()->size()) == 0) {
echo "No chart or chart-owned shapes found." . PHP_EOL;
return;
}
$updated = false;
$userShapes = $chart->getUserShapes()->getShapes();
for ($i = 0; $i < java_values($userShapes->size()); $i++) {
$shape = $userShapes->get_Item($i);
if (java_instanceof($shape, $autoShapeType)) {
$annotation = $shape;
if (!java_is_null($annotation->getTextFrame()) && java_values($annotation->getTextFrame()->getText()) === "Preliminary results") {
$annotation->getTextFrame()->setText("Final results");
$updated = true;
break;
}
}
}
if ($updated) {
$presentation->save("chart-annotations-updated.pptx", SaveFormat::Pptx);
} else {
echo "No matching text annotation found." . PHP_EOL;
}
} 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 a [GroupShape](https://reference.aspose.com/slides/php-java/aspose.slides/groupshape/), inspect that group's [getShapes](https://reference.aspose.com/slides/php-java/aspose.slides/groupshape/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 PHP](https://docs.aspose.com/slides/php-java/chart-axis/)
- [Customize Presentation Chart Entities in PHP](https://docs.aspose.com/slides/php-java/chart-entities/)
# Customize Chart Legends in Presentations Using PHP
> Customize chart legends with Aspose.Slides for PHP via Java to optimize PowerPoint presentations with tailored legend formatting.
Source: https://docs.aspose.com/slides/php-java/chart-legend/
Updated: 2026-09-30
## **Overview**
Aspose.Slides for PHP via 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/php-java/aspose.slides/legend/setx/), [setY](https://reference.aspose.com/slides/php-java/aspose.slides/legend/sety/), [setWidth](https://reference.aspose.com/slides/php-java/aspose.slides/legend/setwidth/), and [setHeight](https://reference.aspose.com/slides/php-java/aspose.slides/legend/setheight/) 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. The example uses java_values to convert the chart dimensions returned by PHP/Java Bridge to PHP numbers before division.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 50, 50, 500, 500);
$chartWidth = java_values($chart->getWidth());
$chartHeight = java_values($chart->getHeight());
// Express the legend's position and size relative to the chart.
$chart->getLegend()->setX(50 / $chartWidth);
$chart->getLegend()->setY(50 / $chartHeight);
$chart->getLegend()->setWidth(100 / $chartWidth);
$chart->getLegend()->setHeight(100 / $chartHeight);
$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/php-java/aspose.slides/legend/gettextformat/) to access its text formatting and use [setFontHeight](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setFontHeight) 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.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$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/php-java/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.
```php
use aspose\slides\ChartType;
use aspose\slides\FillType;
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 50, 50, 600, 400);
$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(java("java.awt.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 [LegendEntryProperties::setHide](https://reference.aspose.com/slides/php-java/aspose.slides/legendentryproperties/sethide/) with `true` through [ChartSeries::getRelatedLegendEntry](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/getrelatedlegendentry/). This hides only the selected legend entry; it does not remove the series or its data points. Calling [Chart::setLegend](https://reference.aspose.com/slides/php-java/aspose.slides/chart/setlegend/) 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/php-java/aspose.slides/legendentryproperties/sethide/) with `false` and saves a second copy. The columns remain visible in both files.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 50, 50, 600, 400);
$chart->setLegend(true);
$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 [ChartDataPoint::getRelatedLegendEntry](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapoint/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/php-java/aspose.slides/legend/setoverlay/) 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 PHP
> Discover how to customize chart plot areas in PowerPoint presentations with Aspose.Slides for PHP via Java. Improve your slide visuals effortlessly.
Source: https://docs.aspose.com/slides/php-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 PHP via Java provides a simple API for .
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation) class.
1. Access first slide.
1. Add chart with default data.
1. Call method [Chart.validateChartLayout](https://reference.aspose.com/slides/php-java/aspose.slides/chart/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.
```php
# Create an instance of Presentation class
$pres = new Presentation();
try {
$chart = $pres->getSlides()->get_Item(0)->getShapes()->addChart(ChartType::ClusteredColumn, 100, 100, 500, 350);
$chart->validateChartLayout();
$x = $chart->getPlotArea()->getActualX();
$y = $chart->getPlotArea()->getActualY();
$w = $chart->getPlotArea()->getActualWidth();
$h = $chart->getPlotArea()->getActualHeight();
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Set the Layout Mode of a Chart Plot Area**
Aspose.Slides for PHP via Java provides a simple API to set the layout mode of the chart plot area. Methods [**setLayoutTargetType**](https://reference.aspose.com/slides/php-java/aspose.slides/ChartPlotArea#setLayoutTargetType-int-) and [**getLayoutTargetType**](https://reference.aspose.com/slides/php-java/aspose.slides/ChartPlotArea#getLayoutTargetType--) have been added to [**ChartPlotArea**](https://reference.aspose.com/slides/php-java/aspose.slides/ChartPlotArea) class. 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/php-java/aspose.slides/LayoutTargetType) enum.
- [**LayoutTargetType::Inner**](https://reference.aspose.com/slides/php-java/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/php-java/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/php-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.
```php
# Create an instance of Presentation class
$pres = new Presentation();
try {
$slide = $pres->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 20, 100, 600, 400);
$chart->getPlotArea()->setX(0.2);
$chart->getPlotArea()->setY(0.2);
$chart->getPlotArea()->setWidth(0.7);
$chart->getPlotArea()->setHeight(0.7);
$chart->getPlotArea()->setLayoutTargetType(LayoutTargetType::Inner);
$pres->save("SetLayoutMode_outer.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$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 PHP
> Learn how to manage chart series, data points, workbook cells, formatting, overlap, gap width, and negative values in presentations with PHP.
Source: https://docs.aspose.com/slides/php-java/chart-series/
Updated: 2026-10-26
## **Overview**
A chart can store its plotted values in workbook cells or directly as numeric literals. A [ChartSeries](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/) represents one set of related values, and each [ChartDataPoint](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapoint/) represents a point in that series. [ChartCategory](https://reference.aspose.com/slides/php-java/aspose.slides/chartcategory/) objects provide the labels or grouping values shared by the series. In charts created with default data, series names, categories, and point values use [ChartDataCell](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatacell/) 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 [ChartDataWorkbook::getCell](https://reference.aspose.com/slides/php-java/aspose.slides/chartdataworkbook/getcell/) 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 [ChartSeries::getFormat](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/getformat/), provide the default appearance for all points in one series.
- Data-point settings, such as [ChartDataPoint::getFormat](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapoint/getformat/), override the series appearance for one point.
- Group settings apply to compatible series that belong to the same [ChartSeriesGroup](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/). Access the group through [ChartSeries::getParentSeriesGroup](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/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/php-java/aspose.slides/chartdatapointcollection/setdatasourcetypeforvalues/) with [DataSourceType::DoubleLiterals](https://reference.aspose.com/slides/php-java/aspose.slides/datasourcetype/) before assigning each point's [getValue](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapoint/getvalue/) result through [setAsLiteralDouble](https://reference.aspose.com/slides/php-java/aspose.slides/doublechartvalue/setasliteraldouble/).
The collection setting controls the source type of all point values in that series. Each point value's [getDataSourceType](https://reference.aspose.com/slides/php-java/aspose.slides/basechartvalue/) method reports the selected type; change it through the collection setting. With `Worksheet`, use [getAsCell](https://reference.aspose.com/slides/php-java/aspose.slides/doublechartvalue/getascell/) to access the referenced cell. With `DoubleLiterals`, use [getAsLiteralDouble](https://reference.aspose.com/slides/php-java/aspose.slides/doublechartvalue/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.
```php
use aspose\slides\ChartType;
use aspose\slides\DataSourceType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 20, 20, 500, 300);
$series = $chart->getChartData()->getSeries()->get_Item(0);
$series->getDataPoints()->setDataSourceTypeForValues(DataSourceType::DoubleLiterals);
$pointCount = java_values($series->getDataPoints()->size());
for ($i = 0; $i < $pointCount; $i++) {
$series->getDataPoints()->get_Item($i)->getValue()->setAsLiteralDouble(($i + 1) * 10);
}
$presentation->save("numeric_literals.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
$reopenedPresentation = new Presentation("numeric_literals.pptx");
try {
$reopenedSlide = $reopenedPresentation->getSlides()->get_Item(0);
$reopenedChart = $reopenedSlide->getShapes()->get_Item(0);
$reopenedSeries = $reopenedChart->getChartData()->getSeries()->get_Item(0);
$pointCount = java_values($reopenedSeries->getDataPoints()->size());
for ($i = 0; $i < $pointCount; $i++) {
$point = $reopenedSeries->getDataPoints()->get_Item($i);
echo java_values($point->getValue()->getAsLiteralDouble()), PHP_EOL;
}
} finally {
$reopenedPresentation->dispose();
}
```
The point value source type is separate from [ChartData::getDataSourceType](https://reference.aspose.com/slides/php-java/aspose.slides/chartdata/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/php-java/chart-workbook/) for workbook management.
For scatter and bubble charts, use [setDataSourceTypeForXValues](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapointcollection/setdatasourcetypeforxvalues/) and [setDataSourceTypeForYValues](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapointcollection/setdatasourcetypeforyvalues/) to choose the sources for [getXValue](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapoint/getxvalue/) and [getYValue](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapoint/getyvalue/). Bubble charts also use [setDataSourceTypeForBubbleSizes](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapointcollection/setdatasourcetypeforbubblesizes/) for [getBubbleSize](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapoint/getbubblesize/). Set each applicable source to `DoubleLiterals` before assigning numbers through that value's `setAsLiteralDouble` method.
## **Set the Chart Series Overlap**
[ChartSeries::getOverlap](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/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 [ChartSeriesGroup::setOverlap](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/setoverlap/) 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:
```php
$firstSlideIndex = 0;
$firstSeriesIndex = 0;
$overlapPercent = 30;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item($firstSlideIndex);
// The new chart contains sample series, categories, and values.
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 20, 20, 500, 200);
$series = $chart->getChartData()->getSeries()->get_Item($firstSeriesIndex);
$series->getParentSeriesGroup()->setOverlap($overlapPercent);
$presentation->save("series_overlap.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
The result:

## **Change the Series Fill Color**
Use [ChartSeries::getFormat](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/getformat/) to set the default fill for an entire series. If a point already has an explicit fill, its [ChartDataPoint::getFormat](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapoint/getformat/) setting overrides the series fill for that point.
The following example applies a solid blue fill to the first series:
```php
$firstSlideIndex = 0;
$firstSeriesIndex = 0;
$blueColor = java("java.awt.Color")->BLUE;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item($firstSlideIndex);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 20, 20, 500, 200);
$series = $chart->getChartData()->getSeries()->get_Item($firstSeriesIndex);
$series->getFormat()->getFill()->setFillType(FillType::Solid);
$series->getFormat()->getFill()->getSolidFillColor()->setColor($blueColor);
$presentation->save("series_color.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$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 variables in the following example make that structure explicit:
```php
$firstSlideIndex = 0;
$worksheetIndex = 0;
$seriesNameRowIndex = 0;
$firstSeriesColumnIndex = 1;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item($firstSlideIndex);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 20, 20, 500, 200);
$workbook = $chart->getChartData()->getChartDataWorkbook();
$seriesNameCell = $workbook->getCell($worksheetIndex, $seriesNameRowIndex, $firstSeriesColumnIndex);
$seriesNameCell->setValue("Revenue");
$presentation->save("series_name.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
You can also update the cell already referenced by [ChartSeries::getName](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/getname/). This approach avoids assuming a particular row and column in an existing chart:
```php
$firstSlideIndex = 0;
$firstSeriesIndex = 0;
$firstNameCellIndex = 0;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item($firstSlideIndex);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 20, 20, 500, 200);
$series = $chart->getChartData()->getSeries()->get_Item($firstSeriesIndex);
$seriesNameCell = $series->getName()->getAsCells()->get_Item($firstNameCellIndex);
$seriesNameCell->setValue("Revenue");
$presentation->save("series_name.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$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 [ChartDataWorkbook::getCellCollection](https://reference.aspose.com/slides/php-java/aspose.slides/chartdataworkbook/getcellcollection/) to retrieve the name range, then pass that collection to [ChartSeriesCollection::add](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriescollection/add/). 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.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 50, 50, 620, 180);
$chart->getChartData()->getSeries()->clear();
$chart->getChartData()->getCategories()->clear();
$chart->setLegend(true);
$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");
$nameCells = $workbook->getCellCollection('Sheet1!$B$1:$C$1', false);
$series = $chart->getChartData()->getSeries()->add($nameCells, ChartType::ClusteredColumn);
// Separate cells supply the categories and numeric data points.
$northCategory = $workbook->getCell(0, 1, 0, "North");
$southCategory = $workbook->getCell(0, 2, 0, "South");
$chart->getChartData()->getCategories()->add($northCategory);
$chart->getChartData()->getCategories()->add($southCategory);
$northValue = $workbook->getCell(0, 1, 1, 120);
$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**
[ChartSeries::getAutomaticSeriesColor](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/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:
```php
$firstSlideIndex = 0;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item($firstSlideIndex);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 20, 20, 500, 200);
$seriesCount = java_values($chart->getChartData()->getSeries()->size());
for ($seriesIndex = 0; $seriesIndex < $seriesCount; $seriesIndex++) {
$series = $chart->getChartData()->getSeries()->get_Item($seriesIndex);
$automaticColor = $series->getAutomaticSeriesColor();
$red = java_values($automaticColor->getRed());
$green = java_values($automaticColor->getGreen());
$blue = java_values($automaticColor->getBlue());
echo "Series " . $seriesIndex . ": java.awt.Color[r=" . $red . ",g=" . $green . ",b=" . $blue . "]" . PHP_EOL;
}
} finally {
if (!java_is_null($presentation)) {
$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, [ChartSeries::setInvertIfNegative](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/setinvertifnegative/) can display negative values with a different fill. Set the regular series fill to solid, enable inversion, and assign the negative-value color through [ChartSeries::getInvertedSolidFillColor](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/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:
```php
$firstSlideIndex = 0;
$worksheetIndex = 0;
$headerRowIndex = 0;
$categoryColumnIndex = 0;
$firstSeriesColumnIndex = 1;
$firstDataRowIndex = 1;
$categoryNames = ["Category 1", "Category 2", "Category 3"];
$seriesValues = [-20, 50, -30];
$redColor = java("java.awt.Color")->RED;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item($firstSlideIndex);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 20, 20, 500, 200);
$chartData = $chart->getChartData();
$workbook = $chartData->getChartDataWorkbook();
$chartData->getSeries()->clear();
$chartData->getCategories()->clear();
$seriesNameCell = $workbook->getCell($worksheetIndex, $headerRowIndex, $firstSeriesColumnIndex, "Series 1");
$chartType = $chart->getType();
$series = $chartData->getSeries()->add($seriesNameCell, $chartType);
$categoryCount = count($categoryNames);
for ($categoryIndex = 0; $categoryIndex < $categoryCount; $categoryIndex++) {
$dataRowIndex = $firstDataRowIndex + $categoryIndex;
$categoryName = $categoryNames[$categoryIndex];
$seriesValue = $seriesValues[$categoryIndex];
$categoryCell = $workbook->getCell($worksheetIndex, $dataRowIndex, $categoryColumnIndex, $categoryName);
$chartData->getCategories()->add($categoryCell);
$valueCell = $workbook->getCell($worksheetIndex, $dataRowIndex, $firstSeriesColumnIndex, $seriesValue);
$series->getDataPoints()->addDataPointForBarSeries($valueCell);
}
$automaticSeriesColor = $series->getAutomaticSeriesColor();
$series->getFormat()->getFill()->setFillType(FillType::Solid);
$series->getFormat()->getFill()->getSolidFillColor()->setColor($automaticSeriesColor);
$series->setInvertIfNegative(true);
$series->getInvertedSolidFillColor()->setColor($redColor);
$presentation->save("inverted_solid_fill_color.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
The result:

You can enable inversion for one point through [ChartDataPoint::setInvertIfNegative](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapoint/setinvertifnegative/). 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:
```php
$firstSlideIndex = 0;
$firstSeriesIndex = 0;
$targetDataPointIndex = 2;
$negativeValue = -30;
$redColor = java("java.awt.Color")->RED;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item($firstSlideIndex);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 20, 20, 500, 200);
$series = $chart->getChartData()->getSeries()->get_Item($firstSeriesIndex);
$automaticSeriesColor = $series->getAutomaticSeriesColor();
$series->getFormat()->getFill()->setFillType(FillType::Solid);
$series->getFormat()->getFill()->getSolidFillColor()->setColor($automaticSeriesColor);
$series->getInvertedSolidFillColor()->setColor($redColor);
$series->setInvertIfNegative(false);
$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 {
if (!java_is_null($presentation)) {
$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 [ChartDataPoint::getValue](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapoint/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:
```php
$firstSlideIndex = 0;
$firstSeriesIndex = 0;
$targetDataPointIndex = 1;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item($firstSlideIndex);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 20, 20, 500, 200);
$series = $chart->getChartData()->getSeries()->get_Item($firstSeriesIndex);
$dataPoint = $series->getDataPoints()->get_Item($targetDataPointIndex);
$dataPoint->getValue()->getAsCell()->setValue(null);
$presentation->save("clear_data_point_value.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$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 [ChartDataPointCollection::clear](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapointcollection/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/php-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 [ChartDataCell::setValue](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatacell/setvalue/) with `null` to make a cell empty. A numeric zero remains a zero regardless of the blank-cell setting.
Use [Chart::setDisplayBlanksAs](https://reference.aspose.com/slides/php-java/aspose.slides/chart/setdisplayblanksas/) 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 [ChartDataWorkbook](https://reference.aspose.com/slides/php-java/aspose.slides/chartdataworkbook/) 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`.
```php
use aspose\slides\ChartType;
use aspose\slides\DisplayBlanksAsType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::LineWithMarkers, 40, 40, 640, 400);
$chartData = $chart->getChartData();
$workbook = $chartData->getChartDataWorkbook();
$chartData->getSeries()->clear();
$chartData->getCategories()->clear();
$seriesNameCell = $workbook->getCell(0, 0, 1, "Measurements");
$series = $chartData->getSeries()->add($seriesNameCell, $chart->getType());
$values = [10, 20, 25, 30, 40];
for ($i = 0; $i < count($values); $i++) {
$categoryCell = $workbook->getCell(0, $i + 1, 0, "Day " . ($i + 1));
$chartData->getCategories()->add($categoryCell);
$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);
$modes = [DisplayBlanksAsType::Gap, DisplayBlanksAsType::Zero, DisplayBlanksAsType::Span];
$modeNames = ["Gap", "Zero", "Span"];
for ($i = 0; $i < count($modes); $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 [ChartSeriesGroup::setGapWidth](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/setgapwidth/) 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:
```php
$firstSlideIndex = 0;
$firstSeriesIndex = 0;
$gapWidthPercent = 30;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item($firstSlideIndex);
$chart = $slide->getShapes()->addChart(ChartType::StackedColumn, 20, 20, 500, 200);
$series = $chart->getChartData()->getSeries()->get_Item($firstSeriesIndex);
$series->getParentSeriesGroup()->setGapWidth($gapWidthPercent);
$presentation->save("gap_width_30.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
The result:

## **Show or Hide Series Lines**
Series lines visually connect related parts of a chart. Use [ChartSeriesGroup::setSeriesLines](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/setserieslines/) 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 [ChartSeries::getParentSeriesGroup](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/getparentseriesgroup/). The setting applies to every series in that group. [ChartSeries::hasSeriesLines](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/hasserieslines/) is read-only and reflects the parent group's setting; call the group's setter to update it.
The following example creates one [ChartType::PieOfPie](https://reference.aspose.com/slides/php-java/aspose.slides/charttype/) chart with default data. It saves the same chart with series lines enabled and then disabled, producing two presentations for comparison.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::PieOfPie, 50, 50, 600, 400);
$series = $chart->getChartData()->getSeries()->get_Item(0);
$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/php-java/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?**
A [ChartSeriesGroup](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/) 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, [ShapeCollection::addChart](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/addchart/) 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 a [ChartDataWorkbook](https://reference.aspose.com/slides/php-java/aspose.slides/chartdataworkbook/). 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 [ChartDataPointCollection::clear](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapointcollection/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 [Chart::setDisplayBlanksAs](https://reference.aspose.com/slides/php-java/aspose.slides/chart/setdisplayblanksas/). 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/php-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 [ChartSeries::setInvertIfNegative](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/setinvertifnegative/) and set the color returned by [ChartSeries::getInvertedSolidFillColor](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/getinvertedsolidfillcolor/). You can override the behavior for an individual point with [ChartDataPoint::setInvertIfNegative](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapoint/setinvertifnegative/). 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 [ChartSeriesGroup::setGapWidth](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/setgapwidth/) 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 PHP
> Explore every chart type you can create or edit with Aspose.Slides for PHP via Java – fast, code-first guides for PowerPoint presentations.
Source: https://docs.aspose.com/slides/php-java/chart-types/
Updated: 2025-11-30
---
lastmod: 2025-11-30T13:47:17+04:00
title: Customize Presentation Charts in PHP
linktitle: Chart Types
type: docs
weight: 20
url: /php-java/chart-types/
keywords:
- customize chart
- manage chart
- chart type
- PowerPoint chart
- presentation chart
- PPT chart
- PPTX chart
- PowerPoint
- presentation
- PHP
- Aspose.Slides
description: "Explore every chart type you can create or edit with Aspose.Slides for PHP via Java – fast, code-first guides for PowerPoint presentations."
---
## Related articles
- [Create and Customize PowerPoint Charts in PHP](https://docs.aspose.com/slides/php-java/powerpoint-charts/)
- [AI Features in Aspose.Slides](https://docs.aspose.com/slides/php-java/ai/)
- [Manage Media Files in PHP](https://docs.aspose.com/slides/php-java/manage-media-files/)
# Manage Chart Workbooks in Presentations Using PHP
> Discover Aspose.Slides for PHP via Java: effortlessly manage chart workbooks in PowerPoint and OpenDocument formats to streamline your presentation data.
Source: https://docs.aspose.com/slides/php-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/php-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 [Chart::setPlotVisibleCellsOnly](https://reference.aspose.com/slides/php-java/aspose.slides/chart/setplotvisiblecellsonly/) 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/php-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 [ChartData::getChartDataWorkbook](https://reference.aspose.com/slides/php-java/aspose.slides/chartdata/getchartdataworkbook/) and read [ChartDataCell::isHidden](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatacell/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/php-java/aspose.slides/chartdata/readworkbookstream/) and reload it with [writeWorkbookStream](https://reference.aspose.com/slides/php-java/aspose.slides/chartdata/writeworkbookstream/). When including all cells, also use [setRange](https://reference.aspose.com/slides/php-java/aspose.slides/chartdata/setrange/) 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.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("hidden-source-data.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapeCount = java_values($slide->getShapes()->size());
if ($shapeCount > 0 && java_instanceof($slide->getShapes()->get_Item(0), new JavaClass("com.aspose.slides.IChart"))) {
$chart = $slide->getShapes()->get_Item(0);
$workbook = $chart->getChartData()->getChartDataWorkbook();
echo "B2 hidden: " . (java_values($workbook->getCell(0, "B2")->isHidden()) ? "true" : "false"), PHP_EOL;
echo "B3 hidden: " . (java_values($workbook->getCell(0, "B3")->isHidden()) ? "true" : "false"), PHP_EOL;
echo "C2 hidden: " . (java_values($workbook->getCell(0, "C2")->isHidden()) ? "true" : "false"), PHP_EOL;
$workbookData = $chart->getChartData()->readWorkbookStream();
foreach ([true, false] as $visibleOnly) {
$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 ? "true" : "false") . ".pptx", SaveFormat::Pptx);
}
} else {
echo "The first shape is not a chart.", PHP_EOL;
}
} 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. [Chart::setDisplayBlanksAs](https://reference.aspose.com/slides/php-java/aspose.slides/chart/setdisplayblanksas/) 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/php-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 [ChartData::getRange](https://reference.aspose.com/slides/php-java/aspose.slides/chartdata/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 an exception. For more information, see the [ChartData API Reference](https://reference.aspose.com/slides/php-java/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.
```php
use aspose\slides\Presentation;
$presentation = new Presentation("presentation.pptx");
try {
$slideCount = java_values($presentation->getSlides()->size());
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$shapeCount = java_values($slide->getShapes()->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $slide->getShapes()->get_Item($shapeIndex);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.IChart"))) {
$chart = $shape;
try {
$range = $chart->getChartData()->getRange();
echo $chart->getName() . ": " . $range, PHP_EOL;
} catch (JavaException $exception) {
if (java_instanceof($exception, new JavaClass("com.aspose.slides.exceptions.InvalidOperationException"))) {
echo $chart->getName() . ": The chart does not use a workbook as its data source.", PHP_EOL;
} else {
echo $chart->getName() . ": " . $exception->getMessage(), PHP_EOL;
}
}
}
}
}
} finally {
$presentation->dispose();
}
```
## **Read and Write Chart Data from a Workbook**
Aspose.Slides for PHP via Java provides the [readWorkbookStream](https://reference.aspose.com/slides/php-java/aspose.slides/chartdata/readworkbookstream/) and [writeWorkbookStream](https://reference.aspose.com/slides/php-java/aspose.slides/chartdata/writeworkbookstream/) 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.
```php
use aspose\slides\Presentation;
$presentation = new Presentation("chart.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapeCount = java_values($slide->getShapes()->size());
if ($shapeCount > 0 && java_instanceof($slide->getShapes()->get_Item(0), new JavaClass("com.aspose.slides.IChart"))) {
$chart = $slide->getShapes()->get_Item(0);
$chartData = $chart->getChartData();
$workbookData = $chartData->readWorkbookStream();
$chartData->getSeries()->clear();
$chartData->getCategories()->clear();
$chartData->writeWorkbookStream($workbookData);
} else {
echo "The first shape is not a chart.", PHP_EOL;
}
} 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 [Chart::validateChartLayout](https://reference.aspose.com/slides/php-java/aspose.slides/chart/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.
```php
use aspose\slides\Presentation;
$presentation = new Presentation("chart.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapeCount = java_values($slide->getShapes()->size());
if ($shapeCount > 0 && java_instanceof($slide->getShapes()->get_Item(0), new JavaClass("com.aspose.slides.IChart"))) {
$chart = $slide->getShapes()->get_Item(0);
$chartData = $chart->getChartData();
$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 {
echo "The first shape is not a chart.", PHP_EOL;
}
} 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 [ChartDataCell::setCustomNumberFormat](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatacell/setcustomnumberformat/) 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/php-java/aspose.slides/chartdatacell/getpresetnumberformat/) is used instead.
The following example creates a column chart and accesses its cells through [getChartDataWorkbook](https://reference.aspose.com/slides/php-java/aspose.slides/chartdata/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.
```php
use aspose\slides\Presentation;
use aspose\slides\ChartType;
use aspose\slides\SlideSizeScaleType;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$presentation->getSlideSize()->setSize(720, 270, SlideSizeScaleType::DoNotScale);
$slide = $presentation->getSlides()->get_Item(0);
$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();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$workbook->clear(0);
$categoryCell = $workbook->getCell(0, "A2", "Sample");
$chart->getChartData()->getCategories()->add($categoryCell);
$percentageCell = $workbook->getCell(0, "B2", 0.125);
$percentageCell->setCustomNumberFormat("0.0000%");
$percentageName = $workbook->getCell(0, "B1", "Conversion rate");
$percentageSeries = $chart->getChartData()->getSeries()->add($percentageName, $chart->getType());
$percentageSeries->getDataPoints()->addDataPointForBarSeries($percentageCell);
$precisionCell = $workbook->getCell(0, "C2", 0.1234567);
$precisionCell->setCustomNumberFormat("0.00000");
$precisionName = $workbook->getCell(0, "C1", "Coefficient");
$precisionSeries = $chart->getChartData()->getSeries()->add($precisionName, $chart->getType());
$precisionSeries->getDataPoints()->addDataPointForBarSeries($precisionCell);
for ($seriesIndex = 0; $seriesIndex < java_values($chart->getChartData()->getSeries()->size()); $seriesIndex++) {
$series = $chart->getChartData()->getSeries()->get_Item($seriesIndex);
$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/php-java/aspose.slides/datalabelformat/setshowvalue/) is set to `true`, and follows the source number format because [setNumberFormatLinkedToSource](https://reference.aspose.com/slides/php-java/aspose.slides/datalabelformat/setnumberformatlinkedtosource/) 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/php-java/aspose.slides/axis/setnumberformat/) as `0.00`, with [setNumberFormatLinkedToSource](https://reference.aspose.com/slides/php-java/aspose.slides/axis/setnumberformatlinkedtosource/) 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/php-java/aspose.slides/datalabelformat/setnumberformat/). 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/php-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.
```php
use aspose\slides\Presentation;
use aspose\slides\ChartType;
use aspose\slides\SaveFormat;
$presentation = new Presentation("chart2.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::Bubble, 50, 50, 600, 400, true);
$series = $chart->getChartData()->getSeries()->get_Item(0);
$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 [ChartDataWorkbook::getWorksheets](https://reference.aspose.com/slides/php-java/aspose.slides/chartdataworkbook/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.
```php
use aspose\slides\Presentation;
use aspose\slides\ChartType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::Pie, 50, 50, 400, 500);
$workbook = $chart->getChartData()->getChartDataWorkbook();
for ($i = 0; $i < java_values($workbook->getWorksheets()->size()); $i++) {
echo $workbook->getWorksheets()->get_Item($i)->getName(), PHP_EOL;
}
} 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/php-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/php-java/aspose.slides/datasourcetype/) enumeration selects the source for each name. The example saves the presentation with the updated series names.
```php
use aspose\slides\Presentation;
use aspose\slides\ChartType;
use aspose\slides\SaveFormat;
use aspose\slides\DataSourceType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::Column3D, 50, 50, 600, 400, true);
$literalName = $chart->getChartData()->getSeries()->get_Item(0)->getName();
$literalName->setDataSourceType(DataSourceType::StringLiterals);
$literalName->setData("LiteralString");
$cellName = $chart->getChartData()->getSeries()->get_Item(1)->getName();
$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` method on [ChartData](https://reference.aspose.com/slides/php-java/aspose.slides/chartdata/) together with the [WorkbookType](https://reference.aspose.com/slides/php-java/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.
```php
use aspose\slides\Presentation;
use aspose\slides\ChartDataSourceType;
use aspose\slides\WorkbookType;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapeCount = java_values($slide->getShapes()->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $slide->getShapes()->get_Item($shapeIndex);
if (!java_instanceof($shape, new JavaClass("com.aspose.slides.IChart"))) {
continue;
}
$chart = $shape;
$chartData = $chart->getChartData();
$isInternalWorkbook = java_values($chartData->getDataSourceType()) == ChartDataSourceType::InternalWorkbook;
$isBinaryMacro = java_values($chartData->getEmbeddedWorkbookType()) == WorkbookType::WorkbookBinaryMacro;
if ($isInternalWorkbook && $isBinaryMacro) {
echo "Skipping a chart with an unsupported .xlsb workbook.", PHP_EOL;
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/php-java/aspose.slides/chartdata/readworkbookstream/) and [setExternalWorkbook](https://reference.aspose.com/slides/php-java/aspose.slides/chartdata/setexternalworkbook/) 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.
```php
use aspose\slides\Presentation;
use aspose\slides\ChartType;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::Pie, 50, 50, 400, 600);
$workbookPath = new Java("java.io.File", "externalWorkbook1.xlsx");
$workbookData = $chart->getChartData()->readWorkbookStream();
try {
$fileStream = new Java("java.io.FileOutputStream", $workbookPath);
try {
$fileStream->write($workbookData);
} finally {
$fileStream->close();
}
$chart->getChartData()->setExternalWorkbook($workbookPath->getAbsolutePath());
$presentation->save("externalWorkbook.pptx", SaveFormat::Pptx);
} catch (JavaException $exception) {
echo "Could not write the external workbook: " . $exception->getMessage(), PHP_EOL;
}
} finally {
$presentation->dispose();
}
```
### **Set an External Workbook**
Using the [setExternalWorkbook](https://reference.aspose.com/slides/php-java/aspose.slides/chartdata/setexternalworkbook/) 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/php-java/aspose.slides/chartdata/setrange/) to map A1:B4 to one series and three categories. It saves the presentation with the linked chart.
```php
use aspose\slides\Presentation;
use aspose\slides\ChartType;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::Pie, 50, 50, 400, 600, true);
$chartData = $chart->getChartData();
$workbookFile = new Java("java.io.File", "externalWorkbook.xlsx");
$workbookPath = $workbookFile->getAbsolutePath();
$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/php-java/aspose.slides/chartdata/setexternalworkbook/) 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.
```php
use aspose\slides\Presentation;
use aspose\slides\ChartType;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$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/php-java/aspose.slides/chartdata/getexternalworkbookpath/) to the console. It then saves a copy of the presentation.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ChartDataSourceType;
$presentation = new Presentation("externalWorkbook.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapeCount = java_values($slide->getShapes()->size());
if ($shapeCount > 0 && java_instanceof($slide->getShapes()->get_Item(0), new JavaClass("com.aspose.slides.IChart"))) {
$chart = $slide->getShapes()->get_Item(0);
$chartData = $chart->getChartData();
if (java_values($chartData->getDataSourceType()) == ChartDataSourceType::ExternalWorkbook) {
echo $chartData->getExternalWorkbookPath(), PHP_EOL;
} else {
echo "The chart does not use an external workbook.", PHP_EOL;
}
} else {
echo "The first shape is not a chart.", PHP_EOL;
}
$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.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("presentation.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapeCount = java_values($slide->getShapes()->size());
if ($shapeCount > 0 && java_instanceof($slide->getShapes()->get_Item(0), new JavaClass("com.aspose.slides.IChart"))) {
$chart = $slide->getShapes()->get_Item(0);
$series = $chart->getChartData()->getSeries();
if (java_values($series->size()) > 0 && java_values($series->get_Item(0)->getDataPoints()->size()) > 0) {
$valueCell = $series->get_Item(0)->getDataPoints()->get_Item(0)->getValue()->getAsCell();
if (!java_is_null($valueCell)) {
$valueCell->setValue(100);
$presentation->save("presentation_out.pptx", SaveFormat::Pptx);
} else {
echo "The first data point is not linked to a workbook cell.", PHP_EOL;
}
} else {
echo "The chart has no data points to edit.", PHP_EOL;
}
} else {
echo "The first shape is not a chart.", PHP_EOL;
}
} 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/php-java/aspose.slides/loadoptions/), call [LoadOptions::setSpreadsheetOptions](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/setspreadsheetoptions/), and set [SpreadsheetOptions::setRecoverWorkbookFromChartCache](https://reference.aspose.com/slides/php-java/aspose.slides/spreadsheetoptions/setrecoverworkbookfromchartcache/) to `true` before opening the presentation.
The following PHP 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 [Chart::getChartData](https://reference.aspose.com/slides/php-java/aspose.slides/chart/getchartdata/) and [ChartData::getChartDataWorkbook](https://reference.aspose.com/slides/php-java/aspose.slides/chartdata/getchartdataworkbook/):
```php
use aspose\slides\Presentation;
use aspose\slides\SpreadsheetOptions;
use aspose\slides\LoadOptions;
$spreadsheetOptions = new SpreadsheetOptions();
$spreadsheetOptions->setRecoverWorkbookFromChartCache(true);
$loadOptions = new LoadOptions();
$loadOptions->setSpreadsheetOptions($spreadsheetOptions);
$presentation = new Presentation("presentation.pptx", $loadOptions);
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapeCount = java_values($slide->getShapes()->size());
if ($shapeCount > 0 && java_instanceof($slide->getShapes()->get_Item(0), new JavaClass("com.aspose.slides.IChart"))) {
$chart = $slide->getShapes()->get_Item(0);
$recoveredWorkbook = $chart->getChartData()->getChartDataWorkbook();
// Read or modify the recovered workbook data here.
} else {
echo "The first shape is not a chart.", PHP_EOL;
}
} 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/php-java/aspose.slides/chartdata/getdatasourcetype/) and a [path to an external workbook](https://reference.aspose.com/slides/php-java/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/php-java/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 PHP
> Apply Excel-style formulas in Aspose.Slides for PHP via Java chart worksheets, recalculate values, and use the results in PowerPoint charts.
Source: https://docs.aspose.com/slides/php-java/chart-worksheet-formulas/
Updated: 2026-08-21
## **Overview**
PowerPoint charts usually store their source data in an embedded worksheet. In Aspose.Slides for PHP via 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 [ChartDataWorkbook](https://reference.aspose.com/slides/php-java/aspose.slides/chartdataworkbook/) class. Use [ChartDataCell::setFormula](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatacell/#setFormula) for A1-style formulas and [ChartDataCell::setR1C1Formula](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatacell/#setR1C1Formula) for R1C1-style formulas. After changing input cells or formulas, call [ChartDataWorkbook::calculateFormulas](https://reference.aspose.com/slides/php-java/aspose.slides/chartdataworkbook/#calculateFormulas) to recalculate supported formulas and update the corresponding cell values.
A calculated cell still exposes its result through [ChartDataCell::getValue](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatacell/#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.
```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 50, 50, 600, 350);
$workbook = $chart->getChartData()->getChartDataWorkbook();
$worksheetIndex = 0;
$chart->getChartData()->getSeries()->clear();
$chart->getChartData()->getCategories()->clear();
$workbook->clear($worksheetIndex);
$category1 = $workbook->getCell($worksheetIndex, "A2", "Q1");
$category2 = $workbook->getCell($worksheetIndex, "A3", "Q2");
$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);
$profit1 = $workbook->getCell($worksheetIndex, "D2");
$profit2 = $workbook->getCell($worksheetIndex, "D3");
$profit3 = $workbook->getCell($worksheetIndex, "D4");
$profit1->setFormula("B2-C2");
$profit2->setFormula("B3-C3");
$profit3->setFormula("B4-C4");
$workbook->calculateFormulas();
$q1Profit = java_values($profit1->getValue()); // 40
$q2Profit = java_values($profit2->getValue()); // 55
$q3Profit = java_values($profit3->getValue()); // 25
echo "Q1 profit: " . $q1Profit . PHP_EOL;
echo "Q2 profit: " . $q2Profit . PHP_EOL;
echo "Q3 profit: " . $q3Profit . PHP_EOL;
$chart->getChartData()->getCategories()->add($category1);
$chart->getChartData()->getCategories()->add($category2);
$chart->getChartData()->getCategories()->add($category3);
$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 [ChartDataCell::setFormula](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatacell/#setFormula).
```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 50, 50, 500, 300);
$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);
$cell = $workbook->getCell(0, "A2");
$cell->setFormula("C3+SUM(F2:H2)");
$workbook->calculateFormulas();
$value = java_values($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 [ChartDataCell::setR1C1Formula](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatacell/#setR1C1Formula).
```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 50, 50, 500, 300);
$workbook = $chart->getChartData()->getChartDataWorkbook();
$workbook->getCell(0, "B2")->setValue(12);
$workbook->getCell(0, "C2")->setValue(5);
$cell = $workbook->getCell(0, "D2");
$cell->setR1C1Formula("RC[-2]-RC[-1]");
$workbook->calculateFormulas();
$value = java_values($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:
```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 50, 50, 500, 300);
$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();
$logicalValue = java_values($workbook->getCell(0, "B2")->getValue()); // false
$numericValue = java_values($workbook->getCell(0, "C2")->getValue()); // 1.5
$scientificValue = java_values($workbook->getCell(0, "D2")->getValue()); // 0.003
$stringValue = java_values($workbook->getCell(0, "E2")->getValue()); // abc
$errorValue = java_values($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 [ChartDataWorkbook::calculateFormulas](https://reference.aspose.com/slides/php-java/aspose.slides/chartdataworkbook/#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/php-java/aspose.slides/loadoptions/), set the preferred culture with [SpreadsheetOptions::setPreferredCulture](https://reference.aspose.com/slides/php-java/aspose.slides/spreadsheetoptions/#setPreferredCulture), assign the spreadsheet options through [LoadOptions::setSpreadsheetOptions](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/#setSpreadsheetOptions), and then load the presentation.
The following example selects the Japanese culture, opens a presentation with the configured load options, and calls [ChartDataWorkbook::calculateFormulas](https://reference.aspose.com/slides/php-java/aspose.slides/chartdataworkbook/#calculateFormulas) for every chart workbook:
```php
use aspose\slides\LoadOptions;
use aspose\slides\Presentation;
use aspose\slides\SpreadsheetOptions;
$japaneseCulture = new Java("java.util.Locale", "ja", "JP");
$spreadsheetOptions = new SpreadsheetOptions();
$spreadsheetOptions->setPreferredCulture($japaneseCulture);
$loadOptions = new LoadOptions();
$loadOptions->setSpreadsheetOptions($spreadsheetOptions);
$chartClass = new JavaClass("com.aspose.slides.IChart");
$presentation = new Presentation("presentation.pptx", $loadOptions);
try {
$slideCount = java_values($presentation->getSlides()->size());
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$shapeCount = java_values($slide->getShapes()->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $slide->getShapes()->get_Item($shapeIndex);
if (java_instanceof($shape, $chartClass)) {
$shape->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/php-java/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 [ChartDataCell::getValue](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatacell/#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 [ChartDataWorkbook::calculateFormulas](https://reference.aspose.com/slides/php-java/aspose.slides/chartdataworkbook/#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/php-java/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 [ChartDataCell::getValue](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatacell/#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/php-java/aspose.slides/cellinvalidformulaexception/), [CellInvalidReferenceException](https://reference.aspose.com/slides/php-java/aspose.slides/cellinvalidreferenceexception/), [CellCircularReferenceException](https://reference.aspose.com/slides/php-java/aspose.slides/cellcircularreferenceexception/), and [CellUnsupportedDataException](https://reference.aspose.com/slides/php-java/aspose.slides/cellunsupporteddataexception/).
In PHP via Java, Java exceptions are surfaced through `JavaException`. When formulas come from templates or user input, handle it around recalculation and value access. The Java exception reported in the stack trace identifies the specific spreadsheet failure:
```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 50, 50, 500, 300);
$workbook = $chart->getChartData()->getChartDataWorkbook();
$cell = $workbook->getCell(0, "A2");
$cell->setFormula("SUM(B2:B5)");
try {
$workbook->calculateFormulas();
echo java_values($cell->getValue()) . PHP_EOL;
} catch (JavaException $ex) {
$ex->printStackTrace();
}
} 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 [ChartDataCell::setFormula](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatacell/#setFormula) and [ChartDataCell::setR1C1Formula](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatacell/#setR1C1Formula)?**
[ChartDataCell::setFormula](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatacell/#setFormula) stores an A1-style expression such as `B2-C2`. [ChartDataCell::setR1C1Formula](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatacell/#setR1C1Formula) 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?**
[ChartDataWorkbook::getCell](https://reference.aspose.com/slides/php-java/aspose.slides/chartdataworkbook/#getCell) returns a [ChartDataCell](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatacell/). To obtain the calculated result, call that cell's [ChartDataCell::getValue](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatacell/#getValue) method after recalculation.
**When should I call [ChartDataWorkbook::calculateFormulas](https://reference.aspose.com/slides/php-java/aspose.slides/chartdataworkbook/#calculateFormulas)?**
Call [ChartDataWorkbook::calculateFormulas](https://reference.aspose.com/slides/php-java/aspose.slides/chartdataworkbook/#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/php-java/aspose.slides/cellunsupporteddataexception/).
**Are formula error values the same as PHP exceptions?**
No. A result such as `#DIV/0!` is a spreadsheet value produced by a valid calculation. Spreadsheet-processing failures such as [CellInvalidFormulaException](https://reference.aspose.com/slides/php-java/aspose.slides/cellinvalidformulaexception/) or [CellCircularReferenceException](https://reference.aspose.com/slides/php-java/aspose.slides/cellcircularreferenceexception/) are Java exceptions surfaced to PHP through `JavaException`.
**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 [ChartDataWorkbook::calculateFormulas](https://reference.aspose.com/slides/php-java/aspose.slides/chartdataworkbook/#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 PHP
> Quickly duplicate PowerPoint slides with Aspose.Slides for PHP. Follow our clear code examples to automate PPT creation in seconds and eliminate manual work.
Source: https://docs.aspose.com/slides/php-java/clone-slides/
Updated: 2026-08-18
## **Introduction**
Cloning is the process of making an exact copy or replica of something. Aspose.Slides for PHP via 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 at a specific position in another Presentation.
In Aspose.Slides for PHP via Java, (a collection of [Slide](https://reference.aspose.com/slides/php-java/aspose.slides/Slide) objects) exposed by the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation) object provides the [addClone](https://reference.aspose.com/slides/php-java/aspose.slides/SlideCollection/#addClone) and [insertClone](https://reference.aspose.com/slides/php-java/aspose.slides/SlideCollection/#insertClone) 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/php-java/aspose.slides/SlideCollection/#addClone) method according to the steps listed below:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation) class.
1. Get the [SlideCollection](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation/#getSlides) object by referencing the slide collection exposed by the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation) object.
1. Call the [addClone](https://reference.aspose.com/slides/php-java/aspose.slides/SlideCollection/#addClone) method exposed by the [SlideCollection](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation/#getSlides) object and pass the slide to be cloned as a parameter to the [addClone](https://reference.aspose.com/slides/php-java/aspose.slides/SlideCollection/#addClone) 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.
```php
# Instantiate Presentation class that represents a presentation file
$pres = new Presentation("CloneWithinSamePresentationToEnd.pptx");
try {
# Clone the desired slide to the end of the collection of slides in the same presentation
$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/php-java/aspose.slides/SlideCollection/#insertClone) method:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation) class.
1. Get the [SlideCollection](https://reference.aspose.com/slides/php-java/aspose.slides/SlideCollection) object by referencing the [**Slides**](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation/#getSlides) collection exposed by the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation) object.
1. Call the [insertClone](https://reference.aspose.com/slides/php-java/aspose.slides/SlideCollection/#insertClone) method exposed by the [SlideCollection](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/SlideCollection/#insertClone) method.
1. Write the modified presentation as a PPTX file.
In the example given below, we have cloned a slide (lying at the zero index – position 1 – of the presentation) to index 1 – Position 2 – of the presentation.
```php
# Instantiate Presentation class that represents a presentation file
$pres = new Presentation("CloneWithInSamePresentation.pptx");
try {
# Clone the desired slide to the end of the collection of slides in the same presentation
$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/php-java/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/php-java/aspose.slides/Presentation) class containing the destination presentation that the slide will be added to.
1. Get the [SlideCollection](https://reference.aspose.com/slides/php-java/aspose.slides/SlideCollection) object by referencing the [**Slides**](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation/#getSlides) collection exposed by the Presentation object of the destination presentation.
1. Call the [addClone](https://reference.aspose.com/slides/php-java/aspose.slides/SlideCollection/#addClone) method exposed by the [SlideCollection](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation/#getSlides) object and pass the slide from the source presentation as a parameter to the [addClone](https://reference.aspose.com/slides/php-java/aspose.slides/SlideCollection/#addClone) 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.
```php
# Instantiate Presentation class to load the source presentation file
$srcPres = new Presentation("CloneAtEndOfAnother.pptx");
try {
# Instantiate Presentation class for destination PPTX (where slide is to be cloned)
$destPres = new Presentation();
try {
# Clone the desired slide from the source presentation to the end of the collection of slides in destination presentation
$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/php-java/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/php-java/aspose.slides/Presentation) class containing the presentation the slide will be added to.
1. Get the [SlideCollection](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/SlideCollection/#insertClone) method exposed by the [SlideCollection](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/SlideCollection/#insertClone) 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.
```php
# Instantiate Presentation class to load the source presentation file
$srcPres = new Presentation("CloneAtEndOfAnother.pptx");
try {
# Instantiate Presentation class for destination PPTX (where slide is to be cloned)
$destPres = new Presentation();
try {
# Clone the desired slide from the source presentation to the end of the collection of slides in destination presentation
$slds = $destPres->getSlides();
$slds->insertClone(2, $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 at a Specific Position in 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(Slide, MasterSlide, boolean)**](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/addclone/) 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/php-java/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/php-java/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 [MasterSlideCollection](https://reference.aspose.com/slides/php-java/aspose.slides/MasterSlideCollection) class by referencing the Masters collection exposed by the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation) object of the destination presentation.
1. Call the [addClone](https://reference.aspose.com/slides/php-java/aspose.slides/SlideCollection/#addClone) method exposed by the [MasterSlideCollection](https://reference.aspose.com/slides/php-java/aspose.slides/MasterSlideCollection) object and pass the master from the source PPTX to be cloned as a parameter to the [addClone](https://reference.aspose.com/slides/php-java/aspose.slides/SlideCollection/#addClone) method.
1. Instantiate the [SlideCollection](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation/#getSlides) class by setting the reference to the Slides collection exposed by the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation) object of the destination presentation.
1. Call the [addClone](https://reference.aspose.com/slides/php-java/aspose.slides/SlideCollection/#addClone) method exposed by the [SlideCollection](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/SlideCollection/#addClone) 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.
```php
# Instantiate Presentation class to load the source presentation file
$srcPres = new Presentation("CloneToAnotherPresentationWithMaster.pptx");
try {
# Instantiate Presentation class for destination presentation (where slide is to be cloned)
$destPres = new Presentation();
try {
# Instantiate ISlide from the collection of slides in source presentation along with
# Master slide
$SourceSlide = $srcPres->getSlides()->get_Item(0);
$SourceMaster = $SourceSlide->getLayoutSlide()->getMasterSlide();
# Clone the desired master slide from the source presentation to the collection of masters in the
# Destination presentation
$masters = $destPres->getMasters();
$DestMaster = $SourceSlide->getLayoutSlide()->getMasterSlide();
# Clone the desired master slide from the source presentation to the collection of masters in the
# Destination presentation
$iSlide = $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
$slds = $destPres->getSlides();
$slds->addClone($SourceSlide, $iSlide, 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/php-java/aspose.slides/SlideCollection/#addClone) method exposed by the [SlideCollection](https://reference.aspose.com/slides/php-java/aspose.slides/SlideCollection) class. Aspose.Slides for PHP via 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.
```php
$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));
$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 (!java_is_null($presentation)) {
$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:
```php
$sourceSize = $sourcePresentation->getSlideSize()->getSize();
$targetPresentation->getSlideSize()->setSize(
$sourceSize->getWidth(), $sourceSize->getHeight(), SlideSizeScaleType::DoNotScale);
```
Do this before cloning the master and the slide.
## **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/php-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/php-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/php-java/slide-section/). If the target section doesn’t exist, create it first and then move the slide into it.
# Compare Presentation Slides in PHP
> Compare PowerPoint and OpenDocument presentations programmatically with Aspose.Slides for PHP via Java. Identify slide differences in code quickly.
Source: https://docs.aspose.com/slides/php-java/compare-slides/
Updated: 2026-08-02
## **Introduction**
Aspose.Slides allows you to compare slides, layout slides, and master slides using the `equals` method provided by 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 [BaseSlide](https://reference.aspose.com/slides/php-java/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.
```php
$presentation1 = new Presentation("AccessSlides.pptx");
try {
$presentation2 = new Presentation("HelloWorld.pptx");
try {
for($i = 0; $i < java_values($presentation1->getMasters()->size()) ; $i++) {
for($j = 0; $j < java_values($presentation2->getMasters()->size()) ; $j++) {
if ($presentation1->getMasters()->get_Item($i)->equals($presentation2->getMasters()->get_Item($j))) {
echo(sprintf("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/php-java/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 Using PHP
> Learn how to add, attach, reroute, adjust, and inspect straight, bent, and curved PowerPoint connectors with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-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 [Connector](https://reference.aspose.com/slides/php-java/aspose.slides/connector/) class. 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/php-java/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 [ShapeCollection::addConnector](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/addconnector/) to add a connector, and use [Connector::setStartShapeConnectedTo](https://reference.aspose.com/slides/php-java/aspose.slides/connector/setstartshapeconnectedto/) and [Connector::setEndShapeConnectedTo](https://reference.aspose.com/slides/php-java/aspose.slides/connector/setendshapeconnectedto/) to attach its ends. After both ends are attached, [Connector::reroute](https://reference.aspose.com/slides/php-java/aspose.slides/connector/reroute/) selects a short route between the shapes.
The following example connects an ellipse and a rectangle with a bent connector:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$ellipse = $slide->getShapes()->addAutoShape(ShapeType::Ellipse, 40, 80, 120, 80);
$rectangle = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 320, 240, 140, 80);
$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 [Connector::setStartShapeConnectionSiteIndex](https://reference.aspose.com/slides/php-java/aspose.slides/connector/setstartshapeconnectionsiteindex/) and [Connector::setEndShapeConnectionSiteIndex](https://reference.aspose.com/slides/php-java/aspose.slides/connector/setendshapeconnectionsiteindex/) 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 [Shape::getConnectionSiteCount](https://reference.aspose.com/slides/php-java/aspose.slides/shape/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:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$ellipse = $slide->getShapes()->addAutoShape(ShapeType::Ellipse, 40, 80, 120, 80);
$rectangle = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 320, 240, 140, 80);
$connector = $slide->getShapes()->addConnector(ShapeType::BentConnector3, 0, 0, 10, 10);
$connector->setStartShapeConnectedTo($ellipse);
$connector->setEndShapeConnectedTo($rectangle);
$preferredSiteIndex = 2;
$connectionSiteCount = java_values($ellipse->getConnectionSiteCount());
if ($preferredSiteIndex < $connectionSiteCount) {
$connector->setStartShapeConnectionSiteIndex($preferredSiteIndex);
} else {
echo "The ellipse has only " . $connectionSiteCount . " connection sites." . PHP_EOL;
}
$presentation->save("specific-connection-site.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Adjust a Connector Point**
Connectors with adjustment points expose them through [GeometryShape::getAdjustments](https://reference.aspose.com/slides/php-java/aspose.slides/geometryshape/#getadjustments). Inspect every [AdjustValue](https://reference.aspose.com/slides/php-java/aspose.slides/adjustvalue/) and check its [AdjustValue::getType](https://reference.aspose.com/slides/php-java/aspose.slides/adjustvalue/#gettype) value before changing it with [AdjustValue::setRawValue](https://reference.aspose.com/slides/php-java/aspose.slides/adjustvalue/setrawvalue/). The general rules for identifying preset shape adjustments are described in [Shape Manipulation](https://docs.aspose.com/slides/php-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 [AdjustValue::getName](https://reference.aspose.com/slides/php-java/aspose.slides/adjustvalue/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:
```php
use aspose\slides\FillType;
use aspose\slides\LineArrowheadStyle;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use java\awt\Color;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$slide->getShapes()->addAutoShape(ShapeType::Rectangle, 300, 150, 150, 75);
$sourceShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 500, 400, 100, 50);
$targetShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 70, 30);
$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(new Color(0, 0, 0));
$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:
```php
use aspose\slides\FillType;
use aspose\slides\LineArrowheadStyle;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeAdjustmentType;
use aspose\slides\ShapeType;
use java\awt\Color;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$slide->getShapes()->addAutoShape(ShapeType::Rectangle, 300, 150, 150, 75);
$sourceShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 500, 400, 100, 50);
$targetShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 70, 30);
$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(new Color(0, 0, 0));
$connector->setStartShapeConnectedTo($sourceShape);
$connector->setEndShapeConnectedTo($targetShape);
$connector->setStartShapeConnectionSiteIndex(2);
$verticalBend = null;
$adjustmentCount = java_values($connector->getAdjustments()->size());
for ($adjustmentIndex = 0; $adjustmentIndex < $adjustmentCount; $adjustmentIndex++) {
$adjustment = $connector->getAdjustments()->get_Item($adjustmentIndex);
$adjustmentName = java_values($adjustment->getName());
$adjustmentType = java_values($adjustment->getType());
$rawValue = java_values($adjustment->getRawValue());
echo $adjustmentName . ": " . $adjustmentType . ", raw value = " . $rawValue . PHP_EOL;
if ($adjustmentType == ShapeAdjustmentType::ConnectorBendPositionY) {
$verticalBend = $adjustment;
break;
}
}
if ($verticalBend === null) {
echo "The connector does not expose a vertical bend adjustment." . PHP_EOL;
} 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 `100000` 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:
```php
use aspose\slides\FillType;
use aspose\slides\LineArrowheadStyle;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
use java\awt\Color;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$sourceShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 60, 25);
$sourceShape->getTextFrame()->setText("From");
$targetShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 500, 100, 60, 25);
$targetShape->getTextFrame()->setText("To");
$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(255, 0, 0));
$connector->getLineFormat()->setWidth(3);
$connector->setStartShapeConnectedTo($sourceShape);
$connector->setStartShapeConnectionSiteIndex(3);
$connector->setEndShapeConnectedTo($targetShape);
$connector->setEndShapeConnectionSiteIndex(2);
$adjustmentCount = java_values($connector->getAdjustments()->size());
for ($adjustmentIndex = 0; $adjustmentIndex < $adjustmentCount; $adjustmentIndex++) {
$adjustment = $connector->getAdjustments()->get_Item($adjustmentIndex);
echo $adjustment->getName() . ": " . $adjustment->getType() . ", raw value = " . $adjustment->getRawValue() . PHP_EOL;
}
} finally {
$presentation->dispose();
}
```
To change both bends, locate each expected type and modify the values only after both have been found:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeAdjustmentType;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$sourceShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 60, 25);
$targetShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 500, 100, 60, 25);
$connector = $slide->getShapes()->addConnector(ShapeType::BentConnector4, 20, 20, 400, 300);
$connector->setStartShapeConnectedTo($sourceShape);
$connector->setStartShapeConnectionSiteIndex(3);
$connector->setEndShapeConnectedTo($targetShape);
$connector->setEndShapeConnectionSiteIndex(2);
$horizontalBend = null;
$verticalBend = null;
$adjustmentCount = java_values($connector->getAdjustments()->size());
for ($adjustmentIndex = 0; $adjustmentIndex < $adjustmentCount; $adjustmentIndex++) {
$adjustment = $connector->getAdjustments()->get_Item($adjustmentIndex);
$adjustmentType = java_values($adjustment->getType());
if ($adjustmentType == ShapeAdjustmentType::ConnectorBendPositionX) {
$horizontalBend = $adjustment;
} elseif ($adjustmentType == ShapeAdjustmentType::ConnectorBendPositionY) {
$verticalBend = $adjustment;
}
}
if ($horizontalBend === null || $verticalBend === null) {
echo "The connector does not expose the expected bend adjustments." . PHP_EOL;
} else {
$horizontalBendValue = java_values($horizontalBend->getRawValue());
$verticalBendValue = java_values($verticalBend->getRawValue());
$horizontalBendValue += 20000;
$verticalBendValue += 200000;
$horizontalBend->setRawValue($horizontalBendValue);
$verticalBend->setRawValue($verticalBendValue);
$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:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeAdjustmentType;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$sourceShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 60, 25);
$targetShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 500, 100, 60, 25);
$connector = $slide->getShapes()->addConnector(ShapeType::BentConnector4, 20, 20, 400, 300);
$connector->setStartShapeConnectedTo($sourceShape);
$connector->setStartShapeConnectionSiteIndex(3);
$connector->setEndShapeConnectedTo($targetShape);
$connector->setEndShapeConnectionSiteIndex(2);
$horizontalBend = null;
$verticalBend = null;
$adjustmentCount = java_values($connector->getAdjustments()->size());
for ($adjustmentIndex = 0; $adjustmentIndex < $adjustmentCount; $adjustmentIndex++) {
$adjustment = $connector->getAdjustments()->get_Item($adjustmentIndex);
$adjustmentType = java_values($adjustment->getType());
if ($adjustmentType == ShapeAdjustmentType::ConnectorBendPositionX) {
$horizontalBend = $adjustment;
} elseif ($adjustmentType == ShapeAdjustmentType::ConnectorBendPositionY) {
$verticalBend = $adjustment;
}
}
if ($horizontalBend === null || $verticalBend === null) {
echo "The connector does not expose the expected bend adjustments." . PHP_EOL;
} else {
$connectorX = java_values($connector->getX());
$connectorY = java_values($connector->getY());
$connectorWidth = java_values($connector->getWidth());
$connectorHeight = java_values($connector->getHeight());
$horizontalBendValue = java_values($horizontalBend->getRawValue());
$verticalBendValue = java_values($verticalBend->getRawValue());
$x = $connectorX + $connectorWidth * $horizontalBendValue / 100000;
$y = $connectorY;
$height = $connectorHeight * $verticalBendValue / 100000;
$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 [Shape::getFrame](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getframe/), [ShapeFrame::getFlipH](https://reference.aspose.com/slides/php-java/aspose.slides/shapeframe/getfliph/), and [ShapeFrame::getFlipV](https://reference.aspose.com/slides/php-java/aspose.slides/shapeframe/getflipv/) values affect the conversion from connector-frame coordinates to slide coordinates.
This example creates and adjusts the vertically oriented connector:
```php
use aspose\slides\FillType;
use aspose\slides\LineArrowheadStyle;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeAdjustmentType;
use aspose\slides\ShapeType;
use java\awt\Color;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$sourceShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 60, 25);
$sourceShape->getTextFrame()->setText("From");
$targetShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 400, 60, 25);
$targetShape->getTextFrame()->setText("To 1");
$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);
$adjustmentCount = java_values($connector->getAdjustments()->size());
for ($adjustmentIndex = 0; $adjustmentIndex < $adjustmentCount; $adjustmentIndex++) {
$adjustment = $connector->getAdjustments()->get_Item($adjustmentIndex);
$adjustmentType = java_values($adjustment->getType());
if ($adjustmentType == ShapeAdjustmentType::ConnectorBendPositionX) {
$rawValue = java_values($adjustment->getRawValue());
$adjustment->setRawValue($rawValue + 20000);
} elseif ($adjustmentType == ShapeAdjustmentType::ConnectorBendPositionY) {
$rawValue = java_values($adjustment->getRawValue());
$adjustment->setRawValue($rawValue + 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:
```php
use aspose\slides\FillType;
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeAdjustmentType;
use aspose\slides\ShapeType;
use java\awt\Color;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$sourceShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 60, 25);
$targetShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 400, 60, 25);
$connector = $slide->getShapes()->addConnector(ShapeType::BentConnector4, 20, 20, 400, 300);
$connector->setStartShapeConnectedTo($sourceShape);
$connector->setStartShapeConnectionSiteIndex(2);
$connector->setEndShapeConnectedTo($targetShape);
$connector->setEndShapeConnectionSiteIndex(3);
$horizontalBend = null;
$verticalBend = null;
$adjustmentCount = java_values($connector->getAdjustments()->size());
for ($adjustmentIndex = 0; $adjustmentIndex < $adjustmentCount; $adjustmentIndex++) {
$adjustment = $connector->getAdjustments()->get_Item($adjustmentIndex);
$adjustmentType = java_values($adjustment->getType());
if ($adjustmentType == ShapeAdjustmentType::ConnectorBendPositionX) {
$horizontalBend = $adjustment;
} elseif ($adjustmentType == ShapeAdjustmentType::ConnectorBendPositionY) {
$verticalBend = $adjustment;
}
}
if ($horizontalBend === null || $verticalBend === null) {
echo "The connector does not expose the expected bend adjustments." . PHP_EOL;
} else {
$horizontalBendValue = java_values($horizontalBend->getRawValue());
$verticalBendValue = java_values($verticalBend->getRawValue());
$horizontalBendValue += 20000;
$verticalBendValue += 200000;
$horizontalBend->setRawValue($horizontalBendValue);
$verticalBend->setRawValue($verticalBendValue);
$frame = $connector->getFrame();
$connectorX = java_values($connector->getX());
$connectorY = java_values($connector->getY());
$connectorWidth = java_values($connector->getWidth());
$connectorHeight = java_values($connector->getHeight());
$flipH = java_values($frame->getFlipH()) == NullableBool::True;
$flipV = java_values($frame->getFlipV()) == NullableBool::True;
$centerX = java_values($frame->getCenterX());
$centerY = java_values($frame->getCenterY());
$x = $connectorX;
$y = $connectorY;
if ($flipH) {
$x += $connectorWidth;
}
if ($flipV) {
$y += $connectorHeight;
}
$x += $connectorWidth * $horizontalBendValue / 100000;
$rotatedX = $centerX - $y + $centerY;
$rotatedY = $x - $centerX + $centerY;
$segmentWidth = $connectorHeight * $verticalBendValue / 100000;
$guide = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, $rotatedX, $rotatedY, $segmentWidth, 1);
$guide->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$guide->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor(new Color(255, 0, 0));
$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:
```php
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$connector = $slide->getShapes()->addConnector(ShapeType::StraightConnector1, 100, 100, 200, 100);
$frame = $connector->getFrame();
$flipH = java_values($frame->getFlipH()) == NullableBool::True;
$flipV = java_values($frame->getFlipV()) == NullableBool::True;
$width = java_values($connector->getWidth());
$height = java_values($connector->getHeight());
$deltaX = $width * ($flipH ? -1 : 1);
$deltaY = $height * ($flipV ? -1 : 1);
$angle = atan2($deltaY, $deltaX) * 180.0 / pi();
if ($angle < 0) {
$angle += 360;
}
printf("Connector direction: %.2f degrees%s", $angle, PHP_EOL);
} finally {
$presentation->dispose();
}
```
## **FAQ**
**How can I tell whether a connector can attach to a shape?**
Check the shape's [Shape::getConnectionSiteCount](https://reference.aspose.com/slides/php-java/aspose.slides/shape/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 [AdjustValue::getType](https://reference.aspose.com/slides/php-java/aspose.slides/adjustvalue/#gettype) before modifying a value, and use [AdjustValue::getName](https://reference.aspose.com/slides/php-java/aspose.slides/adjustvalue/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.
## Related articles
- [Connector](https://docs.aspose.com/slides/php-java/examples/elements/connector/)
# Convert ODP to PPTX in PHP
> Convert ODP to PPTX with Aspose.Slides for PHP via Java. Clean code examples, batch tips, and high-quality results—no PowerPoint needed.
Source: https://docs.aspose.com/slides/php-java/convert-odp-to-pptx/
Updated: 2026-08-02
## **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 PHP via Java offers [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation) class that represents a presentation file. [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation) class can now also access ODP through [Presentation](https://reference.aspose.com/slides/php-java/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.
```php
// Open the ODP file
$pres = new Presentation("AccessOpenDoc.odp");
try {
} finally {
}
# Saving the ODP presentation to PPTX format
$pres->save("AccessOpenDoc_out.pptx", SaveFormat::Pptx);
```
## **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/php-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.
## Related articles
- [Convert PPT to PPTX in PHP](https://docs.aspose.com/slides/php-java/convert-ppt-to-pptx/)
# Convert OpenDocument Presentations in PHP
> Aspose.Slides for PHP lets you convert ODP to PDF, HTML, and image formats with ease. Boost your PHP apps with fast and accurate presentation conversion.
Source: https://docs.aspose.com/slides/php-java/convert-openoffice-odp/
Updated: 2026-08-02
## **Introduction**
[**Aspose.Slides API**](https://products.aspose.com/slides/php-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.
## **Convert ODP to PDF**
For example, if you need to convert an ODP presentation to PDF, you can do it as follows:
```php
$presentation = null;
try {
$presentation = new Presentation("pres.odp");
$presentation->save("pres.pdf", SaveFormat::Pdf);
} finally {
if ($presentation != null) {
$presentation->dispose();
}
}
```
## **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/php-java/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 PHP | HTML, PNG, PDF, Word, TIFF](https://docs.aspose.com/slides/php-java/convert-powerpoint/)
- [Convert Presentations to Multiple Formats in PHP](https://docs.aspose.com/slides/php-java/convert-presentation/)
# Convert PowerPoint Presentations in Handout Mode Using PHP
> Convert presentations to handouts in PHP. Set slides per page, keep notes, export to PDF or images with Aspose.Slides for PHP, with sample code. Try it free.
Source: https://docs.aspose.com/slides/php-java/convert-powerpoint-in-handout-mode/
Updated: 2026-11-08
## **Introduction**
Aspose.Slides provides the ability to convert presentations into various formats, including creating handouts for printing in Handout mode. This mode allows you to configure how multiple slides appear on a single page, making it useful for conferences, seminars, and other events. You can enable this mode by setting the `setSlidesLayoutOptions` method in the [PdfOptions](https://reference.aspose.com/slides/php-java/aspose.slides/pdfoptions/), [RenderingOptions](https://reference.aspose.com/slides/php-java/aspose.slides/renderingoptions/), [HtmlOptions](https://reference.aspose.com/slides/php-java/aspose.slides/htmloptions/), and [TiffOptions](https://reference.aspose.com/slides/php-java/aspose.slides/tiffoptions/) classes.
To set the handout page dimensions and orientation before export, see [Notes Page Size](https://docs.aspose.com/slides/php-java/notes-size/).
## **Handout Mode Export**
To configure Handout mode, use the [HandoutLayoutingOptions](https://reference.aspose.com/slides/php-java/aspose.slides/handoutlayoutingoptions/) object, which determines how many slides are placed on a single page and other display parameters.
Below is a code example showing how to convert a presentation to PDF in Handout mode.
```php
// Load a presentation.
$presentation = new Presentation("sample.pptx");
// Set the export options.
$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 = new PdfOptions();
$pdfOptions->setSlidesLayoutOptions($slidesLayoutOptions);
// Export the presentation to PDF with the chosen layout.
$presentation->save("output.pdf", SaveFormat::Pdf, $pdfOptions);
$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/php-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/php-java/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/php-java/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/php-java/aspose.slides/pdfoptions/), [HtmlOptions](https://reference.aspose.com/slides/php-java/aspose.slides/htmloptions/), or [TiffOptions](https://reference.aspose.com/slides/php-java/aspose.slides/tiffoptions/).
# Convert PowerPoint Presentations to Animated GIFs in PHP
> Easily convert PowerPoint presentations (PPT, PPTX) to animated GIFs with Aspose.Slides for PHP via Java. Fast, high-quality results.
Source: https://docs.aspose.com/slides/php-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/php-java/aspose.slides/gifoptions/).
## **Convert Presentations to Animated GIF Using Default Settings**
This sample code shows you how to convert a presentation to animated GIF using standard settings:
```php
$pres = new Presentation("pres.pptx");
try {
$pres->save("pres.gif", SaveFormat::Gif);
} finally {
if (!java_is_null($pres)) {
$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/php-java/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 :
```php
$pres = new Presentation("pres.pptx");
try {
$gifOptions = new GifOptions();
$gifOptions->setFrameSize(new Java("java.awt.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 (!java_is_null($pres)) {
$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/php-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/php-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 PHP
> Convert PowerPoint presentations to HTML in PHP. Use Aspose.Slides to export PPT and PPTX files, selected slides, notes, fonts, images, SVG, and media.
Source: https://docs.aspose.com/slides/php-java/convert-powerpoint-to-html/
Updated: 2026-08-02
## **Overview**
Aspose.Slides for PHP via Java can save PowerPoint presentations as HTML without Microsoft PowerPoint. The basic conversion is a single [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) load and a `save` call with [SaveFormat](https://reference.aspose.com/slides/php-java/aspose.slides/saveformat/). Use [HtmlOptions](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/presentation/) and save it with [SaveFormat.Html](https://reference.aspose.com/slides/php-java/aspose.slides/saveformat/).
```php
$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/php-java/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 `save` overload that accepts slide numbers uses 1-based slide positions. The loop below saves every slide to a separate HTML file.
```php
$presentation = new Presentation("presentation.pptx");
try {
$slideCount = java_values($presentation->getSlides()->size());
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slideNumber = $slideIndex + 1;
$slideNumbers = array($slideNumber);
$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/php-java/aspose.slides/htmloptions/) instance and pass it to each `save` call.
## **Create Responsive HTML**
[ResponsiveHtmlController](https://reference.aspose.com/slides/php-java/aspose.slides/responsivehtmlcontroller/) provides responsive HTML output through [HtmlFormatter](https://reference.aspose.com/slides/php-java/aspose.slides/htmlformatter/). Use it when the exported page should adapt better to browser width.
```php
$presentation = new Presentation("presentation.pptx");
try {
$controller = new ResponsiveHtmlController();
$formatter = java("com.aspose.slides.HtmlFormatter")->createCustomFormatter($controller);
$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/php-java/aspose.slides/htmloptions/). This is useful when the slide content is exported as scalable SVG markup.
```php
$presentation = new Presentation("presentation.pptx");
try {
$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/php-java/aspose.slides/notescommentslayoutingoptions/) through `HtmlOptions.SlidesLayoutOptions` 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.
```php
$presentation = new Presentation("presentation.pptx");
try {
$layoutOptions = new NotesCommentsLayoutingOptions();
$layoutOptions->setNotesPosition(NotesPositions::BottomFull);
$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/php-java/aspose.slides/picturescompression/) when you need higher image quality.
```php
$presentation = new Presentation("presentation.pptx");
try {
$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.
```php
$presentation = new Presentation("presentation.pptx");
try {
$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](https://reference.aspose.com/slides/php-java/aspose.slides/htmlformatter/) through `createDocumentFormatter`. This changes the surrounding HTML document while Aspose.Slides continues to render the slide content.
```php
$presentation = new Presentation("presentation.pptx");
try {
$cssRules = "body { margin: 0; background: #f7f7f7; } .slide { margin: 24px auto; }";
$showSlideTitle = true;
$formatter = java("com.aspose.slides.HtmlFormatter")->createDocumentFormatter($cssRules, $showSlideTitle);
$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, use a custom formatting controller and pass it to [HtmlFormatter](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/embedallfontshtmlcontroller/). Embedding improves visual fidelity but increases output size.
```php
$presentation = new Presentation("presentation.pptx");
try {
$arrayClass = new JavaClass("java.lang.reflect.Array");
$stringClass = new JavaClass("java.lang.String");
$fontNamesToExclude = $arrayClass->newInstance($stringClass, 1);
$arrayClass->set($fontNamesToExclude, 0, new Java("java.lang.String", "Calibri"));
$fontController = new EmbedAllFontsHtmlController(java_values($fontNamesToExclude));
$formatter = java("com.aspose.slides.HtmlFormatter")->createCustomFormatter($fontController);
$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. In PHP via Java, this scenario is usually implemented with a small Java helper class that extends [EmbedAllFontsHtmlController](https://reference.aspose.com/slides/php-java/aspose.slides/embedallfontshtmlcontroller/), writes font bytes to an output directory, and injects `@font-face` rules into the generated HTML. Compile that helper, add it to the PHP Java Bridge classpath, and then instantiate it from PHP with `new Java(...)`.
When you build such a helper, choose two paths deliberately:
- The file system output path, where generated font files are written.
- The URL path, which is what the browser uses from the HTML document to load those font files.
## **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, provide a custom link/embed controller to the [HtmlOptions](https://reference.aspose.com/slides/php-java/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.
Keep these paths consistent with your deployment layout so the generated HTML can load its external resources after it is moved to a web server or another directory.
## **Export Media Files**
[VideoPlayerHtmlController](https://reference.aspose.com/slides/php-java/aspose.slides/videoplayerhtmlcontroller/) exports video and audio files and writes HTML that can play them in a browser. Its constructor takes:
- `path`: the output directory used by the generated HTML and media files.
- `fileName`: the HTML file name being generated.
- `baseUri`: the absolute URI prefix used in the HTML links to media files.
If the HTML file is `html-output/presentation.html`, `path` should point to `html-output`, and `baseUri` should point to the same directory from the browser's point of view. For local preview, you can build a `file:///` URI from the output directory. For a deployed application, use the absolute URL of the published output directory.
```php
$outputDirectory = getcwd() . DIRECTORY_SEPARATOR . "html-output";
if (!is_dir($outputDirectory)) {
mkdir($outputDirectory, 0777, true);
}
$htmlFileName = "presentation.html";
$outputDirectoryPath = realpath($outputDirectory);
$outputDirectoryPath = str_replace("\\", "/", $outputDirectoryPath);
$outputBaseUri = "file:///" . ltrim($outputDirectoryPath, "/") . "/";
$presentation = new Presentation();
$videoStream = null;
try {
$videoFilePath = getcwd() . DIRECTORY_SEPARATOR . "intro.mp4";
$videoStream = new Java("java.io.FileInputStream", $videoFilePath);
$video = $presentation->getVideos()->addVideo($videoStream, LoadingStreamBehavior::ReadStreamAndRelease);
$slide = $presentation->getSlides()->get_Item(0);
$slide->getShapes()->addVideoFrame(20, 20, 480, 270, $video);
$controller = new VideoPlayerHtmlController($outputDirectory, $htmlFileName, $outputBaseUri);
$formatter = java("com.aspose.slides.HtmlFormatter")->createCustomFormatter($controller);
$svgOptions = new SVGOptions($controller);
$slideImageFormat = SlideImageFormat::svg($svgOptions);
$htmlOptions = new HtmlOptions($controller);
$htmlOptions->setHtmlFormatter($formatter);
$htmlOptions->setSlideImageFormat($slideImageFormat);
$htmlFilePath = $outputDirectory . DIRECTORY_SEPARATOR . $htmlFileName;
$presentation->save($htmlFilePath, SaveFormat::Html, $htmlOptions);
} finally {
if ($videoStream !== null) {
$videoStream->close();
}
$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/php-java/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/php-java/aspose.slides/presentation/) instance across threads. Process different files with separate presentation instances, separate streams, and separate output directories.
### Is a Presentation object thread-safe?
No. A single [Presentation](https://reference.aspose.com/slides/php-java/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 a Java file URI. For deployment, use the absolute URL of the published media directory. The file system `path` and browser `baseUri` do not have to be the same string, but they must describe the same resource location.
### Can I include hidden slides?
Yes. Set `ShowHiddenSlides` to `true` on [HtmlOptions](https://reference.aspose.com/slides/php-java/aspose.slides/htmloptions/) when hidden slides must be exported.
## Related articles
- [Export Presentations to HTML with Externally Linked Images](https://docs.aspose.com/slides/php-java/exporting-presentations-to-html-with-externally-linked-images/)
# Convert PPT and PPTX to JPG in PHP
> Convert PowerPoint (PPT, PPTX) slides to high-quality JPG images in PHP with Aspose.Slides for PHP using fast, reliable code examples.
Source: https://docs.aspose.com/slides/php-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/php-java/aspose.slides/Presentation) type.
2. Get the slide object of [Slide](https://reference.aspose.com/slides/php-java/aspose.slides/slide/) type from [Presentation::getSlides()](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation#getSlides--) collection.
3. Create the thumbnail of each slide and then convert it into JPG. [**Slide::getImage(float scaleX, float scaleY)**](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#getImage) method is used to get a thumbnail of a slide. [getImage](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#getImage) method has to be called from the needed slide of [Slide](https://reference.aspose.com/slides/php-java/aspose.slides/slide/) 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/php-java/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 [**Presentation::Save(String fname, int format, SaveOptions options)**](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/save/) method, but here you need [**IImage::save(String formatName, int imageFormat)**](https://reference.aspose.com/slides/php-java/aspose.slides/IImage#save(String formatName, int imageFormat)) method.
```php
$pres = new Presentation("PowerPoint-Presentation.pptx");
try {
$slides = $pres->getSlides();
foreach($slides as $sld) {
# Creates a full scale image
$slideImage = $sld->getImage(1.0, 1.0);
# Saves the image to disk in JPEG format
try {
$slideImage->save(sprintf("Slide_%d.jpg", java_values($sld->getSlideNumber())), ImageFormat::Jpeg);
} finally {
if (!java_is_null($slideImage)) {
$slideImage->dispose();
}
}
}
} finally {
if (!java_is_null($pres)) {
$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 [**Slide::getImage(float scaleX, float scaleY)**](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#getImage) methods:
```php
$pres = new Presentation("PowerPoint-Presentation.pptx");
try {
# Defines dimensions
$desiredX = 1200;
$desiredY = 800;
# Gets scaled values of X and Y
$ScaleX = 1.0 / java_values($pres->getSlideSize()->getSize()->getWidth()) * $desiredX;
$ScaleY = 1.0 / java_values($pres->getSlideSize()->getSize()->getHeight()) * $desiredY;
$slides = $pres->getSlides();
foreach($slides as $sld) {
# Creates a scaled image
$slideImage = $sld->getImage($ScaleX, $ScaleY);
# Saves the image to disk in JPEG format
try {
$slideImage->save(sprintf("Slide_%d.jpg", java_values($sld->getSlideNumber())), ImageFormat::Jpeg);
} finally {
if (!java_is_null($slideImage)) {
$slideImage->dispose();
}
}
}
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Render Comments When Saving Slides as Images**
Aspose.Slides for PHP via Java provides a facility that allows you to render comments in a presentation's slides when you are converting those slides into images. This PHP code demonstrates the operation:
```php
$pres = new Presentation("presentation.pptx");
try {
$notesOptions = new NotesCommentsLayoutingOptions();
$notesOptions->setNotesPosition(NotesPositions::BottomTruncated);
$opts = new RenderingOptions();
$opts->setSlidesLayoutOptions($notesOptions);
$slides = $pres->getSlides();
foreach($slides as $sld) {
$slideImage = $sld->getImage($opts, new Java("java.awt.Dimension", 740, 960));
try {
$slideImage->save(sprintf("Slide_%d.png", java_values($sld->getSlideNumber())));
} finally {
if (!java_is_null($slideImage)) {
$slideImage->dispose();
}
}
}
} finally {
if (!java_is_null($pres)) {
$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/php-java/conversion/image-to-jpg/); convert [JPG to image](https://products.aspose.com/slides/php-java/conversion/jpg-to-image/); convert [JPG to PNG](https://products.aspose.com/slides/php-java/conversion/jpg-to-png/), convert [PNG to JPG](https://products.aspose.com/slides/php-java/conversion/png-to-jpg/); convert [PNG to SVG](https://products.aspose.com/slides/php-java/conversion/png-to-svg/), convert [SVG to PNG](https://products.aspose.com/slides/php-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/php-java/render-a-slide-as-an-svg-image/).
## Related articles
- [Convert Presentation Slides to Images in PHP](https://docs.aspose.com/slides/php-java/convert-slide/)
# Convert PowerPoint Presentations to Markdown in PHP
> Convert PPT and PPTX presentations to Markdown in PHP and control where exported bitmap, metafile, and SVG images are saved and referenced.
Source: https://docs.aspose.com/slides/php-java/convert-powerpoint-to-markdown/
Updated: 2026-10-01
## **Overview**
Aspose.Slides for PHP via 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/php-java/aspose.slides/markdownsaveoptions/) method to the `Sequential` or `Visual` value from the [MarkdownExportType](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/presentation/) class, and then call the [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) method with the `Md` value from the [SaveFormat](https://reference.aspose.com/slides/php-java/aspose.slides/saveformat/) enumeration.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$inputPath = __DIR__ . DIRECTORY_SEPARATOR . "presentation.pptx";
$outputPath = __DIR__ . DIRECTORY_SEPARATOR . "presentation.md";
$presentation = new Presentation($inputPath);
try {
$presentation->save($outputPath, SaveFormat::Md);
} finally {
$presentation->dispose();
}
```
## **Select a Markdown Flavor**
The [MarkdownSaveOptions::setFlavor](https://reference.aspose.com/slides/php-java/aspose.slides/markdownsaveoptions/) method controls the Markdown specification used for the output. The [Flavor](https://reference.aspose.com/slides/php-java/aspose.slides/flavor/) enumeration includes CommonMark, GitHub Flavored Markdown, and other supported variants.
The following example exports a presentation as CommonMark:
```php
use aspose\slides\Flavor;
use aspose\slides\MarkdownSaveOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$inputPath = __DIR__ . DIRECTORY_SEPARATOR . "presentation.pptx";
$outputPath = __DIR__ . DIRECTORY_SEPARATOR . "presentation.md";
$presentation = new Presentation($inputPath);
try {
$options = new MarkdownSaveOptions();
$options->setFlavor(Flavor::CommonMark);
$presentation->save($outputPath, 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/php-java/aspose.slides/markdownsaveoptions/#setHandleRepeatedSpaces) 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.
```php
use aspose\slides\Flavor;
use aspose\slides\HandleRepeatedSpaces;
use aspose\slides\MarkdownSaveOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 20, 600, 100);
$shape->getTextFrame()->setText("One space; two spaces; three spaces.");
$modes = [
HandleRepeatedSpaces::None,
HandleRepeatedSpaces::AlternateSpacesToNbsp,
HandleRepeatedSpaces::MultipleSpacesToNbsp
];
$modeNames = ["None", "AlternateSpacesToNbsp", "MultipleSpacesToNbsp"];
for ($i = 0; $i < count($modes); $i++) {
$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/php-java/aspose.slides/markdownsaveoptions/#setRemoveEmptyLines) 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/php-java/aspose.slides/handlerepeatedspaces/) makes the treatment of ordinary spaces easier to inspect.
```php
use aspose\slides\Flavor;
use aspose\slides\HandleRepeatedSpaces;
use aspose\slides\MarkdownSaveOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$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.");
$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/php-java/aspose.slides/markdownsaveoptions/#setRemoveEmptyLines) 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/php-java/aspose.slides/markdownsaveoptions/#setRemoveEmptyLines) 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/php-java/aspose.slides/markdownsaveoptions/#setRemoveEmptyLines) 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/php-java/aspose.slides/markdownsaveoptions/) class provides two methods for configuring locally saved images:
- [setBasePath](https://reference.aspose.com/slides/php-java/aspose.slides/markdownsaveoptions/) specifies the base directory for the Markdown document and its resources.
- [setImagesSaveFolderName](https://reference.aspose.com/slides/php-java/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:
```php
use aspose\slides\MarkdownExportType;
use aspose\slides\MarkdownSaveOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$inputPath = __DIR__ . DIRECTORY_SEPARATOR . "presentation.pptx";
$outputDirectory = __DIR__ . DIRECTORY_SEPARATOR . "output";
if (!is_dir($outputDirectory)) {
mkdir($outputDirectory, 0777, true);
}
$presentation = new Presentation($inputPath);
try {
$options = new MarkdownSaveOptions();
$options->setExportType(MarkdownExportType::Visual);
$options->setBasePath($outputDirectory);
$options->setImagesSaveFolderName("assets");
$markdownPath = $outputDirectory . DIRECTORY_SEPARATOR . "presentation.md";
$presentation->save($markdownPath, 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/php-java/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/php-java/aspose.slides/iimage/) object, its [ImageFormat](https://reference.aspose.com/slides/php-java/aspose.slides/imageformat/) value, and the generated Markdown link as a one-element Java string array. 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/php-java/aspose.slides/markdownsaveoptions/) method. Its `MarkdownSvgImageSavingHandler` callback receives an [SvgImage](https://reference.aspose.com/slides/php-java/aspose.slides/svgimage/) object and the one-element Java string array `$link`. An SVG has no `ImageFormat` argument; write or upload its XML data from the [SvgImage::getSvgData](https://reference.aspose.com/slides/php-java/aspose.slides/svgimage/#getSvgData) 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.
In PHP via Java, implement each callback in a PHP class and use `java_closure` to expose that object as the corresponding Java interface.
Initialize the PHP/Java Bridge with `JAVA_PREFER_VALUES` enabled before loading `Java.inc`. The [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) method returns `void`, and the bridge's default stream mode cannot invoke a PHP callback during that queued call. The complete example below includes the required initialization.
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/php-java/aspose.slides/markdownsaveoptions/) and [MarkdownSaveOptions::setImagesSaveFolderName](https://reference.aspose.com/slides/php-java/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.
```php
use aspose\slides\MarkdownExportType;
use aspose\slides\MarkdownSaveOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
define("JAVA_PREFER_VALUES", 1);
require_once("http://localhost:8080/JavaBridge/java/Java.inc");
require_once("lib/aspose.slides.php");
function getFileNameFromLink($generatedLink)
{
$urlCompatibleLink = str_replace("\\", "/", java_values($generatedLink));
return basename($urlCompatibleLink);
}
function buildPublicUrl($publicBaseUrl, $fileName)
{
return rtrim($publicBaseUrl, "/") . "/" . rawurlencode($fileName);
}
class CustomImageSavingHandler
{
private $storageDirectory;
private $publicBaseUrl;
function __construct($storageDirectory, $publicBaseUrl)
{
$this->storageDirectory = $storageDirectory;
$this->publicBaseUrl = $publicBaseUrl;
}
function invoke($image, $format, $link)
{
if (java_values($image->getWidth()) < 128 || java_values($image->getHeight()) < 128) {
return false;
}
$fileName = getFileNameFromLink($link[0]);
$storagePath = $this->storageDirectory . DIRECTORY_SEPARATOR . $fileName;
$image->save($storagePath, $format);
$link[0] = buildPublicUrl($this->publicBaseUrl, $fileName);
return true;
}
}
class CustomSvgImageSavingHandler
{
private $storageDirectory;
private $publicBaseUrl;
function __construct($storageDirectory, $publicBaseUrl)
{
$this->storageDirectory = $storageDirectory;
$this->publicBaseUrl = $publicBaseUrl;
}
function invoke($svgImage, $link)
{
$fileName = getFileNameFromLink($link[0]);
$storagePath = $this->storageDirectory . DIRECTORY_SEPARATOR . $fileName;
$outputStream = null;
try {
$outputStream = new Java("java.io.FileOutputStream", $storagePath);
$outputStream->write($svgImage->getSvgData());
} catch (Throwable $exception) {
fwrite(STDERR, "Could not save the SVG image: " . $exception->getMessage() . PHP_EOL);
return false;
} finally {
if ($outputStream !== null) {
$outputStream->close();
}
}
$link[0] = buildPublicUrl($this->publicBaseUrl, $fileName);
return true;
}
}
$inputPath = __DIR__ . DIRECTORY_SEPARATOR . "presentation.pptx";
$outputDirectory = __DIR__ . DIRECTORY_SEPARATOR . "output";
$publicBaseUrl = "https://cdn.example.com/presentations/quarterly-report";
$storageDirectory = __DIR__ . DIRECTORY_SEPARATOR . "cdn-origin" . DIRECTORY_SEPARATOR . "presentations" . DIRECTORY_SEPARATOR . "quarterly-report";
if (!is_dir($outputDirectory)) {
mkdir($outputDirectory, 0777, true);
}
if (!is_dir($storageDirectory)) {
mkdir($storageDirectory, 0777, true);
}
$presentation = new Presentation($inputPath);
try {
$options = new MarkdownSaveOptions();
$options->setExportType(MarkdownExportType::Visual);
$options->setBasePath($outputDirectory);
$options->setImagesSaveFolderName("fallback-images");
$imageSavingHandler = java_closure(new CustomImageSavingHandler($storageDirectory, $publicBaseUrl), null, java('com.aspose.slides.MarkdownSaveOptions$MarkdownImageSavingHandler'));
$svgImageSavingHandler = java_closure(new CustomSvgImageSavingHandler($storageDirectory, $publicBaseUrl), null, java('com.aspose.slides.MarkdownSaveOptions$MarkdownSvgImageSavingHandler'));
$options->setImageSaving($imageSavingHandler);
$options->setSvgImageSaving($svgImageSavingHandler);
$markdownPath = $outputDirectory . DIRECTORY_SEPARATOR . "presentation.md";
$presentation->save($markdownPath, 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/php-java/aspose.slides/markdownsaveoptions/) for emitted bitmap and metafile resources and [MarkdownSaveOptions::setSvgImageSaving](https://reference.aspose.com/slides/php-java/aspose.slides/markdownsaveoptions/) for resources emitted as SVG. The former provides an [IImage](https://reference.aspose.com/slides/php-java/aspose.slides/iimage/) object and an [ImageFormat](https://reference.aspose.com/slides/php-java/aspose.slides/imageformat/) value; the latter provides an [SvgImage](https://reference.aspose.com/slides/php-java/aspose.slides/svgimage/) object whose SVG data can be read with [SvgImage::getSvgData](https://reference.aspose.com/slides/php-java/aspose.slides/svgimage/#getSvgData). 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/php-java/aspose.slides/markdownsaveoptions/) and [MarkdownSaveOptions::setImagesSaveFolderName](https://reference.aspose.com/slides/php-java/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 `DIRECTORY_SEPARATOR` 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/php-java/manage-hyperlinks/) are preserved as standard Markdown links. Slide [transitions](https://docs.aspose.com/slides/php-java/slide-transition/) and [animations](https://docs.aspose.com/slides/php-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/php-java/aspose.slides/presentation/) instance between threads. Follow the [multithreading guidelines](https://docs.aspose.com/slides/php-java/multithreading/) and use a separate instance for each file.
# Convert PowerPoint Presentations to PDF with Notes in PHP
> Convert formats PPT and PPTX to PDF with notes using Aspose.Slides for PHP via Java. Preserve layouts and speaker notes for professional presentations.
Source: https://docs.aspose.com/slides/php-java/convert-powerpoint-to-pdf-with-notes/
Updated: 2026-11-08
## **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/php-java/notes-size/).
## **Convert PowerPoint to PDF with Notes**
The `save` method in the [Presentation](https://reference.aspose.com/slides/php-java/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/php-java/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.
```php
$presentation = new Presentation("sample.pptx");
// Configure PDF options for rendering speaker notes.
$notesOptions = new NotesCommentsLayoutingOptions();
$notesOptions->setNotesPosition(NotesPositions::BottomFull); // Render speaker notes below the slide.
$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).
[](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-pdf-with-notes/visual-notes-export-f0ed0501bd93.svg)
*This BottomFull PDF places the speaker note below the slide.*
## Related articles
- [Convert PowerPoint Presentations to TIFF with Notes in PHP](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-tiff-with-notes/)
- [Note](https://docs.aspose.com/slides/php-java/examples/elements/note/)
# Convert PPT and PPTX to PDF in PHP [Advanced Features Included]
> Convert PowerPoint PPT/PPTX to high-quality, searchable PDFs in PHP using Aspose.Slides, with fast code examples and advanced conversion options.
Source: https://docs.aspose.com/slides/php-java/convert-powerpoint-to-pdf/
Updated: 2026-10-20
## **Overview**
Converting PowerPoint presentations (PPT, PPTX, ODP, etc.) into PDF format in PHP 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/php-java/aspose.slides/presentation/) class and then save the presentation as a PDF using a [save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/save/) method. The [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class exposes the [save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/save/) method that is typically used to convert a presentation to PDF.
Aspose.Slides for PHP via 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.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("PowerPoint.pptx");
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/php-java/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.
```php
use aspose\slides\PdfCompliance;
use aspose\slides\PdfOptions;
use aspose\slides\PdfTextCompression;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$pdfOptions = new PdfOptions();
$pdfOptions->setJpegQuality(90);
$pdfOptions->setSufficientResolution(300);
$pdfOptions->setSaveMetafilesAsPng(true);
$pdfOptions->setTextCompression(PdfTextCompression::Flate);
$pdfOptions->setCompliance(PdfCompliance::Pdf15);
$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/php-java/aspose.slides/pdfoptions/setbestimagescompressionratio/) 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.
```php
use aspose\slides\PdfOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$pdfOptions = new PdfOptions();
$pdfOptions->setBestImagesCompressionRatio(true);
$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/php-java/aspose.slides/pdfoptions/setjpegquality/) instead reduces JPEG image quality, while lowering the value passed to [setSufficientResolution](https://reference.aspose.com/slides/php-java/aspose.slides/pdfoptions/setsufficientresolution/) 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/php-java/aspose.slides/pdfoptions/) 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.
```php
use aspose\slides\PdfOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$pdfOptions = new PdfOptions();
$pdfOptions->setIncludeOleData(true);
$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/php-java/aspose.slides/pdfoptions/setshowhiddenslides/) method from the [PdfOptions](https://reference.aspose.com/slides/php-java/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.
```php
use aspose\slides\PdfOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$pdfOptions = new PdfOptions();
$pdfOptions->setShowHiddenSlides(true);
$presentation = new Presentation("PowerPoint.pptx");
try {
$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.
```php
use aspose\slides\PdfAccessPermissions;
use aspose\slides\PdfOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$pdfOptions = new PdfOptions();
$pdfOptions->setPassword("password");
$pdfOptions->setAccessPermissions(PdfAccessPermissions::PrintDocument | PdfAccessPermissions::HighQualityPrint);
$presentation = new Presentation("PowerPoint.pptx");
try {
$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/php-java/aspose.slides/saveoptions/) method under the [PdfOptions](https://reference.aspose.com/slides/php-java/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.
```php
use aspose\slides\PdfOptions;
use aspose\slides\Presentation;
use aspose\slides\ReturnAction;
use aspose\slides\SaveFormat;
use aspose\slides\WarningType;
class FontSubstitutionHandler {
function warning($warning)
{
if (java_values($warning->getWarningType()) == WarningType::DataLoss && $warning->getDescription()->startsWith("Font will be substituted")) {
echo("Font substitution warning: " . $warning->getDescription());
}
return ReturnAction::Continue;
}
}
$warningCallback = java_closure(new FontSubstitutionHandler(), null, java("com.aspose.slides.IWarningCallback"));
$pdfOptions = new PdfOptions();
$pdfOptions->setWarningCallback($warningCallback);
$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/php-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/php-java/aspose.slides/pdfoptions/) 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:
```php
use aspose\slides\PdfOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$pdfOptions = new PdfOptions();
$pdfOptions->setRasterizeUnsupportedFontStyles(true);
$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/php-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.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("PowerPoint.pptx");
try {
$slides = array(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.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SlideSizeScaleType;
$slideWidth = 612.0;
$slideHeight = 792.0;
$presentation = new Presentation("SelectedSlides.pptx");
$resizedPresentation = new Presentation();
try {
$resizedPresentation->getSlideSize()->setSize($slideWidth, $slideHeight, SlideSizeScaleType::EnsureFit);
$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.
```php
use aspose\slides\NotesCommentsLayoutingOptions;
use aspose\slides\NotesPositions;
use aspose\slides\PdfOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$notesOptions = new NotesCommentsLayoutingOptions();
$notesOptions->setNotesPosition(NotesPositions::BottomFull);
$pdfOptions = new PdfOptions();
$pdfOptions->setSlidesLayoutOptions($notesOptions);
$presentation = new Presentation("SelectedSlides.pptx");
try {
$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:
```php
$presentation = new Presentation("pres.pptx");
try {
$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/php-java/conversion/pdf-to-html/), [PDF to image](https://products.aspose.com/slides/php-java/conversion/pdf-to-image/), [PDF to JPG](https://products.aspose.com/slides/php-java/conversion/pdf-to-jpg/), and [PDF to PNG](https://products.aspose.com/slides/php-java/conversion/pdf-to-png/) conversions. Other PDF conversion operations to specialized formats—[PDF to SVG](https://products.aspose.com/slides/php-java/conversion/pdf-to-svg/), [PDF to TIFF](https://products.aspose.com/slides/php-java/conversion/pdf-to-tiff/), and [PDF to XML](https://products.aspose.com/slides/php-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/php-java/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/php-java/aspose.slides/pdfoptions/setshowhiddenslides/) with `true` in the [PdfOptions](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/pdfoptions/setjpegquality/) and [setSufficientResolution](https://reference.aspose.com/slides/php-java/aspose.slides/pdfoptions/setsufficientresolution/) in the [PdfOptions](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/pdfcompliance/), including PDF/A1a, PDF/A1b, and PDF/UA, ensuring your documents meet accessibility and archival requirements.
## **Additional Resources**
- [Aspose.Slides for PHP via Java Documentation](https://docs.aspose.com/slides/php-java/)
- [Aspose.Slides for PHP via Java API Reference](https://reference.aspose.com/slides/php-java/)
- [Aspose Free Online Converters](https://products.aspose.app/slides/conversion)
# Convert PowerPoint Slides to PNG in PHP
> Convert PowerPoint presentations to high-quality PNG images quickly with Aspose.Slides for PHP via Java, ensuring precise, automated results.
Source: https://docs.aspose.com/slides/php-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 PHP via 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/php-java/aspose.slides/presentation/) class and access its slides through the [Presentation::getSlides](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getSlides) collection. The example renders every slide with [Slide::getImage](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#getImage) without parameters to create a thumbnail. It then calls [IImage::save](https://reference.aspose.com/slides/php-java/aspose.slides/iimage/#save) with [ImageFormat::Png](https://reference.aspose.com/slides/php-java/aspose.slides/imageformat/#Png) to save each rendered slide as a PNG image.
```php
use aspose\slides\ImageFormat;
use aspose\slides\Presentation;
$presentation = new Presentation("presentation.pptx");
try {
$slideCount = java_values($presentation->getSlides()->size());
for ($index = 0; $index < $slideCount; $index++) {
$slide = $presentation->getSlides()->get_Item($index);
$image = $slide->getImage();
try {
$image->save("slide_" . $index . ".png", ImageFormat::Png);
} finally {
$image->dispose();
}
}
} finally {
$presentation->dispose();
}
```
The parameterless [Slide::getImage](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#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 [Slide::getImage](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#getImage) 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/php-java/aspose.slides/iimage/#save).
```php
use aspose\slides\ImageFormat;
use aspose\slides\Presentation;
$presentation = new Presentation("presentation.pptx");
try {
$scaleX = 2.0;
$scaleY = $scaleX;
$slideCount = java_values($presentation->getSlides()->size());
for ($index = 0; $index < $slideCount; $index++) {
$slide = $presentation->getSlides()->get_Item($index);
$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 [Slide::getImage](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#getImage) 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/php-java/aspose.slides/iimage/#save). Choose dimensions that match the slide's aspect ratio to avoid stretching the image.
```php
use aspose\slides\ImageFormat;
use aspose\slides\Presentation;
$presentation = new Presentation("presentation.pptx");
try {
$imageSize = new Java("java.awt.Dimension", 960, 720);
$slideCount = java_values($presentation->getSlides()->size());
for ($index = 0; $index < $slideCount; $index++) {
$slide = $presentation->getSlides()->get_Item($index);
$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/php-java/aspose.slides/saveoptions/#setGradientStyle) method inherited by [RenderingOptions](https://reference.aspose.com/slides/php-java/aspose.slides/renderingoptions/) to choose how the gradients are rendered.
Download [gradient-styles.pptx](https://docs.aspose.com/slides/php-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 [Slide::getImage](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#getImage).
```php
use aspose\slides\GradientStyle;
use aspose\slides\ImageFormat;
use aspose\slides\Presentation;
use aspose\slides\RenderingOptions;
$presentation = new Presentation("gradient-styles.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$gradientStyles = [GradientStyle::Default, GradientStyle::PowerPointUI];
foreach ($gradientStyles as $style) {
$options = new RenderingOptions();
$options->setGradientStyle($style);
$styleName = $style == GradientStyle::Default ? "Default" : "PowerPointUI";
$image = $slide->getImage($options, 1.0, 1.0);
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/php-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/php-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/php-java/licensing/) until a license is applied.
# Convert PowerPoint Presentations to SWF Flash in PHP
> Convert PowerPoint (PPT/PPTX) to SWF Flash in PHP with Aspose.Slides. Step‑by‑step code samples, fast quality output, no PowerPoint automation.
Source: https://docs.aspose.com/slides/php-java/convert-powerpoint-to-swf-flash/
Updated: 2026-08-02
## **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/php-java/aspose.slides/presentation/save/) method and how to configure the export with [SwfOptions](https://reference.aspose.com/slides/php-java/aspose.slides/swfoptions/), including viewer settings and notes or comments layout.
## **Convert Presentations to Flash**
The [save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/save/) method exposed by the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class can be used to convert the whole presentation into an **SWF** document. The following example shows how to convert a presentation into an **SWF** document by using the options provided by the [SWFOptions](https://reference.aspose.com/slides/php-java/aspose.slides/swfoptions/) class. You can also include comments in the generated SWF by using the [NotesCommentsLayoutingOptions](https://reference.aspose.com/slides/php-java/aspose.slides/notescommentslayoutingoptions/) class.
```php
$pres = new Presentation("Sample.pptx");
try {
$swfOptions = new SwfOptions();
$swfOptions->setViewerIncluded(false);
$swfOptions->getNotesCommentsLayouting()->setNotesPosition(NotesPositions::BottomFull);
# Saving presentation
$pres->save("Sample.swf", SaveFormat::Swf, $swfOptions);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **FAQ**
### Can I include hidden slides in the SWF?
Yes. Enable the hidden slides using the [setShowHiddenSlides](https://reference.aspose.com/slides/php-java/aspose.slides/swfoptions/setshowhiddenslides/) method in [SwfOptions](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/swfoptions/setcompressed/) method and [adjust JPEG quality](https://reference.aspose.com/slides/php-java/aspose.slides/swfoptions/setjpegquality/) to balance file size and image fidelity.
### What is 'setViewerIncluded' for, and when should I disable it?
[setViewerIncluded](https://reference.aspose.com/slides/php-java/aspose.slides/swfoptions/setviewerincluded/) 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/php-java/aspose.slides/saveoptions/#setDefaultRegularFont) in [SwfOptions](https://reference.aspose.com/slides/php-java/aspose.slides/swfoptions/) to avoid an unintended fallback.
## Related articles
- [Extract Flash Objects from Presentations in PHP](https://docs.aspose.com/slides/php-java/flash/)
# Convert PowerPoint Presentations to TIFF with Notes in PHP
> Convert PowerPoint presentations to TIFF with notes using Aspose.Slides for PHP via Java. Learn how to export slides with speaker notes efficiently.
Source: https://docs.aspose.com/slides/php-java/convert-powerpoint-to-tiff-with-notes/
Updated: 2026-08-13
## **Introduction**
Aspose.Slides for PHP via 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/php-java/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 PHP via Java involves the following steps:
1. Instantiate the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class: Load a PowerPoint or OpenDocument file.
1. Configure the output layout options: Use the [NotesCommentsLayoutingOptions](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/presentation/#save) 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/php-java/aspose.slides/tiffoptions/#setSlidesLayoutOptions) method.
```php
// Instantiate the Presentation class that represents a presentation file.
$presentation = new Presentation("speaker_notes.pptx");
try {
$notesOptions = new NotesCommentsLayoutingOptions();
$notesOptions->setNotesPosition(NotesPositions::BottomFull); // Display the notes below the slide.
// Configure the TIFF options with Notes layouting.
$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/php-java/aspose.slides/tiffoptions/#setSlidesLayoutOptions) 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/php-java/aspose.slides/tiffoptions/setcompressiontype/) (e.g., `LZW` or `RLE`), set a reasonable DPI, and, if acceptable, use a lower [pixel format](https://reference.aspose.com/slides/php-java/aspose.slides/tiffoptions/setpixelformat/) (such as 8 bpp or 1 bpp for monochrome). Slightly reducing the [image dimensions](https://reference.aspose.com/slides/php-java/aspose.slides/tiffoptions/setimagesize/) 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/php-java/font-selection-sequence/), which can change text metrics and appearance. To avoid this, [supply the required fonts](https://docs.aspose.com/slides/php-java/custom-font/) or set a default [fallback font](https://docs.aspose.com/slides/php-java/fallback-font/) so the intended typefaces are used.
## Related articles
- [Convert PowerPoint Presentations to PDF with Notes in PHP](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-pdf-with-notes/)
- [Convert Presentation Slides to Images in PHP](https://docs.aspose.com/slides/php-java/convert-slide/)
# Convert PowerPoint Presentations to TIFF in PHP
> Learn how to easily convert PowerPoint (PPT, PPTX) presentations to high-quality TIFF images using Aspose.Slides for PHP via Java, with code examples.
Source: https://docs.aspose.com/slides/php-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/php-java/aspose.slides/presentation/#save) method provided by the [Presentation](https://reference.aspose.com/slides/php-java/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:
```php
// Instantiate the Presentation class that represents a presentation file (PPT, PPTX, ODP, etc.).
$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/php-java/aspose.slides/tiffoptions/#setBwConversionMode) in the [TiffOptions](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/tiffoptions/#getCompressionType) method is set to `CCITT4` or `CCITT3`.
[TiffOptions::setBwConversionMode](https://reference.aspose.com/slides/php-java/aspose.slides/tiffoptions/#setBwConversionMode) 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 [Shape::setBlackWhiteMode](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#setBlackWhiteMode). See [Control Black-and-White Rendering for Shapes](https://docs.aspose.com/slides/php-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:
```php
$tiffOptions = new TiffOptions();
$tiffOptions->setCompressionType(TiffCompressionTypes::CCITT4);
$tiffOptions->setBwConversionMode(BlackWhiteConversionMode::Dithering);
$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/php-java/aspose.slides/tiffoptions/). For instance, the [setImageSize](https://reference.aspose.com/slides/php-java/aspose.slides/tiffoptions/#getImageSize) 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:
```php
// Instantiate the Presentation class that represents a presentation file (PPT, PPTX, ODP, etc.).
$presentation = new Presentation("presentation.pptx");
try {
$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 Java("java.awt.Dimension", 1728, 1078));
$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/php-java/aspose.slides/tiffoptions/#getPixelFormat) method from the [TiffOptions](https://reference.aspose.com/slides/php-java/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:
```php
// Instantiate the Presentation class that represents a presentation file (PPT, PPTX, ODP, etc.).
$presentation = new Presentation("presentation.pptx");
try {
$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 image size.
$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 PHP](https://docs.aspose.com/slides/php-java/convert-slide/)
# Convert PowerPoint Presentations to Video in PHP
> Learn how to convert PowerPoint presentations to video with Aspose.Slides for PHP. Discover sample code and automation techniques to streamline your workflow.
Source: https://docs.aspose.com/slides/php-java/convert-powerpoint-to-video/
Updated: 2026-11-08
## **Introduction**
By converting your PowerPoint presentation to video, you get
* **Increase in accessibility:** All devices (regardless of platform) are equipped with video players by default compared to presentation-opening applications, so users find it easier to open or play videos.
* **More reach:** Through videos, you can reach a large audience and target them with information that might otherwise seem tedious in a presentation. Most surveys and statistics suggest that people watch and consume videos more than other forms of content, and they generally prefer such content.
You may want to check our [**PowerPoint to Video Online Converter**](https://products.aspose.app/slides/conversion/ppt-to-word) because it is a live and effective implementation of the process described here.
## **PowerPoint to Video Conversion in Aspose.Slides**
Aspose.Slides supports 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.
[](https://docs.aspose.com/slides/php-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.*
### **Convert PowerPoint to Video**
1. Add this to your POM file:
```xml
net.bramp.ffmpegffmpeg0.7.0
```php
```
2. Download ffmpeg [here](https://ffmpeg.org/download.html).
4. Run the PowerPoint to video PHP code.
This PHP code shows you how to convert a presentation (containing a figure and two animation effects) to a video:
```php
$presentation = new Presentation();
try {
# Adds a smile shape and then animates it
$smile = $presentation->getSlides()->get_Item(0)->getShapes()->addAutoShape(ShapeType::SmileyFace, 110, 20, 500, 500);
$mainSequence = $presentation->getSlides()->get_Item(0)->getTimeline()->getMainSequence();
$effectIn = $mainSequence->addEffect($smile, EffectType::Fly, EffectSubtype::TopLeft, EffectTriggerType::AfterPrevious);
$effectOut = $mainSequence->addEffect($smile, EffectType::Fly, EffectSubtype::BottomRight, EffectTriggerType::AfterPrevious);
$effectIn->getTiming()->setDuration(2.0);
$effectOut->setPresetClassType(EffectPresetClassType::Exit);
$fps = 33;
class FrameTick {
function invoke($sender, $arguments) {
try {
$frame = sprintf("frame_%04d.png", $sender->getFrameIndex());
$arguments->getFrame()->save($frame, ImageFormat::Png);
$frames->add($frame);
} catch (JavaException $e) {
}
}
}
$frames = new Java("java.util.ArrayList");
$animationsGenerator = new PresentationAnimationsGenerator($presentation);
try {
$player = new PresentationPlayer($animationsGenerator, $fps);
try {
$frameTick = java_closure(new FrameTick(), null, java("com.aspose.slides.PresentationPlayerFrameTick"));
$player->setFrameTick($frameTick);
$animationsGenerator->run($presentation->getSlides());
} finally {
if (!java_is_null($player)) {
$player->dispose();
}
}
} finally {
if (!java_is_null($animationsGenerator)) {
$animationsGenerator->dispose();
}
}
# Configure ffmpeg binaries folder. See this page: https://github.com/rosenbjerg/FFMpegCore#installation
$ffmpeg = new Java("net.bramp.ffmpeg.builder.FFmpeg", "path/to/ffmpeg");
$ffprobe = new Java("net.bramp.ffmpeg.builder.FFprobe", "path/to/ffprobe");
$builder = (new Java("net.bramp.ffmpeg.builder.FFmpegBuilder"))->addExtraArgs("-start_number", "1")->setInput("frame_%04d.png")->addOutput("output.avi")->setVideoFrameRate(FFmpeg->FPS_24)->setFormat("avi")->done();
$executor = new Java("net.bramp.ffmpeg.builder.FFmpegExecutor", $ffmpeg, $ffprobe);
$executor->createJob($builder)->run();
} catch (JavaException $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/php-java/powerpoint-animation/), [Shape Animation](https://docs.aspose.com/slides/php-java/shape-animation/), and [Shape Effect](https://docs.aspose.com/slides/php-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:
```php
$presentation = new Presentation();
# Adds a smile shape and animates it
# ...
# Adds a new slide and animated transition
$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(java("java.awt.Color")->MAGENTA);
$newSlide->getSlideShowTransition()->setType(TransitionType::Push);
```
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):
```php
$presentation = new Presentation();
try {
# Adds text and animations
$autoShape = $presentation->getSlides()->get_Item(0)->getShapes()->addAutoShape(ShapeType::Rectangle, 210, 120, 300, 300);
$para1 = new Paragraph();
$para1->getPortions()->add(new Portion("Aspose Slides for Java"));
$para2 = new Paragraph();
$para2->getPortions()->add(new Portion("convert PowerPoint Presentation with text to video"));
$para3 = new Paragraph();
$para3->getPortions()->add(new Portion("paragraph by paragraph"));
$paragraphCollection = $autoShape->getTextFrame()->getParagraphs();
$paragraphCollection->add($para1);
$paragraphCollection->add($para2);
$paragraphCollection->add($para3);
$paragraphCollection->add(new Paragraph());
$mainSequence = $presentation->getSlides()->get_Item(0)->getTimeline()->getMainSequence();
$effect1 = $mainSequence->addEffect($para1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$effect2 = $mainSequence->addEffect($para2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$effect3 = $mainSequence->addEffect($para3, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$effect4 = $mainSequence->addEffect($para3, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
$effect1->getTiming()->setTriggerDelayTime(1.0);
$effect2->getTiming()->setTriggerDelayTime(1.0);
$effect3->getTiming()->setTriggerDelayTime(1.0);
$effect4->getTiming()->setTriggerDelayTime(1.0);
$fps = 33;
class FrameTick {
function invoke($sender, $arguments) {
try {
$frame = sprintf("frame_%04d.png", $sender->getFrameIndex());
$arguments->getFrame()->save($frame, ImageFormat::Png);
$frames->add($frame);
} catch (JavaException $e) {
}
}
}
$frames = new Java("java.util.ArrayList");
$animationsGenerator = new PresentationAnimationsGenerator($presentation);
try {
$player = new PresentationPlayer($animationsGenerator, $fps);
try {
$frameTick = java_closure(new FrameTick(), null, java("com.aspose.slides.PresentationPlayerFrameTick"));
$player->setFrameTick($frameTick);
$animationsGenerator->run($presentation->getSlides());
} finally {
if (!java_is_null($player)) {
$player->dispose();
}
}
} finally {
if (!java_is_null($animationsGenerator)) {
$animationsGenerator->dispose();
}
}
# Configure ffmpeg binaries folder. See this page: https://github.com/rosenbjerg/FFMpegCore#installation
$ffmpeg = new Java("net.bramp.ffmpeg.builder.FFmpeg", "path/to/ffmpeg");
$ffprobe = new Java("net.bramp.ffmpeg.builder.FFprobe", "path/to/ffprobe");
$builder = (new Java("net.bramp.ffmpeg.builder.FFmpegBuilder"))->addExtraArgs("-start_number", "1")->setInput("frame_%04d.png")->addOutput("output.avi")->setVideoFrameRate(FFmpeg->FPS_24)->setFormat("avi")->done();
$executor = new Java("net.bramp.ffmpeg.builder.FFmpegExecutor", $ffmpeg, $ffprobe);
$executor->createJob($builder)->run();
} catch (JavaException $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/php-java/aspose.slides/presentationanimationsgenerator/) and [PresentationPlayer](https://reference.aspose.com/slides/php-java/aspose.slides/presentationplayer/) classes.
[PresentationAnimationsGenerator](https://reference.aspose.com/slides/php-java/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::getSlideSize` will be used and it generates animations that [PresentationPlayer](https://reference.aspose.com/slides/php-java/aspose.slides/presentationplayer/) uses.
When animations are generated, a `NewAnimation` event is generated for each subsequent animation, which has the presentation animation player parameter. The latter is a class that represents a player for a separate animation.
To work with the presentation animation player, the `getDuration` (the full duration of the animation) and `setTimePosition` methods are used. Each animation position is set within the *0 to duration* range, and then the `getFrame` method will return a BufferedImage that corresponds to the animation state at that moment:
```php
use aspose\slides\Presentation;
use aspose\slides\PresentationPlayer;
use aspose\slides\PresentationAnimationsGenerator;
use aspose\slides\ImageFormat;
use aspose\slides\ShapeType;
use aspose\slides\EffectType;
use aspose\slides\EffectSubtype;
use aspose\slides\EffectTriggerType;
use aspose\slides\EffectPresetClassType;
class PresentationAnimationPlayer {
function invoke($animationPlayer) {
echo(sprintf("Animation total duration: %f", $animationPlayer->getDuration()));
$animationPlayer->setTimePosition(0);// initial animation state
try {
# initial animation state bitmap
$animationPlayer->getFrame()->save("firstFrame.png", ImageFormat::Png);
} catch (JavaException $e) {
}
$animationPlayer->setTimePosition($animationPlayer->getDuration());// final state of the animation
try {
# last frame of the animation
$animationPlayer->getFrame()->save("lastFrame.png", ImageFormat::Png);
} catch (JavaException $e) {
}
}
}
$presentation = new Presentation();
try {
# Adds a smile shape and animates it
$smile = $presentation->getSlides()->get_Item(0)->getShapes()->addAutoShape(ShapeType::SmileyFace, 110, 20, 500, 500);
$mainSequence = $presentation->getSlides()->get_Item(0)->getTimeline()->getMainSequence();
$effectIn = $mainSequence->addEffect($smile, EffectType::Fly, EffectSubtype::TopLeft, EffectTriggerType::AfterPrevious);
$effectOut = $mainSequence->addEffect($smile, EffectType::Fly, EffectSubtype::BottomRight, EffectTriggerType::AfterPrevious);
$effectIn->getTiming()->setDuration(2.0);
$effectOut->setPresetClassType(EffectPresetClassType::Exit);
$animationsGenerator = new PresentationAnimationsGenerator($presentation);
$presentationAnimation=java_closure(new PresentationAnimationPlayer(), null, java("com.aspose.slides.PresentationAnimationsGeneratorNewAnimation"));
try {
$animationsGenerator->setNewAnimation($presentationAnimation);
} finally {
if (!java_is_null($animationsGenerator)) {
$animationsGenerator->dispose();
}
}
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
To make all animations in a presentation play at once, the [PresentationPlayer](https://reference.aspose.com/slides/php-java/aspose.slides/presentationplayer/) class is used. This class takes a [PresentationAnimationsGenerator](https://reference.aspose.com/slides/php-java/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:
```php
class FrameTick {
function invoke($sender, $arguments) {
try {
$arguments->getFrame()->save("frame_" . $sender->getFrameIndex() . ".png", ImageFormat::Png);
} catch (JavaException $e) {
}
}
}
$presentation = new Presentation("animated.pptx");
try {
$animationsGenerator = new PresentationAnimationsGenerator($presentation);
try {
$player = new PresentationPlayer($animationsGenerator, 33);
try {
$frameTick = java_closure(new FrameTick(), null, java("com.aspose.slides.PresentationPlayerFrameTick"));
$player->setFrameTick($frameTick);
$animationsGenerator->run($presentation->getSlides());
} finally {
if (!java_is_null($player)) {
$player->dispose();
}
}
} finally {
if (!java_is_null($animationsGenerator)) {
$animationsGenerator->dispose();
}
}
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
Then the generated frames can be compiled to produce a video. See the [Convert PowerPoint to Video](https://docs.aspose.com/slides/php-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/php-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 XML in PHP
> Convert PowerPoint and OpenDocument presentations to PowerPoint XML files or streams in PHP with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/convert-powerpoint-to-xml/
Updated: 2026-09-01
## **Overview**
Aspose.Slides for PHP via 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/php-java/aspose.slides/presentation/) method with the `Xml` value from the [SaveFormat](https://reference.aspose.com/slides/php-java/aspose.slides/saveformat/) enumeration. 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/php-java/aspose.slides/presentation/) class, and then pass the output path and `SaveFormat::Xml` to [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/). 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:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$inputPath = __DIR__ . DIRECTORY_SEPARATOR . "presentation.pptx";
$outputPath = __DIR__ . DIRECTORY_SEPARATOR . "presentation.xml";
$presentation = new Presentation($inputPath);
try {
$presentation->save($outputPath, SaveFormat::Xml);
} finally {
$presentation->dispose();
}
```
## **Write the XML Output to a Stream**
Use the stream overload of [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) 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/javase/8/docs/api/java/io/ByteArrayOutputStream.html) and obtains the generated XML as a byte array:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$inputPath = __DIR__ . DIRECTORY_SEPARATOR . "presentation.pptx";
$presentation = new Presentation($inputPath);
try {
$xmlStream = new Java("java.io.ByteArrayOutputStream");
try {
$presentation->save($xmlStream, SaveFormat::Xml);
$xmlBytes = $xmlStream->toByteArray();
// Pass $xmlBytes to the next component in the workflow.
} finally {
$xmlStream->close();
}
} finally {
$presentation->dispose();
}
```
A `ByteArrayOutputStream` stores all generated data in memory, so no position reset is required before calling `toByteArray`.
## **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/php-java/supported-file-formats/) table lists PowerPoint XML Presentation as a save-only format, so do not use it when a workflow must load the exported file back into Aspose.Slides for continued editing.
## **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/php-java/aspose.slides/presentation/). For example, use a [ByteArrayOutputStream](https://docs.oracle.com/javase/8/docs/api/java/io/ByteArrayOutputStream.html) for in-memory processing.
**Can Aspose.Slides load the exported XML file again?**
No. PowerPoint XML Presentation is currently supported for saving but not for loading. Use PPTX or another supported presentation format when round-trip editing is required.
**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 PHP
> Convert PowerPoint PPT/PPTX to high-quality, platform-independent XPS using Aspose.Slides for PHP via Java. Get step-by-step guide and sample code.
Source: https://docs.aspose.com/slides/php-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/php-java/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/php-java/) for Java, you can use the [**Save**](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation#save-java.lang.String-int-com.aspose.slides.ISaveOptions-) method exposed by the [Presentation](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/xpsoptions))
- Custom settings (with [**XPSOptions**](https://reference.aspose.com/slides/php-java/aspose.slides/xpsoptions))
### **Convert Presentations to XPS Using Default Settings**
This sample code shows you how to convert a presentation to an XPS document using standard settings:
```php
# Instantiate a Presentation object that represents a presentation file
$pres = new Presentation("Convert_XPS.pptx");
try {
# Saving the presentation to XPS document
$pres->save("XPS_Output_Without_XPSOption.xps", SaveFormat::Xps);
} finally {
if (!java_is_null($pres)) {
$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 :
```php
# Instantiate a Presentation object that represents a presentation file
$pres = new Presentation("Convert_XPS_Options.pptx");
try {
# Instantiate the TiffOptions class
$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 (!java_is_null($pres)) {
$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/php-java/aspose.slides/xpsoptions/setshowhiddenslides/) through [export settings](https://reference.aspose.com/slides/php-java/aspose.slides/xpsoptions/) before saving to XPS, ensuring the output contains exactly the pages you intend.
# Convert PowerPoint Presentations in PHP | HTML, PNG, PDF, Word, TIFF
> Convert PowerPoint presentations to other formats using Aspose.Slides for PHP via Java. Fast, accurate, and seamless PPT and PPTX conversion.
Source: https://docs.aspose.com/slides/php-java/convert-powerpoint/
Updated: 2026-07-31
---
lastmod: 2026-07-31T17:58:46+04:00
title: Convert PowerPoint Presentations in PHP | HTML, PNG, PDF, Word, TIFF
linktitle: Convert PowerPoint
type: docs
weight: 20
url: /php-java/convert-powerpoint/
aliases:
- /php-java/convert-powerpoint-to-word/
keywords:
- convert PowerPoint
- convert presentation
- convert slide
- convert PPT
- convert PPTX
- export PowerPoint
- export presentation
- export slide
- export PPT
- export PPTX
- PHP
- Aspose.Slides
description: "Convert PowerPoint presentations to other formats using Aspose.Slides for PHP via Java. Fast, accurate, and seamless PPT and PPTX conversion."
---
## Related articles
- [Convert OpenDocument Presentations in PHP](https://docs.aspose.com/slides/php-java/convert-openoffice-odp/)
- [Convert PPTX to PPT in PHP](https://docs.aspose.com/slides/php-java/convert-pptx-to-ppt/)
- [Import Presentations from PDF or HTML in PHP](https://docs.aspose.com/slides/php-java/import-presentation/)
# Convert PPT to PPTX in PHP
> Convert legacy PPT files to PPTX in PHP with Aspose.Slides. Includes PHP examples for single-file and batch conversion, error handling, and fidelity notes.
Source: https://docs.aspose.com/slides/php-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 PHP via 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/php-java/aspose.slides/presentation/) class, then call [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#save) with [SaveFormat::Pptx](https://reference.aspose.com/slides/php-java/aspose.slides/saveformat/#Pptx). The `finally` block disposes the presentation and releases its resources.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
// Load the legacy PPT presentation.
$presentation = new Presentation("presentation.ppt");
try {
// Save the presentation in PPTX format.
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The file extension does not select the output format by itself; the [SaveFormat::Pptx](https://reference.aspose.com/slides/php-java/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.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$inputDirectory = "input";
$outputDirectory = "output";
if (!is_dir($outputDirectory) && !mkdir($outputDirectory, 0777, true)) {
throw new RuntimeException("Cannot create the output directory: " . $outputDirectory);
}
$inputFiles = [];
foreach (new DirectoryIterator($inputDirectory) as $fileInfo) {
if ($fileInfo->isFile() && strtolower($fileInfo->getExtension()) === "ppt") {
$inputFiles[] = $fileInfo->getPathname();
}
}
foreach ($inputFiles as $inputPath) {
$outputFileName = pathinfo($inputPath, PATHINFO_FILENAME) . ".pptx";
$outputPath = $outputDirectory . DIRECTORY_SEPARATOR . $outputFileName;
$presentation = null;
try {
$presentation = new Presentation($inputPath);
$presentation->save($outputPath, SaveFormat::Pptx);
echo "Converted: " . $inputPath . PHP_EOL;
} catch (Throwable $exception) {
fwrite(STDERR, "Failed: " . $inputPath . " (" . $exception->getMessage() . ")" . PHP_EOL);
} 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/php-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/php-java/aspose.slides/presentation/#save) 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/php-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 PHP API.
## **Related Articles**
- [PPT vs PPTX](https://docs.aspose.com/slides/php-java/ppt-vs-pptx/)
- [Save Presentations in PHP](https://docs.aspose.com/slides/php-java/save-presentation/)
- [Supported File Formats](https://docs.aspose.com/slides/php-java/supported-file-formats/)
- [Open Presentations in PHP](https://docs.aspose.com/slides/php-java/open-presentation/)
## **FAQ**
**Can I convert PPT to PPTX without Microsoft PowerPoint installed?**
Yes. Aspose.Slides for PHP via 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/php-java/ppt-to-pptx-conversion/)
- [Convert ODP to PPTX in PHP](https://docs.aspose.com/slides/php-java/convert-odp-to-pptx/)
- [Convert PPTX to PPT in PHP](https://docs.aspose.com/slides/php-java/convert-pptx-to-ppt/)
# Convert PPTX to PPT in PHP
> Easily convert PPTX to PPT with Aspose.Slides — ensure seamless compatibility with PowerPoint formats while preserving your presentation’s layout and quality.
Source: https://docs.aspose.com/slides/php-java/convert-pptx-to-ppt/
Updated: 2026-08-02
## **Overview**
This article explains how to convert PowerPoint Presentation in PPTX format into PPT format using PHP. The following topic is covered.
- Convert PPTX to PPT
## **Convert PPTX to PPT in PHP**
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/php-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 PHP](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-pdf/)
- [Convert PPTX to XPS in PHP](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-xps/)
- [Convert PPTX to HTML in PHP](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-html/)
- [Convert PPTX to ODP in PHP](https://docs.aspose.com/slides/php-java/save-presentation/)
- [Convert PPTX to PNG in PHP](https://docs.aspose.com/slides/php-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/php-java/aspose.slides/Presentation) class. The PHP code sample below converts a Presentation from PPTX to PPT using default options.
```php
# instantiate a Presentation object that represents a PPTX file
$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/php-java/password-protected-presentation/) for the saved PPT.
## Related articles
- [Convert PowerPoint Presentations in PHP | HTML, PNG, PDF, Word, TIFF](https://docs.aspose.com/slides/php-java/convert-powerpoint/)
- [Convert PPT to PPTX in PHP](https://docs.aspose.com/slides/php-java/convert-ppt-to-pptx/)
# Convert Presentations to Multiple Formats in PHP
> Convert PowerPoint and OpenDocument presentations to PPTX, PDF, HTML, images, XPS, TIFF, and more with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/convert-presentation/
Updated: 2026-09-01
## **Overview**
Aspose.Slides for PHP via 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 PHP 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/php-java/convert-ppt-to-pptx/), [Convert ODP to PPTX](https://docs.aspose.com/slides/php-java/convert-odp-to-pptx/), [Save Presentations](https://docs.aspose.com/slides/php-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/php-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/php-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/php-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/php-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/php-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/php-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/php-java/convert-powerpoint-to-jpg/) |
| Slide to SVG | Export individual slides as scalable vector graphics. | [Render Slide as SVG](https://docs.aspose.com/slides/php-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/php-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/php-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/php-java/convert-powerpoint-to-tiff-with-notes/) |
| PPT/PPTX to Markdown | Extract presentation content into Markdown for documentation and text-based workflows. | [Convert PowerPoint to Markdown](https://docs.aspose.com/slides/php-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/php-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/php-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/php-java/convert-powerpoint-to-video/) |
| Presentation to XAML | Export slides to XAML for PHP or Java UI scenarios. | [Export Presentations to XAML](https://docs.aspose.com/slides/php-java/export-to-xaml/) |
For a broader list of input and output formats, see [Supported File Formats](https://docs.aspose.com/slides/php-java/supported-file-formats/).
## **PowerPoint and OpenDocument Conversion**
Aspose.Slides for PHP via 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/php-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 PHP via 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/php-java/convert-ppt-to-pptx/) and [PPT vs PPTX](https://docs.aspose.com/slides/php-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 PHP via 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/php-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/php-java/convert-powerpoint-to-pdf/) and [XPS](https://docs.aspose.com/slides/php-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/php-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/php-java/embedded-font/), [Fallback Font](https://docs.aspose.com/slides/php-java/fallback-font/), and [Font Substitution](https://docs.aspose.com/slides/php-java/font-substitution/).
## Related articles
- [Convert OpenDocument Presentations in PHP](https://docs.aspose.com/slides/php-java/convert-openoffice-odp/)
- [Supported File Formats](https://docs.aspose.com/slides/php-java/supported-file-formats/)
# Convert Presentation Slides to Images in PHP
> Convert slides from PPT, PPTX, and ODP presentations to PNG, JPEG, GIF, TIFF, EMF, and other image formats in PHP with Aspose.Slides.
Source: https://docs.aspose.com/slides/php-java/convert-slide/
Updated: 2026-08-28
## **Introduction**
Aspose.Slides for PHP via 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/php-java/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/php-java/aspose.slides/renderingoptions/) or [TiffOptions](https://reference.aspose.com/slides/php-java/aspose.slides/tiffoptions/) class.
4. Call the [Slide::getImage](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#getImage) method. It returns an [IImage](https://reference.aspose.com/slides/php-java/aspose.slides/iimage/) object.
5. Call the [IImage::save](https://reference.aspose.com/slides/php-java/aspose.slides/iimage/#save) method and specify the output format with an [ImageFormat](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/iimage/) object can be processed in memory or saved to a file.
The following PHP example renders the first slide and saves it as a PNG image:
```php
use aspose\slides\ImageFormat;
use aspose\slides\Presentation;
$presentation = new Presentation("Presentation.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$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 [Slide::getImage](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#getImage) 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:
```php
use aspose\slides\ImageFormat;
use aspose\slides\Presentation;
$imageSize = new Java("java.awt.Dimension", 1820, 1040);
$presentation = new Presentation("Presentation.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$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/php-java/aspose.slides/notescommentslayoutingoptions/) object to the [RenderingOptions::setSlidesLayoutOptions](https://reference.aspose.com/slides/php-java/aspose.slides/renderingoptions/#setSlidesLayoutOptions) method to control where notes and comments appear.
The following example places truncated notes below the slide and comments to its right:
```php
use aspose\slides\CommentsPositions;
use aspose\slides\ImageFormat;
use aspose\slides\NotesCommentsLayoutingOptions;
use aspose\slides\NotesPositions;
use aspose\slides\Presentation;
use aspose\slides\RenderingOptions;
$scaleX = 2;
$scaleY = $scaleX;
$commentsAreaColor = new Java("java.awt.Color", 250, 235, 215);
$layoutOptions = new NotesCommentsLayoutingOptions();
$layoutOptions->setNotesPosition(NotesPositions::BottomTruncated);
$layoutOptions->setCommentsPosition(CommentsPositions::Right);
$layoutOptions->setCommentsAreaWidth(500);
$layoutOptions->setCommentsAreaColor($commentsAreaColor);
$renderingOptions = new RenderingOptions();
$renderingOptions->setSlidesLayoutOptions($layoutOptions);
$presentation = new Presentation("Presentation_with_notes_and_comments.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$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/php-java/aspose.slides/notespositions/) to the [NotesCommentsLayoutingOptions::setNotesPosition](https://reference.aspose.com/slides/php-java/aspose.slides/notescommentslayoutingoptions/#setNotesPosition) method. Notes can contain more text than the fixed image size can accommodate. Use [BottomTruncated](https://reference.aspose.com/slides/php-java/aspose.slides/notespositions/) instead.
## **Convert Slides to Images Using TIFF Options**
The [TiffOptions](https://reference.aspose.com/slides/php-java/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:
```php
use aspose\slides\ImageFormat;
use aspose\slides\Presentation;
use aspose\slides\TiffOptions;
$imageSize = new Java("java.awt.Dimension", 2160, 2880);
$tiffOptions = new TiffOptions();
$tiffOptions->setImageSize($imageSize);
$tiffOptions->setDpiX(300);
$tiffOptions->setDpiY(300);
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$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:
```php
use aspose\slides\ImageFormat;
use aspose\slides\Presentation;
$scaleX = 2;
$scaleY = $scaleX;
$presentation = new Presentation("Presentation.pptx");
try {
$slideCount = java_values($presentation->getSlides()->size());
for ($index = 0; $index < $slideCount; $index++) {
$slide = $presentation->getSlides()->get_Item($index);
$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 [Slide::writeAsEmf](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#writeAsEmf) method writes a slide 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:
```php
use aspose\slides\Presentation;
$presentation = new Presentation("Presentation.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$emfStream = new Java("java.io.FileOutputStream", "Slide_0.emf");
try {
$slide->writeAsEmf($emfStream);
} finally {
$emfStream->close();
}
} finally {
$presentation->dispose();
}
```
The caller owns the stream passed to [Slide::writeAsEmf](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#writeAsEmf) and is responsible for closing it, as shown above.
### **Convert an SVG Image to EMF and Add It to a Presentation**
Use [SvgImage::writeAsEmf](https://reference.aspose.com/slides/php-java/aspose.slides/svgimage/#writeAsEmf) to convert SVG content to EMF. The resulting bytes can be added to the presentation through [ImageCollection::addImage](https://reference.aspose.com/slides/php-java/aspose.slides/imagecollection/#addImage) and placed on a slide with [ShapeCollection::addPictureFrame](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/#addPictureFrame).
The following example creates an [SvgImage](https://reference.aspose.com/slides/php-java/aspose.slides/svgimage/) from SVG markup, converts it to an in-memory EMF, inserts the metafile on the first slide, and saves the presentation:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\SvgImage;
$svgContent = '';
$svgImage = new SvgImage($svgContent);
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$emfStream = new Java("java.io.ByteArrayOutputStream");
try {
$svgImage->writeAsEmf($emfStream);
$emfData = $emfStream->toByteArray();
$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();
}
```
[SvgImage::writeAsEmf](https://reference.aspose.com/slides/php-java/aspose.slides/svgimage/#writeAsEmf) 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 PHP via 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/php-java/system-requirements/) for Aspose.Slides for PHP via 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 [Slide::getImage](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#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 articles
- [Convert PowerPoint Presentations to TIFF in PHP](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-tiff/)
- [Convert PPT and PPTX to JPG in PHP](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-jpg/)
- [Convert PowerPoint Presentations to TIFF with Notes in PHP](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-tiff-with-notes/)
# Create or Update PowerPoint Presentation Charts in PHP
> Create and customize charts in PowerPoint presentations using Aspose.Slides for PHP via Java. Add, format, and edit charts with practical code examples in PHP.
Source: https://docs.aspose.com/slides/php-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 PHP via 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 PHP 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/php-java/aspose.slides/charttype/) enumeration in the [aspose\slides](https://reference.aspose.com/slides/php-java/aspose.slides/) namespace. The values in this enumeration correspond to different chart types.
### **Create Clustered Column Charts**
This example uses [addChart](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/addchart/) 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.
```php
use aspose\slides\ChartType;
use aspose\slides\FillType;
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try
{
$slide = $presentation->getSlides()->get_Item(0);
$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);
$workbook = $chart->getChartData()->getChartDataWorkbook();
$worksheetIndex = 0;
$chart->getChartData()->getSeries()->clear();
$chart->getChartData()->getCategories()->clear();
$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());
$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);
$series = $chart->getChartData()->getSeries()->get_Item(0);
$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);
$color = new Java("java.awt.Color", 255, 0, 0);
$series->getFormat()->getFill()->getSolidFillColor()->setColor($color);
$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);
$color = new Java("java.awt.Color", 0, 128, 0);
$series->getFormat()->getFill()->getSolidFillColor()->setColor($color);
$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/php-java/aspose.slides/marker/setsize/). The [setSymbol](https://reference.aspose.com/slides/php-java/aspose.slides/marker/setsymbol/) method controls the marker shape.
```php
use aspose\slides\ChartType;
use aspose\slides\MarkerStyleType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try
{
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ScatterWithSmoothLines, 20, 20, 500, 300);
$workbook = $chart->getChartData()->getChartDataWorkbook();
$worksheetIndex = 0;
$chart->getChartData()->getSeries()->clear();
$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());
$series = $chart->getChartData()->getSeries()->get_Item(0);
$xValueCell = $workbook->getCell($worksheetIndex, 2, 1, 1);
$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/php-java/aspose.slides/chartseriesgroup/setfirstsliceangle/) method sets the first slice to start at 180 degrees.
```php
use aspose\slides\ChartType;
use aspose\slides\FillType;
use aspose\slides\LineDashStyle;
use aspose\slides\LineStyle;
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try
{
$slide = $presentation->getSlides()->get_Item(0);
$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);
$workbook = $chart->getChartData()->getChartDataWorkbook();
$worksheetIndex = 0;
$chart->getChartData()->getSeries()->clear();
$chart->getChartData()->getCategories()->clear();
$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);
$seriesNameCell = $workbook->getCell(0, 0, 1, "Series 1");
$series = $chart->getChartData()->getSeries()->add($seriesNameCell, $chart->getType());
$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);
$firstSlice = $series->getDataPoints()->get_Item(0);
$firstSlice->getFormat()->getFill()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 0, 255, 255);
$firstSlice->getFormat()->getFill()->getSolidFillColor()->setColor($color);
$firstSlice->getFormat()->getLine()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 128, 128, 128);
$firstSlice->getFormat()->getLine()->getFillFormat()->getSolidFillColor()->setColor($color);
$firstSlice->getFormat()->getLine()->setWidth(3.0);
$firstSlice->getFormat()->getLine()->setStyle(LineStyle::ThinThick);
$firstSlice->getFormat()->getLine()->setDashStyle(LineDashStyle::LargeDash);
$secondSlice = $series->getDataPoints()->get_Item(1);
$secondSlice->getFormat()->getFill()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 165, 42, 42);
$secondSlice->getFormat()->getFill()->getSolidFillColor()->setColor($color);
$secondSlice->getFormat()->getLine()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 0, 0, 255);
$secondSlice->getFormat()->getLine()->getFillFormat()->getSolidFillColor()->setColor($color);
$secondSlice->getFormat()->getLine()->setWidth(3.0);
$secondSlice->getFormat()->getLine()->setStyle(LineStyle::Single);
$secondSlice->getFormat()->getLine()->setDashStyle(LineDashStyle::LargeDashDot);
$thirdSlice = $series->getDataPoints()->get_Item(2);
$thirdSlice->getFormat()->getFill()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 255, 127, 80);
$thirdSlice->getFormat()->getFill()->getSolidFillColor()->setColor($color);
$thirdSlice->getFormat()->getLine()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 255, 0, 0);
$thirdSlice->getFormat()->getLine()->getFillFormat()->getSolidFillColor()->setColor($color);
$thirdSlice->getFormat()->getLine()->setWidth(2.0);
$thirdSlice->getFormat()->getLine()->setStyle(LineStyle::ThinThin);
$thirdSlice->getFormat()->getLine()->setDashStyle(LineDashStyle::LargeDashDotDot);
$firstLabel = $series->getDataPoints()->get_Item(0)->getLabel();
$firstLabel->getDataLabelFormat()->setShowValue(true);
$secondLabel = $series->getDataPoints()->get_Item(1)->getLabel();
$secondLabel->getDataLabelFormat()->setShowValue(true);
$secondLabel->getDataLabelFormat()->setShowLegendKey(true);
$secondLabel->getDataLabelFormat()->setShowPercentage(true);
$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/php-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/php-java/aspose.slides/shapecollection/addchart/) to create a line chart with the default series and categories, then saves the presentation as PPTX.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try
{
$slide = $presentation->getSlides()->get_Item(0);
$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/php-java/aspose.slides/lineformat/setdashstyle/) with a value from [LineDashStyle](https://reference.aspose.com/slides/php-java/aspose.slides/linedashstyle/):
```php
use aspose\slides\ChartType;
use aspose\slides\LineDashStyle;
use aspose\slides\Presentation;
$presentation = new Presentation();
try
{
$slide = $presentation->getSlides()->get_Item(0);
$lineChart = $slide->getShapes()->addChart(ChartType::Line, 20, 20, 500, 300);
for ($i = 0; $i < java_values($lineChart->getChartData()->getSeries()->size()); $i++)
{
$series = $lineChart->getChartData()->getSeries()->get_Item($i);
$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/php-java/aspose.slides/chartcategorylevelsmanager/setgroupingitem/) 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.
```php
use aspose\slides\ChartType;
use aspose\slides\ParentLabelLayoutType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try
{
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::Treemap, 20, 20, 500, 300);
$chart->getChartData()->getCategories()->clear();
$chart->getChartData()->getSeries()->clear();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$workbook->clear(0);
// Branch 1
$categoryCell = $workbook->getCell(0, "C1", "Leaf1");
$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);
$series = $chart->getChartData()->getSeries()->add(ChartType::Treemap);
$series->getLabels()->getDefaultDataLabelFormat()->setShowCategoryName(true);
$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/php-java/aspose.slides/chartdatapoint/setsetastotal/) 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 PHP example creates a chart using the `Waterfall` member of [ChartType](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/chartdatapointcollection/adddatapointforwaterfallseries/). The zero-based point indices `2` and `5` identify the intermediate and final totals. Calling [setShowValue](https://reference.aspose.com/slides/php-java/aspose.slides/datalabelformat/setshowvalue/) with `true` displays the amounts on the columns. No input presentation or workbook is required.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try
{
$slide = $presentation->getSlides()->get_Item(0);
$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();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$worksheetIndex = 0;
$workbook->clear($worksheetIndex);
$seriesNameCell = $workbook->getCell($worksheetIndex, 0, 1, "Profit");
$series = $chart->getChartData()->getSeries()->add($seriesNameCell, ChartType::Waterfall);
$categories = [ "Revenue", "Cost of sales", "Gross profit", "Operating expenses", "Other income", "Net profit" ];
$values = [ 1000, -400, 600, -200, 50, 450 ];
for ($i = 0; $i < count($categories); $i++)
{
$categoryCell = $workbook->getCell($worksheetIndex, $i + 1, 0, $categories[$i]);
$chart->getChartData()->getCategories()->add($categoryCell);
$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/php-java/aspose.slides/chartseries/setshowconnectorlines/) 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/php-java/aspose.slides/updownbarsmanager/setupdownbars/) method enables up/down bars, and [getHiLowLinesFormat](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/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/php-java/aspose.slides/chartseriesgroup/getupdownbars/) exposes separate formatting objects through [getUpBarsFormat](https://reference.aspose.com/slides/php-java/aspose.slides/updownbarsmanager/getupbarsformat/) and [getDownBarsFormat](https://reference.aspose.com/slides/php-java/aspose.slides/updownbarsmanager/getdownbarsformat/). Use each object's [getFill](https://reference.aspose.com/slides/php-java/aspose.slides/format/getfill/) and [getLine](https://reference.aspose.com/slides/php-java/aspose.slides/format/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/php-java/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/php-java/aspose.slides/charttype/); do not assume that other stock, stacked-line, or 3D variants use the same data arrangement or interval interpretation.
```php
use aspose\slides\ChartType;
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try
{
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::OpenHighLowClose, 20, 20, 500, 150, false);
$workbook = $chart->getChartData()->getChartDataWorkbook();
$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);
$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);
$series = $chart->getChartData()->getSeries()->get_Item(0);
$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);
$upDownBars = $chart->getChartData()->getSeriesGroups()->get_Item(0)->getUpDownBars();
$upDownBars->setUpDownBars(true);
$upDownBars->getUpBarsFormat()->getFill()->setFillType(FillType::Solid);
$upDownBars->getUpBarsFormat()->getFill()->getSolidFillColor()->setColor(new Java("java.awt.Color", 50, 205, 50));
$upDownBars->getUpBarsFormat()->getLine()->getFillFormat()->setFillType(FillType::Solid);
$upDownBars->getUpBarsFormat()->getLine()->getFillFormat()->getSolidFillColor()->setColor(new Java("java.awt.Color", 0, 100, 0));
$upDownBars->getUpBarsFormat()->getLine()->setWidth(2);
$upDownBars->getDownBarsFormat()->getFill()->setFillType(FillType::Solid);
$upDownBars->getDownBarsFormat()->getFill()->getSolidFillColor()->setColor(new Java("java.awt.Color", 255, 69, 0));
$upDownBars->getDownBarsFormat()->getLine()->getFillFormat()->setFillType(FillType::Solid);
$upDownBars->getDownBarsFormat()->getLine()->getFillFormat()->getSolidFillColor()->setColor(new Java("java.awt.Color", 139, 0, 0));
$upDownBars->getDownBarsFormat()->getLine()->setWidth(2);
$chart->getChartData()->getSeriesGroups()->get_Item(0)->getHiLowLinesFormat()->getLine()->getFillFormat()->setFillType(FillType::Solid);
for ($i = 0; $i < java_values($chart->getChartData()->getSeries()->size()); $i++)
{
$stockSeries = $chart->getChartData()->getSeries()->get_Item($i);
$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/php-java/aspose.slides/chartseries/setquartilemethod/) method selects the exclusive quartile calculation. The example also enables mean lines, mean markers, inner points, and outlier points.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\QuartileMethodType;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try
{
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::BoxAndWhisker, 20, 20, 500, 300);
$chart->getChartData()->getCategories()->clear();
$chart->getChartData()->getSeries()->clear();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$workbook->clear(0);
$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);
$series = $chart->getChartData()->getSeries()->add(ChartType::BoxAndWhisker);
$series->setQuartileMethod(QuartileMethodType::Exclusive);
$series->setShowMeanLine(true);
$series->setShowMeanMarkers(true);
$series->setShowInnerPoints(true);
$series->setShowOutlierPoints(true);
$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/php-java/aspose.slides/shapecollection/addchart/) 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.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("test.pptx");
try
{
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::Funnel, 50, 50, 500, 400);
$chart->getChartData()->getCategories()->clear();
$chart->getChartData()->getSeries()->clear();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$workbook->clear(0);
$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);
$series = $chart->getChartData()->getSeries()->add(ChartType::Funnel);
$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/php-java/aspose.slides/chartcategorylevelsmanager/setgroupingitem/) method assigns stems at grouping level 1 and branches at level 2. Category labels identify the segments, and the values determine their relative sizes.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try
{
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::Sunburst, 20, 20, 500, 300);
$chart->getChartData()->getCategories()->clear();
$chart->getChartData()->getSeries()->clear();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$workbook->clear(0);
// Branch 1
$categoryCell = $workbook->getCell(0, "C1", "Leaf1");
$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);
$series = $chart->getChartData()->getSeries()->add(ChartType::Sunburst);
$series->getLabels()->getDefaultDataLabelFormat()->setShowCategoryName(true);
$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/php-java/aspose.slides/axis/setaggregationtype/) on the horizontal axis with a mode from [AxisAggregationType](https://reference.aspose.com/slides/php-java/aspose.slides/axisaggregationtype/). [setBinWidth](https://reference.aspose.com/slides/php-java/aspose.slides/axis/setbinwidth/) applies only to `ByBinWidth`; [setNumberOfBins](https://reference.aspose.com/slides/php-java/aspose.slides/axis/setnumberofbins/) 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/php-java/aspose.slides/axis/setunderflowbin/) and [setOverflowBin](https://reference.aspose.com/slides/php-java/aspose.slides/axis/setoverflowbin/). When supplying explicit thresholds through [setUnderflowBin](https://reference.aspose.com/slides/php-java/aspose.slides/axis/setunderflowbin/) and [setOverflowBin](https://reference.aspose.com/slides/php-java/aspose.slides/axis/setoverflowbin/), call [setAutomaticUnderflowBin](https://reference.aspose.com/slides/php-java/aspose.slides/axis/setautomaticunderflowbin/) and [setAutomaticOverflowBin](https://reference.aspose.com/slides/php-java/aspose.slides/axis/setautomaticoverflowbin/) with `false`.
```php
use aspose\slides\AxisAggregationType;
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try
{
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::Histogram, 20, 20, 680, 200);
$chart->setLegend(false);
$chart->setTitle(false);
$chart->getChartData()->getCategories()->clear();
$chart->getChartData()->getSeries()->clear();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$workbook->clear(0);
$series = $chart->getChartData()->getSeries()->add(ChartType::Histogram);
$values = [ 5, 10, 10, 11, 15, 20, 20, 21, 25, 30, 30, 31, 35, 40, 40, 41, 50 ];
for ($i = 0; $i < count($values); $i++)
{
$valueCell = $workbook->getCell(0, $i, 0, $values[$i]);
$series->getDataPoints()->addDataPointForHistogramSeries($valueCell);
}
$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.
```php
use aspose\slides\AxisAggregationType;
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try
{
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::Histogram, 20, 20, 680, 200);
$chart->setLegend(false);
$chart->setTitle(false);
$chart->getChartData()->getCategories()->clear();
$chart->getChartData()->getSeries()->clear();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$workbook->clear(0);
$series = $chart->getChartData()->getSeries()->add(ChartType::Histogram);
$values = [ 5, 10, 10, 11, 15, 20, 20, 21, 25, 30, 30, 31, 35, 40, 40, 41, 50 ];
for ($i = 0; $i < count($values); $i++)
{
$valueCell = $workbook->getCell(0, $i, 0, $values[$i]);
$series->getDataPoints()->addDataPointForHistogramSeries($valueCell);
}
$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/php-java/aspose.slides/shapecollection/addchart/) to create a radar chart with the default series and categories, then saves the presentation as PPTX.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try
{
$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/php-java/aspose.slides/chartcategorylevelsmanager/setgroupingitem/) method gives each pair a shared label at grouping level 1, producing a category axis with both individual and group labels.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try
{
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 20, 20, 500, 300);
$chart->getChartData()->getSeries()->clear();
$chart->getChartData()->getCategories()->clear();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$workbook->clear(0);
$worksheetIndex = 0;
$categoryCell = $workbook->getCell(0, "c2", "A");
$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);
$seriesNameCell = $workbook->getCell(0, "D1", "Series 1");
$series = $chart->getChartData()->getSeries()->add($seriesNameCell, ChartType::ClusteredColumn);
$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/php-java/create-chart/quarters.pptx) and place it in the same directory as the PHP script. 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/php-java/aspose.slides/chartcategory/getgroupinglevels/) to access April's grouping levels, then call [deleteGroupingItem](https://reference.aspose.com/slides/php-java/aspose.slides/chartcategorylevelsmanager/deletegroupingitem/) with level 1 to remove its quarter label. Level 0 represents the month itself and cannot be removed with this method.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation(__DIR__ . "/quarters.pptx");
try
{
$chart = $presentation->getSlides()->get_Item(0)->getShapes()->get_Item(0);
$april = $chart->getChartData()->getCategories()->get_Item(3);
$april->getGroupingLevels()->deleteGroupingItem(1);
$presentation->save(__DIR__ . "/quarters-updated.pptx", SaveFormat::Pptx);
}
finally
{
$presentation->dispose();
}
$reopened = new Presentation(__DIR__ . "/quarters-updated.pptx");
try
{
$updatedChart = $reopened->getSlides()->get_Item(0)->getShapes()->get_Item(0);
$data = $updatedChart->getChartData();
$months = [];
$categories = $data->getCategories();
for ($i = 0; $i < java_values($categories->size()); $i++)
{
$months[] = (string)$categories->get_Item($i)->getAsCell()->getValue();
}
$sales = [];
$points = $data->getSeries()->get_Item(0)->getDataPoints();
for ($i = 0; $i < java_values($points->size()); $i++)
{
$sales[] = (string)$points->get_Item($i)->getValue()->getData();
}
echo implode(", ", $months), PHP_EOL;
echo implode(", ", $sales), PHP_EOL;
}
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.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0`) 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/php-java/aspose.slides/shapecollection/addchart/) to create a map chart with the default geographical data and saves it for viewing in PowerPoint.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try
{
$slide = $presentation->getSlides()->get_Item(0);
$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/php-java/aspose.slides/chartseries/setplotonsecondaxis/) places the line on a secondary vertical axis on the right. The helper functions configure the title, legend, axis labels, and gridlines.
```php
use aspose\slides\AxisPositionType;
use aspose\slides\ChartType;
use aspose\slides\CrossesType;
use aspose\slides\FillType;
use aspose\slides\LegendPositionType;
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
function createComboChart()
{
$presentation = new Presentation();
try
{
$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();
}
}
function createChartWithFirstSeries($slide)
{
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 50, 50, 600, 400);
$chart->setTitle(true);
$chart->getChartTitle()->addTextFrameForOverriding("Chart Title");
$chart->getChartTitle()->setOverlay(false);
$portionFormat = $chart->getChartTitle()->getTextFrameForOverriding()->getParagraphs()->get_Item(0)->getParagraphFormat()->getDefaultPortionFormat();
$portionFormat->setFontBold(NullableBool::False);
$portionFormat->setFontHeight(18);
$chart->getLegend()->setPosition(LegendPositionType::Bottom);
$chart->getLegend()->getTextFormat()->getPortionFormat()->setFontHeight(12);
$chart->getChartData()->getSeries()->clear();
$chart->getChartData()->getCategories()->clear();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$worksheetIndex = 0;
$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);
$seriesNameCell = $workbook->getCell($worksheetIndex, 0, 1, "Series 1");
$series = $chart->getChartData()->getSeries()->add($seriesNameCell, $chart->getType());
$series->getParentSeriesGroup()->setOverlap(-25);
$series->getParentSeriesGroup()->setGapWidth(220);
$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;
}
function addSecondSeriesToChart($chart)
{
$workbook = $chart->getChartData()->getChartDataWorkbook();
$worksheetIndex = 0;
$seriesNameCell = $workbook->getCell($worksheetIndex, 0, 2, "Series 2");
$series = $chart->getChartData()->getSeries()->add($seriesNameCell, ChartType::ClusteredColumn);
$series->getParentSeriesGroup()->setOverlap(-25);
$series->getParentSeriesGroup()->setGapWidth(220);
$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);
}
function addThirdSeriesToChart($chart)
{
$workbook = $chart->getChartData()->getChartDataWorkbook();
$worksheetIndex = 0;
$seriesNameCell = $workbook->getCell($worksheetIndex, 0, 3, "Series 3");
$series = $chart->getChartData()->getSeries()->add($seriesNameCell, ChartType::Line);
$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);
}
function setPrimaryAxesFormat($chart)
{
$horizontalAxis = $chart->getAxes()->getHorizontalAxis();
$horizontalAxis->getTextFormat()->getPortionFormat()->setFontHeight(12);
$horizontalAxis->getFormat()->getLine()->getFillFormat()->setFillType(FillType::NoFill);
setAxisTitle($horizontalAxis, "X Axis");
$verticalAxis = $chart->getAxes()->getVerticalAxis();
$verticalAxis->getTextFormat()->getPortionFormat()->setFontHeight(12);
$verticalAxis->getFormat()->getLine()->getFillFormat()->setFillType(FillType::NoFill);
setAxisTitle($verticalAxis, "Y Axis 1");
$majorGridLinesFormat = $verticalAxis->getMajorGridLinesFormat()->getLine()->getFillFormat();
$majorGridLinesFormat->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 217, 217, 217);
$majorGridLinesFormat->getSolidFillColor()->setColor($color);
}
function setSecondaryAxesFormat($chart)
{
$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);
$secondaryVerticalAxis = $chart->getAxes()->getSecondaryVerticalAxis();
$secondaryVerticalAxis->setPosition(AxisPositionType::Right);
$secondaryVerticalAxis->getTextFormat()->getPortionFormat()->setFontHeight(12);
$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");
}
function setAxisTitle($axis, $axisTitle)
{
$axis->setTitle(true);
$axis->getTitle()->setOverlay(false);
$titlePortionFormat = $axis->getTitle()->addTextFrameForOverriding($axisTitle)->getParagraphs()->get_Item(0)->getParagraphFormat()->getDefaultPortionFormat();
$titlePortionFormat->setFontBold(NullableBool::False);
$titlePortionFormat->setFontHeight(12);
}
createComboChart();
```
## **Update Charts**
Aspose.Slides for PHP via 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/php-java/aspose.slides/chartdataworkbook/getcell/) 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/php-java/aspose.slides/chart/settype/).
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$chartName = "My chart";
$chartClass = new JavaClass("com.aspose.slides.IChart");
$presentation = new Presentation("ExistingChart.pptx");
try
{
$slide = $presentation->getSlides()->get_Item(0);
for ($i = 0; $i < java_values($slide->getShapes()->size()); $i++)
{
$shape = $slide->getShapes()->get_Item($i);
if (java_instanceof($shape, $chartClass) && $chartName === java_values($shape->getName()))
{
$chart = $shape;
$worksheetIndex = 0;
$workbook = $chart->getChartData()->getChartDataWorkbook();
$workbook->getCell($worksheetIndex, 1, 0, "Modified Category 1");
$workbook->getCell($worksheetIndex, 2, 0, "Modified Category 2");
$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);
$seriesNameCell = $workbook->getCell($worksheetIndex, 0, 3, "Series 3");
$series = $chart->getChartData()->getSeries()->add($seriesNameCell, $chart->getType());
$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/php-java/chart-workbook/#retrieve-a-charts-data-range).
Aspose.Slides for PHP via 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/php-java/aspose.slides/chartdata/setrange/) 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.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$chartName = "My chart";
$chartClass = new JavaClass("com.aspose.slides.IChart");
$presentation = new Presentation("ExistingChart.pptx");
try
{
$slide = $presentation->getSlides()->get_Item(0);
for ($i = 0; $i < java_values($slide->getShapes()->size()); $i++)
{
$shape = $slide->getShapes()->get_Item($i);
if (java_instanceof($shape, $chartClass) && $chartName === java_values($shape->getName()))
{
$chart = $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/php-java/aspose.slides/shapecollection/addchart/) to create a chart with two line series and a legend. The marker settings accessed through [getMarker](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/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.
```php
use aspose\slides\ChartType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try
{
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::LineWithMarkers, 10, 10, 400, 400);
$chart->getChartData()->getSeries()->clear();
$chart->getChartData()->getCategories()->clear();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$seriesNameCell = $workbook->getCell(0, 0, 1, "Series 1");
$series = $chart->getChartData()->getSeries()->add($seriesNameCell, $chart->getType());
$categoryCell = $workbook->getCell(0, 1, 0, "C1");
$chart->getChartData()->getCategories()->add($categoryCell);
$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");
$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 PHP via Java?**
Aspose.Slides for PHP via 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/php-java/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 ([ChartDataWorkbook](https://reference.aspose.com/slides/php-java/aspose.slides/chartdataworkbook/)), 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 PHP via 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.
# Specify Fallback Fonts for Presentations in PHP
> Master Aspose.Slides for PHP via 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/php-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 [FontFallBackRule](https://reference.aspose.com/slides/php-java/aspose.slides/FontFallBackRule) class to specify the rules to apply a fallback font. [FontFallBackRule](https://reference.aspose.com/slides/php-java/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:
```php
$startUnicodeIndex = 0xb80;
$endUnicodeIndex = 0xbff;
$firstRule = new FontFallBackRule($startUnicodeIndex, $endUnicodeIndex, "Vijaya");
$secondRule = new FontFallBackRule(0x3040, 0x309f, "MS Mincho, MS Gothic");
# Using multiple ways you can add fonts list:
$fontNames = array("Segoe UI Emoji, Segoe UI Symbol", "Arial" );
$thirdRule = new FontFallBackRule(0x1f300, 0x1f64f, $fontNames);
```
It is also possible to [remove](https://reference.aspose.com/slides/php-java/aspose.slides/fontfallbackrule/remove/) fallback font or [addFallBackFonts](https://reference.aspose.com/slides/php-java/aspose.slides/fontfallbackrule/addfallbackfonts/) into existing [FontFallBackRule](https://reference.aspose.com/slides/php-java/aspose.slides/FontFallBackRule) object.
[FontFallBackRulesCollection](https://reference.aspose.com/slides/php-java/aspose.slides/FontFallBackRulesCollection) can be used to organize a list of [FontFallBackRule](https://reference.aspose.com/slides/php-java/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/php-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/php-java/font-substitution/) replaces the entire specified font with another font. [Font embedding](https://docs.aspose.com/slides/php-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/php-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/php-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 PHP](https://docs.aspose.com/slides/php-java/fallback-font/)
- [Configure Fallback Font Collections in PHP](https://docs.aspose.com/slides/php-java/create-fallback-fonts-collection/)
- [Streamline Font Replacement in Presentations Using PHP](https://docs.aspose.com/slides/php-java/font-replacement/)
# Configure Fallback Font Collections in PHP
> Set up a fallback fonts collection in Aspose.Slides for PHP via Java to keep text consistent and crisp in PowerPoint and OpenDocument presentations.
Source: https://docs.aspose.com/slides/php-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`.
After creating the collection, you can assign it using the `setFontFallBackRulesCollection` method 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/php-java/aspose.slides/FontFallBackRule) class can be organized into [FontFallBackRulesCollection](https://reference.aspose.com/slides/php-java/aspose.slides/FontFallBackRulesCollection). It is possible to add or remove rules from the collection.
Then this collection may be assigned to [FontFallBackRulesCollection](https://reference.aspose.com/slides/php-java/aspose.slides/FontFallBackRulesCollection) method of the [FontsManager](https://reference.aspose.com/slides/php-java/aspose.slides/FontsManager) class. FontsManager controls fonts across the presentation.
Each [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation) has a [getFontsManager](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation#getFontsManager) method with its own instance of the [FontsManager](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/Presentation#getFontsManager) of a certain presentation:
```php
$pres = new Presentation();
try {
$userRulesList = new FontFallBackRulesCollection();
$userRulesList->add(new FontFallBackRule(0xb80, 0xbff, "Vijaya"));
$userRulesList->add(new FontFallBackRule(0x3040, 0x309f, "MS Mincho, MS Gothic"));
$pres->getFontsManager()->setFontFallBackRulesCollection($userRulesList);
} finally {
if (!java_is_null($pres)) {
$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/php-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/php-java/font-replacement/)/[substitution](https://docs.aspose.com/slides/php-java/font-substitution/)), then fallback fills gaps for missing glyphs in available fonts.
## Related articles
- [Render Presentations with Fallback Fonts in PHP](https://docs.aspose.com/slides/php-java/render-presentation-with-fallback-font/)
- [Manage Fallback Fonts for Presentations in PHP](https://docs.aspose.com/slides/php-java/fallback-font/)
- [Specify Fallback Fonts for Presentations in PHP](https://docs.aspose.com/slides/php-java/create-fallback-font/)
# Create Presentations in PHP
> Create presentations with Aspose.Slides for PHP via Java — produce PPT, PPTX, and ODP files and save them programmatically for reliable results.
Source: https://docs.aspose.com/slides/php-java/create-presentation/
Updated: 2026-09-27
## **Overview**
This article shows how to create a presentation in Aspose.Slides, add a text box to its first slide, and save the result as a file. It also shows how to create and save an empty presentation, and how to open an existing presentation in a supported format and save it in another format. 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, install Aspose.Slides for PHP via Java with Composer and start PHP/Java Bridge in Apache Tomcat. See [Installation](https://docs.aspose.com/slides/php-java/installation/) for the complete setup. The examples below expect Tomcat to be running on `localhost:8080` and the Composer `vendor` folder to be next to the script.
## **Create a PowerPoint Presentation**
To create a presentation and put a text box on its first slide, follow these steps:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class. A new presentation already contains one empty slide.
1. Get that slide from the collection returned by [Presentation::getSlides](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/getslides/), by its index, 0.
1. Add a rectangle with the [ShapeCollection::addAutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/addautoshape/) method and set its text with [TextFrame::setText](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/settext/).
1. Save the presentation as a PPTX file with the [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/save/) method.
```php
getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 400, 100);
$shape->getTextFrame()->setText("Hello, Aspose.Slides!");
$presentation->save(__DIR__ . "/hello.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The two `require_once` lines load the PHP/Java Bridge client from Tomcat and the Aspose.Slides classes from the Composer package. The rectangle's top-left corner is 50 points from the left edge and 50 points from the top edge of the slide, and the rectangle is 400 points wide and 100 points high. The saved file contains one slide with that rectangle 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/php-java/licensing/).
Aspose.Slides reads and writes files inside Tomcat, not in your PHP process, so a relative path such as `"hello.pptx"` is resolved against Tomcat's working folder. The examples on this page build absolute paths with `__DIR__`, so the files are read from and saved next to the script.
## **Create and Save a Presentation**
To create an empty presentation and save it, create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class and save it in any format of the [SaveFormat](https://reference.aspose.com/slides/php-java/aspose.slides/saveformat/) enumeration. The result is a presentation with one empty slide.
```php
save(__DIR__ . "/OutputPresentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Open and Save a Presentation**
To convert a presentation from one format to another, open it by passing its path to the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) constructor, then save it in the target format. Aspose.Slides detects the input format, such as PPT, PPTX, or ODP, from the file itself.
The example below expects an OpenDocument presentation named *Sample.odp* next to the script and saves it as PPTX.
```php
save(__DIR__ . "/OutputPresentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **FAQ**
### What formats can I save a new presentation to?
You can save to [PPTX, PPT, and ODP](https://docs.aspose.com/slides/php-java/save-presentation/), and export to [PDF](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-pdf/), [XPS](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-xps/), [HTML](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-html/), [SVG](https://docs.aspose.com/slides/php-java/render-a-slide-as-an-svg-image/), and [images](https://docs.aspose.com/slides/php-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/php-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/php-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/php-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/php-java/aspose.slides/presentation/) instance from [multiple threads](https://docs.aspose.com/slides/php-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/php-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/php-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/php-java/presentation-via-vba/) and save macro-enabled files such as PPTM/PPSM.
# Create Thumbnails of Presentation Shapes in PHP
> Generate high-quality shape thumbnails from PowerPoint slides with Aspose.Slides for PHP via Java – easily create and export presentation thumbnails.
Source: https://docs.aspose.com/slides/php-java/create-shape-thumbnails/
Updated: 2026-11-08
## **Introduction**
Aspose.Slides is used to create presentation files where each page is a slides. These slides can be viewed by opening the presentation files using Microsoft PowerPoint. But sometimes, developers may need to view the images of the shapes separately in an image viewer. In such cases, Aspose.Slides helps you generate thumbnail images of the slide shapes. How to use this feature is described in this article.
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 PHP via Java, do this:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/shape/#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:
```php
# Instantiate a Presentation class that represents the presentation file
$pres = new Presentation("Thumbnail.pptx");
try {
# Create a full scale image
$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 (!java_is_null($slideImage)) {
$slideImage->dispose();
}
}
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Generate a User-Defined Scaling Factor Thumbnail**
To generate the shape thumbnail of a slide using Aspose.Slides for PHP via Java, do this:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/shape/#getImage) 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:
```php
# Instantiate a Presentation class that represents the presentation file
$pres = new Presentation("Thumbnail.pptx");
try {
# Create a full scale image
$slideImage = $pres->getSlides()->get_Item(0)->getShapes()->get_Item(0)->getImage(ShapeThumbnailBounds->Shape, 1, 1);
# Save the image to disk in PNG format
try {
$slideImage->save("output.png", ImageFormat::Png);
} finally {
if (!java_is_null($slideImage)) {
$slideImage->dispose();
}
}
} finally {
if (!java_is_null($pres)) {
$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/php-java/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:
```php
# Instantiate a Presentation class that represents the presentation file
$pres = new Presentation("Thumbnail.pptx");
try {
# Create a full scale image
$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 (!java_is_null($slideImage)) {
$slideImage->dispose();
}
}
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
[](https://docs.aspose.com/slides/php-java/create-shape-thumbnails/visual-shape-thumbnail-bounds-2f4141e8a2fe.svg)
*The shadow extends past the slide’s right edge. The Appearance thumbnail is clipped at that edge.*
## **Get the Actual Visual Bounds of a Shape**
The frame properties of [Shape](https://reference.aspose.com/slides/php-java/aspose.slides/shape/)—`Shape::getX()`, `Shape::getY()`, `Shape::getWidth()`, and `Shape::getHeight()`—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/php-java/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.
The following example gets and compares the frame and visual bounds:
```php
$presentation = new Presentation("example.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->get_Item(0);
$visualBounds = $shape->getVisualBounds();
$frameX = $shape->getX();
$frameY = $shape->getY();
$frameWidth = $shape->getWidth();
$frameHeight = $shape->getHeight();
$visualX = $visualBounds->getX();
$visualY = $visualBounds->getY();
$visualWidth = $visualBounds->getWidth();
$visualHeight = $visualBounds->getHeight();
echo "Frame bounds (x, y, width, height): $frameX, $frameY, $frameWidth, $frameHeight\n";
echo "Visual bounds (x, y, width, height): $visualX, $visualY, $visualWidth, $visualHeight\n";
} 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/php-java/aspose.slides/shape/#getVisualBounds) when you need coordinates for layout or validation and do not need a bitmap. Use [Shape::getImage](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#getImage) when you need to render the shape. With [ShapeThumbnailBounds](https://reference.aspose.com/slides/php-java/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` returns only the calculated rectangle and does not clip it to the slide.
## **FAQ**
**What image formats can be used when saving shape thumbnails?**
[PNG, JPEG, BMP, GIF, TIFF](https://reference.aspose.com/slides/php-java/aspose.slides/imageformat/), and others. Shapes can also be [exported as vector SVG](https://reference.aspose.com/slides/php-java/aspose.slides/shape/writeassvg/) 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/php-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/php-java/aspose.slides/shape/) (including [GroupShape](https://reference.aspose.com/slides/php-java/aspose.slides/groupshape/), [Chart](https://reference.aspose.com/slides/php-java/aspose.slides/chart/), and [SmartArt](https://reference.aspose.com/slides/php-java/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/php-java/custom-font/) (or [configure font substitutions](https://docs.aspose.com/slides/php-java/font-substitution/)) to avoid unwanted fallbacks and text reflow.
## Related articles
- [Create a Presentation Viewer in PHP](https://docs.aspose.com/slides/php-java/presentation-viewer/)
# Create Excel Charts and Embed Them in Presentations as OLE Objects
> Create an Excel chart with Aspose.Cells for PHP via Java and embed the workbook in a PowerPoint presentation with Aspose.Slides for PHP via Java, including a chart preview.
Source: https://docs.aspose.com/slides/php-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 PHP via Java and embed its workbook in a PowerPoint presentation with Aspose.Slides for PHP via 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**
Configure Aspose.Cells for PHP via Java and Aspose.Slides for PHP via Java with the same PHP/Java Bridge instance. Load both PHP wrappers and make both products' Java libraries available to the bridge. 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. [WorksheetCollection::setOleSize](https://reference.aspose.com/cells/php/aspose.cells/worksheetcollection/#setolesize) takes zero-based start/end row and column indices. [ChartCollection::add](https://reference.aspose.com/cells/php/aspose.cells/chartcollection/#add) 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/php-java/aspose.slides/oleembeddeddatainfo/). Java numeric results are converted with `java_values` before PHP performs arithmetic, while binary data remains in Java byte arrays. The PNG is loaded directly from its bytes without an intermediate bitmap conversion. Assigning it through [OleObjectFrame::getSubstitutePictureFormat](https://reference.aspose.com/slides/php-java/aspose.slides/oleobjectframe/#getSubstitutePictureFormat) replaces the default OLE placeholder.
```php
getWorksheets()->get(0);
$dataSheet->setName("DataSheet");
$values = [
[67, 44, 46, 43, 24],
[86, 64, 97, 29, 40],
[68, 89, 78, 69, 38],
[91, 48, 60, 26, 25]
];
foreach ($values as $row => $rowValues) {
foreach ($rowValues as $column => $value) {
$dataSheet->getCells()->get($row, $column)->putValue($value);
}
}
$chartSheetIndex = java_values($workbook->getWorksheets()->add(SheetType::CHART));
$chartSheet = $workbook->getWorksheets()->get($chartSheetIndex);
$chartSheet->setName("ChartSheet");
$lastChartRow = 55;
$lastChartColumn = 25;
$chartIndex = java_values($chartSheet->getCharts()->add(ChartType::COLUMN, 0, 0, $lastChartRow, $lastChartColumn));
$chart = $chartSheet->getCharts()->get($chartIndex);
for ($row = 1; $row <= count($values); $row++) {
$chart->getNSeries()->add("DataSheet!A" . $row . ":E" . $row, false);
}
$workbook->getWorksheets()->setActiveSheetIndex($chartSheetIndex);
$workbook->getWorksheets()->setOleSize(0, $lastChartRow, 0, $lastChartColumn);
// Keep the PNG and XLSX as Java byte arrays when passing them to Slides.
$imageOptions = new ImageOrPrintOptions();
$imageOptions->setImageType(ImageType::PNG);
$chartImageStream = new JavaObject("java.io.ByteArrayOutputStream");
$chart->toImage($chartImageStream, $imageOptions);
$chartImageBytes = $chartImageStream->toByteArray();
$workbookStream = new JavaObject("java.io.ByteArrayOutputStream");
$workbook->save($workbookStream, CellsSaveFormat::XLSX);
$workbookBytes = $workbookStream->toByteArray();
$chartImage = Images::fromData($chartImageBytes);
try {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$slideWidth = java_values($presentation->getSlideSize()->getSize()->getWidth());
$slideHeight = java_values($presentation->getSlideSize()->getSize()->getHeight());
$imageWidth = java_values($chartImage->getWidth());
$imageHeight = java_values($chartImage->getHeight());
// Fit and center the preview while preserving its aspect ratio.
$scale = min($slideWidth / $imageWidth, $slideHeight / $imageHeight);
$frameWidth = $imageWidth * $scale;
$frameHeight = $imageHeight * $scale;
$frameX = ($slideWidth - $frameWidth) / 2;
$frameY = ($slideHeight - $frameHeight) / 2;
$embeddedData = new OleEmbeddedDataInfo($workbookBytes, "xlsx");
$oleFrame = $slide->getShapes()->addOleObjectFrame($frameX, $frameY, $frameWidth, $frameHeight, $embeddedData);
$previewImage = $presentation->getImages()->addImage($chartImage);
$oleFrame->getSubstitutePictureFormat()->getPicture()->setImage($previewImage);
$presentation->save("OutputChart.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
} finally {
$chartImage->dispose();
}
} finally {
$workbook->dispose();
}
```
## **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/php-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/php-java/object-preview-issue-when-adding-oleobjectframe/)
- [Manage OLE Objects](https://docs.aspose.com/slides/php-java/manage-ole/)
# Create and Modify Custom Animation Behaviors in PHP
> Create, inspect, and modify custom animation behaviors and editable motion paths in PowerPoint presentations with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-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/php-java/shape-animation/).
## **Understand the Animation Model**
An animation is organized as **Timeline → Sequence → Effect → Behaviors**:
- Each slide has a timeline containing its main sequence and interactive sequences.
- A [Sequence](https://reference.aspose.com/slides/php-java/aspose.slides/sequence/) contains effects, potentially targeting different shapes.
- An [Effect](https://reference.aspose.com/slides/php-java/aspose.slides/effect/) identifies a target shape, preset, subtype, and effect timing.
- The collection returned by [Effect::getBehaviors](https://reference.aspose.com/slides/php-java/aspose.slides/effect/getbehaviors/) contains the operations that implement the effect: changing color, moving, rotating, setting a property, and so on.
## **Create Individual Behaviors**
Call [Sequence::addEffect](https://reference.aspose.com/slides/php-java/aspose.slides/sequence/addeffect/) to create an effect and access the [getBehaviors](https://reference.aspose.com/slides/php-java/aspose.slides/effect/getbehaviors/) collection. A preset can populate this collection automatically. Keep its operations when extending the preset, or use [clear](https://reference.aspose.com/slides/php-java/aspose.slides/behaviorcollection/clear/) when deliberately replacing them.
[BehaviorFactory](https://reference.aspose.com/slides/php-java/aspose.slides/behaviorfactory/) creates the eight behavior types illustrated below. Motion is covered in [Build a Motion Path](https://docs.aspose.com/slides/php-java/custom-animation/#build-a-motion-path). Each snippet includes its imports and assumes that the PHP/Java Bridge and the Aspose.Slides PHP library have been loaded. Later editing examples state which output file they use.
### **Rotation**
Use [createRotationEffect](https://reference.aspose.com/slides/php-java/aspose.slides/behaviorfactory/createrotationeffect/) to create a rotation. [getBy](https://reference.aspose.com/slides/php-java/aspose.slides/rotationeffect/getby/) specifies a relative angle in degrees; [getFrom](https://reference.aspose.com/slides/php-java/aspose.slides/rotationeffect/getfrom/) and [getTo](https://reference.aspose.com/slides/php-java/aspose.slides/rotationeffect/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.
```php
use aspose\slides\BehaviorFactory;
use aspose\slides\EffectSubtype;
use aspose\slides\EffectTriggerType;
use aspose\slides\EffectType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$baseDirectory = getcwd();
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 160, 80);
$effect = $slide->getTimeline()->getMainSequence()->addEffect($shape, EffectType::Spin, EffectSubtype::None, EffectTriggerType::OnClick);
$effect->getBehaviors()->clear();
$factory = new BehaviorFactory();
$rotation = $factory->createRotationEffect();
$rotation->setBy(90);
$rotation->getTiming()->setDuration(2);
$effect->getBehaviors()->add($rotation);
$presentation->save($baseDirectory . DIRECTORY_SEPARATOR . "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/php-java/aspose.slides/behaviorfactory/createscaleeffect/) with X/Y percentages: [getFrom](https://reference.aspose.com/slides/php-java/aspose.slides/scaleeffect/getfrom/) and [getTo](https://reference.aspose.com/slides/php-java/aspose.slides/scaleeffect/getto/) describe the starting and ending size, while [getBy](https://reference.aspose.com/slides/php-java/aspose.slides/scaleeffect/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.
```php
use aspose\slides\BehaviorFactory;
use aspose\slides\EffectSubtype;
use aspose\slides\EffectTriggerType;
use aspose\slides\EffectType;
use aspose\slides\Point2DFloat;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$baseDirectory = getcwd();
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 160, 80);
$effect = $slide->getTimeline()->getMainSequence()->addEffect($shape, EffectType::GrowShrink, EffectSubtype::None, EffectTriggerType::OnClick);
$effect->getBehaviors()->clear();
$factory = new BehaviorFactory();
$scale = $factory->createScaleEffect();
$initialSize = new Point2DFloat(100, 100);
$scale->setFrom($initialSize);
$targetSize = new Point2DFloat(125, 125);
$scale->setTo($targetSize);
$scale->getTiming()->setDuration(2);
$effect->getBehaviors()->add($scale);
$presentation->save($baseDirectory . DIRECTORY_SEPARATOR . "scale.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Color**
Use [createColorEffect](https://reference.aspose.com/slides/php-java/aspose.slides/behaviorfactory/createcoloreffect/) to change the fill from blue to orange. [getFrom](https://reference.aspose.com/slides/php-java/aspose.slides/coloreffect/getfrom/) and [getTo](https://reference.aspose.com/slides/php-java/aspose.slides/coloreffect/getto/) are colors; [getBy](https://reference.aspose.com/slides/php-java/aspose.slides/coloreffect/getby/) is a color offset. The behavior's [BehaviorPropertyCollection](https://reference.aspose.com/slides/php-java/aspose.slides/behaviorpropertycollection/) 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.
```php
use aspose\slides\BehaviorFactory;
use aspose\slides\BehaviorProperty;
use aspose\slides\EffectSubtype;
use aspose\slides\EffectTriggerType;
use aspose\slides\EffectType;
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$baseDirectory = getcwd();
$blue = new Java("java.awt.Color", 0, 0, 255);
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 160, 80);
$shape->getFillFormat()->setFillType(FillType::Solid);
$shape->getFillFormat()->getSolidFillColor()->setColor($blue);
$effect = $slide->getTimeline()->getMainSequence()->addEffect($shape, EffectType::ChangeFillColor, EffectSubtype::None, EffectTriggerType::OnClick);
$effect->getBehaviors()->clear();
$factory = new BehaviorFactory();
$color = $factory->createColorEffect();
$color->getProperties()->add(BehaviorProperty::getFillColor()->getValue());
$color->getFrom()->setColor($blue);
$orange = new Java("java.awt.Color", 255, 165, 0);
$color->getTo()->setColor($orange);
$color->getTiming()->setDuration(2);
$effect->getBehaviors()->add($color);
$presentation->save($baseDirectory . DIRECTORY_SEPARATOR . "color.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Filter**
Use [createFilterEffect](https://reference.aspose.com/slides/php-java/aspose.slides/behaviorfactory/createfiltereffect/) to select a wipe. [getType](https://reference.aspose.com/slides/php-java/aspose.slides/filtereffect/gettype/), [getSubtype](https://reference.aspose.com/slides/php-java/aspose.slides/filtereffect/getsubtype/), and [getReveal](https://reference.aspose.com/slides/php-java/aspose.slides/filtereffect/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.
```php
use aspose\slides\BehaviorFactory;
use aspose\slides\EffectSubtype;
use aspose\slides\EffectTriggerType;
use aspose\slides\EffectType;
use aspose\slides\FilterEffectRevealType;
use aspose\slides\FilterEffectSubtype;
use aspose\slides\FilterEffectType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$baseDirectory = getcwd();
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 160, 80);
$effect = $slide->getTimeline()->getMainSequence()->addEffect($shape, EffectType::Wipe, EffectSubtype::None, EffectTriggerType::OnClick);
$effect->getBehaviors()->clear();
$factory = new BehaviorFactory();
$filter = $factory->createFilterEffect();
$filter->setType(FilterEffectType::Wipe);
$filter->setSubtype(FilterEffectSubtype::Right);
$filter->setReveal(FilterEffectRevealType::In);
$filter->getTiming()->setDuration(2);
$effect->getBehaviors()->add($filter);
$presentation->save($baseDirectory . DIRECTORY_SEPARATOR . "filter.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Property**
Use [createPropertyEffect](https://reference.aspose.com/slides/php-java/aspose.slides/behaviorfactory/createpropertyeffect/) to animate opacity. [getFrom](https://reference.aspose.com/slides/php-java/aspose.slides/propertyeffect/getfrom/), [getTo](https://reference.aspose.com/slides/php-java/aspose.slides/propertyeffect/getto/), and [getBy](https://reference.aspose.com/slides/php-java/aspose.slides/propertyeffect/getby/) are strings interpreted using [getValueType](https://reference.aspose.com/slides/php-java/aspose.slides/propertyeffect/getvaluetype/) and [getCalcMode](https://reference.aspose.com/slides/php-java/aspose.slides/propertyeffect/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.
```php
use aspose\slides\BehaviorFactory;
use aspose\slides\BehaviorProperty;
use aspose\slides\EffectSubtype;
use aspose\slides\EffectTriggerType;
use aspose\slides\EffectType;
use aspose\slides\Presentation;
use aspose\slides\PropertyCalcModeType;
use aspose\slides\PropertyValueType;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$baseDirectory = getcwd();
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 160, 80);
$effect = $slide->getTimeline()->getMainSequence()->addEffect($shape, EffectType::Fade, EffectSubtype::None, EffectTriggerType::OnClick);
$effect->getBehaviors()->clear();
$factory = new BehaviorFactory();
$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(2);
$effect->getBehaviors()->add($property);
$presentation->save($baseDirectory . DIRECTORY_SEPARATOR . "property.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Set**
Use [createSetEffect](https://reference.aspose.com/slides/php-java/aspose.slides/behaviorfactory/createseteffect/) to assign visibility through [getTo](https://reference.aspose.com/slides/php-java/aspose.slides/seteffect/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.
```php
use aspose\slides\BehaviorFactory;
use aspose\slides\BehaviorProperty;
use aspose\slides\EffectSubtype;
use aspose\slides\EffectTriggerType;
use aspose\slides\EffectType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$baseDirectory = getcwd();
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 160, 80);
$effect = $slide->getTimeline()->getMainSequence()->addEffect($shape, EffectType::Appear, EffectSubtype::None, EffectTriggerType::OnClick);
$effect->getBehaviors()->clear();
$factory = new BehaviorFactory();
$set = $factory->createSetEffect();
$set->getProperties()->add(BehaviorProperty::getStyleVisibility()->getValue());
$set->setTo("visible");
$effect->getBehaviors()->add($set);
$presentation->save($baseDirectory . DIRECTORY_SEPARATOR . "set.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Command**
Use [createCommandEffect](https://reference.aspose.com/slides/php-java/aspose.slides/behaviorfactory/createcommandeffect/) and configure [getType](https://reference.aspose.com/slides/php-java/aspose.slides/commandeffect/gettype/), [getCommandString](https://reference.aspose.com/slides/php-java/aspose.slides/commandeffect/getcommandstring/), and [getShapeTarget](https://reference.aspose.com/slides/php-java/aspose.slides/commandeffect/getshapetarget/). Place a WAV recording named `sample.wav` in the working directory. This example embeds it with [addAudioFrameEmbedded](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/addaudioframeembedded/) 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.
```php
use aspose\slides\BehaviorFactory;
use aspose\slides\CommandEffectType;
use aspose\slides\EffectSubtype;
use aspose\slides\EffectTriggerType;
use aspose\slides\EffectType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$baseDirectory = getcwd();
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$audioPath = $baseDirectory . DIRECTORY_SEPARATOR . "sample.wav";
$audioStream = new Java("java.io.FileInputStream", $audioPath);
try {
$audioFrame = $slide->getShapes()->addAudioFrameEmbedded(100, 100, 40, 40, $audioStream);
$effect = $slide->getTimeline()->getMainSequence()->addEffect($audioFrame, EffectType::MediaPlay, EffectSubtype::None, EffectTriggerType::OnClick);
$effect->getBehaviors()->clear();
$factory = new BehaviorFactory();
$command = $factory->createCommandEffect();
$command->setType(CommandEffectType::Call);
$command->setCommandString("play");
$command->setShapeTarget($audioFrame);
$effect->getBehaviors()->add($command);
$presentation->save($baseDirectory . DIRECTORY_SEPARATOR . "command.pptx", SaveFormat::Pptx);
} finally {
$audioStream->close();
}
} 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**
[BehaviorCollection](https://reference.aspose.com/slides/php-java/aspose.slides/behaviorcollection/) supports [add](https://reference.aspose.com/slides/php-java/aspose.slides/behaviorcollection/add/), [insert](https://reference.aspose.com/slides/php-java/aspose.slides/behaviorcollection/insert/), [remove](https://reference.aspose.com/slides/php-java/aspose.slides/behaviorcollection/remove/), and [removeAt](https://reference.aspose.com/slides/php-java/aspose.slides/behaviorcollection/removeat/). 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.
```php
use aspose\slides\BehaviorFactory;
use aspose\slides\Point2DFloat;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$baseDirectory = getcwd();
$presentation = new Presentation($baseDirectory . DIRECTORY_SEPARATOR . "rotation.pptx");
try {
$effect = $presentation->getSlides()->get_Item(0)->getTimeline()->getMainSequence()->get_Item(0);
$behaviors = $effect->getBehaviors();
$factory = new BehaviorFactory();
$scale = $factory->createScaleEffect();
$targetSize = new Point2DFloat(125, 125);
$scale->setTo($targetSize);
$scale->getTiming()->setDuration(2);
$behaviors->add($scale);
$behaviors->remove($scale);
$behaviors->insert(0, $scale);
$behaviors->removeAt(1);
$behaviorCount = java_values($behaviors->getCount());
for ($i = 0; $i < $behaviorCount; $i++) {
$behavior = $behaviors->get_Item($i);
echo java_values($behavior->getClass()->getSimpleName()) . PHP_EOL;
}
$presentation->save($baseDirectory . DIRECTORY_SEPARATOR . "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**
A behavior has its own [Timing](https://reference.aspose.com/slides/php-java/aspose.slides/timing/), independent of the timing returned by [Effect::getTiming](https://reference.aspose.com/slides/php-java/aspose.slides/effect/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/php-java/aspose.slides/timing/getduration/)) and trigger delay ([getTriggerDelayTime](https://reference.aspose.com/slides/php-java/aspose.slides/timing/gettriggerdelaytime/)) in seconds, then configure the repeat count through [setRepeatCount](https://reference.aspose.com/slides/php-java/aspose.slides/timing/setrepeatcount/). [getAccelerate](https://reference.aspose.com/slides/php-java/aspose.slides/timing/getaccelerate/) and [getDecelerate](https://reference.aspose.com/slides/php-java/aspose.slides/timing/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.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$baseDirectory = getcwd();
$presentation = new Presentation($baseDirectory . DIRECTORY_SEPARATOR . "rotation.pptx");
try {
$effect = $presentation->getSlides()->get_Item(0)->getTimeline()->getMainSequence()->get_Item(0);
$rotation = $effect->getBehaviors()->get_Item(0);
$rotation->getTiming()->setDuration(2);
$rotation->getTiming()->setTriggerDelayTime(0.5);
$rotation->getTiming()->setRepeatCount(3);
$rotation->getTiming()->setAccelerate(0.2);
$rotation->getTiming()->setDecelerate(0.2);
$presentation->save($baseDirectory . DIRECTORY_SEPARATOR . "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/php-java/aspose.slides/timing/getrepeatduration/), [getRepeatUntilEndSlide](https://reference.aspose.com/slides/php-java/aspose.slides/timing/getrepeatuntilendslide/), and [getRepeatUntilNextClick](https://reference.aspose.com/slides/php-java/aspose.slides/timing/getrepeatuntilnextclick/); choose a policy rather than enabling them all together. [getAutoReverse](https://reference.aspose.com/slides/php-java/aspose.slides/timing/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/php-java/aspose.slides/behaviorfactory/createmotioneffect/) to create motion. Its [getFrom](https://reference.aspose.com/slides/php-java/aspose.slides/motioneffect/getfrom/), [getTo](https://reference.aspose.com/slides/php-java/aspose.slides/motioneffect/getto/), and [getBy](https://reference.aspose.com/slides/php-java/aspose.slides/motioneffect/getby/) describe percentage-based coordinates or offsets. For an editable route, create a [MotionPath](https://reference.aspose.com/slides/php-java/aspose.slides/motionpath/) and assign it with [MotionEffect::setPath](https://reference.aspose.com/slides/php-java/aspose.slides/motioneffect/setpath/). [MotionPath](https://reference.aspose.com/slides/php-java/aspose.slides/motionpath/) stores the path commands.
[MotionCommandPathType](https://reference.aspose.com/slides/php-java/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/php-java/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/php-java/aspose.slides/motioneffect/getorigin/), which selects the path's reference frame, and [getPathEditMode](https://reference.aspose.com/slides/php-java/aspose.slides/motioneffect/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. [MotionPath::add](https://reference.aspose.com/slides/php-java/aspose.slides/motionpath/add/) 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.
```php
use aspose\slides\BehaviorFactory;
use aspose\slides\EffectSubtype;
use aspose\slides\EffectTriggerType;
use aspose\slides\EffectType;
use aspose\slides\MotionCommandPathType;
use aspose\slides\MotionOriginType;
use aspose\slides\MotionPath;
use aspose\slides\MotionPathPointsType;
use aspose\slides\Point2DFloat;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$baseDirectory = getcwd();
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 160, 80);
$effect = $slide->getTimeline()->getMainSequence()->addEffect($shape, EffectType::PathRight, EffectSubtype::None, EffectTriggerType::OnClick);
$effect->getBehaviors()->clear();
$factory = new BehaviorFactory();
$motion = $factory->createMotionEffect();
$motion->setOrigin(MotionOriginType::Layout);
$motion->getTiming()->setDuration(2);
$path = new MotionPath();
$startPoints = [new Point2DFloat(0, 0)];
$path->add(MotionCommandPathType::MoveTo, $startPoints, MotionPathPointsType::Auto, false);
$endPoints = [new Point2DFloat(0.25, 0)];
$path->add(MotionCommandPathType::LineTo, $endPoints, MotionPathPointsType::Corner, false);
$path->add(MotionCommandPathType::End, [], MotionPathPointsType::None, false);
$motion->setPath($path);
$effect->getBehaviors()->add($motion);
$presentation->save($baseDirectory . DIRECTORY_SEPARATOR . "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.
```php
use aspose\slides\MotionCommandPathType;
use aspose\slides\MotionPath;
use aspose\slides\MotionPathPointsType;
use aspose\slides\Point2DFloat;
$absolutePath = new MotionPath();
$absoluteStart = [new Point2DFloat(0.2, 0)];
$absolutePath->add(MotionCommandPathType::MoveTo, $absoluteStart, MotionPathPointsType::Auto, false);
$absoluteEnd = [new Point2DFloat(0.3, 0.1)];
$absolutePath->add(MotionCommandPathType::LineTo, $absoluteEnd, MotionPathPointsType::Corner, false);
$relativePath = new MotionPath();
$relativeStart = [new Point2DFloat(0.2, 0)];
$relativePath->add(MotionCommandPathType::MoveTo, $relativeStart, MotionPathPointsType::Auto, false);
$relativeOffset = [new Point2DFloat(0.1, 0.1)];
$relativePath->add(MotionCommandPathType::LineTo, $relativeOffset, 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.
[](https://docs.aspose.com/slides/php-java/custom-animation/visual-custom-animation-2b5c03cbaedf.svg)
*Both path commands end at (0.3, 0.1). The absolute command specifies that endpoint; the relative command adds (0.1, 0.1) to the current position (0.2, 0). The diagrams show path-coordinate arithmetic, not measured slide pixels.*
### **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.
```php
use aspose\slides\MotionCommandPathType;
use aspose\slides\MotionPathPointsType;
use aspose\slides\Point2DFloat;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$baseDirectory = getcwd();
$presentation = new Presentation($baseDirectory . DIRECTORY_SEPARATOR . "motion.pptx");
try {
$effect = $presentation->getSlides()->get_Item(0)->getTimeline()->getMainSequence()->get_Item(0);
$motion = $effect->getBehaviors()->get_Item(0);
$path = $motion->getPath();
$path->get_Item(1)->setCommandType(MotionCommandPathType::CurveTo);
$path->get_Item(1)->setPointsType(MotionPathPointsType::CurveSmooth);
$curvePoints = [new Point2DFloat(0.1, 0), new Point2DFloat(0.2, 0.1), new Point2DFloat(0.3, 0.1)];
$path->get_Item(1)->setPoints($curvePoints);
$presentation->save($baseDirectory . DIRECTORY_SEPARATOR . "curve.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The path in `curve.pptx` still has three commands; its middle command now defines a curve.
## **Inspect and Edit a Saved Path**
Each [MotionCmdPath](https://reference.aspose.com/slides/php-java/aspose.slides/motioncmdpath/) exposes [getPoints](https://reference.aspose.com/slides/php-java/aspose.slides/motioncmdpath/getpoints/), [getCommandType](https://reference.aspose.com/slides/php-java/aspose.slides/motioncmdpath/getcommandtype/), [getPointsType](https://reference.aspose.com/slides/php-java/aspose.slides/motioncmdpath/getpointstype/), and [isRelative](https://reference.aspose.com/slides/php-java/aspose.slides/motioncmdpath/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.
```php
use aspose\slides\Presentation;
$baseDirectory = getcwd();
$presentation = new Presentation($baseDirectory . DIRECTORY_SEPARATOR . "motion.pptx");
try {
$effect = $presentation->getSlides()->get_Item(0)->getTimeline()->getMainSequence()->get_Item(0);
$motion = $effect->getBehaviors()->get_Item(0);
$path = $motion->getPath();
$commandCount = java_values($path->getCount());
for ($i = 0; $i < $commandCount; $i++) {
$segment = $path->get_Item($i);
$commandType = java_values($segment->getCommandType());
$relative = java_values($segment->isRelative()) ? "true" : "false";
echo $commandType . ", relative: " . $relative . PHP_EOL;
$points = $segment->getPoints();
if (!java_is_null($points)) {
foreach ($points as $point) {
echo "X=" . java_values($point->getX()) . ", Y=" . java_values($point->getY()) . PHP_EOL;
}
}
}
} 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.
```php
use aspose\slides\Point2DFloat;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$baseDirectory = getcwd();
$presentation = new Presentation($baseDirectory . DIRECTORY_SEPARATOR . "motion.pptx");
try {
$effect = $presentation->getSlides()->get_Item(0)->getTimeline()->getMainSequence()->get_Item(0);
$motion = $effect->getBehaviors()->get_Item(0);
$endPoints = [new Point2DFloat(0.4, 0.1)];
$motion->getPath()->get_Item(1)->setPoints($endPoints);
$presentation->save($baseDirectory . DIRECTORY_SEPARATOR . "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/php-java/aspose.slides/motionpath/insert/) and [removeAt](https://reference.aspose.com/slides/php-java/aspose.slides/motionpath/removeat/) 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.
```php
use aspose\slides\MotionCommandPathType;
use aspose\slides\MotionPathPointsType;
use aspose\slides\Point2DFloat;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$baseDirectory = getcwd();
$presentation = new Presentation($baseDirectory . DIRECTORY_SEPARATOR . "motion.pptx");
try {
$effect = $presentation->getSlides()->get_Item(0)->getTimeline()->getMainSequence()->get_Item(0);
$motion = $effect->getBehaviors()->get_Item(0);
$path = $motion->getPath();
$replacementPoints = [new Point2DFloat(0.2, 0.1)];
$path->insert(1, MotionCommandPathType::LineTo, $replacementPoints, MotionPathPointsType::Corner, false);
$path->removeAt(2);
$presentation->save($baseDirectory . DIRECTORY_SEPARATOR . "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 [RotationEffect](https://reference.aspose.com/slides/php-java/aspose.slides/rotationeffect/), 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.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$baseDirectory = getcwd();
$rotationClass = new JavaClass("com.aspose.slides.IRotationEffect");
$presentation = new Presentation($baseDirectory . DIRECTORY_SEPARATOR . "rotation.pptx");
try {
$effect = $presentation->getSlides()->get_Item(0)->getTimeline()->getMainSequence()->get_Item(0);
$behaviors = $effect->getBehaviors();
$behaviorCount = java_values($behaviors->getCount());
for ($i = 0; $i < $behaviorCount; $i++) {
$behavior = $behaviors->get_Item($i);
if (java_instanceof($behavior, $rotationClass)) {
$rotation = $behavior;
$rotation->setBy(180);
}
}
$presentation->save($baseDirectory . DIRECTORY_SEPARATOR . "rotation-edited.pptx", SaveFormat::Pptx);
$reopened = new Presentation($baseDirectory . DIRECTORY_SEPARATOR . "rotation-edited.pptx");
try {
$savedEffect = $reopened->getSlides()->get_Item(0)->getTimeline()->getMainSequence()->get_Item(0);
$savedBehaviors = $savedEffect->getBehaviors();
$savedBehaviorCount = java_values($savedBehaviors->getCount());
for ($i = 0; $i < $savedBehaviorCount; $i++) {
$behavior = $savedBehaviors->get_Item($i);
if (java_instanceof($behavior, $rotationClass)) {
$rotation = $behavior;
$preserved = abs(java_values($rotation->getBy()) - 180) < 0.001;
echo "Rotation preserved: " . ($preserved ? "true" : "false") . PHP_EOL;
}
}
} 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/php-java/shape-animation/#read-shape-animations) for traversal of main and interactive sequences.
## **Behavior Order, Presets, and Playback**
The order in [BehaviorCollection](https://reference.aspose.com/slides/php-java/aspose.slides/behaviorcollection/) 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 [additive](https://reference.aspose.com/slides/php-java/aspose.slides/behavioradditivetype/) and [accumulation](https://reference.aspose.com/slides/php-java/aspose.slides/behavioraccumulatetype/) settings. 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/php-java/shape-animation/).
The effect's [getType](https://reference.aspose.com/slides/php-java/aspose.slides/effect/gettype/) and [getSubtype](https://reference.aspose.com/slides/php-java/aspose.slides/effect/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/php-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/php-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/php-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/php-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 PHP
> Customize fonts in PowerPoint slides with Aspose.Slides for PHP via Java to keep your presentations sharp and consistent across any device.
Source: https://docs.aspose.com/slides/php-java/custom-font/
Updated: 2026-08-25
## **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/php-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/php-java/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/php-java/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/php-java/aspose.slides/fontsloader/#clearCache--) to clear the font cache.
The following code example demonstrates the font loading process:
```php
// Define folders that contain custom font files.
$externalFontFolder1 = __DIR__ . "/external-fonts-1";
$externalFontFolder2 = __DIR__ . "/external-fonts-2";
$fontFolders = array($externalFontFolder1, $externalFontFolder2);
// Load custom fonts from the specified folders.
FontsLoader::loadExternalFonts($fontFolders);
$presentation = null;
try {
$presentationPath = __DIR__ . "/sample.pptx";
$presentation = new Presentation($presentationPath);
// Render/export the presentation (e.g., to PDF, images, or other formats) using the loaded fonts.
$outputPath = __DIR__ . "/output.pdf";
$presentation->save($outputPath, 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/php-java/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/php-java/aspose.slides/fontsloader/).
## **Get Custom Font Folders**
Aspose.Slides provides the [getFontFolders](https://reference.aspose.com/slides/php-java/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 PHP code shows you how to use [getFontFolders](https://reference.aspose.com/slides/php-java/aspose.slides/fontsloader/#getFontFolders--):
```php
# This line outputs folders where font files are searched.
# Those are folders added through the LoadExternalFonts method and system font folders.
$fontFolders = FontsLoader::getFontFolders();
```
## **Specify Custom Fonts Used with a Presentation**
Aspose.Slides provides the [LoadOptions.setDocumentLevelFontSources](https://reference.aspose.com/slides/java/com.aspose.slides/loadoptions/#setDocumentLevelFontSources-com.aspose.slides.IFontSources-) method to allow you to specify external fonts that will be used with the presentation.
This PHP code shows you how to use the [LoadOptions.setDocumentLevelFontSources](https://reference.aspose.com/slides/java/com.aspose.slides/loadoptions/#setDocumentLevelFontSources-com.aspose.slides.IFontSources-) method:
```php
$javaArray = new JavaClass("java.lang.reflect.Array");
$javaByteType = (new JavaClass("java.lang.Byte"))->TYPE;
$customFontsDirectory = __DIR__ . "/customfonts/";
$customFont1Path = $customFontsDirectory . "CustomFont1.ttf";
$customFontFile1 = new Java("java.io.File", $customFont1Path);
$customFontFile1Length = $customFontFile1->length();
$memoryFont1 = $javaArray->newInstance($javaByteType, $customFontFile1Length);
$dataInputStream1 = null;
try {
$fileInputStream1 = new Java("java.io.FileInputStream", $customFontFile1);
$dataInputStream1 = new Java("java.io.DataInputStream", $fileInputStream1);
$dataInputStream1->readFully($memoryFont1);
} finally {
if (!java_is_null($dataInputStream1)) $dataInputStream1->close();
}
$customFont2Path = $customFontsDirectory . "CustomFont2.ttf";
$customFontFile2 = new Java("java.io.File", $customFont2Path);
$customFontFile2Length = $customFontFile2->length();
$memoryFont2 = $javaArray->newInstance($javaByteType, $customFontFile2Length);
$dataInputStream2 = null;
try {
$fileInputStream2 = new Java("java.io.FileInputStream", $customFontFile2);
$dataInputStream2 = new Java("java.io.DataInputStream", $fileInputStream2);
$dataInputStream2->readFully($memoryFont2);
} finally {
if (!java_is_null($dataInputStream2)) $dataInputStream2->close();
}
$loadOptions = new LoadOptions();
$assetFontsFolder = __DIR__ . "/assets/fonts";
$globalFontsFolder = __DIR__ . "/global/fonts";
$loadOptions->getDocumentLevelFontSources()->setFontFolders(array($assetFontsFolder, $globalFontsFolder));
$loadOptions->getDocumentLevelFontSources()->setMemoryFonts(array($memoryFont1, $memoryFont2 ));
$presentationPath = __DIR__ . "/MyPresentation.pptx";
$presentation = new Presentation($presentationPath, $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 (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
## **Manage Fonts Externally**
Aspose.Slides provides the [loadExternalFont](https://reference.aspose.com/slides/php-java/aspose.slides/fontsloader/#loadExternalFont-byte---)(byte[] data) method to allow you to load external fonts from binary data.
This PHP code demonstrates the byte array font loading process:
```php
$javaArray = new JavaClass("java.lang.reflect.Array");
$javaByteType = (new JavaClass("java.lang.Byte"))->TYPE;
$fontDirectory = __DIR__ . "/";
$dataInputStream = null;
try {
$fontPath = $fontDirectory . "ARIALN.TTF";
$fileInputStream = new Java("java.io.FileInputStream", $fontPath);
$dataInputStream = new Java("java.io.DataInputStream", $fileInputStream);
$fontBytes = $javaArray->newInstance($javaByteType, $dataInputStream->available());
$dataInputStream->readFully($fontBytes);
} finally {
if (!java_is_null($dataInputStream)) $dataInputStream->close();
}
FontsLoader::loadExternalFont($fontBytes);
$dataInputStream = null;
try {
$fontPath = $fontDirectory . "ARIALNBI.TTF";
$fileInputStream = new Java("java.io.FileInputStream", $fontPath);
$dataInputStream = new Java("java.io.DataInputStream", $fileInputStream);
$fontBytes = $javaArray->newInstance($javaByteType, $dataInputStream->available());
$dataInputStream->readFully($fontBytes);
} finally {
if (!java_is_null($dataInputStream)) $dataInputStream->close();
}
FontsLoader::loadExternalFont($fontBytes);
$dataInputStream = null;
try {
$fontPath = $fontDirectory . "ARIALNI.TTF";
$fileInputStream = new Java("java.io.FileInputStream", $fontPath);
$dataInputStream = new Java("java.io.DataInputStream", $fileInputStream);
$fontBytes = $javaArray->newInstance($javaByteType, $dataInputStream->available());
$dataInputStream->readFully($fontBytes);
} finally {
if (!java_is_null($dataInputStream)) $dataInputStream->close();
}
FontsLoader::loadExternalFont($fontBytes);
try {
$presentation = new Presentation();
try {
# external font loaded during the presentation lifetime
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
} 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/php-java/embedded-font/).
### Can I control fallback behavior when a custom font lacks certain glyphs?
Yes. Configure [font substitution](https://docs.aspose.com/slides/php-java/font-substitution/), [replacement rules](https://docs.aspose.com/slides/php-java/font-replacement/), and [fallback sets](https://docs.aspose.com/slides/php-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?
Yes. Point to your own font folders or load fonts from byte arrays. This removes any dependency on system font directories in the container image.
### 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 PHP
> Create and customize shapes in PowerPoint presentations with Aspose.Slides for PHP via Java: geometry paths, curved corners, composite shapes.
Source: https://docs.aspose.com/slides/php-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/php-java/aspose.slides/geometrypath/) 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/php-java/aspose.slides/geometrypath/) class.
* A [GeometryPath](https://reference.aspose.com/slides/php-java/aspose.slides/geometrypath/) instance represents a geometry path of the [GeometryShape](https://reference.aspose.com/slides/php-java/aspose.slides/geometryshape/) object.
* To retrieve the [GeometryPath](https://reference.aspose.com/slides/php-java/aspose.slides/geometrypath/) from the [GeometryShape](https://reference.aspose.com/slides/php-java/aspose.slides/geometryshape/) instance, you can use the [GeometryShape::getGeometryPaths](https://reference.aspose.com/slides/php-java/aspose.slides/geometryshape/#getGeometryPaths) method.
* To set the [GeometryPath](https://reference.aspose.com/slides/php-java/aspose.slides/geometrypath/) for a shape, you can use these methods: [GeometryShape::setGeometryPath](https://reference.aspose.com/slides/php-java/aspose.slides/geometryshape/#setGeometryPath) for shapes with a single path and [GeometryShape::setGeometryPaths](https://reference.aspose.com/slides/php-java/aspose.slides/geometryshape/#setGeometryPaths) for shapes with multiple paths.
* To add segments, you can use the methods under [GeometryPath](https://reference.aspose.com/slides/php-java/aspose.slides/geometrypath/).
* Using the [GeometryPath::setStroke](https://reference.aspose.com/slides/php-java/aspose.slides/geometrypath/#setStroke) and [GeometryPath::setFillMode](https://reference.aspose.com/slides/php-java/aspose.slides/geometrypath/#setFillMode) methods, you can set the appearance for a geometry path.
* Using the [GeometryPath::getPathData](https://reference.aspose.com/slides/php-java/aspose.slides/geometrypath/#getPathData) method, you can retrieve the geometry path of a [GeometryShape](https://reference.aspose.com/slides/php-java/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/php-java/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/php-java/aspose.slides/geometrypath/#lineTo) |
| Append or insert a cubic Bézier curve with two control points and an endpoint. | [GeometryPath::cubicBezierTo](https://reference.aspose.com/slides/php-java/aspose.slides/geometrypath/#cubicBezierTo) |
| Append or insert a quadratic Bézier curve with one control point and an endpoint. | [GeometryPath::quadraticBezierTo](https://reference.aspose.com/slides/php-java/aspose.slides/geometrypath/#quadraticBezierTo) |
| Append an elliptical arc with the specified dimensions and angles in degrees. | [GeometryPath::arcTo](https://reference.aspose.com/slides/php-java/aspose.slides/geometrypath/#arcTo) |
| Close the current figure by connecting its endpoint to its starting point. | [GeometryPath::closeFigure](https://reference.aspose.com/slides/php-java/aspose.slides/geometrypath/#closeFigure) |
| Set the starting point of a figure. | [GeometryPath::moveTo](https://reference.aspose.com/slides/php-java/aspose.slides/geometrypath/#moveTo) |
| Remove a segment at a zero-based index. | [GeometryPath::removeAt](https://reference.aspose.com/slides/php-java/aspose.slides/geometrypath/#removeAt) |
## **Add Custom Points to a Shape**
This example inserts two points into a rectangular shape using [GeometryPath::lineTo](https://reference.aspose.com/slides/php-java/aspose.slides/geometrypath/#lineTo) and applies the edited path with [GeometryShape::setGeometryPath](https://reference.aspose.com/slides/php-java/aspose.slides/geometryshape/#setGeometryPath). 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.
```php
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 200, 100);
$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/php-java/aspose.slides/geometrypath/#removeAt). Applying the modified path with [GeometryShape::setGeometryPath](https://reference.aspose.com/slides/php-java/aspose.slides/geometryshape/#setGeometryPath) updates the shape’s contour.
```php
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Heart, 100, 100, 300, 300);
$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/php-java/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/php-java/aspose.slides/geometrypath/#closeFigure) and applied to a rectangular shape using [GeometryShape::setGeometryPath](https://reference.aspose.com/slides/php-java/aspose.slides/geometryshape/#setGeometryPath), replacing its outline.
```php
use aspose\slides\GeometryPath;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$points = [];
$outerRadius = 100;
$innerRadius = 50;
$angleStep = 72;
for ($angle = -90; $angle < 270; $angle += $angleStep) {
$radians = deg2rad($angle);
$points[] = [$outerRadius * cos($radians) + $outerRadius, $outerRadius * sin($radians) + $outerRadius];
$radians = deg2rad($angle + $angleStep / 2);
$points[] = [$innerRadius * cos($radians) + $outerRadius, $innerRadius * sin($radians) + $outerRadius];
}
$starPath = new GeometryPath();
$starPath->moveTo($points[0][0], $points[0][1]);
for ($i = 1; $i < count($points); $i++) {
$starPath->lineTo($points[$i][0], $points[$i][1]);
}
$starPath->closeFigure();
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$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/php-java/aspose.slides/geometrypath/) objects for the top and bottom thirds of a shape. Applying both paths with [GeometryShape::setGeometryPaths](https://reference.aspose.com/slides/php-java/aspose.slides/geometryshape/#setGeometryPaths) creates a single composite shape with a gap across its middle third.
```php
use aspose\slides\GeometryPath;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 200, 100);
$topPath = new GeometryPath();
$topPath->moveTo(0, 0);
$topPath->lineTo(java_values($shape->getWidth()), 0);
$topPath->lineTo(java_values($shape->getWidth()), java_values($shape->getHeight()) / 3);
$topPath->lineTo(0, java_values($shape->getHeight()) / 3);
$topPath->closeFigure();
$bottomPath = new GeometryPath();
$bottomPath->moveTo(0, java_values($shape->getHeight()) / 3 * 2);
$bottomPath->lineTo(java_values($shape->getWidth()), java_values($shape->getHeight()) / 3 * 2);
$bottomPath->lineTo(java_values($shape->getWidth()), java_values($shape->getHeight()));
$bottomPath->lineTo(0, java_values($shape->getHeight()));
$bottomPath->closeFigure();
$shape->setGeometryPaths([$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/php-java/aspose.slides/geometrypath/#arcTo) 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 [GeometryShape::setGeometryPath](https://reference.aspose.com/slides/php-java/aspose.slides/geometryshape/#setGeometryPath), and the presentation is saved in PPTX format.
```php
use aspose\slides\GeometryPath;
use aspose\slides\Point2DFloat;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$shapeX = 20;
$shapeY = 20;
$shapeWidth = 300;
$shapeHeight = 200;
$leftTopSize = 50;
$rightTopSize = 20;
$rightBottomSize = 40;
$leftBottomSize = 10;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Custom, $shapeX, $shapeY, $shapeWidth, $shapeHeight);
$topLeft = new Point2DFloat($leftTopSize, 0);
$topRight = new Point2DFloat($shapeWidth - $rightTopSize, 0);
$rightBottom = new Point2DFloat($shapeWidth, $shapeHeight - $rightBottomSize);
$bottomLeft = new Point2DFloat($leftBottomSize, $shapeHeight);
$leftTop = new Point2DFloat(0, $leftTopSize);
$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 [GeometryPath::getPathData](https://reference.aspose.com/slides/php-java/aspose.slides/geometrypath/#getPathData) and compares the final segment’s [PathSegment::getPathCommand](https://reference.aspose.com/slides/php-java/aspose.slides/pathsegment/#getPathCommand) with [PathCommandType::Close](https://reference.aspose.com/slides/php-java/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.
```php
use aspose\slides\PathCommandType;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
function isGeometryClosed($geometryShape)
{
$hasNonemptyPath = false;
foreach ($geometryShape->getGeometryPaths() as $geometryPath) {
$segments = java_values($geometryPath->getPathData());
if (count($segments) === 0) {
continue;
}
$hasNonemptyPath = true;
$lastSegment = $segments[count($segments) - 1];
if (java_values($lastSegment->getPathCommand()) !== PathCommandType::Close) {
return false;
}
}
return $hasNonemptyPath;
}
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 200, 100);
$closed = isGeometryClosed($shape);
echo ($closed ? "true" : "false") . PHP_EOL;
} finally {
$presentation->dispose();
}
```
## **Extract and Inspect Shape Elements**
Use [GeometryShape::createShapeElements](https://reference.aspose.com/slides/php-java/aspose.slides/geometryshape/#createShapeElements) to inspect an existing shape as elements containing path points and point types. Use each returned [ShapeElement](https://reference.aspose.com/slides/php-java/aspose.slides/shapeelement/) to retrieve the point and type arrays through [getPathPoints](https://reference.aspose.com/slides/php-java/aspose.slides/shapeelement/#getPathPoints) and [getPathTypes](https://reference.aspose.com/slides/php-java/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.
```php
use aspose\slides\Presentation;
$presentation = new Presentation("input.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = null;
$shapes = $slide->getShapes();
for ($shapeIndex = 0; $shapeIndex < java_values($shapes->size()); $shapeIndex++) {
$candidate = $shapes->get_Item($shapeIndex);
if (java_instanceof($candidate, java("com.aspose.slides.GeometryShape"))) {
$shape = $candidate;
break;
}
}
if ($shape === null) {
echo "No geometry shape found on the first slide." . PHP_EOL;
} else {
foreach ($shape->createShapeElements() as $element) {
$points = java_values($element->getPathPoints());
$types = array_values(unpack("C*", java_values($element->getPathTypes())));
echo "Shape element:" . PHP_EOL;
for ($i = 0; $i < count($points); $i++) {
$pointType = $types[$i] & 0x07; // Keep the segment type, excluding flags.
switch ($pointType) {
case 0:
echo "Start figure at " . $points[$i] . PHP_EOL;
break;
case 1:
echo "Line to " . $points[$i] . PHP_EOL;
break;
case 3:
echo "Cubic Bezier: controls " . $points[$i] . ", " . $points[$i + 1] . "; end " . $points[$i + 2] . PHP_EOL;
$i += 2; // Consume both control points and the endpoint.
break;
}
if (($types[$i] & 0x80) !== 0) {
echo "Close subpath back to its starting point." . PHP_EOL;
}
}
}
}
} 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. The PHP/Java Bridge returns the byte array as a binary string; unpacking it with "C*" produces unsigned byte values. 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/php-java/aspose.slides/shape/#getX) and [getY](https://reference.aspose.com/slides/php-java/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/php-java/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/php-java/aspose.slides/geometryshape/#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/php-java/aspose.slides/geometryshape/#setGeometryPath) or [setGeometryPaths](https://reference.aspose.com/slides/php-java/aspose.slides/geometryshape/#setGeometryPaths).
## **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/php-java/aspose.slides/geometrypath/#setFillMode) 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/php-java/aspose.slides/geometrypath/).
The example uses a Java float array so the PHP/Java Bridge retains the coordinates written by the iterator. 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 [GeometryShape::setGeometryPaths](https://reference.aspose.com/slides/php-java/aspose.slides/geometryshape/#setGeometryPaths) produces a single shape containing the rectangle and text.
```php
use aspose\slides\GeometryPath;
use aspose\slides\PathFillModeType;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 300, 100);
$originalPath = $shape->getGeometryPaths()[0];
$originalPath->setFillMode(PathFillModeType::None);
$fontClass = java("java.awt.Font");
$imageClass = java("java.awt.image.BufferedImage");
$font = new Java("java.awt.Font", "Arial", $fontClass->PLAIN, 40);
$image = new Java("java.awt.image.BufferedImage", 100, 100, $imageClass->TYPE_INT_ARGB);
$graphics = $image->createGraphics();
try {
$fontContext = $graphics->getFontRenderContext();
$glyphVector = $font->createGlyphVector($fontContext, "Text in shape");
$textBounds = $glyphVector->getVisualBounds();
$baseline = -java_values($textBounds->getY()) + 10;
$graphicsPath = $glyphVector->getOutline(20.0, $baseline);
} finally {
$graphics->dispose();
}
$textPath = new GeometryPath();
$pathIterator = $graphicsPath->getPathIterator(null);
$iteratorClass = java("java.awt.geom.PathIterator");
$arrayClass = java("java.lang.reflect.Array");
$floatClass = java("java.lang.Float");
$coordinates = $arrayClass->newInstance($floatClass->TYPE, 6);
while (!java_values($pathIterator->isDone())) {
$segmentType = java_values($pathIterator->currentSegment($coordinates));
$points = java_values($coordinates);
switch ($segmentType) {
case java_values($iteratorClass->SEG_MOVETO):
$textPath->moveTo($points[0], $points[1]);
break;
case java_values($iteratorClass->SEG_LINETO):
$textPath->lineTo($points[0], $points[1]);
break;
case java_values($iteratorClass->SEG_QUADTO):
$textPath->quadraticBezierTo($points[0], $points[1], $points[2], $points[3]);
break;
case java_values($iteratorClass->SEG_CUBICTO):
$textPath->cubicBezierTo($points[0], $points[1], $points[2], $points[3], $points[4], $points[5]);
break;
case java_values($iteratorClass->SEG_CLOSE):
$textPath->closeFigure();
break;
}
$pathIterator->next();
}
$textPath->setFillMode(PathFillModeType::Normal);
$shape->setGeometryPaths([$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/php-java/aspose.slides/shape/#setRotation) 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/php-java/convert-powerpoint-to-png/) area or the [shape](https://docs.aspose.com/slides/php-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 PHP
> Learn how to create hierarchical data and customize levels, labels, and colors in Treemap and Sunburst charts with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-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 PHP via Java, each numeric value is a [ChartDataPoint](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapoint/). Its [ChartDataPoint.getDataPointLevels](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapoint/#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 [ChartDataPoint.getDataPointLevels](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapoint/#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.
```php
$presentation = new Presentation();
try {
$worksheetIndex = 0;
$leafLevelIndex = 0;
$stemLevelIndex = 1;
$branchLevelIndex = 2;
$branchNames = [
"Consumer", "Consumer", "Consumer", "Consumer",
"Business", "Business", "Business", "Business"
];
$stemNames = [
"Computers", "Computers", "Mobile", "Mobile",
"Services", "Services", "Software", "Software"
];
$leafNames = [
"Laptops", "Desktops", "Phones", "Tablets",
"Consulting", "Support", "Licenses", "Subscriptions"
];
$revenues = [12, 8, 15, 6, 10, 7, 11, 14];
$dataPointCount = count($leafNames);
$chartTypes = [ChartType::Treemap, ChartType::Sunburst];
$chartCount = count($chartTypes);
$layoutSlide = $presentation->getLayoutSlides()->get_Item(0);
for ($chartIndex = 0; $chartIndex < $chartCount; $chartIndex++) {
$chartType = $chartTypes[$chartIndex];
if ($chartIndex === 0) {
$slide = $presentation->getSlides()->get_Item(0);
} else {
$slide = $presentation->getSlides()->addEmptySlide($layoutSlide);
}
$chart = $slide->getShapes()->addChart($chartType, 40, 40, 640, 440);
$chart->setTitle(false);
$chart->setLegend(false);
$chartData = $chart->getChartData();
$chartData->getCategories()->clear();
$chartData->getSeries()->clear();
$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 ($dataIndex = 0; $dataIndex < $dataPointCount; $dataIndex++) {
$rowIndex = $dataIndex + 1;
$leafName = $leafNames[$dataIndex];
$categoryCell = $workbook->getCell($worksheetIndex, $rowIndex, 2, $leafName);
$category = $chartData->getCategories()->add($categoryCell);
$stemName = $stemNames[$dataIndex];
$startsNewStem = $dataIndex === 0;
if ($dataIndex > 0) {
$previousStemName = $stemNames[$dataIndex - 1];
$startsNewStem = $stemName !== $previousStemName;
}
if ($startsNewStem) {
$category->getGroupingLevels()->setGroupingItem($stemLevelIndex, $stemName);
}
$branchName = $branchNames[$dataIndex];
$startsNewBranch = $dataIndex === 0;
if ($dataIndex > 0) {
$previousBranchName = $branchNames[$dataIndex - 1];
$startsNewBranch = $branchName !== $previousBranchName;
}
if ($startsNewBranch) {
$category->getGroupingLevels()->setGroupingItem($branchLevelIndex, $branchName);
}
}
$seriesNameCell = $workbook->getCell($worksheetIndex, 0, 3, "Revenue");
$series = $chartData->getSeries()->add($seriesNameCell, $chartType);
$series->getLabels()->getDefaultDataLabelFormat()->setShowCategoryName(true);
$laptopsDataPoint = null;
$tabletsDataPoint = null;
$licensesDataPoint = null;
for ($dataIndex = 0; $dataIndex < $dataPointCount; $dataIndex++) {
$rowIndex = $dataIndex + 1;
$leafName = $leafNames[$dataIndex];
$revenue = $revenues[$dataIndex];
$valueCell = $workbook->getCell($worksheetIndex, $rowIndex, 3, $revenue);
if ($chartType === ChartType::Treemap) {
$dataPoint = $series->getDataPoints()->addDataPointForTreemapSeries($valueCell);
} else {
$dataPoint = $series->getDataPoints()->addDataPointForSunburstSeries($valueCell);
}
if ($leafName === "Laptops") {
$laptopsDataPoint = $dataPoint;
} elseif ($leafName === "Tablets") {
$tabletsDataPoint = $dataPoint;
} elseif ($leafName === "Licenses") {
$licensesDataPoint = $dataPoint;
}
}
// Show the category and value on the Tablets leaf.
$tabletsLeafLevel = $tabletsDataPoint->getDataPointLevels()->get_Item($leafLevelIndex);
$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.
$consumerBranchLevel = $laptopsDataPoint->getDataPointLevels()->get_Item($branchLevelIndex);
$consumerBranchFill = $consumerBranchLevel->getFormat()->getFill();
$consumerBranchColor = new java("java.awt.Color", 31, 78, 121);
$consumerBranchFill->setFillType(FillType::Solid);
$consumerBranchFill->getSolidFillColor()->setColor($consumerBranchColor);
$consumerLabelFormat = $consumerBranchLevel->getLabel()->getDataLabelFormat();
$consumerLabelFormat->setShowCategoryName(true);
$consumerLabelFormat->setShowSeriesName(false);
$consumerLabelTextFill = $consumerLabelFormat->getTextFormat()->getPortionFormat()->getFillFormat();
$white = java("java.awt.Color")->WHITE;
$consumerLabelTextFill->setFillType(FillType::Solid);
$consumerLabelTextFill->getSolidFillColor()->setColor($white);
// Format the Software stem through the first leaf in that stem.
$softwareStemLevel = $licensesDataPoint->getDataPointLevels()->get_Item($stemLevelIndex);
$softwareStemFill = $softwareStemLevel->getFormat()->getFill();
$softwareStemColor = new java("java.awt.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 [ChartSeries.setParentLabelLayout](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/#setParentLabelLayout) method controls how parent labels appear in this chart type.
- A Sunburst uses angle to communicate value and ring depth to communicate hierarchy. [ChartSeries.setParentLabelLayout](https://reference.aspose.com/slides/php-java/aspose.slides/chartseries/#setParentLabelLayout) does not control its ring labels.
- Both chart types use the same category grouping levels and the same leaf-to-parent order returned by [ChartDataPoint.getDataPointLevels](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapoint/#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 [DataLabelFormat](https://reference.aspose.com/slides/php-java/aspose.slides/datalabelformat/), 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 [ChartDataPointLevel](https://reference.aspose.com/slides/php-java/aspose.slides/chartdatapointlevel/) 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 [DataLabelFormat](https://reference.aspose.com/slides/php-java/aspose.slides/datalabelformat/) 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/php-java/create-chart/#create-tree-map-charts)
- [Create Sunburst charts](https://docs.aspose.com/slides/php-java/create-chart/#create-sunburst-charts)
- [Export presentation charts](https://docs.aspose.com/slides/php-java/export-chart/)
- [Manage presentation themes](https://docs.aspose.com/slides/php-java/presentation-theme/)
# Declaration
> Learn about Aspose.Slides for PHP trust requirements, permissions, and hosting limitations so you can safely deploy apps that process PPT, PPTX and ODP on servers.
Source: https://docs.aspose.com/slides/php-java/declaration/
Updated: 2026-08-13
All Aspose Java components require Full Trust permission set. The reason is, Aspose Java components need to access registry settings, system files other than virtual directory for certain operations like parsing fonts etc. Moreover, Aspose Java Components are based on core Java system classes that also require Full Trust permission set in many cases.
Internet Service Providers hosting multiple applications from different companies mostly enforce Medium Trust security level:
- OleDbPermission is not available. This means you cannot use the ADO.NET managed OLE DB data provider to access databases.
- EventLogPermission is not available. This means you cannot access the Windows event log.
- ReflectionPermission is not available. This means you cannot use reflection.
- RegistryPermission is not available. This means you cannot access the registry.
- WebPermission is restricted. This means your application can only communicate with an address or range of addresses that you define in the element.
- FileIOPermission is restricted. This means you can only access files in your application's virtual directory hierarchy.
Due to the reasons specified above, Aspose Java components cannot be used on servers granting permission set other than Full Trust.
# Specify Default Presentation Fonts in PHP
> Set default fonts in Aspose.Slides for PHP via Java to ensure proper PowerPoint (PPT, PPTX) and OpenDocument (ODP) conversion to PDF, XPS and images.
Source: https://docs.aspose.com/slides/php-java/default-font/
Updated: 2026-08-02
## **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 PHP via Java API:
1. Create an instance of [LoadOptions](https://reference.aspose.com/slides/php-java/aspose.slides/LoadOptions).
1. [Set the DefaultRegularFont](https://reference.aspose.com/slides/php-java/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/php-java/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.
```php
# Use load options to define the default regualr and asian fonts
$loadOptions = new LoadOptions(LoadFormat::Auto);
$loadOptions->setDefaultRegularFont("Wingdings");
$loadOptions->setDefaultAsianFont("Wingdings");
# Load the presentation
$pres = new Presentation("DefaultFonts.pptx", $loadOptions);
try {
# Generate slide thumbnail
$slideImage = $pres->getSlides()->get_Item(0)->getImage(1, 1);
try {
# save the image on the disk.
$slideImage->save("output.png", ImageFormat::Png);
} finally {
if (!java_is_null($slideImage)) {
$slideImage->dispose();
}
}
# Generate PDF
$pres->save("output_out.pdf", SaveFormat::Pdf);
# Generate XPS
$pres->save("output_out.xps", SaveFormat::Xps);
} catch (JavaException $e) {
} finally {
if (!java_is_null($pres)) {
$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/php-java/convert-powerpoint-to-pdf/), [XPS](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-xps/), [raster images](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-png/), [HTML](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-html/), and [SVG](https://docs.aspose.com/slides/php-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/php-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/php-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/php-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/php-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.
# Determine the Original Presentation Format in PHP
> Read the original format of a loaded presentation in PHP with Aspose.Slides for PHP via Java, compare detection APIs, and handle files, streams, and legacy formats.
Source: https://docs.aspose.com/slides/php-java/detect-presentation-source-format/
Updated: 2026-09-22
## **Overview**
After loading a presentation, call the [Presentation::getSourceFormat](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getSourceFormat) method to determine its original format. 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/php-java/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/php-java/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.
```php
use aspose\slides\Presentation;
use aspose\slides\SourceFormat;
$presentation = new Presentation("sample.pptx");
try {
switch (java_values($presentation->getSourceFormat())) {
case SourceFormat::Ppt:
case SourceFormat::Pps:
case SourceFormat::Pot:
echo "Use the legacy PowerPoint processing policy." . PHP_EOL;
break;
case SourceFormat::Pptx:
echo "Use the standard PPTX processing policy." . PHP_EOL;
break;
default:
echo "Use the general policy for source format " . java_values($presentation->getSourceFormat()) . "." . PHP_EOL;
break;
}
} finally {
$presentation->dispose();
}
```
## **Recognize the Supported Values**
The [SourceFormat](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/presentation/) constructor receives only the stream.
```php
use aspose\slides\Presentation;
$inputFile = new Java("java.io.File", "sample.pps");
$bytes = java("java.nio.file.Files")->readAllBytes($inputFile->toPath());
$stream = new Java("java.io.ByteArrayInputStream", $bytes);
try {
$presentation = new Presentation($stream);
try {
echo "Source format: " . java_values($presentation->getSourceFormat()) . PHP_EOL;
} finally {
$presentation->dispose();
}
} finally {
$stream->close();
}
```
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/php-java/aspose.slides/presentationfactory/#getPresentationInfo) and [PresentationInfo::getLoadFormat](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/#getLoadFormat) when you need to inspect a file before loading its complete presentation object model. Use [Presentation::getSourceFormat](https://reference.aspose.com/slides/php-java/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.
```php
use aspose\slides\Presentation;
use aspose\slides\PresentationFactory;
$path = "sample.pptx";
$information = PresentationFactory::getInstance()->getPresentationInfo($path);
echo "Before loading: " . java_values($information->getLoadFormat()) . PHP_EOL;
$presentation = new Presentation($path);
try {
echo "After loading: " . java_values($presentation->getSourceFormat()) . PHP_EOL;
} finally {
$presentation->dispose();
}
```
The results use constants from different classes: [LoadFormat](https://reference.aspose.com/slides/php-java/aspose.slides/loadformat/) and [SourceFormat](https://reference.aspose.com/slides/php-java/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`.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("sample.pptx");
try {
echo "Before saving: " . java_values($presentation->getSourceFormat()) . PHP_EOL;
$presentation->save("converted.odp", SaveFormat::Odp);
echo "After saving: " . java_values($presentation->getSourceFormat()) . PHP_EOL;
$reopened = new Presentation("converted.odp");
try {
echo "Reopened output: " . java_values($reopened->getSourceFormat()) . PHP_EOL;
} 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/php-java/aspose.slides/sourceformat/) value to a conventional extension, without parsing the input filename. The fallback avoids silently assigning an extension to an unrecognized value.
```php
use aspose\slides\Presentation;
use aspose\slides\SourceFormat;
$presentation = new Presentation("sample.pptx");
try {
$extension = null;
switch (java_values($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;
}
echo ($extension !== null ? $extension : "No extension mapping is available.") . PHP_EOL;
} 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/php-java/aspose.slides/saveformat/) explicitly, or use the conversion shown in [Save Presentations in Their Original Format](https://docs.aspose.com/slides/php-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`.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$formats = [SaveFormat::Pptx, SaveFormat::Odp, SaveFormat::Pps];
$extensions = ["pptx", "odp", "pps"];
foreach ($formats as $index => $format) {
$path = "roundtrip." . $extensions[$index];
$presentation->save($path, $format);
$fromFile = new Presentation($path);
try {
$inputFile = new Java("java.io.File", $path);
$bytes = java("java.nio.file.Files")->readAllBytes($inputFile->toPath());
$stream = new Java("java.io.ByteArrayInputStream", $bytes);
try {
$fromStream = new Presentation($stream);
try {
echo $extensions[$index] . ": file=" . java_values($fromFile->getSourceFormat()) . ", stream=" . java_values($fromStream->getSourceFormat()) . PHP_EOL;
} finally {
$fromStream->dispose();
}
} finally {
$stream->close();
}
} finally {
$fromFile->dispose();
}
}
} finally {
$presentation->dispose();
}
```
The following table summarizes source-format identification for presentations with matching extensions. Names denote constants; the PHP 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/php-java/aspose.slides/presentation/#getSourceFormat). Use [PresentationFactory::getPresentationInfo](https://reference.aspose.com/slides/php-java/aspose.slides/presentationfactory/#getPresentationInfo) for inspection before loading.
# Developer Guide
> Discover the Aspose.Slides for PHP via 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/php-java/developer-guide/
Updated: 2025-12-01
---
lastmod: 2025-12-01T11:46:27+04:00
title: Developer Guide
type: docs
weight: 20
url: /php-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
- PHP
- Aspose.Slides
description: "Discover the Aspose.Slides for PHP via 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 PHP
> Learn how to sign existing PPTX presentations with PFX certificates and use Aspose.Slides for PHP via Java to validate or remove digital signatures.
Source: https://docs.aspose.com/slides/php-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/php-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 [Presentation::getDigitalSignatures](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getDigitalSignatures), which returns a [DigitalSignatureCollection](https://reference.aspose.com/slides/php-java/aspose.slides/digitalsignaturecollection/) whose items are represented by [DigitalSignature](https://reference.aspose.com/slides/php-java/aspose.slides/digitalsignature/) objects. 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/php-java/aspose.slides/digitalsignature/) from a PFX certificate and its password, add the signature to the presentation's collection, and save to a PPTX file.
```php
$certificatePassword = getenv("PFX_PASSWORD");
if ($certificatePassword === false || $certificatePassword === "") {
throw new RuntimeException("Set the PFX_PASSWORD environment variable.");
}
$presentation = new Presentation("InputPresentation.pptx");
try {
$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 [DigitalSignature::setComments](https://reference.aspose.com/slides/php-java/aspose.slides/digitalsignature/setcomments/) 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 [Presentation::getDigitalSignatures](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getDigitalSignatures). The [DigitalSignature::isValid](https://reference.aspose.com/slides/php-java/aspose.slides/digitalsignature/isvalid/) method indicates whether the embedded signature is valid for the current presentation content.
```php
$presentation = new Presentation("InputPresentation-signed.pptx");
try {
$signatures = $presentation->getDigitalSignatures();
$signatureCount = java_values($signatures->size());
if ($signatureCount === 0) {
echo "The presentation does not contain digital signatures." . PHP_EOL;
} else {
$allSignaturesAreValid = true;
$signTimeFormat = new Java("java.text.SimpleDateFormat", "yyyy-MM-dd HH:mm:ss");
$certificateFactoryClass = new JavaClass("java.security.cert.CertificateFactory");
$certificateFactory = $certificateFactoryClass->getInstance("X.509");
for ($index = 0; $index < $signatureCount; $index++) {
$signature = $signatures->get_Item($index);
$signatureIsValid = java_values($signature->isValid());
$signatureStatus = $signatureIsValid ? "VALID" : "INVALID";
$formattedSignTime = java_values($signTimeFormat->format($signature->getSignTime()));
$certificateData = $signature->getCertificate();
$certificateStream = new Java("java.io.ByteArrayInputStream", $certificateData);
try {
$certificate = $certificateFactory->generateCertificate($certificateStream);
$signerName = java_values($certificate->getSubjectX500Principal()->getName());
} finally {
$certificateStream->close();
}
echo $signerName . ", " . $formattedSignTime . " -- " . $signatureStatus . PHP_EOL;
$allSignaturesAreValid = $allSignaturesAreValid && $signatureIsValid;
}
if ($allSignaturesAreValid) {
echo "All embedded signatures are valid for the current presentation." . PHP_EOL;
} else {
echo "At least one embedded signature is invalid." . PHP_EOL;
}
}
} 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 [DigitalSignature::getSignTime](https://reference.aspose.com/slides/php-java/aspose.slides/digitalsignature/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 [DigitalSignatureCollection::clear](https://reference.aspose.com/slides/php-java/aspose.slides/digitalsignaturecollection/clear/), and saves an unsigned copy.
```php
$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 [DigitalSignatureCollection::removeAt](https://reference.aspose.com/slides/php-java/aspose.slides/digitalsignaturecollection/removeat/) 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/php-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 [Presentation::getDigitalSignatures](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#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 PHP
> Discover how to create and customize doughnut charts in Aspose.Slides for PHP via Java, supporting PowerPoint formats for dynamic presentations.
Source: https://docs.aspose.com/slides/php-java/doughnut-chart/
Updated: 2026-08-02
## **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**
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/php-java/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.
```php
# Create an instance of Presentation class
$pres = new Presentation();
try {
$chart = $pres->getSlides()->get_Item(0)->getShapes()->addChart(ChartType::Doughnut, 50, 50, 400, 400);
$chart->getChartData()->getSeriesGroups()->get_Item(0)->setDoughnutHoleSize(90);
# Write presentation to disk
$pres->save("DoughnutHoleSize_out.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$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/php-java/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/php-java/aspose.slides/shape/#getImage) or export the chart to an [SVG image](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#writeAsSvg).
# Manage Drawing Guides in Presentations in PHP
> Add, access, and clear horizontal and vertical drawing guides in PowerPoint presentations using Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-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 PHP via Java exposes them through the [DrawingGuidesCollection](https://reference.aspose.com/slides/php-java/aspose.slides/drawingguidescollection/) class. A guide is represented by [DrawingGuide](https://reference.aspose.com/slides/php-java/aspose.slides/drawingguide/) 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 [CommonSlideViewProperties::getDrawingGuides](https://reference.aspose.com/slides/php-java/aspose.slides/commonslideviewproperties/#getDrawingGuides) to manage guides displayed while editing normal slides. Call [DrawingGuidesCollection::add](https://reference.aspose.com/slides/php-java/aspose.slides/drawingguidescollection/#add) with an [Orientation](https://reference.aspose.com/slides/php-java/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:
```php
use aspose\slides\Orientation;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slideSize = $presentation->getSlideSize()->getSize();
$slideWidth = java_values($slideSize->getWidth());
$slideHeight = java_values($slideSize->getHeight());
$guides = $presentation->getViewProperties()->getSlideViewProperties()->getDrawingGuides();
$guides->add(Orientation::Vertical, $slideWidth / 2 + 12.5);
$guides->add(Orientation::Horizontal, $slideHeight / 2 + 12.5);
$presentation->save("drawing-guides.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
[](https://docs.aspose.com/slides/php-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 [DrawingGuidesCollection::getCount](https://reference.aspose.com/slides/php-java/aspose.slides/drawingguidescollection/#getCount) and [DrawingGuidesCollection::get_Item](https://reference.aspose.com/slides/php-java/aspose.slides/drawingguidescollection/#get_Item) methods provide access to existing guides. The [DrawingGuide::getOrientation](https://reference.aspose.com/slides/php-java/aspose.slides/drawingguide/#getOrientation), [DrawingGuide::getPosition](https://reference.aspose.com/slides/php-java/aspose.slides/drawingguide/#getPosition), and [DrawingGuide::getColor](https://reference.aspose.com/slides/php-java/aspose.slides/drawingguide/#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:
```php
use aspose\slides\Presentation;
$presentation = new Presentation("drawing-guides.pptx");
try {
$guides = $presentation->getViewProperties()->getSlideViewProperties()->getDrawingGuides();
$guideCount = java_values($guides->getCount());
for ($index = 0; $index < $guideCount; $index++) {
$guide = $guides->get_Item($index);
$orientation = java_values($guide->getOrientation());
$position = java_values($guide->getPosition());
$color = java_values($guide->getColor()->toString());
echo sprintf("Guide %d: orientation = %d, position = %.2f, color = %s", $index, $orientation, $position, $color) . PHP_EOL;
}
} 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 [MasterSlide::getDrawingGuides](https://reference.aspose.com/slides/php-java/aspose.slides/masterslide/#getDrawingGuides) for a master slide and [LayoutSlide::getDrawingGuides](https://reference.aspose.com/slides/php-java/aspose.slides/layoutslide/#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:
```php
use aspose\slides\Orientation;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slideSize = $presentation->getSlideSize()->getSize();
$slideWidth = java_values($slideSize->getWidth());
$slideHeight = java_values($slideSize->getHeight());
$masterGuides = $presentation->getMasters()->get_Item(0)->getDrawingGuides();
$layoutGuides = $presentation->getLayoutSlides()->get_Item(0)->getDrawingGuides();
$masterGuides->add(Orientation::Vertical, $slideWidth / 2 - 20);
$layoutGuides->add(Orientation::Horizontal, $slideHeight / 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 [MasterNotesSlide::getDrawingGuides](https://reference.aspose.com/slides/php-java/aspose.slides/masternotesslide/#getDrawingGuides) and [MasterHandoutSlide::getDrawingGuides](https://reference.aspose.com/slides/php-java/aspose.slides/masterhandoutslide/#getDrawingGuides) to access their collections. If a presentation does not contain one of these masters, retrieve the appropriate manager with [Presentation::getMasterNotesSlideManager](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getMasterNotesSlideManager) or [Presentation::getMasterHandoutSlideManager](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getMasterHandoutSlideManager), then create the default master with `setDefaultMasterNotesSlide` or `setDefaultMasterHandoutSlide`.
The following example adds a horizontal guide to a notes master and a vertical guide to a handout master:
```php
use aspose\slides\Orientation;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$notesSize = $presentation->getNotesSize()->getSize();
$notesWidth = java_values($notesSize->getWidth());
$notesHeight = java_values($notesSize->getHeight());
$notesMaster = $presentation->getMasterNotesSlideManager()->setDefaultMasterNotesSlide();
$handoutMaster = $presentation->getMasterHandoutSlideManager()->setDefaultMasterHandoutSlide();
$notesMaster->getDrawingGuides()->add(Orientation::Horizontal, $notesHeight / 2 + 50);
$handoutMaster->getDrawingGuides()->add(Orientation::Vertical, $notesWidth / 2 - 50);
$presentation->save("notes-handout-drawing-guides.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Clear Drawing Guides**
Call [DrawingGuidesCollection::clear](https://reference.aspose.com/slides/php-java/aspose.slides/drawingguidescollection/#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:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("presentation-with-guides.pptx");
try {
$presentation->getViewProperties()->getSlideViewProperties()->getDrawingGuides()->clear();
$masterCount = java_values($presentation->getMasters()->size());
for ($index = 0; $index < $masterCount; $index++) {
$presentation->getMasters()->get_Item($index)->getDrawingGuides()->clear();
}
$layoutCount = java_values($presentation->getLayoutSlides()->size());
for ($index = 0; $index < $layoutCount; $index++) {
$presentation->getLayoutSlides()->get_Item($index)->getDrawingGuides()->clear();
}
$notesMaster = $presentation->getMasterNotesSlideManager()->getMasterNotesSlide();
if (!java_is_null($notesMaster)) {
$notesMaster->getDrawingGuides()->clear();
}
$handoutMaster = $presentation->getMasterHandoutSlideManager()->getMasterHandoutSlide();
if (!java_is_null($handoutMaster)) {
$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 [DrawingGuidesCollection::clear](https://reference.aspose.com/slides/php-java/aspose.slides/drawingguidescollection/#clear) method removes only the guides in the selected collection. Shapes and other slide content remain unchanged.
# Edit PDF Documents in PHP
> Edit PDF documents in PHP by importing them into Aspose.Slides, replacing text, and saving the modified presentation back to PDF.
Source: https://docs.aspose.com/slides/php-java/edit-pdf/
Updated: 2026-09-21
## **Overview**
Aspose.Slides for PHP via 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 [SlideCollection::addFromPdf](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/#addFromPdf) to import the pages, [Presentation::replaceText](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#replaceText) to update the text, and [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#save) 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.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TextSearchOptions;
$presentation = new Presentation();
try {
$presentation->getSlides()->removeAt(0);
$presentation->getSlides()->addFromPdf("input.pdf");
$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/php-java/search-and-replace-text/) and [Convert PowerPoint to PDF](https://docs.aspose.com/slides/php-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/php-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 PHP
> Learn how to create, format, and manipulate ellipse shapes in Aspose.Slides for PHP via Java across PPT and PPTX presentations — code examples included.
Source: https://docs.aspose.com/slides/php-java/ellipse/
Updated: 2026-08-02
## **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/php-java/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/php-java/aspose.slides/shapecollection/#addAutoShape) method exposed by [ShapeCollection](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/) object.
- Write the modified presentation as a PPTX file.
In the example given below, we have added an ellipse to the first slide
```php
# Instantiate Presentation class that represents the PPTX
$pres = new Presentation();
try {
# Get the first slide
$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 (!java_is_null($pres)) {
$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/php-java/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/php-java/aspose.slides/shapecollection/#addAutoShape) method exposed by [ShapeCollection](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/) object.
- Set the Fill Type of the Ellipse to Solid.
- Set the Color of the Ellipse using `SolidFillColor::setColor` method as exposed by [FillFormat](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/) object associated with the [Shape](https://reference.aspose.com/slides/php-java/aspose.slides/shape/) 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.
```php
# Instantiate Presentation class that represents the PPTX
$pres = new Presentation();
try {
# Get the first slide
$sld = $pres->getSlides()->get_Item(0);
# Add AutoShape of ellipse type
$shp = $sld->getShapes()->addAutoShape(ShapeType::Ellipse, 50, 150, 150, 50);
# Apply some formatting to ellipse shape
$shp->getFillFormat()->setFillType(FillType::Solid);
$shp->getFillFormat()->getSolidFillColor()->setColor(new java("java.awt.Color", PresetColor->Chocolate));
# Apply some formatting to the line of Ellipse
$shp->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$shp->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$shp->getLineFormat()->setWidth(5);
# Write the PPTX file to disk
$pres->save("EllipseShp1.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$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/php-java/shape-animation/) entrance, emphasis, or exit effects to the shape, and configure triggers and timing to orchestrate when and how the animation plays.
## Related articles
- [Add Rectangles to Presentations in PHP](https://docs.aspose.com/slides/php-java/rectangle/)
- [Shape Types in Aspose.Slides for PHP via Java](https://docs.aspose.com/slides/php-java/shape-types/)
# Embed Fonts in Presentations Using PHP
> Manage embedded fonts in PowerPoint with Aspose.Slides for PHP via Java. Add, retrieve, remove, and compress fonts to preserve text appearance and reduce file size.
Source: https://docs.aspose.com/slides/php-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 PHP via Java lets you retrieve, add, and remove embedded fonts through the [FontsManager](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/) class returned by [Presentation::getFontsManager](https://reference.aspose.com/slides/php-java/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 [FontsManager::getEmbeddedFonts](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/#getEmbeddedFonts) to list the fonts stored in a presentation. To remove one, pass a font from that list to [FontsManager::removeEmbeddedFont](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/#removeEmbeddedFont), then save the presentation.
The following example lists the embedded fonts in `EmbeddedFonts.pptx` and removes Calibri if it is present:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("EmbeddedFonts.pptx");
try {
$fontsManager = $presentation->getFontsManager();
$embeddedFonts = $fontsManager->getEmbeddedFonts();
foreach ($embeddedFonts as $font) {
echo java_values($font->getFontName()) . PHP_EOL;
}
$fontToRemove = null;
foreach ($embeddedFonts as $font) {
$fontName = java_values($font->getFontName());
if (strcasecmp($fontName, "Calibri") === 0) {
$fontToRemove = $font;
break;
}
}
if ($fontToRemove !== null) {
$fontsManager->removeEmbeddedFont($fontToRemove);
$presentation->save("WithoutEmbeddedCalibri.pptx", SaveFormat::Pptx);
} else {
echo "Calibri is not embedded. No output file was created." . PHP_EOL;
}
} 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/php-java/font-substitution/), which can affect the layout.
## **Inspect Font Data and Embedding Permissions**
Use the [FontsManager](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/) class to inspect fonts before embedding them. Call [FontsManager::getFonts](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/#getFonts) to retrieve the fonts used in the presentation. For each font, pass a [FontData](https://reference.aspose.com/slides/php-java/aspose.slides/fontdata/) object and the required [FontStyleType](https://reference.aspose.com/slides/php-java/aspose.slides/fontstyletype/) value to [FontsManager::getFontBytes](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/#getFontBytes). 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 [FontsManager::getFontEmbeddingLevel](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/#getFontEmbeddingLevel), because that method requires a byte array.
[EmbeddingLevel](https://reference.aspose.com/slides/php-java/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 `FontsManager::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.
```php
use aspose\slides\EmbedFontCharacters;
use aspose\slides\EmbeddingLevel;
use aspose\slides\FontStyleType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
function getUsagePermission($level) {
$permissionMask = EmbeddingLevel::Restricted | EmbeddingLevel::PreviewPrint | EmbeddingLevel::Editable;
$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 = new Presentation("Fonts.pptx");
try {
$fontsManager = $presentation->getFontsManager();
$fontStyles = [
FontStyleType::Regular,
FontStyleType::Bold,
FontStyleType::Italic,
FontStyleType::Bold | FontStyleType::Italic
];
$embeddedFontNames = [];
foreach ($fontsManager->getEmbeddedFonts() as $embeddedFont) {
$fontName = java_values($embeddedFont->getFontName());
$embeddedFontNames[strtolower($fontName)] = true;
}
$fontsToEmbed = [];
$embeddingRules = [];
foreach ($fontsManager->getFonts() as $font) {
$fontName = java_values($font->getFontName());
if (isset($embeddedFontNames[strtolower($fontName)])) {
echo $fontName . ": already embedded." . PHP_EOL;
continue;
}
$hasAvailableData = false;
$allAvailableStylesCanBeEmbedded = true;
$previewPrintOnly = false;
$requiresFullFont = false;
foreach ($fontStyles as $fontStyle) {
$fontBytes = $fontsManager->getFontBytes($font, $fontStyle);
if (java_is_null($fontBytes)) {
echo $fontName . " (" . $fontStyle . "): font data is unavailable." . PHP_EOL;
continue;
}
$hasAvailableData = true;
$embeddingLevel = java_values($fontsManager->getFontEmbeddingLevel($fontBytes, $fontName));
$usagePermission = getUsagePermission($embeddingLevel);
$noSubsetting = ($embeddingLevel & EmbeddingLevel::NoSubsetting) !== 0;
$bitmapOnly = ($embeddingLevel & EmbeddingLevel::BitmapOnly) !== 0;
$requiresFullFont = $requiresFullFont || $noSubsetting;
$previewPrintOnly = $previewPrintOnly || $usagePermission === EmbeddingLevel::PreviewPrint;
$allAvailableStylesCanBeEmbedded = $allAvailableStylesCanBeEmbedded && $usagePermission !== EmbeddingLevel::Restricted && !$bitmapOnly;
echo $fontName . " (" . $fontStyle . "): " . $embeddingLevel . "." . PHP_EOL;
}
if (!$hasAvailableData) {
echo $fontName . ": skipped because no requested style is available." . PHP_EOL;
} elseif (!$allAvailableStylesCanBeEmbedded) {
echo $fontName . ": skipped because at least one available style does not permit outline embedding." . PHP_EOL;
} elseif ($previewPrintOnly) {
echo $fontName . ": skipped because this example produces an editable presentation." . PHP_EOL;
} else {
$rule = $requiresFullFont ? EmbedFontCharacters::All : EmbedFontCharacters::OnlyUsed;
$fontsToEmbed[] = $font;
$embeddingRules[] = $rule;
}
}
for ($i = 0; $i < count($fontsToEmbed); $i++) {
$fontsManager->addEmbeddedFont($fontsToEmbed[$i], $embeddingRules[$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 [FontsManager::addEmbeddedFont](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/#addEmbeddedFont) to embed a font. Its overloads accept either a [FontData](https://reference.aspose.com/slides/php-java/aspose.slides/fontdata/) object or a byte array containing the font data. The [EmbedFontCharacters](https://reference.aspose.com/slides/php-java/aspose.slides/embedfontcharacters/) enumeration controls which characters are included:
- [All](https://reference.aspose.com/slides/php-java/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/php-java/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 [FontsManager::getFonts](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/#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.
```php
use aspose\slides\EmbedFontCharacters;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("Fonts.pptx");
try {
$fontsManager = $presentation->getFontsManager();
$allFonts = $fontsManager->getFonts();
$embeddedFonts = $fontsManager->getEmbeddedFonts();
$embeddedFontNames = [];
foreach ($embeddedFonts as $embeddedFont) {
$fontName = java_values($embeddedFont->getFontName());
$embeddedFontNames[strtolower($fontName)] = true;
}
foreach ($allFonts as $font) {
$fontName = java_values($font->getFontName());
$normalizedFontName = strtolower($fontName);
if (!isset($embeddedFontNames[$normalizedFontName])) {
$fontsManager->addEmbeddedFont($font, EmbedFontCharacters::All);
$embeddedFontNames[$normalizedFontName] = true;
}
}
$presentation->save("WithEmbeddedFonts.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Compress Embedded Fonts**
[Compress::compressEmbeddedFonts](https://reference.aspose.com/slides/php-java/aspose.slides/compress/#compressEmbeddedFonts) 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:
```php
use aspose\slides\Compress;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$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 [FontsManager::getSubstitutions](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/#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/php-java/font-substitution/) settings and [font fallback](https://docs.aspose.com/slides/php-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 PHP
> Learn how to add and customize error bars in charts with Aspose.Slides for PHP via Java — optimize data visuals in PowerPoint presentations.
Source: https://docs.aspose.com/slides/php-java/error-bar/
Updated: 2026-08-02
## **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 PHP via 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 [**data points**](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriescollection/) collection of series:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/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.
```php
# Create an instance of Presentation class
$pres = new Presentation();
try {
# Creating a bubble chart
$chart = $pres->getSlides()->get_Item(0)->getShapes()->addChart(ChartType::Bubble, 50, 50, 400, 300, true);
# Adding Error bars and setting its format
$errBarX = $chart->getChartData()->getSeries()->get_Item(0)->getErrorBarsXFormat();
$errBarY = $chart->getChartData()->getSeries()->get_Item(0)->getErrorBarsYFormat();
$errBarX->isVisible();
$errBarY->isVisible();
$errBarX->setValueType(ErrorBarValueType::Fixed);
$errBarX->setValue(0.1);
$errBarY->setValueType(ErrorBarValueType::Percentage);
$errBarY->setValue(5);
$errBarX->setType(ErrorBarType::Plus);
$errBarY->getFormat()->getLine()->setWidth(2.0);
$errBarX->hasEndCap();
# Saving presentation
$pres->save("ErrorBars.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Add Custom Error Bar Values**
Aspose.Slides for PHP via Java provides a simple API for managing custom error bar values. The sample code applies when the [**ErrorBarsFormat::getValueType**](https://reference.aspose.com/slides/php-java/aspose.slides/errorbarsformat/#getValueType) method returns **Custom**. To specify a value, use the **ErrorBarCustomValues** property of a specific data point in the [**data points**](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriescollection/) collection of series:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/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.
```php
# Create an instance of Presentation class
$pres = new Presentation();
try {
# Creating a bubble chart
$chart = $pres->getSlides()->get_Item(0)->getShapes()->addChart(ChartType::Bubble, 50, 50, 400, 300, true);
# Adding custom Error bars and setting its format
$series = $chart->getChartData()->getSeries()->get_Item(0);
$errBarX = $series->getErrorBarsXFormat();
$errBarY = $series->getErrorBarsYFormat();
$errBarX->isVisible();
$errBarY->isVisible();
$errBarX->setValueType(ErrorBarValueType::Custom);
$errBarY->setValueType(ErrorBarValueType::Custom);
# Accessing chart series data point and setting error bars values for
# individual point
$points = $series->getDataPoints();
$points->getDataSourceTypeForErrorBarsCustomValues()->setDataSourceTypeForXPlusValues(DataSourceType::DoubleLiterals);
$points->getDataSourceTypeForErrorBarsCustomValues()->setDataSourceTypeForXMinusValues(DataSourceType::DoubleLiterals);
$points->getDataSourceTypeForErrorBarsCustomValues()->setDataSourceTypeForYPlusValues(DataSourceType::DoubleLiterals);
$points->getDataSourceTypeForErrorBarsCustomValues()->setDataSourceTypeForYMinusValues(DataSourceType::DoubleLiterals);
# Setting error bars for chart series points
for($i = 0; $i < java_values($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 (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **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/php-java/aspose.slides/errorbarsformat/) class and the related classes [ErrorBarType](https://reference.aspose.com/slides/php-java/aspose.slides/errorbartype/) and [ErrorBarValueType](https://reference.aspose.com/slides/php-java/aspose.slides/errorbarvaluetype/).
## Related articles
- [Customize Presentation Chart Entities in PHP](https://docs.aspose.com/slides/php-java/chart-entities/)
# Evaluate Aspose.Slides
> Evaluate Aspose.Slides for PHP via Java and explore API features for PowerPoint (PPT, PPTX) and OpenDocument (ODP) presentations—start your free trial.
Source: https://docs.aspose.com/slides/php-java/evaluate-aspose-slides/
Updated: 2026-09-27
## **Aspose.Slides Evaluation**
You can download Aspose.Slides for evaluation. The evaluation package is the same as the purchased package; it becomes licensed after you add a few lines of code to apply the license. See [Installation](https://docs.aspose.com/slides/php-java/installation/) to set it up and [Licensing](https://docs.aspose.com/slides/php-java/licensing/) to apply a license.
Without a license, Aspose.Slides provides its full functionality in evaluation mode, with two limitations: it adds an evaluation watermark text box to the middle of every slide of each presentation it saves, and text that your code reads from a presentation is truncated to its first few characters, followed by a notice about the evaluation limitation. Text that your code writes is saved in full.
If you want to test Aspose.Slides without evaluation version limitations, you can request a **30 Day Temporary License**. Please refer to [How to get a Temporary License?](https://purchase.aspose.com/temporary-license) for more information.
## **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/php-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/php-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/php-java/licensing/)
# Retrieve and Update Presentation Information in PHP
> Explore slides, structure and metadata in PowerPoint and OpenDocument presentations using Aspose.Slides for PHP for faster insights and smarter content audits.
Source: https://docs.aspose.com/slides/php-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/php-java/aspose.slides/presentationfactory/) and [PresentationInfo](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/), as well as targeted updates through [DocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/).
## **Check a Presentation Format**
If you already have a loaded presentation, see [Determine the Original Presentation Format](https://docs.aspose.com/slides/php-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/php-java/aspose.slides/presentationfactory/) to inspect a file without creating a [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) instance. The [PresentationInfo::getLoadFormat](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/#getLoadFormat) method reports the detected format, such as PPTX, PPT, or ODP.
```php
use aspose\slides\LoadFormat;
use aspose\slides\PresentationFactory;
$fileNames = ["pres.pptx", "pres.ppt", "pres.odp"];
foreach ($fileNames as $fileName) {
$presentationInfo = PresentationFactory::getInstance()->getPresentationInfo($fileName);
$loadFormat = java_values($presentationInfo->getLoadFormat());
$formatName = "Other (" . $loadFormat . ")";
if ($loadFormat === LoadFormat::Pptx) {
$formatName = "PPTX";
} elseif ($loadFormat === LoadFormat::Ppt) {
$formatName = "PPT";
} elseif ($loadFormat === LoadFormat::Odp) {
$formatName = "ODP";
}
echo $fileName . ": " . $formatName . PHP_EOL;
}
```
## **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/php-java/aspose.slides/presentationfactory/) to obtain a [PresentationInfo](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/) object, and then call [PresentationInfo::readDocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/#readDocumentProperties) to read the document metadata. This approach does not create a [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) instance or require you to traverse the complete presentation object model.
The extended properties exposed by [DocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/) provide the following inventory values:
| Method | Inventory value |
| --- | --- |
| [getSlides](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/#getSlides) | Total number of slides. |
| [getHiddenSlides](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/#getHiddenSlides) | Number of hidden slides. |
| [getNotes](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/#getNotes) | Number of slides that contain notes. |
| [getParagraphs](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/#getParagraphs) | Total number of paragraphs, when available. |
| [getWords](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/#getWords) | Total number of words. |
| [getMultimediaClips](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/#getMultimediaClips) | Total number of audio and video clips. |
The following example reads these values without creating a [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) object and prints a compact inventory. It also combines [DocumentProperties::getHeadingPairs](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/#getHeadingPairs) with [DocumentProperties::getTitlesOfParts](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/#getTitlesOfParts) to display content groups such as fonts, themes, and slide titles.
```php
use aspose\slides\LoadFormat;
use aspose\slides\PresentationFactory;
$filePath = "sample.pptx";
$presentationInfo = PresentationFactory::getInstance()->getPresentationInfo($filePath);
$documentProperties = $presentationInfo->readDocumentProperties();
$loadFormat = java_values($presentationInfo->getLoadFormat());
$formatName = "Other (" . $loadFormat . ")";
if ($loadFormat === LoadFormat::Pptx) {
$formatName = "PPTX";
} elseif ($loadFormat === LoadFormat::Ppt) {
$formatName = "PPT";
} elseif ($loadFormat === LoadFormat::Odp) {
$formatName = "ODP";
}
echo "File: " . basename($filePath) . PHP_EOL;
echo "Format: " . $formatName . PHP_EOL;
echo "Title: " . java_values($documentProperties->getTitle()) . PHP_EOL;
echo "Author: " . java_values($documentProperties->getAuthor()) . PHP_EOL;
echo "Statistics:" . PHP_EOL;
echo " Slides: " . java_values($documentProperties->getSlides()) . PHP_EOL;
echo " Hidden slides: " . java_values($documentProperties->getHiddenSlides()) . PHP_EOL;
echo " Slides with notes: " . java_values($documentProperties->getNotes()) . PHP_EOL;
echo " Paragraphs: " . java_values($documentProperties->getParagraphs()) . PHP_EOL;
echo " Words: " . java_values($documentProperties->getWords()) . PHP_EOL;
echo " Multimedia clips: " . java_values($documentProperties->getMultimediaClips()) . PHP_EOL;
$headingPairs = $documentProperties->getHeadingPairs();
$titlesOfParts = $documentProperties->getTitlesOfParts();
if (java_is_null($headingPairs) || java_is_null($titlesOfParts)) {
echo "Content groups: not available" . PHP_EOL;
} else {
$headingPairs = java_values($headingPairs);
$titlesOfParts = java_values($titlesOfParts);
$partIndex = 0;
if (count($headingPairs) === 0 || count($titlesOfParts) === 0) {
echo "Content groups: not available" . PHP_EOL;
} else {
echo "Content groups:" . PHP_EOL;
foreach ($headingPairs as $headingPair) {
$partCount = java_values($headingPair->getCount());
echo " " . java_values($headingPair->getName()) . " (" . $partCount . ")" . PHP_EOL;
for ($partOffset = 0; $partOffset < $partCount && $partIndex < count($titlesOfParts); $partOffset++) {
echo " - " . $titlesOfParts[$partIndex] . PHP_EOL;
$partIndex++;
}
}
if ($partIndex < count($titlesOfParts)) {
echo " Other parts:" . PHP_EOL;
while ($partIndex < count($titlesOfParts)) {
echo " - " . $titlesOfParts[$partIndex] . PHP_EOL;
$partIndex++;
}
}
}
}
```
Each [HeadingPair](https://reference.aspose.com/slides/php-java/aspose.slides/headingpair/) supplies a group name and the number of items in that group. [DocumentProperties::getTitlesOfParts](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/#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 [PresentationInfo::readDocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/#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 [PresentationInfo::readDocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/#readDocumentProperties) can also be changed without creating a [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) instance. Apply the changes with [PresentationInfo::updateDocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/#updateDocumentProperties), and then write the bound presentation with [PresentationInfo::writeBindedPresentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/#writeBindedPresentation).
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:
```php
use aspose\slides\PresentationFactory;
$sourceFile = "sample.pptx";
$outputFile = "sample_with_updated_properties.pptx";
$presentationInfo = PresentationFactory::getInstance()->getPresentationInfo($sourceFile);
$documentProperties = $presentationInfo->readDocumentProperties();
$documentProperties->setTitle("Quarterly sales report");
$documentProperties->setLastSavedTime(new Java("java.util.Date"));
$presentationInfo->updateDocumentProperties($documentProperties);
$outputStream = new Java("java.io.FileOutputStream", $outputFile);
try {
$presentationInfo->writeBindedPresentation($outputStream);
} finally {
$outputStream->close();
}
```
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/php-java/password-protected-presentation/)
- [Write-Protect Presentations](https://docs.aspose.com/slides/php-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/php-java/aspose.slides/presentation/#getFontsManager). Call [FontsManager::getEmbeddedFonts](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/#getEmbeddedFonts) to obtain the embedded fonts and [FontsManager::getFonts](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/#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 [DocumentProperties::getHiddenSlides](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/#getHiddenSlides) through [PresentationFactory::getPresentationInfo](https://reference.aspose.com/slides/php-java/aspose.slides/presentationfactory/) and [PresentationInfo::readDocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/#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/php-java/aspose.slides/presentation/#getSlides) and inspect each slide's [Slide::getHidden](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#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/php-java/aspose.slides/presentation/#getSlideSize). Use [SlideSize::getType](https://reference.aspose.com/slides/php-java/aspose.slides/slidesize/#getType), [SlideSize::getSize](https://reference.aspose.com/slides/php-java/aspose.slides/slidesize/#getSize), and [SlideSize::getOrientation](https://reference.aspose.com/slides/php-java/aspose.slides/slidesize/#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/php-java/aspose.slides/chart/) and call [ChartData::getDataSourceType](https://reference.aspose.com/slides/php-java/aspose.slides/chartdata/#getDataSourceType). For an external workbook, call [ChartData::getExternalWorkbookPath](https://reference.aspose.com/slides/php-java/aspose.slides/chartdata/#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/php-java/aspose.slides/presentation/#getSlides) and each slide's [BaseSlide::getShapes](https://reference.aspose.com/slides/php-java/aspose.slides/baseslide/#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
> Browse PHP Aspose.Slides examples for managing slides, shapes, media, charts, text, and more, and learn practical patterns for PowerPoint and OpenDocument.
Source: https://docs.aspose.com/slides/php-java/examples/
Updated: 2026-02-20
---
lastmod: 2026-02-20T10:01:26+06:00
title: Examples
type: docs
weight: 40
url: /php-java/examples/
keywords:
- example
- elements
- PowerPoint
- OpenDocument
- presentation
- PHP
- Aspose.Slides
description: "Browse PHP Aspose.Slides examples for managing slides, shapes, media, charts, text, and more, and learn practical patterns for PowerPoint and OpenDocument."
---
## Related articles
- [Elements](https://docs.aspose.com/slides/php-java/examples/elements/)
# Elements
> Explore PHP examples for every slide element with Aspose.Slides—shapes, text, images, media, charts, animation, and more—covering PowerPoint and OpenDocument.
Source: https://docs.aspose.com/slides/php-java/examples/elements/
Updated: 2026-02-20
---
lastmod: 2026-02-20T10:01:26+06:00
title: Elements
type: docs
weight: 40
url: /php-java/examples/elements/
keywords:
- examples
- elements
- PowerPoint
- OpenDocument
- presentation
- PHP
- Aspose.Slides
description: "Explore PHP examples for every slide element with Aspose.Slides—shapes, text, images, media, charts, animation, and more—covering PowerPoint and OpenDocument."
---
## Related articles
- [Examples](https://docs.aspose.com/slides/php-java/examples/)
- [Customize Presentation Charts in PHP](https://docs.aspose.com/slides/php-java/chart-types/)
# ActiveX
> Learn how to find, edit, and remove ActiveX controls in PHP with Aspose.Slides, including property updates for PowerPoint presentations.
Source: https://docs.aspose.com/slides/php-java/examples/elements/activex/
Updated: 2026-02-20
Demonstrates how to add, access, remove, and configure ActiveX controls in a presentation using **Aspose.Slides for PHP via Java**.
## **Add an ActiveX Control**
Insert a new ActiveX control.
```php
function addActiveX() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
// Add a new ActiveX control.
$control = $slide->getControls()->addControl(ControlType::WindowsMediaPlayer, 50, 50, 100, 50);
$presentation->save("activex.pptm", SaveFormat::Pptm);
} finally {
// Dispose the presentation.
$presentation->dispose();
}
}
```
## **Access an ActiveX Control**
Read information from the first ActiveX control on the slide.
```php
function accessActiveX() {
$presentation = new Presentation("activex.pptm");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Access the first ActiveX control.
$control = $slide->getControls()->get_Item(0);
echo "Control Name: " . $control->getName() . PHP_EOL;
} finally {
// Dispose the presentation.
$presentation->dispose();
}
}
```
## **Remove an ActiveX Control**
Delete an existing ActiveX control from the slide.
```php
function removeActiveX() {
$presentation = new Presentation("activex.pptm");
try {
$slide = $presentation->getSlides()->get_Item(0);
if (java_values($slide->getControls()->size()) > 0) {
// Remove the first ActiveX control.
$slide->getControls()->removeAt(0);
}
$presentation->save("activex_removed.pptm", SaveFormat::Pptm);
} finally {
// Dispose the presentation.
$presentation->dispose();
}
}
```
## **Set ActiveX Properties**
Configure several ActiveX properties.
```php
function setActiveXProperties() {
$presentation = new Presentation("activex.pptm");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first control is the one we added.
$control = $slide->getControls()->get_Item(0);
// Configure properties.
$control->getProperties()->set_Item("Caption", "Click Me");
$control->getProperties()->set_Item("Enabled", "true");
$presentation->save("activex_properties.pptm", SaveFormat::Pptm);
} finally {
// Dispose the presentation.
$presentation->dispose();
}
}
```
## Related articles
- [Manage PowerPoint Shapes in PHP](https://docs.aspose.com/slides/php-java/powerpoint-shapes/)
- [Manage ActiveX Controls in Presentations Using PHP](https://docs.aspose.com/slides/php-java/activex/)
# Animation
> Master slide animations in PHP with Aspose.Slides: add, edit, and remove effects, timings, and triggers to create dynamic presentations in PPT, PPTX and ODP.
Source: https://docs.aspose.com/slides/php-java/examples/elements/animation/
Updated: 2026-02-20
Shows how to create simple animations and manage their sequence using **Aspose.Slides for PHP via Java**.
## **Add an Animation**
Create a rectangle shape and apply a fade-in effect triggered on click.
```php
function addAnimation() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 100, 100);
// Fade in effect.
$slide->getTimeline()->getMainSequence()->addEffect($shape, EffectType::Fade, EffectSubtype::None, EffectTriggerType::OnClick);
$presentation->save("animation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Access an Animation**
Retrieve the first animation effect from the slide timeline.
```php
function accessAnimation() {
$presentation = new Presentation("animation.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Access the first animation effect.
$effect = $slide->getTimeline()->getMainSequence()->get_Item(0);
} finally {
$presentation->dispose();
}
}
```
## **Remove an Animation**
Remove an animation effect from the sequence.
```php
function removeAnimation() {
$presentation = new Presentation("animation.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$effect = $slide->getTimeline()->getMainSequence()->get_Item(0);
// Remove the effect.
$slide->getTimeline()->getMainSequence()->remove($effect);
$presentation->save("animation_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Sequence Animations**
Add multiple effects and demonstrate the order in which animations occur.
```php
function sequenceAnimations() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape1 = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 100, 100);
$shape2 = $slide->getShapes()->addAutoShape(ShapeType::Ellipse, 200, 50, 100, 100);
$sequence = $slide->getTimeline()->getMainSequence();
$sequence->addEffect($shape1, EffectType::Fly, EffectSubtype::Bottom, EffectTriggerType::OnClick);
$sequence->addEffect($shape2, EffectType::Fly, EffectSubtype::Bottom, EffectTriggerType::OnClick);
$presentation->save("animation_sequence.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## Related articles
- [Animate PowerPoint Text in PHP](https://docs.aspose.com/slides/php-java/animated-text/)
- [Manage PowerPoint Shapes in PHP](https://docs.aspose.com/slides/php-java/powerpoint-shapes/)
- [Animate PowerPoint Charts in PHP](https://docs.aspose.com/slides/php-java/animated-charts/)
# Audio
> Work with audio in PHP using Aspose.Slides: add, replace, extract, and trim sounds, set volume and playback for slides and shapes in PowerPoint and OpenDocument.
Source: https://docs.aspose.com/slides/php-java/examples/elements/audio/
Updated: 2026-02-20
Illustrates how to embed audio frames and control playback with **Aspose.Slides for PHP via Java**. The following examples show basic audio operations.
## **Add an Audio Frame**
Insert an audio frame.
```php
function addAudio() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
// Create an audio frame.
$audioStream = new Java("java.io.FileInputStream", new Java("java.io.File", "audio.wav"));
$audioFrame = $slide->getShapes()->addAudioFrameEmbedded(50, 50, 100, 100, $audioStream);
$presentation->save("audio.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Access an Audio Frame**
This code retrieves the first audio frame on a slide.
```php
function accessAudio() {
$presentation = new Presentation("audio.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Access the first audio frame on the slide.
$firstAudioFrame = null;
$shapeCount = java_values($slide->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $slide->getShapes()->get_Item($index);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.AudioFrame"))) {
$firstAudioFrame = $shape;
break;
}
}
} finally {
$presentation->dispose();
}
}
```
## **Remove an Audio Frame**
Delete a previously added audio frame.
```php
function removeAudio() {
$presentation = new Presentation("audio.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first shape on the slide is an audio frame.
$audioFrame = $slide->getShapes()->get_Item(0);
// Remove the audio frame.
$slide->getShapes()->remove($audioFrame);
$presentation->save("audio_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Set Audio Playback**
Configure the audio frame to play automatically when the slide appears.
```php
function setAudioPlayback() {
$presentation = new Presentation("audio.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first shape on the slide is an audio frame.
$audioFrame = $slide->getShapes()->get_Item(0);
// Play automatically when the slide appears.
$audioFrame->setPlayMode(AudioPlayModePreset::Auto);
$presentation->save("audio_playback.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## Related articles
- [Video](https://docs.aspose.com/slides/php-java/examples/elements/video/)
- [Manage Audio in Presentations Using PHP](https://docs.aspose.com/slides/php-java/audio-frame/)
- [Manage Media Files in PHP](https://docs.aspose.com/slides/php-java/manage-media-files/)
# Chart
> Create and customize charts in PHP with Aspose.Slides: add data, format series, axes and labels, change types, and export—works with PPT, PPTX and ODP.
Source: https://docs.aspose.com/slides/php-java/examples/elements/chart/
Updated: 2026-02-20
Examples for adding, accessing, removing, and updating different chart types with **Aspose.Slides for PHP via Java**. The snippets below demonstrate basic chart operations.
## **Add a Chart**
This method adds a simple area chart to the first slide.
```php
function addChart() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
// Add a simple column chart to the slide.
$chart = $slide->getShapes()->addChart(ChartType::Area, 50, 50, 400, 300);
$presentation->save("chart.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Access a Chart**
Retrieve the chart from the shape collection.
```php
function accessChart() {
$presentation = new Presentation("chart.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Access the first chart on the slide.
$firstChart = null;
$shapeCount = java_values($slide->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $slide->getShapes()->get_Item($index);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.Chart"))) {
$firstChart = $shape;
break;
}
}
} finally {
$presentation->dispose();
}
}
```
## **Remove a Chart**
The following code removes a chart from a slide.
```php
function removeChart() {
$presentation = new Presentation("chart.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first shape on the slide is the chart.
$chart = $slide->getShapes()->get_Item(0);
// Remove the chart.
$slide->getShapes()->remove($chart);
$presentation->save("chart_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Update Chart Data**
You can change chart properties such as the title.
```php
function updateChartData() {
$presentation = new Presentation("chart.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first shape on the slide is the chart.
$chart = $slide->getShapes()->get_Item(0);
// Change the chart title.
$chart->getChartTitle()->addTextFrameForOverriding("Sales Report");
$presentation->save("chart_updated.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## Related articles
- [Create and Customize PowerPoint Charts in PHP](https://docs.aspose.com/slides/php-java/powerpoint-charts/)
- [OleObject](https://docs.aspose.com/slides/php-java/examples/elements/ole-object/)
- [Customize Presentation Chart Entities in PHP](https://docs.aspose.com/slides/php-java/chart-entities/)
# Comment
> Manage slide comments in PHP with Aspose.Slides: add, read, reply, edit, delete, and work with threaded comments for PowerPoint and OpenDocument.
Source: https://docs.aspose.com/slides/php-java/examples/elements/comment/
Updated: 2026-02-20
Demonstrates adding, reading, removing, and replying to modern comments using **Aspose.Slides for PHP via Java**.
## **Add a Modern Comment**
Create a comment authored by a user and save the presentation.
```php
function addModernComment() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
// Add a modern comment.
$author = $presentation->getCommentAuthors()->addAuthor("User", "U1");
$author->getComments()->addModernComment("This is a modern comment", $slide, null, new Point2DFloat(100, 100), new Java("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.
```php
function accessModernComment() {
$presentation = new Presentation("modern_comment.pptx");
try {
$author = $presentation->getCommentAuthors()->get_Item(0);
$comment = $author->getComments()->get_Item(0);
echo "Author: " . $author->getName() . ", Comment: " . $comment->getText() . PHP_EOL;
} finally {
$presentation->dispose();
}
}
```
## **Remove a Modern Comment**
Remove a comment and save the updated file.
```php
function removeModernComment() {
$presentation = new Presentation("modern_comment.pptx");
try {
$author = $presentation->getCommentAuthors()->get_Item(0);
$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.
```php
function replyToModernComment() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
// Add a comment author.
$author = $presentation->getCommentAuthors()->addAuthor("User", "U1");
// Add a parent comment and replies.
$parent = $author->getComments()->addModernComment("Parent comment", $slide, null, new Point2DFloat(100, 100), new Java("java.util.Date"));
$reply1 = $author->getComments()->addModernComment("Reply 1", $slide, null, new Point2DFloat(110, 100), new Java("java.util.Date"));
$reply2 = $author->getComments()->addModernComment("Reply 2", $slide, null, new Point2DFloat(120, 100), new Java("java.util.Date"));
// Set the parent comment for replies.
$reply1->setParentComment($parent);
$reply2->setParentComment($parent);
// Save the presentation with replies.
$presentation->save("modern_comment_replies.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## Related articles
- [Manage Presentation Comments in PHP](https://docs.aspose.com/slides/php-java/presentation-comments/)
# Connector
> Draw and control connectors in PHP with Aspose.Slides: add, route, reroute, set connection points, arrows and styles to link shapes in PPT, PPTX and ODP.
Source: https://docs.aspose.com/slides/php-java/examples/elements/connector/
Updated: 2026-02-20
Shows how to connect shapes with connectors and change their targets using **Aspose.Slides for PHP via Java**.
## **Add a Connector**
Insert a connector shape between two points on the slide.
```php
function addConnector() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$connector = $slide->Shapes->addConnector(ShapeType::BentConnector2, 0, 0, 100, 100);
$presentation->save("connector.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Access a Connector**
Retrieve the first connector shape added to a slide.
```php
function accessConnector() {
$presentation = new Presentation("connector.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Access the first connector on the slide.
$firstConnector = null;
$shapeCount = java_values($slide->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $slide->getShapes()->get_Item($index);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.Connector"))) {
$firstConnector = $shape;
break;
}
}
} finally {
$presentation->dispose();
}
}
```
## **Remove a Connector**
Delete a connector from the slide.
```php
function removeConnector() {
$presentation = new Presentation("connector.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first shape on the slide is a connector.
$connector = $slide->getShapes()->get_Item(0);
$slide->getShapes()->remove($connector);
$presentation->save("connector_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Reconnect Shapes**
Attach a connector to two shapes by assigning start and end targets.
```php
function reconnectShapes() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape1 = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 0, 0, 50, 50);
$shape2 = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 50, 50);
$connector = $slide->getShapes()->addConnector(ShapeType::BentConnector2, 0, 0, 100, 100);
$connector->setStartShapeConnectedTo($shape1);
$connector->setEndShapeConnectedTo($shape2);
$presentation->save("shapes_reconnected.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## Related articles
- [Shape Types in Aspose.Slides for PHP via Java](https://docs.aspose.com/slides/php-java/shape-types/)
- [Manage Connectors in Presentations Using PHP](https://docs.aspose.com/slides/php-java/connector/)
# GroupShape
> Work with group shapes in PHP using Aspose.Slides: create and ungroup, reorder child shapes, set transforms and bounds across PowerPoint and OpenDocument.
Source: https://docs.aspose.com/slides/php-java/examples/elements/group-shape/
Updated: 2026-02-20
Examples for creating groups of shapes, accessing them, ungrouping, and removal using **Aspose.Slides for PHP via Java**.
## **Add a Group Shape**
Create a group containing two basic shapes.
```php
function addGroupShape() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$group = $slide->getShapes()->addGroupShape();
$group->getShapes()->addAutoShape(ShapeType::Rectangle, 0, 0, 50, 50);
$group->getShapes()->addAutoShape(ShapeType::Ellipse, 60, 0, 50, 50);
$presentation->save("group_shape.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Access a Group Shape**
Retrieve the first group shape from a slide.
```php
function accessGroupShape() {
$presentation = new Presentation("group_shape.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Access the first group shape on the slide.
$firstGroup = null;
$shapeCount = java_values($slide->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $slide->getShapes()->get_Item($index);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.GroupShape"))) {
$firstGroup = $shape;
break;
}
}
} finally {
$presentation->dispose();
}
}
```
## **Remove a Group Shape**
Delete a group shape from the slide.
```php
function removeGroupShape() {
$presentation = new Presentation("group_shape.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first shape on the slide is a group shape.
$group = $slide->getShapes()->get_Item(0);
$slide->getShapes()->remove($group);
$presentation->save("group_shape_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Ungroup Shapes**
Move shapes out of a group container.
```php
function ungroupShapes() {
$presentation = new Presentation("group_shape.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first shape on the slide is a group shape.
$group = $slide->getShapes()->get_Item(0);
// Clone each shape from the group and add it to the slide.
$shapeCount = java_values($group->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $group->getShapes()->get_Item($index);
$slide->getShapes()->addClone($shape);
}
$slide->getShapes()->remove($group);
$presentation->save("ungrouped_shapes.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## Related articles
- [Group Presentation Shapes in PHP](https://docs.aspose.com/slides/php-java/group/)
# HeaderFooter
> Control headers and footers in PHP with Aspose.Slides: add or edit date/time, slide numbers, and footer text, show or hide placeholders across PPT, PPTX and ODP.
Source: https://docs.aspose.com/slides/php-java/examples/elements/header-footer/
Updated: 2026-02-20
Shows how to add footers and update date and time placeholders using **Aspose.Slides for PHP via Java**.
## **Add a Footer**
Add text to the footer area of a slide and make it visible.
```php
function addHeaderFooter() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$slide->getHeaderFooterManager()->setFooterText("My footer");
$slide->getHeaderFooterManager()->setFooterVisibility(true);
$presentation->save("footer.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Update Date and Time**
Modify the date and time placeholder on a slide.
```php
function updateDateTime() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$slide->getHeaderFooterManager()->setDateTimeText("01/01/2024");
$slide->getHeaderFooterManager()->setDateTimeVisibility(true);
$presentation->save("datetime.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## Related articles
- [Manage Presentation Headers and Footers in PHP](https://docs.aspose.com/slides/php-java/presentation-header-and-footer/)
- [Manage Presentation Placeholders in PHP](https://docs.aspose.com/slides/php-java/manage-placeholder/)
# Hyperlink
> Add, edit, and remove hyperlinks in PHP with Aspose.Slides: link text, shapes, slides, URLs and email; set targets and actions for PPT, PPTX and ODP.
Source: https://docs.aspose.com/slides/php-java/examples/elements/hyperlink/
Updated: 2026-02-20
Demonstrates adding, accessing, removing, and updating hyperlinks on shapes using **Aspose.Slides for PHP via Java**.
## **Add a Hyperlink**
Create a rectangle shape with a hyperlink pointing to an external website.
```php
function addHyperlink() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 150, 50);
$shape->getTextFrame()->setText("Aspose");
$paragraph = $shape->getTextFrame()->getParagraphs()->get_Item(0);
$portion = $paragraph->getPortions()->get_Item(0);
$portion->getPortionFormat()->setHyperlinkClick(new Hyperlink("https://www.aspose.com"));
$presentation->save("hyperlink.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Access a Hyperlink**
Read hyperlink information from a shape's text portion.
```php
function accessHyperlink() {
$presentation = new Presentation("hyperlink.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first shape contains the hyperlink.
$shape = $slide->getShapes()->get_Item(0);
$paragraph = $shape->getTextFrame()->getParagraphs()->get_Item(0);
$portion = $paragraph->getPortions()->get_Item(0);
$hyperlink = $portion->getPortionFormat()->getHyperlinkClick();
} finally {
$presentation->dispose();
}
}
```
## **Remove a Hyperlink**
Clear the hyperlink from a shape's text.
```php
function removeHyperlink() {
$presentation = new Presentation("hyperlink.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first shape contains the hyperlink.
$shape = $slide->getShapes()->get_Item(0);
$paragraph = $shape->getTextFrame()->getParagraphs()->get_Item(0);
$portion = $paragraph->getPortions()->get_Item(0);
$portion->getPortionFormat()->setHyperlinkClick(null);
$presentation->save("hyperlink_removed.pptx", SaveFormat::Pptx);
} 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.
```php
function updateHyperlink() {
$presentation = new Presentation("hyperlink.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first shape contains the hyperlink.
$shape = $slide->getShapes()->get_Item(0);
$paragraph = $shape->getTextFrame()->getParagraphs()->get_Item(0);
$portion = $paragraph->getPortions()->get_Item(0);
// Changing a hyperlink inside existing text should be done via
// HyperlinkManager rather than setting the property directly.
// This mimics how PowerPoint safely updates hyperlinks.
$portion->getPortionFormat()->getHyperlinkManager()->setExternalHyperlinkClick("https://new.example.com");
$presentation->save("hyperlink_updated.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## Related articles
- [Manage Presentation Hyperlinks in PHP](https://docs.aspose.com/slides/php-java/manage-hyperlinks/)
- [Manage Presentation Content in PHP](https://docs.aspose.com/slides/php-java/presentation-content/)
# Ink
> Handle digital ink on slides in PHP with Aspose.Slides: add pen strokes, edit paths, set color and width, and export results for PowerPoint and OpenDocument.
Source: https://docs.aspose.com/slides/php-java/examples/elements/ink/
Updated: 2026-02-20
Provides examples of accessing existing ink shapes and removing them using **Aspose.Slides for PHP via 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**
Get the first ink shape on a slide.
```php
function accessInk() {
$presentation = new Presentation("ink.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Access the first ink shape on the slide.
$firstInk = null;
$shapeCount = java_values($slide->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $slide->getShapes()->get_Item($index);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.Ink"))) {
$firstInk = $shape;
break;
}
}
} finally {
$presentation->dispose();
}
}
```
## **Remove Ink**
Delete an ink shape from the slide.
```php
function removeInk() {
$presentation = new Presentation("ink.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first shape on the slide is an ink shape.
$ink = $slide->getShapes()->get_Item(0);
$slide->getShapes()->remove($ink);
$presentation->save("ink_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## Related articles
- [Manage Presentation Content in PHP](https://docs.aspose.com/slides/php-java/presentation-content/)
- [Manage Presentation Ink Objects in PHP](https://docs.aspose.com/slides/php-java/manage-ink/)
# Layout Slide
> Use PHP to manage layout slides with Aspose.Slides: create, apply, clone, rename, and customize placeholders and themes in presentations for PPT, PPTX and ODP.
Source: https://docs.aspose.com/slides/php-java/examples/elements/layout-slide/
Updated: 2026-02-20
This article demonstrates how to work with **Layout Slides** in Aspose.Slides for PHP via 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.
```php
function addLayoutSlide() {
$presentation = new Presentation();
try {
$masterSlide = $presentation->getMasters()->get_Item(0);
// Create a layout slide with a blank layout type and a custom name.
$layoutSlide = $presentation->getLayoutSlides()->add($masterSlide, SlideLayoutType::Blank, "Main layout");
$presentation->save("layout_slide.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
> 💡 **Tip 1:** Layout slides act as templates for individual slides. You can define common elements once and reuse them across many slides.
> 💡 **Tip 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.).
```php
function accessLayoutSlide() {
$presentation = new Presentation("layout_slide.pptx");
try {
// Access by index.
$firstLayoutSlide = $presentation->getLayoutSlides()->get_Item(0);
// Access by layout type.
$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.
```php
function removeLayoutSlide() {
$presentation = new Presentation("layout_slide.pptx");
try {
// Get a layout slide by type and remove it.
$layoutSlide = $presentation->getLayoutSlides()->getByType(SlideLayoutType::Custom);
$presentation->getLayoutSlides()->remove($layoutSlide);
$presentation->save("layout_slide_removed.pptx", SaveFormat::Pptx);
} 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.
```php
function removeUnusedLayoutSlides() {
$presentation = new Presentation("layout_slide.pptx");
try {
// Automatically removes all layout slides not referenced by any slide.
$presentation->getLayoutSlides()->removeUnused();
$presentation->save("layout_slides_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Clone a Layout Slide**
You can duplicate a layout slide using the `addClone` method.
```php
function cloneLayoutSlides() {
$presentation = new Presentation("layout_slide.pptx");
try {
// Get an existing layout slide by type.
$blankLayoutSlide = $presentation->getLayoutSlides()->getByType(SlideLayoutType::Blank);
// Clone the layout slide to the end of the layout slide collection.
$clonedLayoutSlide = $presentation->getLayoutSlides()->addClone($blankLayoutSlide);
$presentation->save("layout_slide_cloned.pptx", SaveFormat::Pptx);
} 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/php-java/examples/elements/master-slide/)
- [Section](https://docs.aspose.com/slides/php-java/examples/elements/section/)
- [Manage Presentation Slide Masters in PHP](https://docs.aspose.com/slides/php-java/slide-master/)
# Master Slide
> Manage master slides in PHP with Aspose.Slides: create, edit, clone, and format themes, backgrounds, placeholders to unify slides in PowerPoint and OpenDocument.
Source: https://docs.aspose.com/slides/php-java/examples/elements/master-slide/
Updated: 2026-02-20
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 PHP via Java.
## **Add a Master Slide**
This example shows how to create a new master slide by cloning the default one.
```php
function addMasterSlide() {
$presentation = new Presentation();
try {
// Clone the default master slide.
$defaultMasterSlide = $presentation->getMasters()->get_Item(0);
$newMasterSlide = $presentation->getMasters()->addClone($defaultMasterSlide);
$presentation->save("master_slide.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
> 💡 **Tip 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.
> 💡 **Tip 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::getMasters` method. Here’s how to retrieve and work with them:
```php
function accessMasterSlide() {
$presentation = new Presentation("master_slide.pptx");
try {
// Access the first master slide.
$firstMasterSlide = $presentation->getMasters()->get_Item(0);
} finally {
$presentation->dispose();
}
}
```
## **Remove a Master Slide**
Master slides can be removed either by index or by reference.
```php
function removeMasterSlide() {
$presentation = new Presentation("master_slide.pptx");
try {
// Remove by index.
$presentation->getMasters()->removeAt(0);
// Or remove by reference.
$firstMasterSlide = $presentation->getMasters()->get_Item(0);
$presentation->getMasters()->remove($firstMasterSlide);
$presentation->save("master_slide_removed.pptx", SaveFormat::Pptx);
} 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.
```php
function removeUnusedMasterSlide() {
$presentation = new Presentation("master_slide.pptx");
try {
// Remove all unused master slides (even those marked as Preserve).
$presentation->getMasters()->removeUnused(true);
$presentation->save("master_slides_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
> ⚙️ **Tip:** Use `removeUnused(true)` to clean up unused master slides and minimize the presentation size.
## Related articles
- [Layout Slide](https://docs.aspose.com/slides/php-java/examples/elements/layout-slide/)
- [Manage Presentation Slide Masters in PHP](https://docs.aspose.com/slides/php-java/slide-master/)
- [Slide](https://docs.aspose.com/slides/php-java/examples/elements/slide/)
# MathText
> Work with math text in PHP using Aspose.Slides: create and edit equations, fractions, radicals, scripts, formatting, and render results for PPT and PPTX.
Source: https://docs.aspose.com/slides/php-java/examples/elements/math-text/
Updated: 2026-02-20
Illustrates working with mathematical text shapes and formatting equations using **Aspose.Slides for PHP via Java**.
## **Add Math Text**
Create a math shape containing a fraction and the Pythagorean formula.
```php
function addMathText() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
// Add a Math shape to the slide.
$mathShape = $slide->getShapes()->addMathShape(0, 0, 720, 150);
// Access the math paragraph.
$paragraph = $mathShape->getTextFrame()->getParagraphs()->get_Item(0);
$portion = $paragraph->getPortions()->get_Item(0);
$mathParagraph = $portion->getMathParagraph();
// Add a simple fraction: x / y.
$fraction = (new MathematicalText("x"))->divide("y");
$mathParagraph->add(new MathBlock($fraction));
// Add equation: c² = a² + b².
$mathBlock = (new MathematicalText("c"))
->setSuperscript("2")
->join("=")
->join((new MathematicalText("a"))->setSuperscript("2"))
->join("+")
->join((new MathematicalText("b"))->setSuperscript("2"));
$mathParagraph->add($mathBlock);
$presentation->save("math_text.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Access Math Text**
Locate a shape that contains a math paragraph on the slide.
```php
function accessMathText() {
$presentation = new Presentation("math_text.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Find the first shape that contains a math paragraph.
$mathShape = null;
$shapeCount = java_values($slide->getShapes()->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $slide->getShapes()->get_Item($shapeIndex);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.AutoShape"))) {
$textFrame = $shape->getTextFrame();
if ($textFrame !== null) {
$paragraphCount = java_values($textFrame->getParagraphs()->getCount());
for ($paragraphIndex = 0; $paragraphIndex < $paragraphCount; $paragraphIndex++) {
$paragraph = $textFrame->getParagraphs()->get_Item($paragraphIndex);
$portionCount = java_values($paragraph->getPortions()->getCount());
for ($portionIndex = 0; $portionIndex < $portionCount; $portionIndex++) {
$portion = $paragraph->getPortions()->get_Item($portionIndex);
if (java_instanceof($portion, new JavaClass("com.aspose.slides.MathPortion"))) {
$mathShape = $shape;
break 3;
}
}
}
}
}
}
} finally {
$presentation->dispose();
}
}
```
## **Remove Math Text**
Delete a math shape from the slide.
```php
function removeMathText() {
$presentation = new Presentation("math_text.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first shape on the slide is a Math shape.
$mathShape = $slide->getShapes()->get_Item(0);
// Remove the Math shape from the slide.
$slide->getShapes()->remove($mathShape);
$presentation->save("math_text_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Format Math Text**
Set font properties for a math portion.
```php
function formatMathText() {
$presentation = new Presentation("math_text.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first shape on the slide is a Math shape.
$mathShape = $slide->getShapes()->get_Item(0);
$paragraph = $mathShape->getTextFrame()->getParagraphs()->get_Item(0);
$portion = $paragraph->getPortions()->get_Item(0);
$portion->getPortionFormat()->setFontHeight(20);
$presentation->save("math_text_formatted.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## Related articles
- [Add Math Equations to PowerPoint Presentations in PHP](https://docs.aspose.com/slides/php-java/powerpoint-math-equations/)
# Note
> Add, read, edit, and export speaker notes in PHP with Aspose.Slides: format text, manage notes per slide, and control visibility in PowerPoint and OpenDocument.
Source: https://docs.aspose.com/slides/php-java/examples/elements/note/
Updated: 2026-02-20
Shows how to add, read, remove, and update notes slides using **Aspose.Slides for PHP via Java**.
## **Add a Notes Slide**
Create a notes slide and assign text to it.
```php
function addNote() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$notesSlide = $slide->getNotesSlideManager()->addNotesSlide();
$notesSlide->getNotesTextFrame()->setText("My note");
$presentation->save("note.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Access a Notes Slide**
Read text from an existing notes slide.
```php
function accessNote() {
$presentation = new Presentation("note.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$notesSlide = $slide->getNotesSlideManager()->getNotesSlide();
$notes = $notesSlide->getNotesTextFrame()->getText();
} finally {
$presentation->dispose();
}
}
```
## **Remove a Notes Slide**
Remove the notes slide associated with a slide.
```php
function removeNote() {
$presentation = new Presentation("note.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$slide->getNotesSlideManager()->removeNotesSlide();
$presentation->save("note_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Update Notes Text**
Change the text of a notes slide.
```php
function updateNoteText() {
$presentation = new Presentation("note.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$notesSlide = $slide->getNotesSlideManager()->getNotesSlide();
$notesSlide->getNotesTextFrame()->setText("Updated");
$presentation->save("note_updated.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## Related articles
- [Convert PowerPoint Presentations to PDF with Notes in PHP](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-pdf-with-notes/)
# OleObject
> Work with OLE objects in PHP using Aspose.Slides: insert or update embedded files, set icons or links, extract content, control behavior for PPT, PPTX and ODP.
Source: https://docs.aspose.com/slides/php-java/examples/elements/ole-object/
Updated: 2026-02-20
Demonstrates embedding a file as an OLE object and updating its data using **Aspose.Slides for PHP via Java**.
## **Add an OLE Object**
Embed a PDF file into a presentation.
```php
function addOleObject() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$pdfData = new OleEmbeddedDataInfo(file_get_contents("doc.pdf"), "pdf");
$oleFrame = $slide->getShapes()->addOleObjectFrame(20, 20, 50, 50, $pdfData);
$presentation->save("ole_object.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Access an OLE Object**
Retrieve the first OLE object frame on a slide.
```php
function accessOleObject() {
$presentation = new Presentation("ole_object.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Access the first OLE frame on the slide.
$firstOleFrame = null;
$shapeCount = java_values($slide->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $slide->getShapes()->get_Item($index);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.OleObjectFrame"))) {
$firstOleFrame = $shape;
break;
}
}
} finally {
$presentation->dispose();
}
}
```
## **Remove an OLE Object**
Delete an embedded OLE object from the slide.
```php
function removeOleObject() {
$presentation = new Presentation("ole_object.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first shape on the slide is the OLE frame.
$oleFrame = $slide->getShapes()->get_Item(0);
$slide->getShapes()->remove($oleFrame);
$presentation->save("ole_object_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Update OLE Object Data**
Replace the data embedded in an existing OLE object.
```php
function updateOleObjectData() {
$presentation = new Presentation("ole_object.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first shape on the slide is the OLE frame.
$oleFrame = $slide->getShapes()->get_Item(0);
$newData = new OleEmbeddedDataInfo(file_get_contents("picture.png"), "png");
$oleFrame->setEmbeddedData($newData);
$presentation->save("ole_object_updated.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## Related articles
- [Manage Presentation Content in PHP](https://docs.aspose.com/slides/php-java/presentation-content/)
- [Manage OLE in Presentations Using PHP](https://docs.aspose.com/slides/php-java/manage-ole/)
- [Video](https://docs.aspose.com/slides/php-java/examples/elements/video/)
# Picture
> Work with pictures in PHP using Aspose.Slides: insert, replace, crop, compress, adjust transparency and effects, fill shapes, and export for PPT, PPTX and ODP.
Source: https://docs.aspose.com/slides/php-java/examples/elements/picture/
Updated: 2026-02-20
Shows how to insert and access pictures using **Aspose.Slides for PHP via Java**. The examples below place an image on a slide, and then retrieve it.
## **Add a Picture**
This code and inserts an image as a picture frame on the first slide.
```php
function addPicture() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$image = $presentation->getImages()->addImage(
new Java("java.io.FileInputStream", new Java("java.io.File", "image.jpg")));
// Add the image to the presentation resources.
$ppImage = $presentation->getImages()->addImage($image);
// Insert a picture frame showing the image on the first slide.
$slide->getShapes()->addPictureFrame(
ShapeType::Rectangle, 50, 50, $ppImage->getWidth(), $ppImage->getHeight(), $ppImage);
$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.
```php
function accessPicture() {
$presentation = new Presentation("picture.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Access the first PictureFrame on the slide.
$firstPictureFrame = null;
$shapeCount = java_values($slide->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $slide->getShapes()->get_Item($index);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.PictureFrame"))) {
$firstPictureFrame = $shape;
break;
}
}
} finally {
$presentation->dispose();
}
}
```
## Related articles
- [Video](https://docs.aspose.com/slides/php-java/examples/elements/video/)
# Section
> Manage slide sections in PHP with Aspose.Slides: create, rename, reorder easily, move slides between sections, and control visibility for PPT, PPTX and ODP.
Source: https://docs.aspose.com/slides/php-java/examples/elements/section/
Updated: 2026-02-20
Examples for managing presentation sections—add, access, remove, and rename them programmatically using **Aspose.Slides for PHP via Java**.
## **Add a Section**
Create a section that starts at a specific slide.
```php
function addSection() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
// Specify the slide that marks the beginning of the section.
$presentation->getSections()->addSection("New Section", $slide);
$presentation->save("section.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Access a Section**
Read section information from a presentation.
```php
function accessSection() {
$presentation = new Presentation("section.pptx");
try {
// Access a section by index.
$section = $presentation->getSections()->get_Item(0);
$sectionName = $section->getName();
} finally {
$presentation->dispose();
}
}
```
## **Remove a Section**
Delete a previously added section.
```php
function removeSection() {
$presentation = new Presentation("section.pptx");
try {
$section = $presentation->getSections()->get_Item(0);
// Remove the section.
$presentation->getSections()->removeSection($section);
$presentation->save("section_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Rename a Section**
Change the name of an existing section.
```php
function renameSection() {
$presentation = new Presentation("section.pptx");
try {
$section = $presentation->getSections()->get_Item(0);
$section->setName("New Name");
$presentation->save("section_renamed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## Related articles
- [Manage Slide Sections in Presentations Using PHP](https://docs.aspose.com/slides/php-java/slide-section/)
- [Layout Slide](https://docs.aspose.com/slides/php-java/examples/elements/layout-slide/)
# SlideTransition
> Control slide transitions in PHP with Aspose.Slides: choose types, speed, sound, and timing to polish presentations in PPT, PPTX and ODP.
Source: https://docs.aspose.com/slides/php-java/examples/elements/slide-transition/
Updated: 2026-02-20
Demonstrates applying slide transition effects and timings with **Aspose.Slides for PHP via Java**.
## **Add a Slide Transition**
Apply a fade transition effect to the first slide.
```php
function addSlideTransition() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
// Apply a fade transition.
$slide->getSlideShowTransition()->setType(TransitionType::Fade);
$presentation->save("slide_transition.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Access a Slide Transition**
Read the transition type assigned to a slide.
```php
function accessSlideTransition() {
$presentation = new Presentation("slide_transition.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Access the transition type.
$type = $slide->getSlideShowTransition()->getType();
} finally {
$presentation->dispose();
}
}
```
## **Remove a Slide Transition**
Clear any transition effect by setting the type to `None`.
```php
function removeSlideTransition() {
$presentation = new Presentation("slide_transition.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Remove transition by setting none.
$slide->getSlideShowTransition()->setType(TransitionType::None);
$presentation->save("slide_transition_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Set Transition Duration**
Specify how long the slide is displayed before advancing automatically.
```php
function setTransitionDuration() {
$presentation = new Presentation("slide_transition.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$slide->getSlideShowTransition()->setAdvanceOnClick(true);
$slide->getSlideShowTransition()->setAdvanceAfterTime(2000); // in milliseconds.
$presentation->save("slide_transition_duration.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## Related articles
- [Manage Slide Transitions in Presentations Using PHP](https://docs.aspose.com/slides/php-java/slide-transition/)
# Slide
> Manage slides in PHP with Aspose.Slides: create, clone, reorder, hide, set backgrounds and size, apply transitions, and export for PowerPoint and OpenDocument.
Source: https://docs.aspose.com/slides/php-java/examples/elements/slide/
Updated: 2026-02-20
This article provides a series of examples that demonstrate how to work with slides using **Aspose.Slides for PHP via 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 PHP.
## **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.
```php
function addSlide() {
$presentation = new Presentation();
try {
// Each slide is based on a layout, which itself is based on a master slide.
// Use the Blank layout to create a new slide.
$blankLayout = $presentation->getLayoutSlides()->getByType(SlideLayoutType::Blank);
// Add a new empty slide using the selected layout.
$presentation->getSlides()->addEmptySlide($blankLayout);
$presentation->save("slide.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
> 💡 **Tip:** 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.
```php
function accessSlide() {
$presentation = new Presentation("slide.pptx");
try {
// Access a slide by index.
$firstSlide = $presentation->getSlides()->get_Item(0);
} 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.
```php
function cloneSlide() {
// By default, the presentation contains one empty slide.
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
// Clone the first slide; it will be added at the end of the presentation.
$clonedSlide = $presentation->getSlides()->addClone($slide);
// The cloned slide index is 1 (second slide in the presentation).
$clonedSlideIndex = $presentation->getSlides()->indexOf($clonedSlide);
$presentation->save("slide_cloned.pptx", SaveFormat::Pptx);
} 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 slide to the first position.
```php
function reorderSlide() {
$presentation = new Presentation("slide.pptx");
try {
$slide = $presentation->getSlides()->get_Item(1);
// Move the slide to the first position (others shift down).
$presentation->getSlides()->reorder(0, $slide);
$presentation->save("slide_reordered.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Remove a Slide**
To remove a slide, simply reference it and call `remove`. This example removes slides by index and by reference.
```php
function removeSlide() {
$presentation = new Presentation("slide.pptx");
try {
// Remove a slide by index.
$presentation->getSlides()->removeAt(0);
// Remove a slide by reference.
$slide = $presentation->getSlides()->get_Item(0);
$presentation->getSlides()->remove($slide);
$presentation->save("slides_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## Related articles
- [Master Slide](https://docs.aspose.com/slides/php-java/examples/elements/master-slide/)
# SmartArt
> Build and edit SmartArt in PHP with Aspose.Slides: add nodes, change layouts and styles, convert to shapes with precision, and export for PPT, PPTX and ODP.
Source: https://docs.aspose.com/slides/php-java/examples/elements/smartart/
Updated: 2026-02-20
Shows how to add SmartArt graphics, access them, remove them, and change layouts using **Aspose.Slides for PHP via Java**.
## **Add SmartArt**
Insert a SmartArt graphic using one of the built-in layouts.
```php
function addSmartArt() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$smart = $slide->getShapes()->addSmartArt(50, 50, 400, 300, SmartArtLayoutType::BasicProcess);
$presentation->save("smart_art.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Access SmartArt**
Retrieve the first SmartArt object on a slide.
```php
function accessSmartArt() {
$presentation = new Presentation("smart_art.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Access the first SmartArt on the slide.
$firstSmartArt = null;
$shapeCount = java_values($slide->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $slide->getShapes()->get_Item($index);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.SmartArt"))) {
$firstSmartArt = $shape;
break;
}
}
} finally {
$presentation->dispose();
}
}
```
## **Remove SmartArt**
Delete a SmartArt shape from the slide.
```php
function removeSmartArt() {
$presentation = new Presentation("smart_art.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first shape on the slide is a SmartArt.
$smartArt = $slide->getShapes()->get_Item(0);
$slide->getShapes()->remove($smartArt);
$presentation->save("smart_art_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Change SmartArt Layout**
Update the layout type of an existing SmartArt graphic.
```php
function changeSmartArtLayout() {
$presentation = new Presentation("smart_art.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first shape on the slide is a SmartArt.
$smartArt = $slide->getShapes()->get_Item(0);
// Change the layout of the SmartArt.
$smartArt->setLayout(SmartArtLayoutType::VerticalPictureList);
$presentation->save("smart_art_layout_changed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## Related articles
- [Create and Customize PowerPoint SmartArt in PHP](https://docs.aspose.com/slides/php-java/powerpoint-smartart/)
- [Manage SmartArt in PowerPoint Presentations Using PHP](https://docs.aspose.com/slides/php-java/manage-smartart/)
- [Manage Presentation Content in PHP](https://docs.aspose.com/slides/php-java/presentation-content/)
# Table
> Create and format tables in PHP with Aspose.Slides: insert data, merge cells, style borders, align content, and import/export for PPT, PPTX and ODP.
Source: https://docs.aspose.com/slides/php-java/examples/elements/table/
Updated: 2026-02-20
Examples for adding tables, accessing them, removing them, and merging cells using **Aspose.Slides for PHP via Java**.
## **Add a Table**
Create a simple table with two rows and two columns.
```php
function addTable() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$widths = [80, 80];
$heights = [30, 30];
$table = $slide->getShapes()->addTable(50, 50, $widths, $heights);
$presentation->save("table.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Access a Table**
Retrieve the first table shape on the slide.
```php
function accessTable() {
$presentation = new Presentation("table.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Access the first table on the slide.
$firstTable = null;
$shapeCount = java_values($slide->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $slide->getShapes()->get_Item($index);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.Table"))) {
$firstTable = $shape;
break;
}
}
} finally {
$presentation->dispose();
}
}
```
## **Remove a Table**
Delete a table from a slide.
```php
function removeTable() {
$presentation = new Presentation("table.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the table is the first shape on the slide.
$table = $slide->getShapes()->get_Item(0);
$slide->getShapes()->remove($table);
$presentation->save("table_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Merge Table Cells**
Merge adjacent cells of a table into a single cell.
```php
function mergeTableCells() {
$presentation = new Presentation("table.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the table is the first shape on the slide.
$table = $slide->getShapes()->get_Item(0);
$table->mergeCells($table->get_Item(0, 0), $table->get_Item(1, 1), false);
$presentation->save("cells_merged.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## Related articles
- [Create and Customize PowerPoint Tables in PHP](https://docs.aspose.com/slides/php-java/powerpoint-table/)
- [Manage Table Cells in Presentations Using PHP](https://docs.aspose.com/slides/php-java/manage-cells/)
- [Manage Presentation Tables in PHP](https://docs.aspose.com/slides/php-java/manage-table/)
# Text Box
> Create and format text boxes in PHP with Aspose.Slides: set fonts, alignment, wrapping, autofit, and links to polish slides for PowerPoint and OpenDocument.
Source: https://docs.aspose.com/slides/php-java/examples/elements/text-box/
Updated: 2026-02-20
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:
```php
function addTextBox() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
// Create a rectangle shape (defaults to filled with border and no text).
$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.
$paragraph = $textBox->getTextFrame()->getParagraphs()->get_Item(0);
$portionFormat = $paragraph->getParagraphFormat()->getDefaultPortionFormat();
$portionFormat->getFillFormat()->setFillType(FillType::Solid);
$portionFormat->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
// Assign the actual text content.
$textBox->getTextFrame()->setText("Some text...");
$presentation->save("text_box.pptx", SaveFormat::Pptx);
} 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:
```php
function accessTextBox() {
$presentation = new Presentation("text_box.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Access the first text box on the slide.
$firstTextBox = null;
$shapeCount = java_values($slide->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $slide->getShapes()->get_Item($index);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.AutoShape"))) {
$firstTextBox = $shape;
if (strpos($firstTextBox->getTextFrame()->getText(), "Slide") !== false) {
// Do something with the matching text box.
}
break;
}
}
} 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:
```php
function removeTextBoxes() {
$presentation = new Presentation("text_box.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapesToRemove = [];
$shapeCount = java_values($slide->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $slide->getShapes()->get_Item($index);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.AutoShape"))) {
$autoShape = $shape;
if (strpos($autoShape->getTextFrame()->getText(), "Slide") !== false) {
$shapesToRemove[] = $shape;
}
}
}
foreach ($shapesToRemove as $shape) {
$slide->getShapes()->remove($shape);
}
$presentation->save("text_boxes_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
> 💡 **Tip:** Always create a copy of the shape collection before modifying it during iteration to avoid collection modification errors.
# VbaMacro
> Work with VBA macros in PHP using Aspose.Slides: add or edit projects and modules, sign or remove macros, and save presentations in PPT, PPTX and ODP.
Source: https://docs.aspose.com/slides/php-java/examples/elements/vba-macro/
Updated: 2026-02-20
Illustrates how to add, access, and remove VBA macros using **Aspose.Slides for PHP via Java**.
## **Add a VBA Macro**
Create a presentation with a VBA project and a simple macro module.
```php
function addVbaMacro() {
$presentation = new Presentation();
try {
$presentation->setVbaProject(new VbaProject());
$module = $presentation->getVbaProject()->getModules()->addEmptyModule("Module");
$module->setSourceCode("Sub Test()\n MsgBox \"Hi\" \nEnd Sub");
$presentation->save("vba_macro.pptm", SaveFormat::Pptm);
} finally {
$presentation->dispose();
}
}
```
## **Access a VBA Macro**
Retrieve the first module from the VBA project.
```php
function accessVbaMacro() {
$presentation = new Presentation("vba_macro.pptm");
try {
$firstModule = $presentation->getVbaProject()->getModules()->get_Item(0);
} finally {
$presentation->dispose();
}
}
```
## **Remove a VBA Macro**
Delete a module from the VBA project.
```php
function removeVbaMacro() {
$presentation = new Presentation("vba_macro.pptm");
try {
// Assuming there is at least one module in the VBA project.
$module = $presentation->getVbaProject()->getModules()->get_Item(0);
$presentation->getVbaProject()->getModules()->remove($module);
$presentation->save("vba_macro_removed.pptm", SaveFormat::Pptm);
} finally {
$presentation->dispose();
}
}
```
## Related articles
- [Manage VBA Projects in Presentations Using PHP](https://docs.aspose.com/slides/php-java/presentation-via-vba/)
# Video
> Work with video in PHP using Aspose.Slides: insert, replace, trim, set poster frames and playback options, and export presentations for PPT, PPTX and ODP.
Source: https://docs.aspose.com/slides/php-java/examples/elements/video/
Updated: 2026-02-20
Shows how to embed video frames and set playback options using **Aspose.Slides for PHP via Java**.
## **Add a Video Frame**
Insert a video frame into a slide.
```php
function addVideo() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
// Add a video frame.
$videoFrame = $slide->getShapes()->addVideoFrame(50, 50, 320, 240, "video.mp4");
$presentation->save("video.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Access a Video Frame**
Retrieve the first video frame added to a slide.
```php
function accessVideo() {
$presentation = new Presentation("video.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Access the first video frame on the slide.
$firstVideoFrame = null;
$shapeCount = java_values($slide->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $slide->getShapes()->get_Item($index);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.VideoFrame"))) {
$firstVideoFrame = $shape;
break;
}
}
} finally {
$presentation->dispose();
}
}
```
## **Remove a Video Frame**
Delete a video frame from the slide.
```php
function removeVideo() {
$presentation = new Presentation("video.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first shape on the slide is the video frame.
$videoFrame = $slide->getShapes()->get_Item(0);
// Remove the video frame.
$slide->getShapes()->remove($videoFrame);
$presentation->save("video_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## **Set Video Playback**
Configure the video to play automatically when the slide is displayed.
```php
function setVideoPlayback() {
$presentation = new Presentation("video.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first shape on the slide is the video frame.
$videoFrame = $slide->getShapes()->get_Item(0);
// Configure the video to play automatically.
$videoFrame->setPlayMode(VideoPlayModePreset::Auto);
$presentation->save("video_playback.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
## Related articles
- [Audio](https://docs.aspose.com/slides/php-java/examples/elements/audio/)
- [Picture](https://docs.aspose.com/slides/php-java/examples/elements/picture/)
- [OleObject](https://docs.aspose.com/slides/php-java/examples/elements/ole-object/)
# Integrate Excel Data into PowerPoint Presentations
> Read data from Excel workbooks using Aspose.Slides for PHP via Java. Load sheets and cells and use values to generate data-driven PowerPoint presentations.
Source: https://docs.aspose.com/slides/php-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 [ExcelDataWorkbook](https://reference.aspose.com/slides/php-java/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 [ExcelDataWorkbook::getCell](https://reference.aspose.com/slides/php-java/aspose.slides/exceldataworkbook/#getCell) method, which you can use to retrieve specific cells by their position (e.g., row and column indices or named ranges).
Each call to [ExcelDataWorkbook::getCell](https://reference.aspose.com/slides/php-java/aspose.slides/exceldataworkbook/#getCell) returns an instance of the [ExcelDataCell](https://reference.aspose.com/slides/php-java/aspose.slides/exceldatacell/) class. 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/php-java/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/php-java/aspose.slides/excelworkbookimporter/#addChartFromWorkbook) 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/php-java/aspose.slides/excelworkbookimporter/) class also contains several overloads of the [ExcelWorkbookImporter::addTableFromWorkbook](https://reference.aspose.com/slides/php-java/aspose.slides/excelworkbookimporter/#addTableFromWorkbook) 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

```php
// Load the Excel workbook with employee data.
$workbook = new ExcelDataWorkbook("TemplateData.xlsx");
$worksheetIndex = 0;
// Load the presentation template.
$templatePresentation = new Presentation("PresentationTemplate.pptx");
try {
// Loop through Excel rows (excluding header at row 0).
for ($rowIndex = 1; $rowIndex <= 4; $rowIndex++) {
// Create a new presentation for each employee record.
$employeePresentation = new Presentation();
try {
// Remove the default blank slide.
$employeePresentation->getSlides()->removeAt(0);
// Clone the template slide into the new presentation.
$slide = $employeePresentation->getSlides()->addClone($templatePresentation->getSlides()->get_Item(0));
// Get paragraphs from the target shape (assumes shape index 1 is used).
$paragraphs = $slide->getShapes()->get_Item(1)->getTextFrame()->getParagraphs();
// Replace the placeholders with data from Excel.
$employeeName = $workbook->getCell($worksheetIndex, $rowIndex, 0)->getValue()->toString();
$namePortion = $paragraphs->get_Item(0)->getPortions()->get_Item(0);
$namePortion->setText($namePortion->getText()->replace("{{EmployeeName}}", $employeeName));
$department = $workbook->getCell($worksheetIndex, $rowIndex, 1)->getValue()->toString();
$departmentPortion = $paragraphs->get_Item(1)->getPortions()->get_Item(0);
$departmentPortion->setText($departmentPortion->getText()->replace("{{Department}}", $department));
$yearsOfService = $workbook->getCell($worksheetIndex, $rowIndex, 2)->getValue()->toString();
$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(sprintf("%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.
```php
// Load the Excel workbook containing the employee data.
$workbook = new ExcelDataWorkbook("TemplateData.xlsx");
$worksheetIndex = 0;
// Create a new PowerPoint presentation.
$presentation = new Presentation();
try {
// Add a table shape to the first slide.
$table = $presentation->getSlides()->get_Item(0)->getShapes()->addTable(
50, 200,
array(200, 200, 200),
array(30, 30, 30, 30, 30)
);
// Fill the PowerPoint table with data from the Excel workbook.
for ($rowIndex = 0; $rowIndex < 5; $rowIndex++) {
for ($columnIndex = 0; $columnIndex < 3; $columnIndex++) {
$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.

```php
// Create a new PowerPoint presentation.
$presentation = new Presentation();
try {
// Get the shapes collection of the first slide.
$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.
```php
// Load the Excel workbook containing the employee data.
$workbook = new ExcelDataWorkbook("ExcelWithCharts.xlsx");
// Create a new PowerPoint presentation.
$presentation = new Presentation();
try {
// Retrieve the blank slide layout.
$blankLayout = $presentation->getLayoutSlides()->getByType(SlideLayoutType::Blank);
// Get the names of all worksheets contained in the Excel workbook.
$worksheetNames = $workbook->getWorksheetNames()->iterator();
while (java_values($worksheetNames->hasNext())) {
$name = $worksheetNames->next();
// Retrieve a map that maps chart indexes to chart names for the worksheet.
$worksheetCharts = $workbook->getChartsFromWorksheet($name)->iterator();
while (java_values($worksheetCharts->hasNext())) {
$chart = $worksheetCharts->next();
// Add a new slide using the blank layout.
$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:

```php
// Create a new PowerPoint presentation.
$presentation = new Presentation();
try {
// Get the first slide and its shapes collection.
$slide = $presentation->getSlides()->get_Item(0);
$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 PHP
> Learn how to export presentation charts with Aspose.Slides for PHP via Java, supporting PPT and PPTX formats, and streamline reporting into any workflow.
Source: https://docs.aspose.com/slides/php-java/export-chart/
Updated: 2026-08-02
## **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.
## **Get a Chart Image**
Aspose.Slides for PHP via Java provides support for extracting image of specific chart. Below sample example is given.
```php
$pres = new Presentation();
try {
$chart = $pres->getSlides()->get_Item(0)->getShapes()->addChart(ChartType::ClusteredColumn, 50, 50, 600, 400);
$slideImage = $chart->getImage();
try {
$slideImage->save("image.jpg", ImageFormat::Jpeg);
} finally {
if (!java_is_null($slideImage)) {
$slideImage->dispose();
}
}
} finally {
if (!java_is_null($pres)) {
$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/php-java/aspose.slides/shape/writeassvg/).
### 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/php-java/custom-font/) via [FontsLoader](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/)/[documentation](https://docs.aspose.com/slides/php-java/convert-powerpoint/) for output targets ([PDF](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-pdf/), [SVG](https://docs.aspose.com/slides/php-java/render-a-slide-as-an-svg-image/), [XPS](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-xps/), [HTML](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-html/), etc.) and related rendering options.
# Convert Presentations to HTML5 in PHP
> Export PowerPoint & OpenDocument presentations to responsive HTML5 with Aspose.Slides for PHP via Java. Preserve formatting, animations, and interactivity.
Source: https://docs.aspose.com/slides/php-java/export-to-html5/
Updated: 2026-10-05
## **Overview**
This article explains how to convert PowerPoint presentations to HTML5 using Aspose.Slides for PHP via 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.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$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/php-java/aspose.slides/html5options/#setAnimateShapes) and [setAnimateTransitions](https://reference.aspose.com/slides/php-java/aspose.slides/html5options/#setAnimateTransitions) in [Html5Options](https://reference.aspose.com/slides/php-java/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.
```php
use aspose\slides\Html5Options;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$html5Options = new Html5Options();
$html5Options->setAnimateShapes(false);
$html5Options->setAnimateTransitions(false);
$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.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$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/php-java/aspose.slides/html5options/#setAnimateShapes) and [setAnimateTransitions](https://reference.aspose.com/slides/php-java/aspose.slides/html5options/#setAnimateTransitions) 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.
```php
use aspose\slides\Html5Options;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$html5Options = new Html5Options();
$html5Options->setAnimateShapes(true);
$html5Options->setAnimateTransitions(true);
$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/php-java/aspose.slides/notescommentslayoutingoptions/) object to the [setSlidesLayoutOptions](https://reference.aspose.com/slides/php-java/aspose.slides/html5options/#setSlidesLayoutOptions) method of [Html5Options](https://reference.aspose.com/slides/php-java/aspose.slides/html5options/). Use [setCommentsPosition](https://reference.aspose.com/slides/php-java/aspose.slides/notescommentslayoutingoptions/#setCommentsPosition) to select `Right` from the [CommentsPositions](https://reference.aspose.com/slides/php-java/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.
```php
use aspose\slides\CommentsPositions;
use aspose\slides\Html5Options;
use aspose\slides\NotesCommentsLayoutingOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$layoutOptions = new NotesCommentsLayoutingOptions();
$layoutOptions->setCommentsPosition(CommentsPositions::Right);
$html5Options = new Html5Options();
$html5Options->setSlidesLayoutOptions($layoutOptions);
$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/php-java/aspose.slides/saveoptions/#setSkipJavaScriptLinks). 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/php-java/aspose.slides/html5options/):
```php
use aspose\slides\Html5Options;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$html5Options = new Html5Options();
$html5Options->setSkipJavaScriptLinks(true);
$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/php-java/aspose.slides/html5options/#setAnimateShapes) and [slide transitions](https://reference.aspose.com/slides/php-java/aspose.slides/html5options/#setAnimateTransitions).
**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/php-java/aspose.slides/html5options/#setSlidesLayoutOptions) for notes and comments.
**Can I skip links that invoke JavaScript for security or CSP reasons?**
Yes, the [setSkipJavaScriptLinks](https://reference.aspose.com/slides/php-java/aspose.slides/saveoptions/#setSkipJavaScriptLinks) 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/php-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 PHP
> Convert PowerPoint and OpenDocument slides to XAML using Aspose.Slides for PHP via Java — quick, Office-free solution that keeps your layout intact.
Source: https://docs.aspose.com/slides/php-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/php-java/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 PHP example shows how to export a presentation to XAML with default settings. Initialize PHP Java Bridge and load `aspose.slides.php` before running the examples in this article. Place `pres.pptx` in the Java Bridge server's working directory, or supply an absolute path accessible to that server.
```php
use aspose\slides\Presentation;
use aspose\slides\XamlOptions;
$presentation = new Presentation("pres.pptx");
try {
$options = new XamlOptions();
$presentation->save($options);
} finally {
$presentation->dispose();
}
```
By default, the exported slides are saved in a `pres` subfolder of the Java Bridge server's current working directory. 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 Java Bridge server's 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, provide a Java proxy implementing [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/php-java/aspose.slides/xamloptions/#setOutputSaver) method of [XamlOptions](https://reference.aspose.com/slides/php-java/aspose.slides/xamloptions/).
To include hidden slides in the XAML output, call [setExportHiddenSlides](https://reference.aspose.com/slides/php-java/aspose.slides/xamloptions/#setExportHiddenSlides) with `true`, as shown in the following PHP example:
```php
use aspose\slides\Presentation;
use aspose\slides\XamlOptions;
$presentation = new Presentation("pres.pptx");
try {
$options = new XamlOptions();
$options->setExportHiddenSlides(true);
$presentation->save($options);
} 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/php-java/aspose.slides/xamloptions/#setOutputSaver) 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/php-java/aspose.slides/presentation/#save) overload that accepts XAML options.
The PHP Java Bridge `java_closure` function exposes a PHP object as the Java interface. Keep both the PHP saver and its proxy alive until export finishes. The interface links point to the Java API implemented by the proxy.
### **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 convert each Java byte array into a PHP binary string owned by the application.
- 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/php-java/aspose.slides/xamloptions/#setExportHiddenSlides) 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 PHP associative array of binary strings, 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.
```php
use aspose\slides\Presentation;
use aspose\slides\XamlOptions;
class MemoryXamlSaver {
public $artifacts = [];
public $valid = true;
public function save($path, $data) {
$name = (string) java_values($path);
if (array_key_exists($name, $this->artifacts)) {
$this->valid = false;
echo "Export rejected: duplicate artifact name: " . $name . PHP_EOL;
return;
}
$bytes = java_values($data);
if (is_string($bytes)) {
$binary = $bytes;
} else {
$binary = "";
foreach ($bytes as $byte) {
$binary .= chr($byte & 0xff);
}
}
$this->artifacts[$name] = $binary;
}
}
$saver = new MemoryXamlSaver();
$proxy = java_closure($saver, null, java("com.aspose.slides.IXamlOutputSaver"));
$presentation = new Presentation("pres.pptx");
try {
$options = new XamlOptions();
$options->setOutputSaver($proxy);
$options->setExportHiddenSlides(true);
$presentation->save($options);
} finally {
$presentation->dispose();
}
if (!$saver->valid) {
echo "Export rejected: the artifact collection is invalid." . PHP_EOL;
return;
}
$inspectXamlText = false;
foreach ($saver->artifacts as $name => $bytes) {
$extension = strtolower(pathinfo($name, PATHINFO_EXTENSION));
$isXaml = $extension === "xaml";
$isImage = in_array($extension, ["png", "jpg", "jpeg", "gif", "bmp", "tif", "tiff", "svg"], true);
$kind = $isXaml ? "slide XAML" : ($isImage ? "image" : "supporting resource");
echo $name . ": " . strlen($bytes) . " bytes (" . $kind . ")" . PHP_EOL;
// Only XAML is treated as UTF-8 text for optional inspection.
if ($isXaml && $inspectXamlText) {
echo $bytes . PHP_EOL;
}
}
```
Extension checks are useful for inspection; retain all artifacts, including unfamiliar resource types. Leave the bytes unchanged when storing or transmitting them. PHP strings can retain binary data, including zero bytes. Treat a string as UTF-8 text only when inspecting XAML; do not transcode image or resource bytes.
### **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. An exclusively created job directory separates concurrent export jobs. This example requires the PHP Phar extension with ZIP support. 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.
```php
use aspose\slides\Presentation;
use aspose\slides\XamlOptions;
class MemoryXamlSaver {
public $artifacts = [];
public $valid = true;
public function save($path, $data) {
$name = (string) java_values($path);
if (array_key_exists($name, $this->artifacts)) {
$this->valid = false;
echo "Export rejected: duplicate artifact name: " . $name . PHP_EOL;
return;
}
$bytes = java_values($data);
if (is_string($bytes)) {
$binary = $bytes;
} else {
$binary = "";
foreach ($bytes as $byte) {
$binary .= chr($byte & 0xff);
}
}
$this->artifacts[$name] = $binary;
}
}
$saver = new MemoryXamlSaver();
$proxy = java_closure($saver, null, java("com.aspose.slides.IXamlOutputSaver"));
$presentation = new Presentation("pres.pptx");
try {
$options = new XamlOptions();
$options->setOutputSaver($proxy);
$options->setExportHiddenSlides(false);
$presentation->save($options);
} finally {
$presentation->dispose();
}
if (!$saver->valid) {
echo "Export rejected: the artifact collection is invalid." . PHP_EOL;
return;
}
$entries = [];
$entryNames = [];
foreach ($saver->artifacts as $name => $bytes) {
$entryName = str_replace("\\", "/", $name);
$unsafeName = substr($entryName, 0, 1) === "/" || strpos($entryName, ":") !== false;
foreach (explode("/", $entryName) as $segment) {
$unsafeName = $unsafeName || trim($segment) === "" || $segment === "." || $segment === "..";
}
$key = strtolower($entryName);
if ($unsafeName || isset($entryNames[$key])) {
echo "Export rejected: unsafe or duplicate artifact name: " . $name . PHP_EOL;
return;
}
$entryNames[$key] = true;
$entries[$entryName] = $bytes;
}
$jobDirectory = "xaml-" . bin2hex(random_bytes(16));
if (!mkdir($jobDirectory, 0700)) {
echo "Cannot create the export directory." . PHP_EOL;
return;
}
$archivePath = $jobDirectory . "/export.zip";
try {
$archive = new PharData($archivePath, 0, null, Phar::ZIP);
foreach ($entries as $name => $bytes) {
$archive->addFromString($name, $bytes);
}
unset($archive);
echo "Saved " . count($entries) . " artifacts to " . $archivePath . PHP_EOL;
} catch (Throwable $exception) {
unset($archive);
echo "Archive persistence failed: " . $exception->getMessage() . PHP_EOL;
}
```
The example uses [PharData](https://www.php.net/manual/en/class.phardata.php) to write one local ZIP archive in the PHP process's working directory; the exporter itself does not write loose XAML or image files. For remote storage, replace the archive-writing stage with uploads of the collected binary strings. 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 [basename](https://www.php.net/manual/en/function.basename.php) 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 to an absolute path, 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/php-java/aspose.slides/saveoptions/#setDefaultRegularFont) in [XamlOptions](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/xamloptions/#setExportHiddenSlides) in [XamlOptions](https://reference.aspose.com/slides/php-java/aspose.slides/xamloptions/) — keep it disabled if you do not need to export them.
# Export Math Equations from Presentations in PHP
> Export math equations from PowerPoint presentations to LaTeX or MathML directly with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/exporting-math-equations/
Updated: 2026-08-13
## **Introduction**
Aspose.Slides for PHP via Java 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 a [MathPortion](https://reference.aspose.com/slides/php-java/aspose.slides/mathportion/). Use [MathPortion::getMathParagraph](https://reference.aspose.com/slides/php-java/aspose.slides/mathportion/#getMathParagraph) to get a [MathParagraph](https://reference.aspose.com/slides/php-java/aspose.slides/mathparagraph/), and then call [MathParagraph::toLatex](https://reference.aspose.com/slides/php-java/aspose.slides/mathparagraph/#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:
```php
$presentation = new Presentation("equations.pptx");
$arrayClass = new JavaClass("java.lang.reflect.Array");
$mathPortionClass = new JavaClass("com.aspose.slides.MathPortion");
try {
$slideCount = java_values($presentation->getSlides()->size());
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$slideNumber = $slideIndex + 1;
$equationNumber = 1;
$textFrames = SlideUtil::getAllTextBoxes($slide);
$textFrameCount = java_values($arrayClass->getLength($textFrames));
for ($textFrameIndex = 0; $textFrameIndex < $textFrameCount; $textFrameIndex++) {
$textFrame = $textFrames[$textFrameIndex];
$paragraphCount = java_values($textFrame->getParagraphs()->getCount());
for ($paragraphIndex = 0; $paragraphIndex < $paragraphCount; $paragraphIndex++) {
$paragraph = $textFrame->getParagraphs()->get_Item($paragraphIndex);
$portionCount = java_values($paragraph->getPortions()->getCount());
for ($portionIndex = 0; $portionIndex < $portionCount; $portionIndex++) {
$portion = $paragraph->getPortions()->get_Item($portionIndex);
if (!java_instanceof($portion, $mathPortionClass)) {
continue;
}
$mathParagraph = $portion->getMathParagraph();
$latexFileName = "slide_" . $slideNumber . "_equation_" . $equationNumber . ".tex";
$latexText = java_values($mathParagraph->toLatex());
file_put_contents($latexFileName, $latexText);
$equationNumber++;
}
}
}
}
} finally {
$presentation->dispose();
}
```
[SlideUtil::getAllTextBoxes](https://reference.aspose.com/slides/php-java/aspose.slides/slideutil/#getAllTextBoxes) returns all text frames found on a slide. The [MathPortion](https://reference.aspose.com/slides/php-java/aspose.slides/mathportion/) 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:
```php
$pres = new Presentation();
try {
$autoShape = $pres->getSlides()->get_Item(0)->getShapes()->addMathShape(0, 0, 500, 50);
$mathParagraph = $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")));
$stream = new Java("java.io.FileOutputStream", "mathml.xml");
$mathParagraph->writeAsMathMl($stream);
} catch (JavaException $e) {
} finally {
if (!java_is_null($pres)) {
$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/php-java/aspose.slides/mathparagraph/)) or an individual block ([MathBlock](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/mathportion/) and has a [MathParagraph](https://reference.aspose.com/slides/php-java/aspose.slides/mathparagraph/). Images and regular text portions without a [MathParagraph](https://reference.aspose.com/slides/php-java/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/php-java/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 PHP](https://docs.aspose.com/slides/php-java/powerpoint-math-equations/)
# Export Presentations to HTML with Externally Linked Images
> Export PowerPoint and OpenDocument presentations to HTML in PHP via Java using Aspose.Slides with images and other resources saved as external linked files.
Source: https://docs.aspose.com/slides/php-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/php-java/convert-powerpoint-to-html/). This article focuses on the resource-linking part of the export.
## **How Linked Resource Export Works**
[HtmlOptions](https://reference.aspose.com/slides/php-java/aspose.slides/htmloptions/) can use a custom link/embed controller when Aspose.Slides exports a presentation to HTML. In PHP via Java, this scenario is usually implemented with a small Java helper class. Compile that helper, add it to the PHP Java Bridge classpath, and instantiate it from PHP with `new Java(...)`.
The helper class decides, resource by resource, whether the exporter embeds the data in the HTML or saves it externally and writes a link. It needs three callback methods:
- `ExternalResourceController.getObjectStoringLocation` decides whether a resource should be linked or embedded.
- `ExternalResourceController.getUrl` returns the URL that will be written to the generated HTML or to another linked resource.
- `ExternalResourceController.saveExternal` 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`.
## **Create the Java Helper Class**
Create a Java class such as `com.example.slides.ExternalResourceController`, compile it with Aspose.Slides for Java on the classpath, and make the compiled class or JAR available to PHP Java Bridge.
The helper below 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
package com.example.slides;
import com.aspose.slides.ILinkEmbedController;
import com.aspose.slides.LinkEmbedDecision;
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 final class ExternalResourceController implements ILinkEmbedController {
private static final Map EXTENSIONS_BY_CONTENT_TYPE = createExtensionMap();
private final Path assetDirectory;
private final String assetUrlPrefix;
private final Map fileNamesByResourceId = new HashMap<>();
public ExternalResourceController(String assetDirectory, String assetUrlPrefix) {
if (assetDirectory == null || assetDirectory.trim().isEmpty()) {
throw new IllegalArgumentException("The asset output directory must not be empty.");
}
this.assetDirectory = Paths.get(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.");
}
Path filePath = assetDirectory.resolve(fileName);
try {
Files.createDirectories(assetDirectory);
Files.write(filePath, entityData);
} catch (IOException exception) {
throw new IllegalStateException(
"Could not save linked resource " + resourceId + " to " + filePath + ".",
exception);
}
}
private static Map createExtensionMap() {
Map extensions = new HashMap<>();
extensions.put("image/jpeg", ".jpg");
extensions.put("image/png", ".png");
extensions.put("image/gif", ".gif");
extensions.put("image/bmp", ".bmp");
extensions.put("image/svg+xml", ".svg");
extensions.put("image/tiff", ".tiff");
extensions.put("image/x-emf", ".emf");
extensions.put("image/x-wmf", ".wmf");
extensions.put("font/woff", ".woff");
extensions.put("font/woff2", ".woff2");
extensions.put("font/ttf", ".ttf");
extensions.put("application/font-woff", ".woff");
extensions.put("application/vnd.ms-fontobject", ".eot");
extensions.put("application/x-font-ttf", ".ttf");
extensions.put("text/css", ".css");
extensions.put("audio/mpeg", ".mp3");
extensions.put("audio/mp4", ".m4a");
extensions.put("audio/wav", ".wav");
extensions.put("video/mp4", ".mp4");
extensions.put("video/webm", ".webm");
return extensions;
}
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, 6) ||
contentType.regionMatches(true, 0, "font/", 0, 5) ||
contentType.regionMatches(true, 0, "audio/", 0, 6) ||
contentType.regionMatches(true, 0, "video/", 0, 6));
}
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);
}
for (int characterIndex = 0; characterIndex < extensionCharacters.length(); characterIndex++) {
if (!Character.isLetterOrDigit(extensionCharacters.charAt(characterIndex))) {
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 + "/";
}
}
```
## **Export HTML with Linked Resources**
The following PHP code creates an output directory, saves the HTML file there, and stores linked resources in an `assets` subdirectory. It combines [HtmlOptions](https://reference.aspose.com/slides/php-java/aspose.slides/htmloptions/), [SVGOptions](https://reference.aspose.com/slides/php-java/aspose.slides/svgoptions/), [SlideImageFormat](https://reference.aspose.com/slides/php-java/aspose.slides/slideimageformat/), and [SaveFormat](https://reference.aspose.com/slides/php-java/aspose.slides/saveformat/) for the export.
```php
$inputFilePath = "presentation.pptx";
$outputDirectory = "html-output";
$assetDirectoryName = "assets";
$assetDirectory = $outputDirectory . DIRECTORY_SEPARATOR . $assetDirectoryName;
if (!is_dir($outputDirectory) && !mkdir($outputDirectory, 0777, true)) {
throw new RuntimeException("Could not create the HTML output directory: " . $outputDirectory);
}
if (!is_dir($assetDirectory) && !mkdir($assetDirectory, 0777, true)) {
throw new RuntimeException("Could not create the asset output directory: " . $assetDirectory);
}
$assetUrlPrefix = $assetDirectoryName . "/";
$controller = new Java("com.example.slides.ExternalResourceController", $assetDirectory, $assetUrlPrefix);
$svgOptions = new SVGOptions($controller);
$slideImageFormat = SlideImageFormat::svg($svgOptions);
$htmlOptions = new HtmlOptions($controller);
$htmlFormatter = java("com.aspose.slides.HtmlFormatter")->createDocumentFormatter("", false);
$htmlOptions->setHtmlFormatter($htmlFormatter);
$htmlOptions->setSlideImageFormat($slideImageFormat);
$presentation = new Presentation($inputFilePath);
try {
$htmlFilePath = $outputDirectory . DIRECTORY_SEPARATOR . "presentation.html";
$presentation->save($htmlFilePath, SaveFormat::Html, $htmlOptions);
} finally {
$presentation->dispose();
}
```
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 `ExternalResourceController.getUrl` 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 `ExternalResourceController.getUrl` must match the final deployed location of the file written by `ExternalResourceController.saveExternal`. 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 `ExternalResourceController.getObjectStoringLocation`, return the `Link` value from [LinkEmbedDecision](https://reference.aspose.com/slides/php-java/aspose.slides/linkembeddecision/) only for the content types you want to save as separate files, and return the `Embed` value 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 PHP](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-html/)
# Advanced Text Extraction from Presentations in PHP
> Quickly extract text from PowerPoint and OpenDocument presentations using Aspose.Slides for PHP via Java. Follow our simple, step-by-step guide to save time.
Source: https://docs.aspose.com/slides/php-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 PHP via 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 PHP via Java provides the [SlideUtil](https://reference.aspose.com/slides/php-java/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 [getAllTextBoxes](https://reference.aspose.com/slides/php-java/aspose.slides/slideutil/#getAllTextBoxes) method. This method accepts an object of type [BaseSlide](https://reference.aspose.com/slides/php-java/aspose.slides/baseslide/) as a parameter. When executed, the method scans the entire slide for text and returns an array of objects of type [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/), preserving any text formatting.
The following code snippet extracts all the text from the first slide of the presentation:
```php
$slideIndex = 0;
$presentation = new Presentation("demo.pptx");
$arrayClass = new java_class("java.lang.reflect.Array");
try {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$textFrames = SlideUtil::getAllTextBoxes($slide);
$textFrameCount = java_values($arrayClass->getLength($textFrames));
for ($textFrameIndex = 0; $textFrameIndex < $textFrameCount; $textFrameIndex++) {
foreach ($textFrames[$textFrameIndex]->getParagraphs() as $paragraph) {
foreach ($paragraph->getPortions() as $portion) {
$portionText = $portion->getText();
echo($portionText);
$portionFormat = $portion->getPortionFormat();
$fontHeight = $portionFormat->getFontHeight();
echo($fontHeight);
$latinFont = $portionFormat->getLatinFont();
if (!java_is_null($latinFont)) {
$fontName = $latinFont->getFontName();
echo($fontName);
}
}
}
}
} finally {
$presentation->dispose();
}
```
## **Extract Text from a Presentation**
To scan text from the entire presentation, use the [getAllTextFrames](https://reference.aspose.com/slides/php-java/aspose.slides/slideutil/#getAllTextFrames) static method exposed by the [SlideUtil](https://reference.aspose.com/slides/php-java/aspose.slides/slideutil/) class. It accepts two parameters:
1. First, a [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) 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 [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/), including text formatting information. The code below scans the text and formatting details from a presentation, including the master slides.
```php
$presentation = new Presentation("demo.pptx");
$arrayClass = new java_class("java.lang.reflect.Array");
try {
$includeMasterSlides = true;
$textFrames = SlideUtil::getAllTextFrames($presentation, $includeMasterSlides);
$textFrameCount = java_values($arrayClass->getLength($textFrames));
for ($textFrameIndex = 0; $textFrameIndex < $textFrameCount; $textFrameIndex++) {
foreach ($textFrames[$textFrameIndex]->getParagraphs() as $paragraph) {
foreach ($paragraph->getPortions() as $portion) {
$portionText = $portion->getText();
echo($portionText);
$portionFormat = $portion->getPortionFormat();
$fontHeight = $portionFormat->getFontHeight();
echo($fontHeight);
$latinFont = $portionFormat->getLatinFont();
if (!java_is_null($latinFont)) {
$fontName = $latinFont->getFontName();
echo($fontName);
}
}
}
}
} finally {
$presentation->dispose();
}
```
## **Categorized and Fast Text Extraction**
The [PresentationFactory](https://reference.aspose.com/slides/php-java/aspose.slides/presentationfactory/) class also provides methods for extracting all text from presentations:
```php
# The PresentationFactory class exposes these getPresentationText overloads:
# PresentationText getPresentationText(String path, int arrangingMode);
# PresentationText getPresentationText(InputStream stream, int arrangingMode);
# PresentationText getPresentationText(InputStream stream, int arrangingMode, LoadOptions loadOptions);
```
The [TextExtractionArrangingMode](https://reference.aspose.com/slides/php-java/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.
[PresentationText](https://reference.aspose.com/slides/php-java/aspose.slides/presentationtext/) represents the raw text extracted from the presentation. Its `getSlidesText` method returns an array of objects where each object represents the text on the corresponding slide. Each returned object 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.
```php
$presentationPath = "presentation.ppt";
$arrangingMode = TextExtractionArrangingMode::Unarranged;
$presentationText = PresentationFactory::getInstance()->getPresentationText($presentationPath, $arrangingMode);
$slidesText = $presentationText->getSlidesText();
$firstSlideText = $slidesText[0];
echo($firstSlideText->getText());
echo($firstSlideText->getLayoutText());
echo($firstSlideText->getMasterText());
echo($firstSlideText->getNotesText());
echo($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/php-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/php-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 PHP
> Extract images from shapes in PowerPoint and OpenDocument presentations with Aspose.Slides for PHP via Java - quick, code-friendly solution.
Source: https://docs.aspose.com/slides/php-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 [ImageCollection](https://reference.aspose.com/slides/php-java/aspose.slides/imagecollection/) and [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) 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 [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) and its `getBinaryData()` method to preserve the original encoded image data and file type. Use `getImage()` 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.
```php
use aspose\slides\FillType;
use aspose\slides\ImageFormat;
class ShapeReference
{
public $shape;
public $namePart;
public function __construct($shape, $namePart)
{
$this->shape = $shape;
$this->namePart = $namePart;
}
}
function isNullJava($value)
{
return $value == null || java_is_null($value);
}
function saveOriginalImage($image, $outputDirectory, $fileNameBase, &$savedImageHashes)
{
if (isNullJava($image)) {
return false;
}
$imageData = $image->getBinaryData();
$imageBytes = getBinaryString($imageData);
$imageHash = hash("sha256", $imageBytes);
if (isset($savedImageHashes[$imageHash])) {
return false;
}
$savedImageHashes[$imageHash] = true;
$extension = getExtensionFromContentType($image->getContentType());
$fileName = $fileNameBase . "." . $extension;
$outputPath = $outputDirectory . DIRECTORY_SEPARATOR . $fileName;
file_put_contents($outputPath, $imageBytes);
return true;
}
function saveImageAsPng($image, $outputDirectory, $fileNameBase)
{
if (isNullJava($image)) {
return false;
}
$fileName = $fileNameBase . ".png";
$outputPath = $outputDirectory . DIRECTORY_SEPARATOR . $fileName;
$outputImage = $image->getImage();
try {
$outputImage->save($outputPath, ImageFormat::Png);
} finally {
if (!isNullJava($outputImage)) {
$outputImage->dispose();
}
}
return true;
}
function getPictureFillImage($fillFormat)
{
if (isNullJava($fillFormat) || java_values($fillFormat->getFillType()) != FillType::Picture) {
return null;
}
return $fillFormat->getPictureFillFormat()->getPicture()->getImage();
}
function enumerateShapes($shapes, $prefix, $includeGroupedShapes)
{
$shapeReferences = [];
$shapeCount = java_values($shapes->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $shapes->get_Item($shapeIndex);
$displayIndex = $shapeIndex + 1;
$shapeNamePart = $prefix . "_shape_" . $displayIndex;
$shapeReferences[] = new ShapeReference($shape, $shapeNamePart);
if ($includeGroupedShapes && java_instanceof($shape, new JavaClass("com.aspose.slides.GroupShape"))) {
$childShapes = $shape->getShapes();
$childReferences = enumerateShapes(
$childShapes,
$shapeNamePart,
$includeGroupedShapes
);
$shapeReferences = array_merge($shapeReferences, $childReferences);
}
}
return $shapeReferences;
}
function getBinaryString($binaryData)
{
$bytes = java_values($binaryData);
if (is_string($bytes)) {
return $bytes;
}
$binaryString = "";
foreach ($bytes as $byte) {
$binaryString .= chr($byte & 0xff);
}
return $binaryString;
}
function getExtensionFromContentType($contentType)
{
if ($contentType == null || strlen(trim($contentType)) == 0) {
return "bin";
}
$mediaTypeParts = explode(";", $contentType);
$mediaType = strtolower(trim($mediaTypeParts[0]));
if ($mediaType == "image/jpeg") {
return "jpg";
}
if ($mediaType == "image/png") {
return "png";
}
if ($mediaType == "image/gif") {
return "gif";
}
if ($mediaType == "image/bmp") {
return "bmp";
}
if ($mediaType == "image/tiff") {
return "tiff";
}
if ($mediaType == "image/x-emf" || $mediaType == "image/emf") {
return "emf";
}
if ($mediaType == "image/x-wmf" || $mediaType == "image/wmf") {
return "wmf";
}
if ($mediaType == "image/svg+xml") {
return "svg";
}
if (strpos($mediaType, "image/") === 0) {
$extension = substr($mediaType, strlen("image/"));
return makeSafeFileNamePart($extension);
}
return "bin";
}
function makeSafeFileNamePart($value)
{
return preg_replace("/[^A-Za-z0-9._-]/", "_", $value);
}
```
## **Extract Images from Picture Frames**
Use this approach for pictures inserted as standalone objects. A [PictureFrame](https://reference.aspose.com/slides/php-java/aspose.slides/pictureframe/) stores its picture in `getPictureFormat()->getPicture()->getImage()`, which returns a [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) object.
```php
use aspose\slides\Presentation;
$inputPath = "sample.pptx";
$outputDirectory = getcwd() . DIRECTORY_SEPARATOR . "extracted-images";
if (!is_dir($outputDirectory)) {
mkdir($outputDirectory, 0777, true);
}
$savedImageHashes = [];
$presentation = new Presentation($inputPath);
try {
$slideCount = java_values($presentation->getSlides()->size());
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$slideNumber = java_values($slide->getSlideNumber());
$slidePrefix = "slide_" . $slideNumber;
$shapes = $slide->getShapes();
$shapeReferences = enumerateShapes($shapes, $slidePrefix, false);
foreach ($shapeReferences as $shapeReference) {
if (java_instanceof($shapeReference->shape, new JavaClass("com.aspose.slides.PictureFrame"))) {
$pictureFrame = $shapeReference->shape;
$image = $pictureFrame->getPictureFormat()->getPicture()->getImage();
saveOriginalImage($image, $outputDirectory, $shapeReference->namePart, $savedImageHashes);
}
}
}
} finally {
$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/php-java/aspose.slides/filltype/), there is no picture to extract from that fill. The example below handles [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/) objects and saves each image as PNG through [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) and its `getImage()` method.
```php
use aspose\slides\Presentation;
$inputPath = "sample.pptx";
$outputDirectory = getcwd() . DIRECTORY_SEPARATOR . "shape-fill-images";
if (!is_dir($outputDirectory)) {
mkdir($outputDirectory, 0777, true);
}
$presentation = new Presentation($inputPath);
try {
$slideCount = java_values($presentation->getSlides()->size());
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$slideNumber = java_values($slide->getSlideNumber());
$slidePrefix = "slide_" . $slideNumber;
$shapes = $slide->getShapes();
$shapeReferences = enumerateShapes($shapes, $slidePrefix, false);
foreach ($shapeReferences as $shapeReference) {
if (java_instanceof($shapeReference->shape, new JavaClass("com.aspose.slides.AutoShape"))) {
$autoShape = $shapeReference->shape;
$fillFormat = $autoShape->getFillFormat();
$image = getPictureFillImage($fillFormat);
if (!isNullJava($image)) {
saveImageAsPng($image, $outputDirectory, $shapeReference->namePart);
}
}
}
}
} finally {
$presentation->dispose();
}
```
## **Extract Preview Images from OLE Object Frames**
An [OleObjectFrame](https://reference.aspose.com/slides/php-java/aspose.slides/oleobjectframe/) 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.
```php
use aspose\slides\Presentation;
$inputPath = "sample.pptx";
$outputDirectory = getcwd() . DIRECTORY_SEPARATOR . "ole-preview-images";
if (!is_dir($outputDirectory)) {
mkdir($outputDirectory, 0777, true);
}
$savedImageHashes = [];
$presentation = new Presentation($inputPath);
try {
$slideCount = java_values($presentation->getSlides()->size());
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$slideNumber = java_values($slide->getSlideNumber());
$slidePrefix = "slide_" . $slideNumber;
$shapes = $slide->getShapes();
$shapeReferences = enumerateShapes($shapes, $slidePrefix, false);
foreach ($shapeReferences as $shapeReference) {
if (java_instanceof($shapeReference->shape, new JavaClass("com.aspose.slides.OleObjectFrame"))) {
$oleObjectFrame = $shapeReference->shape;
$image = $oleObjectFrame->getSubstitutePictureFormat()->getPicture()->getImage();
if (!isNullJava($image)) {
$fileNameBase = $shapeReference->namePart . "_ole_preview";
saveOriginalImage($image, $outputDirectory, $fileNameBase, $savedImageHashes);
}
}
}
}
} finally {
$presentation->dispose();
}
```
## **Extract Preview Images from Video Frames**
A [VideoFrame](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/) 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.
```php
use aspose\slides\Presentation;
$inputPath = "sample.pptx";
$outputDirectory = getcwd() . DIRECTORY_SEPARATOR . "video-preview-images";
if (!is_dir($outputDirectory)) {
mkdir($outputDirectory, 0777, true);
}
$savedImageHashes = [];
$presentation = new Presentation($inputPath);
try {
$slideCount = java_values($presentation->getSlides()->size());
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$slideNumber = java_values($slide->getSlideNumber());
$slidePrefix = "slide_" . $slideNumber;
$shapes = $slide->getShapes();
$shapeReferences = enumerateShapes($shapes, $slidePrefix, false);
foreach ($shapeReferences as $shapeReference) {
if (java_instanceof($shapeReference->shape, new JavaClass("com.aspose.slides.VideoFrame"))) {
$videoFrame = $shapeReference->shape;
$image = $videoFrame->getPictureFormat()->getPicture()->getImage();
if (!isNullJava($image)) {
$fileNameBase = $shapeReference->namePart . "_video_preview";
saveOriginalImage($image, $outputDirectory, $fileNameBase, $savedImageHashes);
}
}
}
}
} finally {
$presentation->dispose();
}
```
## **Extract Preview Images from Audio Frames**
An [AudioFrame](https://reference.aspose.com/slides/php-java/aspose.slides/audioframe/) can store a thumbnail in `getPictureFormat()->getPicture()->getImage()`. This is the image shown for the audio object on the slide.
```php
use aspose\slides\Presentation;
$inputPath = "sample.pptx";
$outputDirectory = getcwd() . DIRECTORY_SEPARATOR . "audio-preview-images";
if (!is_dir($outputDirectory)) {
mkdir($outputDirectory, 0777, true);
}
$savedImageHashes = [];
$presentation = new Presentation($inputPath);
try {
$slideCount = java_values($presentation->getSlides()->size());
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$slideNumber = java_values($slide->getSlideNumber());
$slidePrefix = "slide_" . $slideNumber;
$shapes = $slide->getShapes();
$shapeReferences = enumerateShapes($shapes, $slidePrefix, false);
foreach ($shapeReferences as $shapeReference) {
if (java_instanceof($shapeReference->shape, new JavaClass("com.aspose.slides.AudioFrame"))) {
$audioFrame = $shapeReference->shape;
$image = $audioFrame->getPictureFormat()->getPicture()->getImage();
if (!isNullJava($image)) {
$fileNameBase = $shapeReference->namePart . "_audio_preview";
saveOriginalImage($image, $outputDirectory, $fileNameBase, $savedImageHashes);
}
}
}
}
} finally {
$presentation->dispose();
}
```
## **Extract Images from Zoom Objects**
[ZoomFrame](https://reference.aspose.com/slides/php-java/aspose.slides/zoomframe/) and [SectionZoomFrame](https://reference.aspose.com/slides/php-java/aspose.slides/sectionzoomframe/) shapes can use custom images. Read `getZoomImage()` from the zoom frame.
```php
use aspose\slides\Presentation;
$inputPath = "sample.pptx";
$outputDirectory = getcwd() . DIRECTORY_SEPARATOR . "zoom-images";
if (!is_dir($outputDirectory)) {
mkdir($outputDirectory, 0777, true);
}
$savedImageHashes = [];
$presentation = new Presentation($inputPath);
try {
$slideCount = java_values($presentation->getSlides()->size());
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$slideNumber = java_values($slide->getSlideNumber());
$slidePrefix = "slide_" . $slideNumber;
$shapes = $slide->getShapes();
$shapeReferences = enumerateShapes($shapes, $slidePrefix, false);
foreach ($shapeReferences as $shapeReference) {
if (java_instanceof($shapeReference->shape, new JavaClass("com.aspose.slides.ZoomFrame"))) {
$zoomFrame = $shapeReference->shape;
$image = $zoomFrame->getZoomImage();
if (!isNullJava($image)) {
$fileNameBase = $shapeReference->namePart . "_zoom";
saveOriginalImage($image, $outputDirectory, $fileNameBase, $savedImageHashes);
continue;
}
}
if (java_instanceof($shapeReference->shape, new JavaClass("com.aspose.slides.SectionZoomFrame"))) {
$sectionZoomFrame = $shapeReference->shape;
$image = $sectionZoomFrame->getZoomImage();
if (!isNullJava($image)) {
$fileNameBase = $shapeReference->namePart . "_section_zoom";
saveOriginalImage($image, $outputDirectory, $fileNameBase, $savedImageHashes);
continue;
}
}
}
}
} finally {
$presentation->dispose();
}
```
## **Extract Images from Summary Zoom Frames**
A [SummaryZoomFrame](https://reference.aspose.com/slides/php-java/aspose.slides/summaryzoomframe/) is also a shape. Its section items can use custom images, exposed through each summary zoom section's `getZoomImage()` method.
```php
use aspose\slides\Presentation;
$inputPath = "sample.pptx";
$outputDirectory = getcwd() . DIRECTORY_SEPARATOR . "summary-zoom-images";
if (!is_dir($outputDirectory)) {
mkdir($outputDirectory, 0777, true);
}
$savedImageHashes = [];
$presentation = new Presentation($inputPath);
try {
$slideCount = java_values($presentation->getSlides()->size());
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$slideNumber = java_values($slide->getSlideNumber());
$slidePrefix = "slide_" . $slideNumber;
$shapes = $slide->getShapes();
$shapeReferences = enumerateShapes($shapes, $slidePrefix, false);
foreach ($shapeReferences as $shapeReference) {
if (java_instanceof($shapeReference->shape, new JavaClass("com.aspose.slides.SummaryZoomFrame"))) {
$summaryZoomFrame = $shapeReference->shape;
$summaryZoomCollection = $summaryZoomFrame->getSummaryZoomCollection();
$sectionCount = java_values($summaryZoomCollection->size());
for ($sectionIndex = 0; $sectionIndex < $sectionCount; $sectionIndex++) {
$summaryZoomSection = $summaryZoomCollection->get_Item($sectionIndex);
$image = $summaryZoomSection->getZoomImage();
if (!isNullJava($image)) {
$displayIndex = $sectionIndex + 1;
$fileNameBase = $shapeReference->namePart . "_summary_zoom_" . $displayIndex;
saveOriginalImage($image, $outputDirectory, $fileNameBase, $savedImageHashes);
}
}
}
}
}
} finally {
$presentation->dispose();
}
```
## **Extract Images from Table Shapes**
A [Table](https://reference.aspose.com/slides/php-java/aspose.slides/table/) is a shape. Images in a table are usually stored as picture fills in table cells.
```php
use aspose\slides\Presentation;
$inputPath = "sample.pptx";
$outputDirectory = getcwd() . DIRECTORY_SEPARATOR . "table-images";
if (!is_dir($outputDirectory)) {
mkdir($outputDirectory, 0777, true);
}
$savedImageHashes = [];
$presentation = new Presentation($inputPath);
try {
$slideCount = java_values($presentation->getSlides()->size());
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$slideNumber = java_values($slide->getSlideNumber());
$slidePrefix = "slide_" . $slideNumber;
$shapes = $slide->getShapes();
$shapeReferences = enumerateShapes($shapes, $slidePrefix, true);
foreach ($shapeReferences as $shapeReference) {
if (java_instanceof($shapeReference->shape, new JavaClass("com.aspose.slides.Table"))) {
$table = $shapeReference->shape;
$rowCount = java_values($table->getRows()->size());
$columnCount = java_values($table->getColumns()->size());
for ($rowIndex = 0; $rowIndex < $rowCount; $rowIndex++) {
for ($columnIndex = 0; $columnIndex < $columnCount; $columnIndex++) {
$cell = $table->get_Item($columnIndex, $rowIndex);
$fillFormat = $cell->getCellFormat()->getFillFormat();
$image = getPictureFillImage($fillFormat);
if (!isNullJava($image)) {
$displayRow = $rowIndex + 1;
$displayColumn = $columnIndex + 1;
$fileNameBase = $shapeReference->namePart . "_cell_" . $displayRow . "_" . $displayColumn;
saveOriginalImage($image, $outputDirectory, $fileNameBase, $savedImageHashes);
}
}
}
}
}
}
} finally {
$presentation->dispose();
}
```
## **Extract Images from Chart Shapes**
A [Chart](https://reference.aspose.com/slides/php-java/aspose.slides/chart/) is a shape. The example below extracts an image from the chart area's picture fill.
```php
use aspose\slides\Presentation;
$inputPath = "sample.pptx";
$outputDirectory = getcwd() . DIRECTORY_SEPARATOR . "chart-images";
if (!is_dir($outputDirectory)) {
mkdir($outputDirectory, 0777, true);
}
$savedImageHashes = [];
$presentation = new Presentation($inputPath);
try {
$slideCount = java_values($presentation->getSlides()->size());
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$slideNumber = java_values($slide->getSlideNumber());
$slidePrefix = "slide_" . $slideNumber;
$shapes = $slide->getShapes();
$shapeReferences = enumerateShapes($shapes, $slidePrefix, true);
foreach ($shapeReferences as $shapeReference) {
if (java_instanceof($shapeReference->shape, new JavaClass("com.aspose.slides.Chart"))) {
$chart = $shapeReference->shape;
$fillFormat = $chart->getFillFormat();
$image = getPictureFillImage($fillFormat);
if (!isNullJava($image)) {
$fileNameBase = $shapeReference->namePart . "_chart_area";
saveOriginalImage($image, $outputDirectory, $fileNameBase, $savedImageHashes);
}
}
}
}
} finally {
$presentation->dispose();
}
```
## **Extract Images from SmartArt Shapes**
A [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/) 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.
```php
use aspose\slides\Presentation;
$inputPath = "sample.pptx";
$outputDirectory = getcwd() . DIRECTORY_SEPARATOR . "smartart-images";
if (!is_dir($outputDirectory)) {
mkdir($outputDirectory, 0777, true);
}
$savedImageHashes = [];
$presentation = new Presentation($inputPath);
try {
$slideCount = java_values($presentation->getSlides()->size());
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$slideNumber = java_values($slide->getSlideNumber());
$slidePrefix = "slide_" . $slideNumber;
$shapes = $slide->getShapes();
$shapeReferences = enumerateShapes($shapes, $slidePrefix, true);
foreach ($shapeReferences as $shapeReference) {
if (java_instanceof($shapeReference->shape, new JavaClass("com.aspose.slides.SmartArt"))) {
$smartArt = $shapeReference->shape;
$allNodes = $smartArt->getAllNodes();
$nodeCount = java_values($allNodes->size());
for ($nodeIndex = 0; $nodeIndex < $nodeCount; $nodeIndex++) {
$node = $allNodes->get_Item($nodeIndex);
$bulletFillFormat = $node->getBulletFillFormat();
$bulletImage = getPictureFillImage($bulletFillFormat);
if (!isNullJava($bulletImage)) {
$displayNode = $nodeIndex + 1;
$fileNameBase = $shapeReference->namePart . "_smartart_node_" . $displayNode . "_bullet";
saveOriginalImage($bulletImage, $outputDirectory, $fileNameBase, $savedImageHashes);
}
$nodeShapes = $node->getShapes();
$nodeShapeCount = java_values($nodeShapes->size());
for ($nodeShapeIndex = 0; $nodeShapeIndex < $nodeShapeCount; $nodeShapeIndex++) {
$nodeShape = $nodeShapes->get_Item($nodeShapeIndex);
$fillFormat = $nodeShape->getFillFormat();
$image = getPictureFillImage($fillFormat);
if (!isNullJava($image)) {
$displayNode = $nodeIndex + 1;
$displayNodeShape = $nodeShapeIndex + 1;
$fileNameBase = $shapeReference->namePart . "_smartart_node_" . $displayNode . "_shape_" . $displayNodeShape;
saveOriginalImage($image, $outputDirectory, $fileNameBase, $savedImageHashes);
}
}
}
}
}
}
} finally {
$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 [GroupShape](https://reference.aspose.com/slides/php-java/aspose.slides/groupshape/) 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.
```php
use aspose\slides\Presentation;
$inputPath = "sample.pptx";
$outputDirectory = getcwd() . DIRECTORY_SEPARATOR . "all-shape-images";
if (!is_dir($outputDirectory)) {
mkdir($outputDirectory, 0777, true);
}
$savedImageHashes = [];
$presentation = new Presentation($inputPath);
try {
$slideCount = java_values($presentation->getSlides()->size());
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$slideNumber = java_values($slide->getSlideNumber());
$slidePrefix = "slide_" . $slideNumber;
$shapes = $slide->getShapes();
$shapeReferences = enumerateShapes($shapes, $slidePrefix, true);
foreach ($shapeReferences as $shapeReference) {
if (java_instanceof($shapeReference->shape, new JavaClass("com.aspose.slides.OleObjectFrame"))) {
$oleObjectFrame = $shapeReference->shape;
$image = $oleObjectFrame->getSubstitutePictureFormat()->getPicture()->getImage();
if (!isNullJava($image)) {
$fileNameBase = $shapeReference->namePart . "_ole_preview";
saveOriginalImage($image, $outputDirectory, $fileNameBase, $savedImageHashes);
}
continue;
}
if (java_instanceof($shapeReference->shape, new JavaClass("com.aspose.slides.VideoFrame"))) {
$videoFrame = $shapeReference->shape;
$image = $videoFrame->getPictureFormat()->getPicture()->getImage();
if (!isNullJava($image)) {
$fileNameBase = $shapeReference->namePart . "_video_preview";
saveOriginalImage($image, $outputDirectory, $fileNameBase, $savedImageHashes);
}
continue;
}
if (java_instanceof($shapeReference->shape, new JavaClass("com.aspose.slides.AudioFrame"))) {
$audioFrame = $shapeReference->shape;
$image = $audioFrame->getPictureFormat()->getPicture()->getImage();
if (!isNullJava($image)) {
$fileNameBase = $shapeReference->namePart . "_audio_preview";
saveOriginalImage($image, $outputDirectory, $fileNameBase, $savedImageHashes);
}
continue;
}
if (java_instanceof($shapeReference->shape, new JavaClass("com.aspose.slides.PictureFrame"))) {
$pictureFrame = $shapeReference->shape;
$image = $pictureFrame->getPictureFormat()->getPicture()->getImage();
saveOriginalImage($image, $outputDirectory, $shapeReference->namePart, $savedImageHashes);
continue;
}
if (java_instanceof($shapeReference->shape, new JavaClass("com.aspose.slides.AutoShape"))) {
$autoShape = $shapeReference->shape;
$fillFormat = $autoShape->getFillFormat();
$image = getPictureFillImage($fillFormat);
if (!isNullJava($image)) {
saveOriginalImage($image, $outputDirectory, $shapeReference->namePart, $savedImageHashes);
}
}
}
}
} finally {
$presentation->dispose();
}
```
## **Edge Cases and Practical Notes**
- **Duplicate images:** Multiple shapes may reference the same image or separate images with identical bytes. Hash [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) data from `getBinaryData()` before writing files if you want one output file per unique image.
- **Original data vs. converted output:** Saving [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) data from `getBinaryData()` preserves the embedded JPEG, PNG, GIF, SVG, EMF, or WMF data. Saving the image returned by `getImage()` 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/php-java/aspose.slides/filltype/) before reading `getPictureFillFormat()`.
- **Grouped shapes:** The top-level slide shape collection does not flatten groups. Recursively inspect [GroupShape](https://reference.aspose.com/slides/php-java/aspose.slides/groupshape/) content through `getShapes()` when grouped content matters.
- **OLE object previews:** An [OleObjectFrame](https://reference.aspose.com/slides/php-java/aspose.slides/oleobjectframe/) 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:** A [VideoFrame](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/) 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 [AudioFrame](https://reference.aspose.com/slides/php-java/aspose.slides/audioframe/) 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 [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) objects through `getZoomImage()`.
- **Nested shape models:** Table, chart, and SmartArt objects implement [Shape](https://reference.aspose.com/slides/php-java/aspose.slides/shape/), but their images are often stored in nested table cell, chart element, or SmartArt node formatting objects.
- **Cropped or transformed pictures:** Accessing [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) 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 [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) object and write the data from `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 [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) and its `getImage()` method, and then call `save()` with [ImageFormat](https://reference.aspose.com/slides/php-java/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 [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) data from `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 [VideoFrame](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/) 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 [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) 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 [OleObjectFrame](https://reference.aspose.com/slides/php-java/aspose.slides/oleobjectframe/). 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 PHP tools to power search, analytics, and automation.
Source: https://docs.aspose.com/slides/php-java/extracting-text-from-ppt-pptx-odp-on-cloud-platforms/
Updated: 2025-12-01
---
lastmod: 2025-12-01T11:46:27+04:00
title: Extracting Text from PPT, PPTX, ODP
type: docs
weight: 40
url: /php-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
- PHP
- Aspose.Slides
description: "Learn essential ways to extract and process slide text from PPT, PPTX and ODP on major cloud platforms, using PHP tools to power search, analytics, and automation."
---
## Related articles
- [Slides on Cloud Platforms](https://docs.aspose.com/slides/php-java/slides-on-cloud-platforms/)
- [Slide Text Extraction: PPT, PPTX, ODP Essentials](https://docs.aspose.com/slides/php-java/slide-text-extraction-ppt-pptx-odp-essentials/)
# Manage Fallback Fonts for Presentations in PHP
> See how Aspose.Slides for PHP uses fallback fonts to keep text readable in PowerPoint and OpenDocument presentations when original fonts aren’t available.
Source: https://docs.aspose.com/slides/php-java/fallback-font/
Updated: 2026-08-02
## **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.
## **Fallback Font**
Fallback font is used when the font specified for text is available in the system, but this font does not contain a necessary glyph. In this case, it is possible to use one of the specified fallback fonts for the glyph replacement.
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/php-java/create-fallback-font)
- [Create Fallback Fonts Collection](https://docs.aspose.com/slides/php-java/create-fallback-fonts-collection)
- [Render Presentation with Fallback Font](https://docs.aspose.com/slides/php-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/php-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 PHP](https://docs.aspose.com/slides/php-java/create-fallback-font/)
- [Configure Fallback Font Collections in PHP](https://docs.aspose.com/slides/php-java/create-fallback-fonts-collection/)
- [Master PowerPoint Fonts in PHP](https://docs.aspose.com/slides/php-java/powerpoint-fonts/)
# FAQ
> Get answers to FAQ on Aspose.Slides for PHP via Java, covering PowerPoint and OpenDocument support, installation guidance, licensing, troubleshooting.
Source: https://docs.aspose.com/slides/php-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 PHP via Java support?
**A**: Aspose.Slides for PHP via Java supports the file formats described in [Supported File Formats](https://docs.aspose.com/slides/php-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 PHP via 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/php-java/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 PHP via 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 PHP via Java provides the [SlideUtil](https://reference.aspose.com/slides/php-java/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/php-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 [Cell](https://reference.aspose.com/slides/php-java/aspose.slides/cell/) class. 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 PHP via 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/php-java/aspose.slides/fontsloader/) class as shown below:
```php
$folders = ["path_to_a_folder_with_fonts"];
FontsLoader::loadExternalFonts($folders);
```
# Features Overview
> Discover Aspose.Slides for PHP via Java: a powerful API to create, edit, automate, and convert PowerPoint and OpenDocument presentations efficiently.
Source: https://docs.aspose.com/slides/php-java/features-overview/
Updated: 2026-08-31
## **Supported Platforms**
Aspose.Slides for PHP via Java is a platform independent API. It can be used on any platform (Windows, Linux, MacOS, etc.) where PHP 7 or higher is installed. Oracle JDK 7 or higher is another requirement.
## **File Formats and Conversions**
Aspose.Slides for PHP via Java supports most PowerPoint document formats. It also lets you export them to the popular file formats organizations use and share among themselves. Go through these details:
|**Feature**|**Description**|
| :- | :- |
|Microsoft PowerPoint (PPT)|Aspose.Slides for PHP via Java provides the fastest processing for this presentation document format.|
|PPT to PPTX conversion|Aspose.Slides for PHP via Java supports PPT to PPTX conversion|
|Portable Document Format (PDF)|You can export all supported file formats to Adobe Portable Document Format (PDF) documents with a single method.|
|XML Parser Specification (XPS)|You can export all supported file formats to XML Parser Specification (XPS) documents with a single method.|
|Tagged Image File Format (TIFF)|You can export all supported presentation file formats to Tagged Image File Format (TIFF).|
|PPTX To HTML Conversion|Aspose.Slides for PHP via Java supports the conversion of PresentationEx to HTML format.|
## **Presentation Rendering**
Aspose.Slides for PHP via Java supports high fidelity rendering of slides in presentation to different graphics formats. Go through these details:
|**Feature**|**Description**|
| :- | :- |
|Java Supported Image Formats|Using Aspose.Slides for PHP via Java, you get to render presentation slides and images on slides to all the Java supported graphics formats such as TIFF, PNG, BMP, JPEG, GIF.|
|SVG Format|Aspose.Slides for PHP via Java also provides built-in methods that allow you to export presentation slides to Scalable Vector Graphics (SVG) formats.|
## **Content Features**
Aspose.Slides for PHP via Java allows you to access, modify, or create almost all the items or contents of presentation documents. Go through these details:
|**Feature**|**Description**|
| :- | :- |
|Master Slides|The master Slides define the layout of the normal slides. Aspose.Slides for PHP via Java allows you to access and modify the Master Slides of presentation documents|
|Normal Slides|With Aspose.Slides for PHP via Java, you can create new slides of different types; you also get to access and modify existing slides in the presentations|
|Cloning / Copying Slides|There are built-in methods provided by Aspose.Slides for PHP via Java that allow you to clone or copy existing slides within a presentation. You also get to use copied and cloned slides from one presentation to another. Since a slide inherits its layout from the master slide, the built-in cloning methods automatically copy the master on cloning|
|Managing Slides sections|Methods to organize slides in different sections inside a presentation|
|Place Holders and Text Holders|You can access the place holders and text holders in a slide. Moreover, you can create a slide with text holders from scratch using the appropriate method|
|Header and Footers|Aspose.Slides for PHP via Java facilitates the handling of headers/footers in slides|
|Notes in Slides|With Aspose.Slides for PHP via Java, you can access and modify notes associated with a slide and also add new notes|
|Finding a Shape|You can also find a particular shape from a slide using the alternative text associated with the shape|
|Backgrounds|Aspose.Slides for PHP via Java allows you to work with backgrounds associated with a master or normal slide in a presentation|
|Text Boxes|Text boxes can be created from scratch. You can access existing text boxes. You also get to modify their texts without losing the original text format|
|Rectangle Shapes|You can create or modify rectangle shapes with Aspose.Slides for PHP via Java|
|Poly Line Shapes|You can create or modify poly line shapes with Aspose.Slides for PHP via Java|
|Ellipse Shapes|You can create or modify Ellipse shapes with Aspose.Slides for PHP via Java|
|Group Shapes| Aspose.Slides for PHP via Java supports group shapes |
|Auto Shapes|Aspose.Slides for PHP via Java supports auto shapes|
|SmartArt|Aspose.Slides for PHP via Java provides support for SmartArt shapes in MS PowerPoint|
|Charts|Aspose.Slides for PHP via Java provides support for MSO Charts in PowerPoint|
|Shapes Serialization| Aspose.Slides for PHP via Java supports a large number of shapes. When Aspose.Slides for PHP via Java lacks support for a shape, you can use a serialization method through which you get to serialize that shape from an existing slide. This way, you get to use the shape further as per your requirements |
|Picture Frames|You can manage pictures in picture frames with Aspose.Slides for PHP via Java|
|Audio Frames|You can link or embed audio files in audio frames on slides with Aspose.Slides for PHP via Java|
|Video Frames| You get to handle video files in video frames. Aspose.Slides for PHP via Java also provides support for linked and embedded videos |
|OLE Frame|You get to manage OLE Objects in OLE frames with Aspose.Slides for PHP via Java|
|Tables|Aspose.Slides for PHP via Java supports tables in slides|
|ActiveX Controls|Support for ActiveX controls|
|VBA Macros|Support for managing VBA macros inside presentations.|
|Text Frame|You get to access the text with any shape through the text frame associated with that shape|
|Text Scanning|You get to scan text in a presentation at the presentation or slide level through built-in scanning methods.|
|Animations|You get to apply animations on shapes|
|Slide Shows|Aspose.Slides for PHP via Java supports slide shows and slide transitions|
## **Formatting Features**
With Aspose.Slides for PHP via Java, you can format texts and shapes on slides in presentations. Go through these details:
|**Feature**|**Description**|
| :- | :- |
|Text Formatting|
In Aspose.Slides for PHP via Java, you can manage texts through the text frames associated with the shapes. Hence, you get to format texts using the paragraphs and portions associated with the text frames. These text elements can be formatted through Aspose.Slides for PHP via Java.
- Font Type
- Font Size
- Font Color
- Font Shades
- Paragraph Alignment
- Paragraph Bulleting
- Paragraph Orientation
|
|Shape Formatting|
In Aspose.Slides for PHP via Java, the basic element of a slide is a shape. You can format these shape elements with Aspose.Slides for PHP via Java:
- Position
- Size
- Line
- Fill (including Pattern, Gradient, Solid)
- Text
- Image
|
## **FAQ**
### Do I need to install Microsoft PowerPoint on the server/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/php-java/aspose.slides/presentation/) object must not be used by [multiple threads](https://docs.aspose.com/slides/php-java/multithreading/) at the same time.
### Are file passwords and encryption supported?
Yes. [You can](https://docs.aspose.com/slides/php-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 font packages in Linux containers?
Yes. It is recommended to install common font packages and/or explicitly [specify font directories](https://docs.aspose.com/slides/php-java/custom-font/) in your application to avoid unexpected substitutions.
### Are there limitations in the evaluation version?
In [evaluation mode](https://docs.aspose.com/slides/php-java/licensing/), a watermark is added to the output and certain limitations apply; 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/HTML → PPTX) supported?
Yes. You can add [PDF pages and HTML content](https://docs.aspose.com/slides/php-java/import-presentation/) to a presentation, turning them into slides.
## Related articles
- [Product Overview](https://docs.aspose.com/slides/php-java/product-overview/)
# File Formats and Conversions
>
Source: https://docs.aspose.com/slides/php-java/file-formats-and-conversions/
Updated: 2024-10-02
---
lastmod: 2024-10-02T16:07:48+04:00
title: File Formats and Conversions
type: docs
weight: 40
url: /php-java/file-formats-and-conversions/
---
# Extract Flash Objects from Presentations in PHP
> Learn how to extract Flash objects from PowerPoint and OpenDocument slides with Aspose.Slides for PHP via Java, complete code samples and best practices.
Source: https://docs.aspose.com/slides/php-java/flash/
Updated: 2026-08-02
## **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 PHP via 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.
```php
# Instantiate Presentation class that represents the PPTX
$pres = new Presentation();
try {
$controls = $pres->getSlides()->get_Item(0)->getControls();
$flashControl = null;
foreach($controls as $control) {
if (java_values($control->getName()) == "ShockwaveFlash1") {
$flashControl = $control;
}
}
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **FAQ**
### What presentation formats are supported when extracting Flash content?
[Aspose.Slides supports](https://docs.aspose.com/slides/php-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/php-java/convert-powerpoint-to-html/)/[HTML5](https://docs.aspose.com/slides/php-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/php-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 PHP](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-swf-flash/)
- [Manage Media Files in PHP](https://docs.aspose.com/slides/php-java/manage-media-files/)
# Streamline Font Replacement in Presentations Using PHP
> Seamlessly replace fonts in Aspose.Slides for PHP via Java to ensure consistent typography in PowerPoint and OpenDocument presentations.
Source: https://docs.aspose.com/slides/php-java/font-replacement/
Updated: 2026-08-02
## **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 PHP code demonstrates font replacement:
```php
# Loads a presentation
$pres = new Presentation("Fonts.pptx");
try {
# Loads the source font that will be replaced
$sourceFont = new FontData("Arial");
# Loads the new font
$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 (!java_is_null($pres)) {
$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/php-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/php-java/font-substitution/) is a rule like "if the font is unavailable, use X." [Fallback](https://docs.aspose.com/slides/php-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/php-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/php-java/aspose.slides/fontsmanager/): it provides a list of the [families in use](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/getfonts/) and information about [substitutions/"unknown" fonts](https://reference.aspose.com/slides/php-java/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/php-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/php-java/custom-font/) from user folders for use during [rendering and export](https://docs.aspose.com/slides/php-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/php-java/fallback-font/) to cover the missing characters.
## Related articles
- [Font Selection Sequence in Aspose.Slides for PHP](https://docs.aspose.com/slides/php-java/font-selection-sequence/)
- [Configure Font Substitution in Presentations Using PHP](https://docs.aspose.com/slides/php-java/font-substitution/)
- [Manage Fallback Fonts for Presentations in PHP](https://docs.aspose.com/slides/php-java/fallback-font/)
# Font Selection Sequence in Aspose.Slides for PHP
> Discover how Aspose.Slides for PHP via Java selects fonts, ensuring crisp, consistent presentation of PPT, PPTX and ODP files — improve your slides now.
Source: https://docs.aspose.com/slides/php-java/font-selection-sequence/
Updated: 2026-11-08
## **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/php-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/php-java/font-replacement/) and [**Font Substitution**](https://docs.aspose.com/slides/php-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/php-java/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/php-java/custom-font/).
When additional fonts are placed within a presentation, they are called [**Embedded fonts**](https://docs.aspose.com/slides/php-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**.
[](https://docs.aspose.com/slides/php-java/font-selection-sequence/visual-font-selection-sequence-503e4c9ad302.svg)
*Resolve the theme token to a family first. An unavailable family can trigger substitution, while a missing character can trigger glyph fallback.*
## **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/php-java/aspose.slides/fontsmanager/), so you can decide whether to [embed](https://docs.aspose.com/slides/php-java/embedded-font/), [replace](https://docs.aspose.com/slides/php-java/font-replacement/), or add [external sources](https://docs.aspose.com/slides/php-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/php-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/php-java/font-replacement/) and font [fallback rules](https://docs.aspose.com/slides/php-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
- [Streamline Font Replacement in Presentations Using PHP](https://docs.aspose.com/slides/php-java/font-replacement/)
- [Configure Font Substitution in Presentations Using PHP](https://docs.aspose.com/slides/php-java/font-substitution/)
- [Master PowerPoint Fonts in PHP](https://docs.aspose.com/slides/php-java/powerpoint-fonts/)
# Configure Font Substitution in Presentations Using PHP
> Configure font substitution rules and inspect substituted fonts in Aspose.Slides for PHP via Java when rendering or converting PowerPoint and OpenDocument presentations.
Source: https://docs.aspose.com/slides/php-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/php-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 [FontsManager::getSubstitutions](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/getsubstitutions/) method to determine which fonts will be substituted when the presentation is rendered. The method returns [FontSubstitutionInfo](https://reference.aspose.com/slides/php-java/aspose.slides/fontsubstitutioninfo/) objects that identify the original and substituted font names.
The following PHP example lists all font substitutions for a presentation:
```php
use aspose\slides\Presentation;
$presentation = new Presentation("Presentation.pptx");
try {
$enumerator = $presentation->getFontsManager()->getSubstitutions()->iterator();
try {
while (java_values($enumerator->hasNext())) {
$substitution = $enumerator->next();
$originalFontName = java_values($substitution->getOriginalFontName());
$substitutedFontName = java_values($substitution->getSubstitutedFontName());
echo $originalFontName . " -> " . $substitutedFontName . PHP_EOL;
}
} finally {
$enumerator->dispose();
}
} finally {
$presentation->dispose();
}
```
## **Get Font Substitutions for Selected Slides**
Use the [FontsManager::getSubstitutions](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/getsubstitutions/) 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/php-java/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/php-java/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/php-java/aspose.slides/fontsubstitutioninfo/) object containing the original and substituted font names. The result reflects the current font environment, configured fallback rules, substitution rules stored in a [FontSubstRuleCollection](https://reference.aspose.com/slides/php-java/aspose.slides/fontsubstrulecollection/), and [externally loaded fonts](https://docs.aspose.com/slides/php-java/custom-font/).
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:
```php
use aspose\slides\Presentation;
$presentation = new Presentation("Presentation.pptx");
try {
$selectedSlides = [1, 3, 5];
$substitutions = [];
$enumerator = $presentation->getFontsManager()->getSubstitutions($selectedSlides)->iterator();
try {
while (java_values($enumerator->hasNext())) {
$substitutions[] = $enumerator->next();
}
} finally {
$enumerator->dispose();
}
echo "Substitutions for the selected slides:" . PHP_EOL;
foreach ($substitutions as $substitution) {
$originalFontName = java_values($substitution->getOriginalFontName());
$substitutedFontName = java_values($substitution->getSubstitutedFontName());
echo $originalFontName . " -> " . $substitutedFontName . PHP_EOL;
}
$sortedPreflightEntries = [];
foreach ($substitutions as $substitution) {
$originalFontName = java_values($substitution->getOriginalFontName());
$substitutedFontName = java_values($substitution->getSubstitutedFontName());
$entry = $originalFontName . " -> " . $substitutedFontName;
$sortedPreflightEntries[strtolower($entry)] = $entry;
}
ksort($sortedPreflightEntries, SORT_NATURAL | SORT_FLAG_CASE);
echo "Deduplicated font preflight report:" . PHP_EOL;
foreach ($sortedPreflightEntries as $entry) {
echo $entry . PHP_EOL;
}
} finally {
$presentation->dispose();
}
```
The [FontsManager](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/) class provides both overloads. Choose one according to the scope of the rendering operation:
| Overload | Use it when |
|---|---|
| [getSubstitutions](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/getsubstitutions/) with no arguments | You need substitutions for the entire presentation. |
| [getSubstitutions](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/getsubstitutions/) 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/php-java/aspose.slides/fontsubstrule/) with the [WhenInaccessible](https://reference.aspose.com/slides/php-java/aspose.slides/fontsubstcondition/) condition.
4. Add the rule to a [FontSubstRuleCollection](https://reference.aspose.com/slides/php-java/aspose.slides/fontsubstrulecollection/).
5. Assign the collection by using the [FontsManager::setFontSubstRuleList](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/setfontsubstrulelist/) method.
6. Render or convert the presentation.
The following PHP 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.
```php
use aspose\slides\FontData;
use aspose\slides\FontSubstCondition;
use aspose\slides\FontSubstRule;
use aspose\slides\FontSubstRuleCollection;
use aspose\slides\ImageFormat;
use aspose\slides\Presentation;
$presentation = new Presentation("Fonts.pptx");
try {
$sourceFont = new FontData("SomeRareFont");
$substituteFont = new FontData("Arial");
$substitutionRule = new FontSubstRule($sourceFont, $substituteFont, FontSubstCondition::WhenInaccessible);
$substitutionRules = new FontSubstRuleCollection();
$substitutionRules->add($substitutionRule);
$presentation->getFontsManager()->setFontSubstRuleList($substitutionRules);
$image = $presentation->getSlides()->get_Item(0)->getImage(1.0, 1.0);
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/php-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/php-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/php-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/php-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/php-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/php-java/custom-font/), and [embed fonts](https://docs.aspose.com/slides/php-java/embedded-font/) when licensing permits. You can also call [FontsManager::getSubstitutions](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/getsubstitutions/) before export to identify unexpected substitutions.
## Related articles
- [Font Selection Sequence in Aspose.Slides for PHP](https://docs.aspose.com/slides/php-java/font-selection-sequence/)
- [Streamline Font Replacement in Presentations Using PHP](https://docs.aspose.com/slides/php-java/font-replacement/)
- [Configure Fallback Font Collections in PHP](https://docs.aspose.com/slides/php-java/create-fallback-fonts-collection/)
# 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 PHP via Java, streamlining visual workflows.
Source: https://docs.aspose.com/slides/php-java/get-the-entire-presentation-slide-background-as-an-image/
Updated: 2026-08-02
## **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. 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 PHP via 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/php-java/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.
```php
$slideIndex = 0;
$imageScale = 1;
$presentation = new Presentation("sample.pptx");
$slideSize = $presentation->getSlideSize()->getSize();
$slide = $presentation->getSlides()->get_Item($slideIndex);
$tempPresentation = new Presentation();
$slideWidth = $slideSize->getWidth();
$slideHeight = $slideSize->getHeight();
$tempPresentation->getSlideSize()->setSize($slideWidth, $slideHeight, SlideSizeScaleType::DoNotScale);
$clonedSlide = $tempPresentation->getSlides()->addClone($slide);
$clonedSlide->getShapes()->clear();
$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/php-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/php-java/watermark/) shape or image on a working [copy of the slide](https://docs.aspose.com/slides/php-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/php-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/php-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
> Get started with Aspose.Slides for PHP via Java: install, create, edit, and convert presentations with code—supporting PowerPoint and OpenDocument formats.
Source: https://docs.aspose.com/slides/php-java/getting-started/
Updated: 2025-12-01
---
lastmod: 2025-12-01T11:46:27+04:00
title: Getting Started
type: docs
weight: 10
url: /php-java/getting-started/
keywords:
- getting started
- PPT processing
- PPTX processing
- ODP processing
- PowerPoint
- OpenDocument
- presentation
- PHP
- Aspose.Slides
description: "Get started with Aspose.Slides for PHP via Java: install, create, edit, and convert presentations with code—supporting PowerPoint and OpenDocument formats."
---
# Group Presentation Shapes in PHP
> Learn to group and ungroup shapes in PowerPoint decks using Aspose.Slides for PHP via Java — fast, step-by-step guide with free code.
Source: https://docs.aspose.com/slides/php-java/group/
Updated: 2026-08-02
## **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 PHP via 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 PHP via Java:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/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.
```php
# Instantiate Presentation class
$pres = new Presentation();
try {
# Get the first slide
$sld = $pres->getSlides()->get_Item(0);
# Accessing the shape collection of slides
$slideShapes = $sld->getShapes();
# Adding a group shape to the slide
$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 (!java_is_null($pres)) {
$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 PHP via Java:
1. Instantiate [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation) class that represents PPTX file.
1. Obtain the reference of a slide by using its Index.
1. Access the shape collection of slides.
1. Access the group shape.
1. Access the [Alternative Text](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#getAlternativeText) property.
The example below accesses alternative text of group shape.
```php
# Instantiate Presentation class that represents PPTX file
$pres = new Presentation("AltText.pptx");
try {
# Get the first slide
$sld = $pres->getSlides()->get_Item(0);
for($i = 0; $i < java_values($sld->getShapes()->size()) ; $i++) {
# Accessing the shape collection of slides
$shape = $sld->getShapes()->get_Item($i);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.GroupShape"))) {
# Accessing the group shape.
$grphShape = $shape;
for($j = 0; $j < java_values($grphShape->getShapes()->size()) ; $j++) {
$shape2 = $grphShape->getShapes()->get_Item($j);
# Accessing the AltText property
echo($shape2->getAlternativeText());
}
}
}
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **FAQ**
### Is nested grouping (a group inside a group) supported?
Yes. [GroupShape](https://reference.aspose.com/slides/php-java/aspose.slides/groupshape/) has a [getParentGroup](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/groupshape/)’s [getZOrderPosition](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/groupshape/getgroupshapelock/), which lets you restrict operations on the object.
## Related articles
- [GroupShape](https://docs.aspose.com/slides/php-java/examples/elements/group-shape/)
# How to Run the Examples
> Run Aspose.Slides for PHP via Java examples fast: clone the repo, restore packages, then build and test features for PPT, PPTX and ODP.
Source: https://docs.aspose.com/slides/php-java/how-to-run-the-examples/
Updated: 2025-12-24
## **Download from GitHub**
All examples of Aspose.Slides for PHP via 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/php-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/php-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:
```php
```
mvn install:install-file
-Dfile=c:\aspose.slides-version.jar
-DgroupId=com.aspose
-DartifactId=aspose-slides
-Dversion={version}
-Dpackaging=jar
```php
```
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
aspose-maven-repositoryhttp://repository.aspose.com/repo/com.asposeaspose-slides18.6jdk16
```php
```
### **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.
# Manage Image Transform Effects in Presentations with PHP
> Apply, chain, inspect, remove, and verify image transform effects for picture frames with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-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 [Picture](https://reference.aspose.com/slides/php-java/aspose.slides/picture/) and access [Picture::getImageTransform](https://reference.aspose.com/slides/php-java/aspose.slides/picture/getimagetransform/). The returned [ImageTransformOperationCollection](https://reference.aspose.com/slides/php-java/aspose.slides/imagetransformoperationcollection/) 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:
- [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) stores or references the source image data owned by the presentation.
- [Picture](https://reference.aspose.com/slides/php-java/aspose.slides/picture/) belongs to a picture fill and refers to an image resource while storing the image transform collection.
- [PictureFrame](https://reference.aspose.com/slides/php-java/aspose.slides/pictureframe/) 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 [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/). When the same `PPImage` is passed to [ShapeCollection::addPictureFrame](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/addpictureframe/) more than once, each new picture frame receives its own `Picture` 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 `Picture::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 |
|---|---|---|
| [addLuminanceEffect](https://reference.aspose.com/slides/php-java/aspose.slides/imagetransformoperationcollection/addluminanceeffect/) | `brightness`, `contrast` | `-100` through `100`, percent; `0` leaves the component unchanged. |
| [addGrayScaleEffect](https://reference.aspose.com/slides/php-java/aspose.slides/imagetransformoperationcollection/addgrayscaleeffect/) | None | No numeric parameters. Alpha is unchanged. |
| [addDuotoneEffect](https://reference.aspose.com/slides/php-java/aspose.slides/imagetransformoperationcollection/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/php-java/aspose.slides/imagetransformoperationcollection/addtinteffect/) | `hue`, `amount` | Hue is `0` inclusive through `360` exclusive, in degrees; amount is `-100` through `100`, percent. |
| [addHSLEffect](https://reference.aspose.com/slides/php-java/aspose.slides/imagetransformoperationcollection/addhsleffect/) | `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/php-java/aspose.slides/imagetransformoperationcollection/addcolorreplaceeffect/) | `color` | The replacement color uses channel values from `0` through `255`. Existing alpha values are unchanged. |
| [addBlurEffect](https://reference.aspose.com/slides/php-java/aspose.slides/imagetransformoperationcollection/addblureffect/) | `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/php-java/aspose.slides/imagetransformoperationcollection/addalphamodulatefixedeffect/) | `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/php-java/aspose.slides/imagetransformoperationcollection/addalphareplaceeffect/) | `alpha` | `0` through `100`, percent opacity. |
| [addAlphaBiLevelEffect](https://reference.aspose.com/slides/php-java/aspose.slides/imagetransformoperationcollection/addalphabileveleffect/) | `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**
[ImageTransformOperationCollection::addLuminanceEffect](https://reference.aspose.com/slides/php-java/aspose.slides/imagetransformoperationcollection/addluminanceeffect/) returns a [Luminance](https://reference.aspose.com/slides/php-java/aspose.slides/luminance/) operation. Its scalar settings are supplied when the operation is created. [Luminance::getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/luminance/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:
```php
use aspose\slides\ImageFormat;
use aspose\slides\Images;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$sourceImage = Images::fromFile("photo.png");
try {
$image = $presentation->getImages()->addImage($sourceImage);
} finally {
if (!java_is_null($sourceImage)) {
$sourceImage->dispose();
}
}
$pictureFrame = $slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 50, 50, 400, 260, $image);
$imageTransform = $pictureFrame->getPictureFormat()->getPicture()->getImageTransform();
$luminance = $imageTransform->addLuminanceEffect(15, 20);
$effectiveValues = $luminance->getEffective();
echo "Brightness: " . java_values($effectiveValues->getBrightness()) . "%" . PHP_EOL;
echo "Contrast: " . java_values($effectiveValues->getContrast()) . "%" . PHP_EOL;
$preview = $slide->getImage();
try {
$preview->save("brightness-contrast-preview.png", ImageFormat::Png);
} finally {
if (!java_is_null($preview)) {
$preview->dispose();
}
}
} finally {
$presentation->dispose();
}
```
`Luminance` is the standard DrawingML brightness and contrast effect. When those settings must remain editable after a PPTX round trip, reopen the saved presentation and verify both the operation type and its effective values.
## **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.
[Duotone](https://reference.aspose.com/slides/php-java/aspose.slides/duotone/) 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.
```php
use aspose\slides\Images;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$sourceImage = Images::fromFile("photo.png");
try {
$image = $presentation->getImages()->addImage($sourceImage);
} finally {
if (!java_is_null($sourceImage)) {
$sourceImage->dispose();
}
}
$grayFrame = $slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 20, 20, 180, 120, $image);
$grayFrame->getPictureFormat()->getPicture()->getImageTransform()->addGrayScaleEffect();
$duotoneFrame = $slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 220, 20, 180, 120, $image);
$duotone = $duotoneFrame->getPictureFormat()->getPicture()->getImageTransform()->addDuotoneEffect();
$duotone->getColor1()->setColor(new Java("java.awt.Color", 0, 0, 128));
$duotone->getColor2()->setColor(new Java("java.awt.Color", 255, 215, 0));
$tintFrame = $slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 420, 20, 180, 120, $image);
$tintFrame->getPictureFormat()->getPicture()->getImageTransform()->addTintEffect(210, 35);
$hslFrame = $slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 120, 170, 180, 120, $image);
$hslFrame->getPictureFormat()->getPicture()->getImageTransform()->addHSLEffect(30, 20, -10);
$replacementFrame = $slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 320, 170, 180, 120, $image);
$colorReplacement = $replacementFrame->getPictureFormat()->getPicture()->getImageTransform()->addColorReplaceEffect();
$colorReplacement->getColor()->setColor(new Java("java.awt.Color", 100, 149, 237));
$presentation->save("color-transformations.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
[addColorReplaceEffect](https://reference.aspose.com/slides/php-java/aspose.slides/imagetransformoperationcollection/addcolorreplaceeffect/) replaces every pixel's color with one fixed color while preserving alpha. It is different from [addColorChangeEffect](https://reference.aspose.com/slides/php-java/aspose.slides/imagetransformoperationcollection/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/php-java/aspose.slides/imagetransformoperationcollection/addgrayscaleeffect/) preserves intermediate shades of gray. [addBiLevelEffect](https://reference.aspose.com/slides/php-java/aspose.slides/imagetransformoperationcollection/addbileveleffect/) maps luminance to black or white, while [addAlphaBiLevelEffect](https://reference.aspose.com/slides/php-java/aspose.slides/imagetransformoperationcollection/addalphabileveleffect/) 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/php-java/image-transform-effects/grayscale-swatches.png) to the directory containing the PHP script. 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.
```php
use aspose\slides\Images;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\SlideSizeScaleType;
$presentation = new Presentation();
try {
$presentation->getSlideSize()->setSize(720, 150, SlideSizeScaleType::DoNotScale);
$shapes = $presentation->getSlides()->get_Item(0)->getShapes();
$sourceImage = Images::fromFile(__DIR__ . "/grayscale-swatches.png");
try {
$image = $presentation->getImages()->addImage($sourceImage);
} finally {
$sourceImage->dispose();
}
$captions = ["Original", "Threshold 20%", "Threshold 60%"];
$frames = [];
foreach ($captions as $index => $caption) {
$x = 12 + 240 * $index;
$label = $shapes->addAutoShape(ShapeType::Rectangle, $x, 12, 216, 36);
$label->getTextFrame()->setText($caption);
$frames[] = $shapes->addPictureFrame(ShapeType::Rectangle, $x, 60, 216, 72, $image);
}
$frames[1]->getPictureFormat()->getPicture()->getImageTransform()->addBiLevelEffect(20);
$frames[2]->getPictureFormat()->getPicture()->getImageTransform()->addBiLevelEffect(60);
$presentation->save(__DIR__ . "/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/php-java/aspose.slides/imagetransformoperationcollection/addblureffect/) 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/php-java/aspose.slides/imagetransformoperationcollection/addalphamodulatefixedeffect/). It multiplies every existing alpha value, so partially transparent pixels remain proportionally different. [addAlphaReplaceEffect](https://reference.aspose.com/slides/php-java/aspose.slides/imagetransformoperationcollection/addalphareplaceeffect/) instead assigns one alpha value to all pixels. [addAlphaBiLevelEffect](https://reference.aspose.com/slides/php-java/aspose.slides/imagetransformoperationcollection/addalphabileveleffect/) converts alpha to two levels based on a threshold.
```php
use aspose\slides\Images;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$sourceImage = Images::fromFile("photo.png");
try {
$image = $presentation->getImages()->addImage($sourceImage);
} finally {
if (!java_is_null($sourceImage)) {
$sourceImage->dispose();
}
}
$blurredFrame = $slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 20, 20, 200, 140, $image);
$blur = $blurredFrame->getPictureFormat()->getPicture()->getImageTransform()->addBlurEffect(4.5, true);
$blur->setRadius(5);
$transparentFrame = $slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 240, 20, 200, 140, $image);
$alphaModulate = $transparentFrame->getPictureFormat()->getPicture()->getImageTransform()->addAlphaModulateFixedEffect(65);
$alphaModulate->setAmount(60);
$uniformAlphaFrame = $slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 20, 180, 200, 140, $image);
$uniformAlphaFrame->getPictureFormat()->getPicture()->getImageTransform()->addAlphaReplaceEffect(55);
$binaryAlphaFrame = $slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 240, 180, 200, 140, $image);
$alphaBiLevel = $binaryAlphaFrame->getPictureFormat()->getPicture()->getImageTransform()->addAlphaBiLevelEffect(50);
$alphaBiLevel->setThreshold(45);
$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/php-java/aspose.slides/imagetransformoperationcollection/addalphaceilingeffect/), which makes every nonzero alpha fully opaque; [addAlphaFloorEffect](https://reference.aspose.com/slides/php-java/aspose.slides/imagetransformoperationcollection/addalphaflooreffect/), which makes every alpha below 100% fully transparent; and [addAlphaInverseEffect](https://reference.aspose.com/slides/php-java/aspose.slides/imagetransformoperationcollection/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:
```php
use aspose\slides\ImageFormat;
use aspose\slides\Images;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$sourceImage = Images::fromFile("photo.png");
try {
$image = $presentation->getImages()->addImage($sourceImage);
} finally {
if (!java_is_null($sourceImage)) {
$sourceImage->dispose();
}
}
$pictureFrame = $slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 50, 50, 400, 260, $image);
$imageTransform = $pictureFrame->getPictureFormat()->getPicture()->getImageTransform();
$imageTransform->addGrayScaleEffect();
$imageTransform->addTintEffect(220, 25);
$imageTransform->addBlurEffect(2.5, false);
$imageTransform->addAlphaModulateFixedEffect(80);
$presentation->save("image-transform-chain.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
$reopenedPresentation = new Presentation("image-transform-chain.pptx");
try {
$reopenedShape = $reopenedPresentation->getSlides()->get_Item(0)->getShapes()->get_Item(0);
if (java_instanceof($reopenedShape, new JavaClass("com.aspose.slides.PictureFrame"))) {
$reopenedTransform = $reopenedShape->getPictureFormat()->getPicture()->getImageTransform();
$orderIsPreserved = java_values($reopenedTransform->size()) === 4 &&
java_instanceof($reopenedTransform->get_Item(0), new JavaClass("com.aspose.slides.GrayScale")) &&
java_instanceof($reopenedTransform->get_Item(1), new JavaClass("com.aspose.slides.Tint")) &&
java_instanceof($reopenedTransform->get_Item(2), new JavaClass("com.aspose.slides.Blur")) &&
java_instanceof($reopenedTransform->get_Item(3), new JavaClass("com.aspose.slides.AlphaModulateFixed"));
echo $orderIsPreserved ? "The effect chain was preserved." : "The effect chain changed during the round trip.";
$renderedSlide = $reopenedPresentation->getSlides()->get_Item(0)->getImage();
try {
$renderedSlide->save("reopened-effect-chain.png", ImageFormat::Png);
} finally {
if (!java_is_null($renderedSlide)) {
$renderedSlide->dispose();
}
}
} else {
echo "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/php-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 `Picture::getImageTransform`. Depending on the effect, it may expose writable members directly. For example, [Blur](https://reference.aspose.com/slides/php-java/aspose.slides/blur/) exposes writable `radius` and `grow` values, [AlphaModulateFixed](https://reference.aspose.com/slides/php-java/aspose.slides/alphamodulatefixed/) exposes a writable `amount`, and [AlphaBiLevel](https://reference.aspose.com/slides/php-java/aspose.slides/alphabilevel/) exposes a writable `threshold`. Color effects such as [Duotone](https://reference.aspose.com/slides/php-java/aspose.slides/duotone/) expose mutable [ColorFormat](https://reference.aspose.com/slides/php-java/aspose.slides/colorformat/) objects.
Some operations, including [Luminance](https://reference.aspose.com/slides/php-java/aspose.slides/luminance/), [HSL](https://reference.aspose.com/slides/php-java/aspose.slides/hsl/), [Tint](https://reference.aspose.com/slides/php-java/aspose.slides/tint/), and [AlphaReplace](https://reference.aspose.com/slides/php-java/aspose.slides/alphareplace/), 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:
```php
use aspose\slides\Presentation;
$presentation = new Presentation("image-transform-chain.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$pictureFrame = null;
$shapeCount = java_values($slide->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $slide->getShapes()->get_Item($index);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.PictureFrame"))) {
$pictureFrame = $shape;
break;
}
}
if ($pictureFrame !== null) {
$imageTransform = $pictureFrame->getPictureFormat()->getPicture()->getImageTransform();
$effectCount = java_values($imageTransform->size());
for ($index = 0; $index < $effectCount; $index++) {
$operation = $imageTransform->get_Item($index);
echo $index . ": " . java_values($operation->getClass()->getSimpleName()) . PHP_EOL;
if (java_instanceof($operation, new JavaClass("com.aspose.slides.Luminance"))) {
$data = $operation->getEffective();
echo " Brightness: " . java_values($data->getBrightness()) . PHP_EOL;
echo " Contrast: " . java_values($data->getContrast()) . PHP_EOL;
} elseif (java_instanceof($operation, new JavaClass("com.aspose.slides.Duotone"))) {
$data = $operation->getEffective();
echo " Dark color: " . java_values($data->getColor1()->toString()) . PHP_EOL;
echo " Light color: " . java_values($data->getColor2()->toString()) . PHP_EOL;
} elseif (java_instanceof($operation, new JavaClass("com.aspose.slides.ColorReplace"))) {
$data = $operation->getEffective();
echo " Replacement color: " . java_values($data->getColor()->toString()) . PHP_EOL;
} elseif (java_instanceof($operation, new JavaClass("com.aspose.slides.HSL"))) {
$data = $operation->getEffective();
echo " HSL: " . java_values($data->getHue()) . ", " . java_values($data->getSaturation()) . ", " . java_values($data->getLuminance()) . PHP_EOL;
} elseif (java_instanceof($operation, new JavaClass("com.aspose.slides.Tint"))) {
$data = $operation->getEffective();
echo " Tint: " . java_values($data->getHue()) . ", " . java_values($data->getAmount()) . PHP_EOL;
} elseif (java_instanceof($operation, new JavaClass("com.aspose.slides.Blur"))) {
$data = $operation->getEffective();
echo " Blur radius: " . java_values($data->getRadius()) . " pt" . PHP_EOL;
} elseif (java_instanceof($operation, new JavaClass("com.aspose.slides.AlphaModulateFixed"))) {
$data = $operation->getEffective();
echo " Alpha amount: " . java_values($data->getAmount()) . "%" . PHP_EOL;
} elseif (java_instanceof($operation, new JavaClass("com.aspose.slides.AlphaReplace"))) {
$data = $operation->getEffective();
echo " Replacement alpha: " . java_values($data->getAlpha()) . "%" . PHP_EOL;
} elseif (java_instanceof($operation, new JavaClass("com.aspose.slides.AlphaBiLevel"))) {
$data = $operation->getEffective();
echo " Alpha threshold: " . java_values($data->getThreshold()) . "%" . PHP_EOL;
}
}
}
} 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 [ImageTransformOperationCollection::removeAt](https://reference.aspose.com/slides/php-java/aspose.slides/imagetransformoperationcollection/removeat/) 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/php-java/aspose.slides/imagetransformoperationcollection/clear/) to remove the entire chain.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("image-transform-chain.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$pictureFrame = null;
$shapeCount = java_values($slide->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $slide->getShapes()->get_Item($index);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.PictureFrame"))) {
$pictureFrame = $shape;
break;
}
}
if ($pictureFrame !== null) {
$imageTransform = $pictureFrame->getPictureFormat()->getPicture()->getImageTransform();
$effectCount = java_values($imageTransform->size());
$blurIndex = -1;
for ($index = 0; $index < $effectCount; $index++) {
if (java_instanceof($imageTransform->get_Item($index), new JavaClass("com.aspose.slides.Blur"))) {
$blurIndex = $index;
break;
}
}
if ($blurIndex >= 0) {
$imageTransform->removeAt($blurIndex);
echo "The blur operation was removed." . PHP_EOL;
}
$imageTransform->clear();
echo "Remaining operations: " . java_values($imageTransform->size()) . PHP_EOL;
$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 [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) 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.
- 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 `ImageTransformOperationCollection`; raster formats flatten the result into pixels, and document or 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 `Picture` used by the picture fill. The underlying `PPImage` bytes remain unchanged.
**Will two picture frames that reuse the same image share their effects?**
No. Reusing a `PPImage` avoids duplicate image data, but each picture frame normally has a separate `Picture` 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 PHP
> Learn how to add, reuse, link, replace, and manage raster and SVG images in PowerPoint and OpenDocument presentations with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/image/
Updated: 2026-11-08
## **Introduction**
Aspose.Slides for PHP via 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/php-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/php-java/aspose.slides/imagecollection/) stores image resources used by the presentation. Use [ImageCollection::addImage](https://reference.aspose.com/slides/php-java/aspose.slides/imagecollection/) to add image data and obtain a [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) resource.
- A [picture frame](https://reference.aspose.com/slides/php-java/aspose.slides/pictureframe/) is a shape that displays an image on a slide, layout, or master. Use [ShapeCollection::addPictureFrame](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/addpictureframe/) 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.
- [PPImage::replaceImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) 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 a [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/), and then use that resource in one or more picture frames or fills.
[](https://docs.aspose.com/slides/php-java/image/visual-image-9c661bc60854.svg)
*In this diagram, replacing the shared image updates both picture frames and the background. SVG conversion creates separate slide objects.*
## **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 `PPImage`.
```php
use aspose\slides\Images;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$image = Images::fromFile("photo.png");
try {
$ppImage = $presentation->getImages()->addImage($image);
} finally {
if (!java_is_null($image)) {
$image->dispose();
}
}
$slide = $presentation->getSlides()->get_Item(0);
$slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 20, 20, 320, 180, $ppImage);
$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.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$imageUrl = new Java("java.net.URL", "https://example.com/image.png");
$connection = $imageUrl->openConnection();
$connection->setConnectTimeout(10000);
$connection->setReadTimeout(10000);
$inputStream = $connection->getInputStream();
$outputStream = new Java("java.io.ByteArrayOutputStream");
$Array = new JavaClass("java.lang.reflect.Array");
$Byte = (new JavaClass("java.lang.Byte"))->TYPE;
try {
$buffer = $Array->newInstance($Byte, 8192);
$bufferLength = $Array->getLength($buffer);
while (($bytesRead = java_values($inputStream->read($buffer, 0, $bufferLength))) != -1) {
$outputStream->write($buffer, 0, $bytesRead);
}
$ppImage = $presentation->getImages()->addImage($outputStream->toByteArray());
$slide = $presentation->getSlides()->get_Item(0);
$slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 20, 20, 320, 180, $ppImage);
} finally {
if (!java_is_null($inputStream)) {
$inputStream->close();
}
$outputStream->close();
}
$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 [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) 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/php-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.
```php
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\Images;
use aspose\slides\PictureFillMode;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$image = Images::fromFile("background.jpg");
try {
$ppImage = $presentation->getImages()->addImage($image);
} finally {
if (!java_is_null($image)) {
$image->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($ppImage);
$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/php-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 [Picture::setLinkPathLong](https://reference.aspose.com/slides/php-java/aspose.slides/picture/) rather than embedding the image data.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$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 a [SvgImage](https://reference.aspose.com/slides/php-java/aspose.slides/svgimage/), add it to the image collection, and place the resulting image resource in a picture frame.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\SvgImage;
$presentation = new Presentation();
try {
$svgContent = file_get_contents("icon.svg");
$svgImage = new SvgImage($svgContent);
$ppImage = $presentation->getImages()->addImage($svgImage);
$slide = $presentation->getSlides()->get_Item(0);
$slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 20, 20, 200, 200, $ppImage);
$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/php-java/aspose.slides/svgimage/) provides constructors that accept an [ExternalResourceResolver](https://reference.aspose.com/slides/php-java/aspose.slides/externalresourceresolver/) 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 [ShapeCollection::addGroupShape](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/addgroupshape/) overload that accepts a [SvgImage](https://reference.aspose.com/slides/php-java/aspose.slides/svgimage/) to perform the conversion.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SvgImage;
$presentation = new Presentation();
try {
$svgContent = file_get_contents("diagram.svg");
$svgImage = new SvgImage($svgContent);
$slideSize = $presentation->getSlideSize()->getSize();
$slide = $presentation->getSlides()->get_Item(0);
$slide->getShapes()->addGroupShape($svgImage, 0, 0, $slideSize->getWidth(), $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 [PPImage::replaceImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) when you want to replace an existing image resource. This is especially useful for shared graphics such as logos.
```php
use aspose\slides\Images;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("input.pptx");
try {
$imageToReplace = $presentation->getImages()->get_Item(0);
$replacementImage = Images::fromFile("new-logo.png");
try {
$imageToReplace->replaceImage($replacementImage);
} finally {
if (!java_is_null($replacementImage)) {
$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.
`PPImage::replaceImage` also provides overloads that accept a byte array or another [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/).
## **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, [PictureFillFormat::compressImage](https://reference.aspose.com/slides/php-java/aspose.slides/picturefillformat/) 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/php-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 PHP via Java code, use the Aspose.Slides [IImage](https://reference.aspose.com/slides/php-java/aspose.slides/iimage/) and [Images](https://reference.aspose.com/slides/php-java/aspose.slides/images/) APIs instead of the legacy public API based on `java.awt.image.BufferedImage`. See [Modern API](https://docs.aspose.com/slides/php-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/php-java/aspose.slides/iimage/), [ImageCollection::addImage](https://reference.aspose.com/slides/php-java/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/php-java/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 [PPImage::replaceImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/). 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 [ShapeCollection::addGroupShape](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/addgroupshape/); 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 PHP
> Learn how to import PDF and HTML content into PowerPoint presentations in PHP with Aspose.Slides and save the results as PPTX files.
Source: https://docs.aspose.com/slides/php-java/import-presentation/
Updated: 2026-11-08
## **Introduction**
Aspose.Slides for PHP via Java can turn PDF pages or HTML content into PowerPoint slides without Microsoft PowerPoint. The [SlideCollection](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/) class provides [SlideCollection::addFromPdf](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/) and [SlideCollection::addFromHtml](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/) for appending imported content to a presentation.
For more control over HTML placement, [SlideCollection::insertFromHtml](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/) 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 [ExternalResourceResolver](https://reference.aspose.com/slides/php-java/aspose.slides/externalresourceresolver/) with a base URI. The returned [Slide](https://reference.aspose.com/slides/php-java/aspose.slides/slide/) 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/php-java/aspose.slides/presentation/) object.
2. Call [SlideCollection::addFromPdf](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/) with the path to the PDF file.
3. Call [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) with [SaveFormat::Pptx](https://reference.aspose.com/slides/php-java/aspose.slides/saveformat/) to write the presentation to a PPTX file.
The following PHP example imports a PDF document and saves the generated slides as a PowerPoint presentation:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$presentation->getSlides()->addFromPdf("document.pdf");
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The [SlideCollection::addFromPdf](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/) 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/php-java/aspose.slides/presentation/) object.
2. Open the HTML file for reading and pass the stream to [SlideCollection::addFromHtml](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/).
3. Call [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) with [SaveFormat::Pptx](https://reference.aspose.com/slides/php-java/aspose.slides/saveformat/) to write the result to a PPTX file.
The following PHP example imports an HTML document and saves the generated slides as a PowerPoint presentation:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$htmlStream = new Java("java.io.FileInputStream", "page.html");
try {
$presentation->getSlides()->addFromHtml($htmlStream);
} finally {
$htmlStream->close();
}
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Insert HTML Content**
Use [SlideCollection::insertFromHtml](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/) 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 `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/php-java/aspose.slides/slidecollection/) returns an array of [Slide](https://reference.aspose.com/slides/php-java/aspose.slides/slide/) 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.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$layoutSlide = $presentation->getLayoutSlides()->get_Item(0);
$presentation->getSlides()->addEmptySlide($layoutSlide);
$presentation->getSlides()->addEmptySlide($layoutSlide);
$insertIndex = 1;
$html = "
Quarterly update
This content is inserted before the slide that was at index 1.
";
$insertedSlides = $presentation->getSlides()->insertFromHtml($insertIndex, $html, false);
$arrayClass = new JavaClass("java.lang.reflect.Array");
$insertedSlideCount = java_values($arrayClass->getLength($insertedSlides));
for ($slideIndex = 0; $slideIndex < $insertedSlideCount; $slideIndex++) {
$slide = $insertedSlides[$slideIndex];
echo "Inserted slide index: " . java_values($presentation->getSlides()->indexOf($slide)) . PHP_EOL;
}
$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 [ExternalResourceResolver](https://reference.aspose.com/slides/php-java/aspose.slides/externalresourceresolver/) 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`.
```php
use aspose\slides\ExternalResourceResolver;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$templateSlide = $presentation->getSlides()->get_Item(0);
$header = $templateSlide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 20, 680, 60);
$header->getTextFrame()->setText("Product roadmap");
$html = "
";
}
$html .= "";
$javaHtml = new Java("java.lang.String", $html);
$htmlData = $javaHtml->getBytes("UTF-8");
$htmlStream = new Java("java.io.ByteArrayInputStream", $htmlData);
$resolver = new ExternalResourceResolver();
$baseDirectory = new Java("java.io.File", "html-assets");
$baseUri = java_values($baseDirectory->toURI()->toString());
try {
$affectedSlides = $presentation->getSlides()->insertFromHtml(0, $htmlStream, $resolver, $baseUri, true);
$arrayClass = new JavaClass("java.lang.reflect.Array");
$affectedSlideCount = java_values($arrayClass->getLength($affectedSlides));
for ($slideIndex = 0; $slideIndex < $affectedSlideCount; $slideIndex++) {
$slide = $affectedSlides[$slideIndex];
echo "Affected slide index: " . java_values($presentation->getSlides()->indexOf($slide)) . PHP_EOL;
}
} finally {
$htmlStream->close();
}
$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 a restricted resolver that allows only permitted schemes, directories, and hosts, and rejects all other URIs.
[](https://docs.aspose.com/slides/php-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/php-java/aspose.slides/pdfimportoptions/) object, call [PdfImportOptions::setDetectTables](https://reference.aspose.com/slides/php-java/aspose.slides/pdfimportoptions/) with `true`, and pass the options to [SlideCollection::addFromPdf](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/). 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/php-java/conversion/html-to-image/)
- [HTML to JPG](https://products.aspose.com/slides/php-java/conversion/html-to-jpg/)
- [HTML to XML](https://products.aspose.com/slides/php-java/conversion/html-to-xml/)
- [HTML to TIFF](https://products.aspose.com/slides/php-java/conversion/html-to-tiff/)
## Related articles
- [Convert PowerPoint Presentations in PHP | HTML, PNG, PDF, Word, TIFF](https://docs.aspose.com/slides/php-java/convert-powerpoint/)
# Installation
> Install Aspose.Slides for PHP via Java on Linux and Windows: set up PHP, Java, Apache Tomcat, and PHP/Java Bridge, add the package with Composer, and verify the setup with a short script.
Source: https://docs.aspose.com/slides/php-java/installation/
Updated: 2026-09-27
## **Overview**
Aspose.Slides for PHP via Java runs in two processes. Your PHP script uses PHP classes that pass every call through PHP/Java Bridge to Aspose.Slides, which runs on Java inside Apache Tomcat. This article explains how to set up both sides, install the package with Composer, and run a short script to verify the installation.
## **Prerequisites**
- **PHP 7.0 to 8.3**, with `allow_url_include = On` in `php.ini`. Your scripts load the bridge's client library, `Java.inc`, from Tomcat over HTTP. On PHP 8.4 and later, `Java.inc` stops with the error "end() expects exactly 1 argument" whenever PHP's `xml` extension is loaded, and the Windows builds of PHP always load it.
- **[Composer](https://getcomposer.org/)**.
- **Java 8 or later.** A JRE is enough.
- **Apache Tomcat 9.** PHP/Java Bridge is built on the `javax.servlet` API, which Tomcat 10 and later no longer provide, so the bridge does not start there.
- **[PHP/Java Bridge](https://sourceforge.net/projects/php-java-bridge/files/Binary%20package/php-java-bridge_7.2.1/) 7.2.1**, its latest release. Its web application, `JavaBridge.war`, runs in Tomcat.
This article runs Tomcat and your PHP scripts on the same computer. Aspose.Slides opens and saves files inside Tomcat, so every path that your scripts pass to it must be valid there.
## **Install on Linux**
These commands install everything in your home folder on Ubuntu 24.04. On other distributions, install the same packages with the distribution's package manager.
1. Install PHP, Composer, Java, and the download tools, then turn on `allow_url_include` for the PHP command line:
```bash
sudo apt-get update
sudo apt-get install -y php-cli composer default-jre-headless curl unzip
sudo sed -i 's/^allow_url_include = Off/allow_url_include = On/' "$(php -r 'echo php_ini_loaded_file();')"
```
1. Download Apache Tomcat 9 and PHP/Java Bridge, put the bridge's `JavaBridge.war` into Tomcat's `webapps` folder, and start Tomcat. Tomcat unpacks the WAR file into `webapps/JavaBridge` as it starts:
```bash
cd ~
curl -fsSLO https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.122/bin/apache-tomcat-9.0.122.tar.gz
tar -xzf apache-tomcat-9.0.122.tar.gz
curl -fsSL -o php-java-bridge.zip "https://sourceforge.net/projects/php-java-bridge/files/Binary%20package/php-java-bridge_7.2.1/php-java-bridge_7.2.1_documentation.zip/download"
unzip -o php-java-bridge.zip JavaBridge.war -d apache-tomcat-9.0.122/webapps
apache-tomcat-9.0.122/bin/startup.sh
```
1. Create a project folder and install Aspose.Slides for PHP via Java from [Packagist](https://packagist.org/packages/aspose/slides):
```bash
mkdir ~/hello-slides
cd ~/hello-slides
composer require aspose/slides
```
1. Stop Tomcat, copy the Aspose.Slides JAR file from the package to the bridge's `WEB-INF/lib` folder, replace the bridge's `Java.inc` with the PHP 8 version from the package, and start Tomcat again:
```bash
~/apache-tomcat-9.0.122/bin/shutdown.sh
cp vendor/aspose/slides/jar/aspose-slides-*-php.jar ~/apache-tomcat-9.0.122/webapps/JavaBridge/WEB-INF/lib/
unzip -o vendor/aspose/slides/Java.inc.php8.zip -d ~/apache-tomcat-9.0.122/webapps/JavaBridge/java/
~/apache-tomcat-9.0.122/bin/startup.sh
```
On PHP 7, skip the `Java.inc` replacement. Tomcat takes a few seconds to start, and it must be running whenever your scripts use Aspose.Slides.
## **Install on Windows**
1. Install [PHP 8.3 for Windows](https://www.php.net/downloads.php?os=windows) and add its folder to the `PATH` environment variable. Copy `php.ini-production` to `php.ini` in the same folder. In `php.ini`, set `allow_url_include = On` and uncomment the `extension_dir = "ext"`, `extension=openssl`, and `extension=zip` lines. Composer needs `openssl` to download packages, and `zip` to unpack them unless 7-Zip is installed or an `unzip` command is on `PATH`.
1. Install [Composer](https://getcomposer.org/download/).
1. Install Java and set the `JAVA_HOME` environment variable to its folder. Tomcat does not start without it.
1. In Command Prompt, download Apache Tomcat 9 and PHP/Java Bridge, put the bridge's `JavaBridge.war` into Tomcat's `webapps` folder, and start Tomcat. Tomcat's scripts find Tomcat through the `CATALINA_HOME` variable, so keep using the same Command Prompt window for the next steps. Tomcat unpacks the WAR file into `webapps\JavaBridge` as it starts:
```bat
cd %USERPROFILE%
curl -fsSLO https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.122/bin/apache-tomcat-9.0.122-windows-x64.zip
tar -xf apache-tomcat-9.0.122-windows-x64.zip
set CATALINA_HOME=%USERPROFILE%\apache-tomcat-9.0.122
curl -fsSL -o php-java-bridge.zip "https://sourceforge.net/projects/php-java-bridge/files/Binary%20package/php-java-bridge_7.2.1/php-java-bridge_7.2.1_documentation.zip/download"
tar -xf php-java-bridge.zip -C "%CATALINA_HOME%\webapps" JavaBridge.war
"%CATALINA_HOME%\bin\startup.bat"
```
1. Create a project folder and install Aspose.Slides for PHP via Java from [Packagist](https://packagist.org/packages/aspose/slides):
```bat
mkdir %USERPROFILE%\hello-slides
cd %USERPROFILE%\hello-slides
composer require aspose/slides
```
1. Stop Tomcat, copy the Aspose.Slides JAR file from the package to the bridge's `WEB-INF\lib` folder, replace the bridge's `Java.inc` with the PHP 8 version from the package, and start Tomcat again:
```bat
"%CATALINA_HOME%\bin\shutdown.bat"
copy vendor\aspose\slides\jar\aspose-slides-*-php.jar "%CATALINA_HOME%\webapps\JavaBridge\WEB-INF\lib\"
tar -xf vendor\aspose\slides\Java.inc.php8.zip -C "%CATALINA_HOME%\webapps\JavaBridge\java"
"%CATALINA_HOME%\bin\startup.bat"
```
On PHP 7, skip the `Java.inc` replacement. Tomcat takes a few seconds to start, and it must be running whenever your scripts use Aspose.Slides.
## **Verify the Installation**
Save this script as *hello.php* in the project folder. It creates a presentation with one text box and saves it next to the script:
```php
getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 400, 100);
$shape->getTextFrame()->setText("Hello, Aspose.Slides!");
$presentation->save(__DIR__ . "/hello.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Run it from the project folder:
```bash
php hello.php
```
The script writes *hello.pptx*, with one slide that holds the text box. Without a license, the slide also carries an evaluation watermark; see [Licensing](https://docs.aspose.com/slides/php-java/licensing/).
The script includes `aspose.slides.php` directly: Composer's autoloader cannot load these classes, because they are all defined in that one file. It also passes an absolute path to `save`, because Aspose.Slides runs inside Tomcat and resolves a relative path against Tomcat's working folder, not your script's.
## **FAQ**
**How can I verify that Aspose.Slides is integrated correctly?**
Run the script in [Verify the Installation](https://docs.aspose.com/slides/php-java/installation/#verify-the-installation). If it writes *hello.pptx* without errors, PHP, PHP/Java Bridge, and Aspose.Slides are working together.
**Why does my script stop with "Failed opening required 'http://localhost:8080/JavaBridge/java/Java.inc'"?**
PHP could not load `Java.inc` from Tomcat. If the message before it says that the `http://` wrapper is disabled, set `allow_url_include = On` in the `php.ini` file that your PHP command line loads; `php --ini` shows which file that is. If it says "Connection refused", Tomcat is not running yet: start it, or wait a few seconds until it has started.
**How can I limit memory consumption when processing large presentations?**
Raise JVM memory limits only as high as needed, and close each [Presentation](https://reference.aspose.com/slides/php-java/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 PHP](https://docs.aspose.com/slides/features/php-api/)
# Install Aspose.Slides for PHP via Java Using Docker
> Run Aspose.Slides in Docker containers: configure images, dependencies, fonts, and licensing to build scalable services that process PowerPoint & OpenDocument.
Source: https://docs.aspose.com/slides/php-java/installing-slides-php-using-docker/
Updated: 2025-12-24
## **Prerequisites**
* Install Docker on your machine. You can follow the official installation guide [here](https://docs.docker.com/get-docker/).
## **Steps**
### **1. Create a Dockerfile**
Create a new file named Dockerfile in your project directory with the following content:
```
# Base image (official Ubuntu image)
FROM ubuntu:20.04
# Set the time zone upfront to avoid interactive selection
ENV DEBIAN_FRONTEND=noninteractive
RUN ln -fs /usr/share/zoneinfo/Europe/Berlin /etc/localtime && \
apt-get update && apt-get install -y tzdata && \
dpkg-reconfigure --frontend noninteractive tzdata
# Install necessary packages and update package lists
RUN apt-get install -y \
wget \
curl \
apt-transport-https \
ca-certificates \
software-properties-common \
php-cli \
php-cgi \
libapache2-mod-php \
unzip \
openjdk-8-jdk \
debconf \
&& rm -rf /var/lib/apt/lists/*
# Automatically accept the license agreement for installing Microsoft TrueType fonts
RUN echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections
# Install Microsoft TrueType fonts
RUN apt-get update && \
apt-get install -y ttf-mscorefonts-installer && \
rm -rf /var/lib/apt/lists/*
# Install Tomcat - using version 9.0.93
RUN wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.93/bin/apache-tomcat-9.0.93.tar.gz -O /tmp/tomcat.tar.gz && \
tar xzf /tmp/tomcat.tar.gz -C /opt/ && \
mv /opt/apache-tomcat-9.0.93 /opt/tomcat && \
rm /tmp/tomcat.tar.gz
# Install PHP/Java Bridge
RUN curl -L http://sourceforge.net/projects/php-java-bridge/files/Binary%20package/php-java-bridge_7.2.1/php-java-bridge_7.2.1_documentation.zip/download -o /tmp/php-java-bridge.zip && \
unzip /tmp/php-java-bridge.zip -d /tmp/php-java-bridge && \
mkdir -p /opt/tomcat/webapps/JavaBridge && \
cp /tmp/php-java-bridge/JavaBridge.war /opt/tomcat/webapps/JavaBridge && \
cd /opt/tomcat/webapps/JavaBridge && \
jar -xvf JavaBridge.war && \
rm -rf /tmp/php-java-bridge.zip /tmp/php-java-bridge
# Download and install Aspose.Slides for PHP via Java
RUN wget https://github.com/aspose-slides/Aspose.Slides-for-PHP-via-Java/archive/refs/heads/master.zip -O /tmp/aspose-slides.zip && \
unzip /tmp/aspose-slides.zip -d /tmp/aspose-slides && \
mkdir -p /opt/tomcat/webapps/JavaBridge/WEB-INF/lib && \
mkdir -p /tmp/sample && \
cp /tmp/aspose-slides/Aspose.Slides-for-PHP-via-Java-master/jar/*.jar /opt/tomcat/webapps/JavaBridge/WEB-INF/lib && \
cp -r /tmp/aspose-slides/Aspose.Slides-for-PHP-via-Java-master/lib /tmp/sample && \
rm -rf /tmp/aspose-slides.zip /tmp/aspose-slides
# Create the test.php file
RUN echo 'getSlides()->get_Item(0);\n\
$slide->getShapes()->addAutoShape(ShapeType::Line, 50, 150, 300, 0);\n\
$presentation->save("output.pdf", SaveFormat::Pdf);\n\n\
?>' > /tmp/sample/test.php
# Create the entrypoint.sh script
RUN echo '#!/bin/bash\n\
# Start Tomcat in the background\n\
catalina.sh start\n\
# Wait for Tomcat to fully start\n\
until curl -s http://localhost:8080 > /dev/null; do\n\
sleep 2\n\
done\n\
echo "Running the PHP script..."\n\
# Run the PHP script\n\
php /tmp/sample/test.php\n\
echo "PHP script completed, please check file /tmp/output.pdf."\n\
# Keep the container alive\n\
echo "Keeping the container alive..."\n\
tail -f /dev/null\n\
' > /tmp/entrypoint.sh
# Explicitly grant execute permissions to the script
RUN chmod 755 /tmp/entrypoint.sh
# Configure php.ini
RUN echo "allow_url_include = On" >> /etc/php/7.4/cli/php.ini
# Set environment variables for Tomcat
ENV CATALINA_HOME /opt/tomcat
ENV PATH $CATALINA_HOME/bin:$PATH
ENV PHP_CLASSPATH /opt/aspose-slides/lib
# Expose port 8080 for Tomcat and port 9000 for PHP/Java Bridge
EXPOSE 8080
EXPOSE 9000
# Set the working directory
WORKDIR /tmp
# Start Tomcat when the container starts
ENTRYPOINT ["/tmp/entrypoint.sh"]
```
### **2. Build the Docker Image**
Run the following command in the directory where your Dockerfile is located to build the Docker image:
```bash
docker build -t aspose-slides-php-java .
```
### **3. Run the Docker Container**
Once the image is built, run the container:
```bash
docker run -p 8080:8080 aspose-slides-php-java
```
### 4. **Access Aspose.Slides in Docker**
After starting the container, the script will generate a PDF file. You can find the generated output file `output.pdf` in the `/tmp` folder inside the container:
```bash
docker exec -it ls /tmp
```
To copy the generated PDF file to your local machine, run the following command:
```bash
docker cp :/tmp/output.pdf ./output.pdf
```
# Known Issues
> Stay informed about current limitations and workarounds in Aspose.Slides for PHP via Java to handle PowerPoint and OpenDocument presentations reliably.
Source: https://docs.aspose.com/slides/php-java/known-issues/
Updated: 2025-11-30
---
lastmod: 2025-11-30T13:47:17+04:00
title: Known Issues
type: docs
weight: 330
url: /php-java/known-issues/
keywords:
- known issue
- PowerPoint
- OpenDocument
- presentation
- PHP
- Aspose.Slides
description: "Stay informed about current limitations and workarounds in Aspose.Slides for PHP via Java to handle PowerPoint and OpenDocument presentations reliably."
---
# Licensing Bug
> Learn how a licensing bug in Aspose.Slides for PHP via Java 23.2–23.7 affects perpetual keys and how to fix it to keep working with PPT, PPTX and ODP.
Source: https://docs.aspose.com/slides/php-java/licensing-bug/
Updated: 2026-05-15
## **Overview**
This article describes a licensing bug encountered in Aspose.Slides for PHP via 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 PHP via Java versions 23.2 - 23.7 may report the license as expired, transitioning all functions into a evaluation mode.
This behavior is incorrect and does not affect versions prior to 23.2 and after 23.7.
## **Resolution**
Aspose.Slides for PHP via 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 PHP via 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/php-java/repo/com/aspose/aspose-slides/23.2.1/) | [Release notes Aspose.Slides for PHP via Java 23.2.1](https://releases.aspose.com/slides/php-java/release-notes/2023/aspose-slides-for-java-23-2-1-release-notes/)|
|[23.3.1](https://releases.aspose.com/php-java/repo/com/aspose/aspose-slides/23.3.1/) | [Release notes Aspose.Slides for PHP via Java 23.3.1](https://releases.aspose.com/slides/php-java/release-notes/2023/aspose-slides-for-java-23-3-1-release-notes/)|
|[23.4.1](https://releases.aspose.com/php-java/repo/com/aspose/aspose-slides/23.4.1/) | [Release notes Aspose.Slides for PHP via Java 23.4.1](https://releases.aspose.com/slides/php-java/release-notes/2023/aspose-slides-for-java-23-4-1-release-notes/)|
|[23.5.1](https://releases.aspose.com/php-java/repo/com/aspose/aspose-slides/23.5.1/) | [Release notes Aspose.Slides for PHP via Java 23.5.1](https://releases.aspose.com/slides/php-java/release-notes/2023/aspose-slides-for-java-23-5-1-release-notes/)|
|[23.6.1](https://releases.aspose.com/php-java/repo/com/aspose/aspose-slides/23.6.1/) | [Release notes Aspose.Slides for PHP via Java 23.6.1](https://releases.aspose.com/slides/php-java/release-notes/2023/aspose-slides-for-java-23-6-1-release-notes/)|
|[23.7.1](https://releases.aspose.com/php-java/repo/com/aspose/aspose-slides/23.7.1/) | [Release notes Aspose.Slides for PHP via Java 23.7.1](https://releases.aspose.com/slides/php-java/release-notes/2023/aspose-slides-for-java-23-7-1-release-notes/)|
If you experience any licensing issues with Aspose.Slides for PHP via Java:
- Check the version you are using and ensure it's not affected by the bug described above.
- Refer to the [Aspose documentation](https://docs.aspose.com/slides/php-java/getting-started/) for troubleshooting steps and known licensing issues.
- Contact [Aspose support](https://forum.aspose.com/) for further assistance.
## **Affected Products and Versions**
Please note that this bug only impacts Aspose.Slides for PHP via 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 PHP via Java. Ensure uninterrupted access to full features with our step-by-step licensing guide.
Source: https://docs.aspose.com/slides/php-java/licensing/
Updated: 2026-09-27
## **Introduction**
Sometimes, for the best evaluation outcomes, a hands-on approach might be needed. For this reason, Aspose.Slides provides different purchase plans and also offers a Free Trial and a 30-day Temporary License for evaluation.
Note that there are a number of general policies and practices that guide you on how to evaluate, properly license, and purchase our products. You can find them in the ["Purchase Policies and FAQ"](https://purchase.aspose.com/policies) section.
## **Evaluate Aspose.Slides**
You can easily download Aspose.Slides for evaluation. 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 apply the license.
## **Evaluation Version Limitation**
The evaluation version of Aspose.Slides (without a license specified) provides the full product functionality, with two limitations:
* It adds an evaluation watermark text box to the middle of every slide of each presentation it saves.
* Text that your code reads from a presentation is truncated to its first few characters, followed by a notice about the evaluation limitation. Text that your code writes is saved in full.
If you want to test Aspose.Slides without the evaluation version limitations, you can request a **30 Day Temporary License**. Please refer to [How to get a Temporary License?](https://purchase.aspose.com/temporary-license) for more information.
## **About the License**
You can easily download an evaluation version of Aspose.Slides for PHP via Java from its [download page](https://packagist.org/packages/aspose/slides). The evaluation version provides absolutely **the same capabilities** as the licensed version of Aspose.Slides. Furthermore, the evaluation version simply becomes licensed after you purchase a license and add a couple of lines of code 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 file is digitally signed, so do not modify the file. Even an inadvertent addition of an extra line break to the contents of the file will invalidate it.
To avoid the limitations associated with the evaluation version, you need to set a license before using **Aspose.Slides**. You are only required to set a license once per application or process.
You may want to see [Metered Licensing](https://docs.aspose.com/slides/php-java/metered-licensing/).
## **Purchased License**
After purchase, you need to apply the license file or stream.
You need to set the license:
* only once per application domain
* before using any other Aspose.Slides classes
You can find pricing information on the [“Pricing Information”](https://purchase.aspose.com/pricing/slides/family) page.
### **Set a License in Aspose.Slides for PHP via Java**
Licenses can be applied from these locations:
* Explicit path
* Stream
* As a Metered License – a new licensing mechanism
Use the **setLicense** method to license a component.
While multiple calls to **setLicense** aren't harmful, they are a waste of resources (processor).
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.
#### **Apply a License Using a File**
This code snippet is used to set a license file:
**PHP**
```php
setLicense(__DIR__ . "/Aspose.Slides.lic");
```
The sample expects the license file next to the script and passes its absolute path: Aspose.Slides runs inside Tomcat, so it does not resolve a relative path against your script's folder. When calling the setLicense method, the license name should be same as that of your license file. For example, you can change the license file name to "Aspose.Slides.lic.xml". Then, in your code, you have to pass the new license name (Aspose.Slides.lic.xml) to the setLicense method.
#### **Apply a License from a Stream**
This code snippet is used to apply a license from a stream:
```php
setLicense($stream);
$stream->close();
```
## **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/php-java/evaluate-aspose-slides/)
# Limitations and API Differences
> Compare the limitations and API differences between Aspose.Slides for PHP via Java and Aspose.Slides for Java.
Source: https://docs.aspose.com/slides/php-java/limitations-and-api-differences/
Updated: 2026-08-05
## **Public API Differences**
This list, using sample code segments, demonstrates certain differences between Aspose.Slides for Java and Aspose.Slides for PHP via Java APIs.
### **Importing library (Package Comparisons)**
**Aspose.Slides for Java**
```java
import com.aspose.slides.*;
```
**Aspose.Slides for PHP via Java**
```php
require_once("Java.inc");
require_once("lib/aspose.slides.php");
use aspose\sldes;
use aspose\sldes\Presentation;
```
### **Instantiating a New Presentation**
**Aspose.Slides for Java**
```java
Presentation presentation = new Presentation();
```
**Aspose.Slides for PHP via Java**
```php
$presentation = new Presentation();
```
### **Enums or Constants**
**Aspose.Slides for Java**
```java
arc2.getLineFormat().setDashStyle(MsoLineDashStyle.SOLID);
```
**Aspose.Slides for PHP via Java**
```php
$arc2->getLineFormat()->setDashStyle(slides\LineDashStyle::Solid);
```
### **Example**
**Aspose.Slides for Java**
```java
import com.aspose.slides.ISlide;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
import com.aspose.slides.ShapeType;
public class Test
{
public static void main(String[] args) throws Exception
{
// Instantiates a Presentation object that represents a presentation file
Presentation pres = new Presentation();
try
{
// Gets the first slide
ISlide slide = pres.getSlides().get_Item(0);
// Adds an autoshape with type set to line
slide.getShapes().addAutoShape(ShapeType.Line, 50, 150, 300, 0);
pres.save("NewPresentation_out.pptx", SaveFormat.Pptx);
}
finally
{
if (pres != null) pres.dispose();
}
}
}
```
**Aspose.Slides for PHP via Java**
```php
getSlides()->get_Item(0);
// Adds an autoshape with type set to line
$slide->getShapes()->addAutoShape(ShapeType::Line, 50, 150, 300, 0);
$pres->save("NewPresentation_out.pptx", SaveFormat::Pptx);
}
finally
{
if (!java_is_null($pres)) $pres->dispose();
}
?>
```
### **Other Limitations of Aspose.Slides for PHP via Java API Compared to Aspose.Slides for Java API**
Aspose.Slides namespaces and the java classes they use are wrappers created by the PhpJavaBridge on top of the Java classes with the same name from the com.aspose.slides package.
#### **1. Wrapping Java Parameters and Arguments**
The parameters and arguments they return and accept are wrappers on top of the Java classes with the same names. Only strings and numeric types are converted automatically. Arrays, collections, bytes, and booleans are not converted.
**A common mistake:**
``` php
# Wrong - a Java Boolean is an object, so it is always truthy in PHP:
# if ($node->isAssistant()) { ... }
# Correct - unwrap the Java value first:
# if (java_values($node->isAssistant())) { ... }
```
#### **2. Extending Java Class and Instanceof Operator**
You cannot extend a Java class from a PHP class. As a workaround, you can implement composition when needed.
The instanceof operator only works for a concrete class. It does not work for a class’s interface or parent class.
[workaround](https://stackoverflow.com/questions/36840618/php-java-bridge-usage-of-extend)
#### **3. A Java Array Is NOT a PHP Array**
Java array creation in PHP:
``` php
$Array = new JavaClass("java.lang.reflect.Array");
$Integer = new JavaClass("java.lang.Integer");
$IntegerArray = $Array->newInstance($Integer, 2);
$IntegerArray[0] = 1;
$IntegerArray[1] = 0;
```
#### **4. A Java Array Length**
``` php
# Does NOT work - a Java array is not a PHP object and has no "length" property:
# $data->length;
```
workaround
``` php
$Array = new JavaClass("java.lang.reflect.Array");
$Integer = new JavaClass("java.lang.Integer");
$data = $Array->newInstance($Integer, 2);
$Array->getLength($data);
```
#### **5. The Java Method Files.readAllBytes**
``` php
# Does NOT work - Files and Paths are Java classes and cannot be used like this in PHP:
# $htmlBytes = Files->readAllBytes(Paths->get("embedOle.html"));
```
workaround
``` php
$file = new Java("java.io.File", "embedOle.html");
$Array = new JavaClass("java.lang.reflect.Array");
$Byte = new JavaClass("java.lang.Byte");
$htmlBytes = $Array->newInstance($Byte, $Array->getLength($file));
try {
$dis = new Java("java.io.DataInputStream", new Java("java.io.FileInputStream", $file));
$dis->readFully($htmlBytes);
} finally {
if (!java_is_null($dis)) $dis->close();
}
```
#### **6. The Java Method Files.write**
``` php
# Does NOT work - Files is a Java class, and "new File($path)->toPath()" is not valid PHP:
# Files->write(new File($path)->toPath(), $fontData, StandardOpenOption::CREATE);
```
workaround
``` php
$path = "font.ttf";
$pres = new Presentation("Fonts.pptx");
$fontData = $pres->getFontsManager()->getFontBytes($pres->getFontsManager()->getFonts()[0], FontStyleType::Regular);
$pres->dispose();
$fstr = new Java("java.io.FileOutputStream", $path);
$Array = new java_class("java.lang.reflect.Array");
try {
$fstr->write($fontData, 0, $Array->getLength($fontData));
} finally {
$fstr->close();
}
```
# Add Line Shapes to Presentations in PHP
> Learn to manipulate line formatting in PowerPoint presentations with Aspose.Slides for PHP via Java. Discover properties, methods, and examples.
Source: https://docs.aspose.com/slides/php-java/line/
Updated: 2026-08-02
## **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/php-java/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/php-java/aspose.slides/shapecollection/#addAutoShape) method exposed by [ShapeCollection](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/) 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.
```php
# Instantiate PresentationEx class that represents the PPTX file
$pres = new Presentation();
try {
# Get the first slide
$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 (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Create an Arrow-Shaped Line**
Aspose.Slides for PHP via 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/php-java/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/php-java/aspose.slides/shapecollection/#addAutoShape) method exposed by [ShapeCollection](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/) object.
- Set the [Line Style](https://reference.aspose.com/slides/php-java/aspose.slides/LineStyle) to one of the styles as offered by Aspose.Slides for PHP via Java.
- Set the Width of the line.
- Set the [Dash Style](https://reference.aspose.com/slides/php-java/aspose.slides/LineDashStyle) of the line to one of the styles offered by Aspose.Slides for PHP via Java.
- Set the [Arrow Head Style](https://reference.aspose.com/slides/php-java/aspose.slides/LineArrowheadStyle) and [Length](https://reference.aspose.com/slides/php-java/aspose.slides/LineArrowheadLength) of the start point of the line.
- Set the [Arrow Head Style](https://reference.aspose.com/slides/php-java/aspose.slides/LineArrowheadStyle) and [Length](https://reference.aspose.com/slides/php-java/aspose.slides/LineArrowheadLength) of the end point of the line.
- Write the modified presentation as a PPTX file.
```php
# Instantiate PresentationEx class that represents the PPTX file
$pres = new Presentation();
try {
# Get the first slide
$sld = $pres->getSlides()->get_Item(0);
# Add an AutoShape of type line
$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()->setColor(new java("java.awt.Color", PresetColor->Maroon));
# Write the PPTX to Disk
$pres->save("LineShape.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$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/php-java/aspose.slides/autoshape/) of type [Line](https://reference.aspose.com/slides/php-java/aspose.slides/shapetype/)) does not automatically become a connector. To make it snap to shapes, use the dedicated [Connector](https://reference.aspose.com/slides/php-java/aspose.slides/connector/) type and the [corresponding APIs](https://docs.aspose.com/slides/php-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/php-java/shape-effective-properties/) through the `LineFormatEffectiveData`/`LineFillFormatEffectiveData`—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/php-java/aspose.slides/autoshape/getautoshapelock/) that let you disallow editing operations.
# Low-Code Presentation Operations in PHP
> Use the Aspose.Slides low-code API in PHP to convert and merge presentations, iterate through content, collect shapes, and reduce presentation size.
Source: https://docs.aspose.com/slides/php-java/low-code-presentation-operations/
Updated: 2026-08-25
## **Overview**
The [aspose.slides](https://reference.aspose.com/slides/php-java/aspose.slides/) namespace 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/php-java/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/php-java/aspose.slides/convert/) | Converting a presentation to another format with a direct file-to-file call. |
| [Merger](https://reference.aspose.com/slides/php-java/aspose.slides/merger/) | Combining complete presentation files of the same format. |
| [ForEach_](https://reference.aspose.com/slides/php-java/aspose.slides/foreach_/) | Running a callback for every slide, shape, paragraph, or text portion. |
| [Collect](https://reference.aspose.com/slides/php-java/aspose.slides/collect/) | Retrieving shapes from the entire presentation for repeated processing or analysis. |
| [Compress](https://reference.aspose.com/slides/php-java/aspose.slides/compress/) | Removing unused masters and layouts and reducing embedded font data. |
## **Convert a Presentation**
Use [Convert::autoByExtension](https://reference.aspose.com/slides/php-java/aspose.slides/convert/#autoByExtension) 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.
```php
use aspose\slides\Convert;
Convert::autoByExtension("input.pptx", "output.pdf");
```
The [Convert](https://reference.aspose.com/slides/php-java/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/php-java/convert-presentation/) for format-specific workflows and options.
## **Merge Presentations**
Use [Merger::process](https://reference.aspose.com/slides/php-java/aspose.slides/merger/#process) to combine complete presentation files with one call. The input presentations must have the same file format.
```php
use aspose\slides\Merger;
$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/php-java/merge-presentation/) for those scenarios.
## **Iterate Through Presentation Elements**
The [ForEach_](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/foreach_/#slide), [ForEach_::shape](https://reference.aspose.com/slides/php-java/aspose.slides/foreach_/#shape), [ForEach_::paragraph](https://reference.aspose.com/slides/php-java/aspose.slides/foreach_/#paragraph), and [ForEach_::portion](https://reference.aspose.com/slides/php-java/aspose.slides/foreach_/#portion) to inspect the corresponding elements:
```php
use aspose\slides\ForEach_;
use aspose\slides\Presentation;
class SlideCallback {
public function invoke($slide, $index): void {
$slideIndex = java_values($index);
$shapeCount = java_values($slide->getShapes()->size());
echo sprintf("Slide %d: %d shapes", $slideIndex, $shapeCount) . PHP_EOL;
}
}
class ShapeCallback {
public function invoke($shape, $slide, $index): void {
$shapeIndex = java_values($index);
$slideType = java_values($slide->getClass()->getSimpleName());
$shapeName = java_values($shape->getName());
echo sprintf("Shape %d on %s: %s", $shapeIndex, $slideType, $shapeName) . PHP_EOL;
}
}
class ParagraphCallback {
public function invoke($paragraph, $slide, $index): void {
$paragraphIndex = java_values($index);
$slideType = java_values($slide->getClass()->getSimpleName());
$text = java_values($paragraph->getText());
echo sprintf("Paragraph %d on %s: %s", $paragraphIndex, $slideType, $text) . PHP_EOL;
}
}
class PortionCallback {
public function invoke($portion, $paragraph, $slide, $index): void {
$portionIndex = java_values($index);
$slideType = java_values($slide->getClass()->getSimpleName());
$text = java_values($portion->getText());
echo sprintf("Portion %d on %s: %s", $portionIndex, $slideType, $text) . PHP_EOL;
}
}
$presentation = new Presentation("input.pptx");
try {
$slideCallback = java_closure(new SlideCallback(), null, java('com.aspose.slides.ForEach_$ForEachSlideCallback'));
$shapeCallback = java_closure(new ShapeCallback(), null, java('com.aspose.slides.ForEach_$ForEachShapeCallback'));
$paragraphCallback = java_closure(new ParagraphCallback(), null, java('com.aspose.slides.ForEach_$ForEachParagraphCallback'));
$portionCallback = java_closure(new PortionCallback(), null, java('com.aspose.slides.ForEach_$ForEachPortionCallback'));
ForEach_::slide($presentation, $slideCallback);
ForEach_::shape($presentation, $shapeCallback);
ForEach_::paragraph($presentation, $paragraphCallback);
ForEach_::portion($presentation, $portionCallback);
} 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/php-java/aspose.slides/collect/#shapes) 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.
```php
use aspose\slides\Collect;
use aspose\slides\Presentation;
$presentation = new Presentation("input.pptx");
try {
$shapes = Collect::shapes($presentation);
foreach ($shapes as $shape) {
$shapeName = java_values($shape->getName());
$shapeType = java_values($shape->getClass()->getSimpleName());
echo sprintf("%s: %s", $shapeName, $shapeType) . PHP_EOL;
}
} finally {
$presentation->dispose();
}
```
Use [ForEach_::shape](https://reference.aspose.com/slides/php-java/aspose.slides/foreach_/#shape) 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/php-java/aspose.slides/compress/) class can remove unused structural elements and reduce embedded font data:
- [Compress::removeUnusedLayoutSlides](https://reference.aspose.com/slides/php-java/aspose.slides/compress/#removeUnusedLayoutSlides) removes layout slides that no normal slide references.
- [Compress::removeUnusedMasterSlides](https://reference.aspose.com/slides/php-java/aspose.slides/compress/#removeUnusedMasterSlides) removes master slides that are no longer used.
- [Compress::compressEmbeddedFonts](https://reference.aspose.com/slides/php-java/aspose.slides/compress/#compressEmbeddedFonts) removes unused characters from embedded fonts.
```php
use aspose\slides\Compress;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$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/php-java/slide-master/) and [Embedded Font](https://docs.aspose.com/slides/php-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/php-java/aspose.slides/merger/#process) 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/php-java/aspose.slides/convert/#autoByExtension), and then merge the converted files.
**Does ForEach_ process master, layout, and notes slides?**
[ForEach_::slide](https://reference.aspose.com/slides/php-java/aspose.slides/foreach_/#slide) iterates through normal presentation slides. Presentation-wide [ForEach_::shape](https://reference.aspose.com/slides/php-java/aspose.slides/foreach_/#shape), [ForEach_::paragraph](https://reference.aspose.com/slides/php-java/aspose.slides/foreach_/#paragraph), and [ForEach_::portion](https://reference.aspose.com/slides/php-java/aspose.slides/foreach_/#portion) 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/php-java/aspose.slides/foreach_/#shape) to process each shape immediately through a callback. Use [Collect::shapes](https://reference.aspose.com/slides/php-java/aspose.slides/collect/#shapes) 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/php-java/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/php-java/aspose.slides/presentation/) object in memory. After changing elements in a [ForEach_](https://reference.aspose.com/slides/php-java/aspose.slides/foreach_/) callback or running [Compress](https://reference.aspose.com/slides/php-java/aspose.slides/compress/), call [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#save) to write the result.
## **Related Articles**
- [Convert Presentation](https://docs.aspose.com/slides/php-java/convert-presentation/)
- [Merge Presentations](https://docs.aspose.com/slides/php-java/merge-presentation/)
- [Slide Master](https://docs.aspose.com/slides/php-java/slide-master/)
- [Manage Text Box](https://docs.aspose.com/slides/php-java/manage-textbox/)
- [Embedded Font](https://docs.aspose.com/slides/php-java/embedded-font/)
# Enhance Your Presentations with AutoFit in PHP
> Manage AutoFit settings in Aspose.Slides for PHP to optimize text display in your PowerPoint and OpenDocument presentations and improve content readability.
Source: https://docs.aspose.com/slides/php-java/manage-autofit-settings/
Updated: 2026-08-02
## **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 PHP via Java provides similar options—some properties under the [TextFrameFormat](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/TextFrameFormat#getAutofitType--) property (from the [TextFrameFormat](https://reference.aspose.com/slides/php-java/aspose.slides/TextFrameFormat) class) to `Shape`.

This PHP code shows you how to specify that a text must always fit into its box in a PowerPoint presentation:
```php
$pres = new Presentation();
try {
$slide = $pres->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 30, 30, 350, 100);
$portion = new Portion("lorem ipsum...");
$portion->getPortionFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$portion->getPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$autoShape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->add($portion);
$textFrameFormat = $autoShape->getTextFrame()->getTextFrameFormat();
$textFrameFormat::setAutofitType(TextAutofitType::Shape);
$pres->save("Output-presentation.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$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/php-java/aspose.slides/TextFrameFormat#getAutofitType--) property (from the [TextFrameFormat](https://reference.aspose.com/slides/php-java/aspose.slides/TextFrameFormat) class) to `None`.

This PHP code shows you how to specify that a textbox must always retain its dimensions in a PowerPoint presentation:
```php
$pres = new Presentation();
try {
$slide = $pres->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 30, 30, 350, 100);
$portion = new Portion("lorem ipsum...");
$portion->getPortionFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$portion->getPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$autoShape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->add($portion);
$textFrameFormat = $autoShape->getTextFrame()->getTextFrameFormat();
$textFrameFormat::setAutofitType(TextAutofitType::None);
$pres->save("Output-presentation.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$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/php-java/aspose.slides/TextFrameFormat#getAutofitType--) property (from the [TextFrameFormat](https://reference.aspose.com/slides/php-java/aspose.slides/TextFrameFormat) class) to `Normal`.

This PHP code shows you how to specify that a text must be shrunk on overflow in a PowerPoint presentation:
```php
$pres = new Presentation();
try {
$slide = $pres->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 30, 30, 350, 100);
$portion = new Portion("lorem ipsum...");
$portion->getPortionFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$portion->getPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$autoShape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->add($portion);
$textFrameFormat = $autoShape->getTextFrame()->getTextFrameFormat();
$textFrameFormat::setAutofitType(TextAutofitType::Normal);
$pres->save("Output-presentation.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$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/php-java/aspose.slides/TextFrameFormat#getWrapText--) property (from the [TextFrameFormat](https://reference.aspose.com/slides/php-java/aspose.slides/TextFrameFormat) class) to `true`.
This PHP code shows you how to use the Wrap Text setting in a PowerPoint presentation:
```php
$pres = new Presentation();
try {
$slide = $pres->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 30, 30, 350, 100);
$portion = new Portion("lorem ipsum...");
$portion->getPortionFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$portion->getPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$autoShape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->add($portion);
$textFrameFormat = $autoShape->getTextFrame()->getTextFrameFormat();
$textFrameFormat::setWrapText(NullableBool::True);
$pres->save("Output-presentation.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$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 PHP for Efficient Memory Use
> Manage BLOB data in Aspose.Slides for PHP via Java to streamline PowerPoint and OpenDocument file operations for efficient presentation handling.
Source: https://docs.aspose.com/slides/php-java/manage-blob/
Updated: 2026-08-02
## **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 PHP via 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/php-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:
```php
$pathToVeryLargeVideo = "veryLargeVideo.avi";
# Creates a new presentation to which the video will be added
$pres = new Presentation();
try {
$fileStream = new Java("java.io.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.
$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 (!java_is_null($fileStream)) {
$fileStream->close();
}
}
} catch (JavaException $e) {
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
### **Export a Large File through BLOB from a Presentation**
Aspose.Slides for PHP via 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 demonstrates the described operation:
```php
$hugePresentationWithAudiosAndVideosFile = "LargeVideoFileTest.pptx";
$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.
$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.
$Array = new JavaClass("java.lang.reflect.Array");
$Byte = new JavaClass("java.lang.Byte");
$buffer = $Array->newInstance($Byte, 8 * 1024);
# Iterates through the videos
for($index = 0; $index < java_values($pres->getVideos()->size()) ; $index++) {
$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.
$presVideoStream = $video->getStream();
try {
$outputFileStream = new Java("java.io.FileOutputStream", "video" . $index . ".avi");
try {
$bytesRead;
while ($bytesRead = $presVideoStream->read($buffer, 0, java_values($Array->getLength($buffer))) > 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 (JavaException $e) {
} finally {
$pres->dispose();
}
```
### **Add an Image as BLOB to a Presentation**
With methods from the [ImageCollection](https://reference.aspose.com/slides/php-java/aspose.slides/imagecollection/) class, you can add a large image as a stream to get it treated as a BLOB.
This PHP code shows you how to add a large image through the BLOB process:
```php
$pathToLargeImage = "large_image.jpg";
# creates a new presentation to which the image will be added.
$pres = new Presentation();
try {
$fileStream = new Java("java.io.FileInputStream", $pathToLargeImage);
try {
# Let's add the image to the presentation - we choose KeepLocked behavior because we do
# NOT intend to access the "largeImage.png" file.
$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 (!java_is_null($fileStream)) {
$fileStream->close();
}
}
} catch (JavaException $e) {
} finally {
if (!java_is_null($pres)) {
$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 PHP code:
```php
$pres = new Presentation("large.pptx");
try {
$pres->save("large.pdf", SaveFormat::Pdf);
} finally {
if (!java_is_null($pres)) {
$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 PHP code describes the implementation where the BLOB process is used to load up a large presentation file (large.pptx):
```php
$loadOptions = new LoadOptions();
$loadOptions->getBlobManagementOptions()->setPresentationLockingBehavior(PresentationLockingBehavior->KeepLocked);
$loadOptions->getBlobManagementOptions()->setTemporaryFilesAllowed(true);
$pres = new Presentation("large.pptx", $loadOptions);
try {
$pres->save("large.pdf", SaveFormat::Pdf);
} finally {
if (!java_is_null($pres)) {
$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 `setTempFilesRootPath`:
```php
$loadOptions = new LoadOptions();
$loadOptions->getBlobManagementOptions()->setPresentationLockingBehavior(PresentationLockingBehavior->KeepLocked);
$loadOptions->getBlobManagementOptions()->setTemporaryFilesAllowed(true);
$loadOptions->getBlobManagementOptions()->setTempFilesRootPath("temp");
```
When you use `setTempFilesRootPath`, 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/php-java/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.
```php
$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/php-java/aspose.slides/loadoptions/) with [BlobManagementOptions](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/blobmanagementoptions/setmaxblobsbytesinmemory/) 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/php-java/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 PHP
> Manage PowerPoint table cells in PHP: identify merged cells, remove borders, split cells, and set background colors and images with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-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/php-java/aspose.slides/cell/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/php-java/aspose.slides/cell/getrowspan/), [getColSpan](https://reference.aspose.com/slides/php-java/aspose.slides/cell/getcolspan/), and the region's starting coordinates, [getFirstRowIndex](https://reference.aspose.com/slides/php-java/aspose.slides/cell/getfirstrowindex/) and [getFirstColumnIndex](https://reference.aspose.com/slides/php-java/aspose.slides/cell/getfirstcolumnindex/).
```php
use aspose\slides\Presentation;
$presentation = new Presentation("presentation_with_table.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$table = $slide->getShapes()->get_Item(0);
$rowCount = java_values($table->getRows()->size());
for ($rowIndex = 0; $rowIndex < $rowCount; $rowIndex++)
{
$columnCount = java_values($table->getColumns()->size());
for ($columnIndex = 0; $columnIndex < $columnCount; $columnIndex++)
{
$cell = $table->get_Item($columnIndex, $rowIndex);
if (java_values($cell->isMergedCell()))
{
printf("Cell %d;%d belongs to a merged region with RowSpan=%d and ColSpan=%d starting at %d;%d.\n", $rowIndex, $columnIndex, java_values($cell->getRowSpan()), java_values($cell->getColSpan()), java_values($cell->getFirstRowIndex()), java_values($cell->getFirstColumnIndex()));
}
}
}
} finally {
$presentation->dispose();
}
```
## **Remove Table Cell Borders**
Create a [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) and add a table to its first slide with [addTable](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/addtable/). 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/php-java/aspose.slides/filltype/), making them invisible.
```php
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$columnWidths = [ 50, 50, 50, 50 ];
$rowHeights = [ 50, 30, 30, 30, 30 ];
$table = $slide->getShapes()->addTable(100, 50, $columnWidths, $rowHeights);
for ($rowIndex = 0; $rowIndex < java_values($table->getRows()->size()); $rowIndex++) {
for ($columnIndex = 0; $columnIndex < java_values($table->getColumns()->size()); $columnIndex++) {
$cell = $table->get_Item($columnIndex, $rowIndex);
$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/php-java/aspose.slides/cellformat/getborderdiagonaldown/) to draw a line from the top-left corner to the bottom-right, and [getBorderDiagonalUp](https://reference.aspose.com/slides/php-java/aspose.slides/cellformat/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 has its own [LineFormat](https://reference.aspose.com/slides/php-java/aspose.slides/lineformat/). In its [getFillFormat](https://reference.aspose.com/slides/php-java/aspose.slides/lineformat/getfillformat/), use [setFillType](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/setfilltype/) to select [FillType::Solid](https://reference.aspose.com/slides/php-java/aspose.slides/filltype/) and choose a color through [getSolidFillColor](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/getsolidfillcolor/). Set the line's width in points with [setWidth](https://reference.aspose.com/slides/php-java/aspose.slides/lineformat/setwidth/).
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.
```php
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$columnWidths = [ 210, 210, 210 ];
$rowHeights = [ 160 ];
$table = $slide->getShapes()->addTable(45, 130, $columnWidths, $rowHeights);
$downwardBorder = $table->get_Item(0, 0)->getCellFormat()->getBorderDiagonalDown();
$downwardBorder->getFillFormat()->setFillType(FillType::Solid);
$downwardBorder->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->RED);
$downwardBorder->setWidth(3);
$upwardBorder = $table->get_Item(1, 0)->getCellFormat()->getBorderDiagonalUp();
$upwardBorder->getFillFormat()->setFillType(FillType::Solid);
$upwardBorder->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLUE);
$upwardBorder->setWidth(5);
$crossDownwardBorder = $table->get_Item(2, 0)->getCellFormat()->getBorderDiagonalDown();
$crossDownwardBorder->getFillFormat()->setFillType(FillType::Solid);
$crossDownwardBorder->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->RED);
$crossDownwardBorder->setWidth(3);
$crossUpwardBorder = $table->get_Item(2, 0)->getCellFormat()->getBorderDiagonalUp();
$crossUpwardBorder->getFillFormat()->setFillType(FillType::Solid);
$crossUpwardBorder->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLUE);
$crossUpwardBorder->setWidth(5);
$presentation->save("diagonal_cell_borders.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
A diagonal changes only the cell formatting. Each cell retains a single text frame, accessed through [getTextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/cell/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/php-java/aspose.slides/table/mergecells/) 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.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$columnWidths = [ 70, 70, 70, 70 ];
$rowHeights = [ 70, 70, 70, 70 ];
$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/php-java/aspose.slides/cell/splitbywidth/) 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.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$columnWidths = [ 70, 70, 70, 70 ];
$rowHeights = [ 70, 70, 70, 70 ];
$table = $slide->getShapes()->addTable(100, 50, $columnWidths, $rowHeights);
$table->get_Item(1, 1)->splitByWidth(java_values($table->get_Item(1, 1)->getWidth()) / 2);
$presentation->save("split_cells.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
[](https://docs.aspose.com/slides/php-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/php-java/aspose.slides/cell/splitbyrowspan/) to split along an existing row boundary, or [splitByColSpan](https://reference.aspose.com/slides/php-java/aspose.slides/cell/splitbycolspan/) 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/php-java/aspose.slides/cell/getrowspan/).
- Column split: `0 < index <` [getColSpan](https://reference.aspose.com/slides/php-java/aspose.slides/cell/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/php-java/aspose.slides/cell/getfirstcolumnindex/) and [getFirstRowIndex](https://reference.aspose.com/slides/php-java/aspose.slides/cell/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.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("table_template.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$table = $slide->getShapes()->get_Item(0);
$selectedCell = $table->get_Item(1, 3);
$firstColumnIndex = java_values($selectedCell->getFirstColumnIndex());
$firstRowIndex = java_values($selectedCell->getFirstRowIndex());
$mergedCell = $table->get_Item($firstColumnIndex, $firstRowIndex);
if (java_values($mergedCell->isMergedCell()) && java_values($mergedCell->getRowSpan()) == 2 && java_values($mergedCell->getColSpan()) == 1)
{
$mergedCell->splitByRowSpan(1);
// Retrieve the resulting cells from the table after splitting.
$upperCell = $table->get_Item($firstColumnIndex, $firstRowIndex);
$lowerCell = $table->get_Item($firstColumnIndex, $firstRowIndex + 1);
echo "Upper cell merged: " . (java_values($upperCell->isMergedCell()) ? "true" : "false") . PHP_EOL;
echo "Lower cell merged: " . (java_values($lowerCell->isMergedCell()) ? "true" : "false") . PHP_EOL;
$upperCell->getTextFrame()->setText("Product A");
$lowerCell->getTextFrame()->setText("Product B");
$presentation->save("split_template.pptx", SaveFormat::Pptx);
}
else
{
echo "Select a merged region spanning exactly two rows and one column." . PHP_EOL;
}
} 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/php-java/aspose.slides/cell/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/php-java/aspose.slides/cell/) for details.
### **Split a Cell at a Specific Height**
[splitByHeight](https://reference.aspose.com/slides/php-java/aspose.slides/cell/splitbyheight/) takes the height of the upper part in points. [splitByRowSpan](https://reference.aspose.com/slides/php-java/aspose.slides/cell/splitbyrowspan/) 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.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$columnWidths = [ 160, 160 ];
$rowHeights = [ 140 ];
$table = $slide->getShapes()->addTable(50, 50, $columnWidths, $rowHeights);
$table->get_Item(0, 0)->getTextFrame()->setText("Left");
$rightCell = $table->get_Item(1, 0);
$height = java_values($rightCell->getHeight());
$margin = ($height - 40) / 2;
$rightCell->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/php-java/aspose.slides/fillformat/setfilltype/) to select a solid fill and sets the color returned by [getSolidFillColor](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/getsolidfillcolor/) to red for cell `(2, 3)`, in the third column and fourth row.
```php
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$columnWidths = [ 150, 150, 150, 150 ];
$rowHeights = [ 50, 50, 50, 50, 50 ];
$table = $slide->getShapes()->addTable(50, 50, $columnWidths, $rowHeights);
$cell = $table->get_Item(2, 3);
$cell->getCellFormat()->getFillFormat()->setFillType(FillType::Solid);
$cell->getCellFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.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/php-java/aspose.slides/images/#fromFile) and adds it to the presentation's image collection with [addImage](https://reference.aspose.com/slides/php-java/aspose.slides/imagecollection/addimage/). 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/php-java/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.
```php
use aspose\slides\FillType;
use aspose\slides\Images;
use aspose\slides\PictureFillMode;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$columnWidths = [ 150, 150, 150, 150 ];
$rowHeights = [ 100, 100, 100, 100, 90 ];
$table = $slide->getShapes()->addTable(50, 50, $columnWidths, $rowHeights);
$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/php-java/aspose.slides/cellformat/getbordertop/)/[bottom](https://reference.aspose.com/slides/php-java/aspose.slides/cellformat/getborderbottom/)/[left](https://reference.aspose.com/slides/php-java/aspose.slides/cellformat/getborderleft/)/[right](https://reference.aspose.com/slides/php-java/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/php-java/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/php-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/php-java/aspose.slides/portion/) (runs) with independent formatting—font family, style, size, and color.
## Related articles
- [Create and Customize PowerPoint Tables in PHP](https://docs.aspose.com/slides/php-java/powerpoint-table/)
- [Table](https://docs.aspose.com/slides/php-java/examples/elements/table/)
- [Manage Presentation Tables in PHP](https://docs.aspose.com/slides/php-java/manage-table/)
# Manage Fonts in Presentations Using PHP
> Control fonts in PHP 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/php-java/manage-fonts/
Updated: 2026-08-13
## **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 PHP via Java to configure the font properties of paragraphs of text on slides.
To manage font properties of a paragraph using Aspose.Slides for PHP via Java:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation) class.
1. Obtain a slide's reference by using its index.
1. Access the [Placeholder](https://reference.aspose.com/slides/php-java/aspose.slides/placeholder/) shapes in the slide and typecast them to [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/).
1. Get the [Paragraph](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/) from the [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/) exposed by [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/).
1. Justify the paragraph.
1. Access a [Paragraph](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/)'s text [Portion](https://reference.aspose.com/slides/php-java/aspose.slides/portion/).
1. Define the font using [FontData](https://reference.aspose.com/slides/php-java/aspose.slides/fontdata/) and set the **Font** of the text [Portion](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/fillformat/) exposed by the [Portion](https://reference.aspose.com/slides/php-java/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**|
```php
# Instantiate a Presentation object that represents a PPTX file
$pres = new Presentation("FontProperties.pptx");
try {
# Accessing a slide using its slide position
$slide = $pres->getSlides()->get_Item(0);
# Accessing the first and second placeholder in the slide and typecasting it as AutoShape
$tf1 = $slide->getShapes()->get_Item(0)->getTextFrame();
$tf2 = $slide->getShapes()->get_Item(1)->getTextFrame();
# Accessing the first Paragraph
$para1 = $tf1->getParagraphs()->get_Item(0);
$para2 = $tf2->getParagraphs()->get_Item(0);
# Justify the paragraph
$para2->getParagraphFormat()->setAlignment(TextAlignment->JustifyLow);
# Accessing the first portion
$port1 = $para1->getPortions()->get_Item(0);
$port2 = $para2->getPortions()->get_Item(0);
# Define new fonts
$fd1 = new FontData("Elephant");
$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(java("java.awt.Color")->BLUE);
$port2->getPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$port2->getPortionFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->GREEN);
# Save the PPTX to disk
$pres->save("WelcomeFont.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Set Text Font Properties**
As mentioned in **Managing Font Related Properties**, a [Portion](https://reference.aspose.com/slides/php-java/aspose.slides/portion/) is used to hold text with similar formatting style in a paragraph. This article shows how to use Aspose.Slides for PHP via 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/php-java/aspose.slides/presentation) class.
1. Obtain the reference of a slide by using its index.
1. Add an [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/) of the type **Rectangle** to the slide.
1. Remove the fill style associated with the [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/).
1. Access the of the [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/)'s [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/).
1. Add some text to the [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/).
1. Access the [Portion](https://reference.aspose.com/slides/php-java/aspose.slides/portion/) object associated with the [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/).
1. Define the font to be used for the [Portion](https://reference.aspose.com/slides/php-java/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/php-java/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 PHP via Java**|
```php
# Instantiate a Presentation object that represents a PPTX file
$pres = new Presentation();
try {
# Get first slide
$sld = $pres->getSlides()->get_Item(0);
# Add an AutoShape of Rectangle type
$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
$tf = $ashp->getTextFrame();
$tf->setText("Aspose TextBox");
# Access the Portion associated with the TextFrame
$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(java("java.awt.Color")->BLUE);
# Save the presentation to disk
$pres->save("pptxFont.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
# Manage Presentation Hyperlinks in PHP
> Add, format, update, and remove hyperlinks in PowerPoint and OpenDocument presentations with Aspose.Slides for PHP via Java, using PHP examples.
Source: https://docs.aspose.com/slides/php-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 PHP via 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. They assume that PHP/Java Bridge and the Aspose.Slides PHP wrapper are initialized. API members without a PHP reference page link to the underlying Java API.
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/php-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/php-java/aspose.slides/hyperlink/) to the text portion's [setHyperlinkClick](https://reference.aspose.com/slides/php-java/aspose.slides/portionformat/sethyperlinkclick/) method, as shown below. Only that portion of text becomes clickable.
```php
use aspose\slides\Hyperlink;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$textShape = $presentation->getSlides()->get_Item(0)->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 600, 50, false);
$textShape->addTextFrame("Aspose: File Format APIs");
$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/php-java/aspose.slides/shape/sethyperlinkclick/) 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/php-java/aspose.slides/hyperlink/settooltip/) if needed.
The following example makes a rectangle clickable:
```php
use aspose\slides\Hyperlink;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$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/php-java/aspose.slides/hyperlinkmanager/setinternalhyperlinkclick/) to link the “Page 2” text on the first slide to the second slide.
```php
use aspose\slides\FillType;
use aspose\slides\Paragraph;
use aspose\slides\Portion;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$firstSlide = $presentation->getSlides()->get_Item(0);
$secondSlide = $presentation->getSlides()->addEmptySlide($firstSlide->getLayoutSlide());
$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 = new Paragraph();
$paragraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$paragraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$paragraph->setText("Title of slide 2 .......... ");
$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/php-java/aspose.slides/hyperlink/setcolorsource/) method of [Hyperlink](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlink/) 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/php-java/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.
```php
use aspose\slides\FillType;
use aspose\slides\Hyperlink;
use aspose\slides\HyperlinkColorSource;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$coloredShape = $presentation->getSlides()->get_Item(0)->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 450, 50, false);
$coloredShape->addTextFrame("This hyperlink uses a custom color.");
$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(java("java.awt.Color")->RED);
$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:
- [Hyperlink::setSound](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlink/setsound/) specifies the audio associated with the hyperlink.
- [Hyperlink::setStopSoundOnClick](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlink/setstopsoundonclick/) 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.
```php
use aspose\slides\Hyperlink;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$audioFile = new Java("java.io.File", "sampleaudio.wav");
$audioPath = $audioFile->toPath();
$audioData = java("java.nio.file.Files")->readAllBytes($audioPath);
$hyperlinkSound = $presentation->getAudios()->addAudio($audioData);
$firstSlide = $presentation->getSlides()->get_Item(0);
$playButton = $firstSlide->getShapes()->addAutoShape(ShapeType::SoundButton, 100, 100, 100, 50);
$playButton->setHyperlinkClick(Hyperlink::getNextSlide());
if (!java_values($playButton->getHyperlinkClick()->getStopSoundOnClick()) && java_is_null($playButton->getHyperlinkClick()->getSound()))
{
$playButton->getHyperlinkClick()->setSound($hyperlinkSound);
}
$secondSlide = $presentation->getSlides()->addEmptySlide($firstSlide->getLayoutSlide());
$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 (JavaException $exception) {
echo "Unable to read the audio file: " . $exception->getMessage() . PHP_EOL;
} 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/php-java/aspose.slides/hyperlink/getsound/) and [getBinaryData](https://reference.aspose.com/slides/php-java/aspose.slides/audio/getbinarydata/).
```php
use aspose\slides\Presentation;
$presentation = new Presentation("hyperlink-sound.pptx");
try {
if (java_values($presentation->getSlides()->size()) > 0 && java_values($presentation->getSlides()->get_Item(0)->getShapes()->size()) > 0) {
$hyperlink = $presentation->getSlides()->get_Item(0)->getShapes()->get_Item(0)->getHyperlinkClick();
$sound = java_is_null($hyperlink) ? null : $hyperlink->getSound();
if (!java_is_null($sound)) {
$audioData = $sound->getBinaryData();
echo "Extracted " . strlen(java_values($audioData)) . " bytes of hyperlink audio." . PHP_EOL;
} else {
echo "The first shape has no hyperlink sound." . PHP_EOL;
}
} else {
echo "The presentation has no first slide or shape to inspect." . PHP_EOL;
}
} finally {
$presentation->dispose();
}
```
### **Tooltip and Interaction Settings**
You can call the following [Hyperlink](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlink/) methods after assigning a hyperlink to text or a shape:
- [setTooltip](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlink/settooltip/) sets the text that a viewer can display as a hint for the link.
- [setTargetFrame](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlink/settargetframe/) specifies the target frame within a parent HTML frameset, when applicable.
- [setHistory](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlink/sethistory/) controls whether activating the link adds its destination to the list of viewed hyperlinks.
- [setHighlightClick](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlink/sethighlightclick/) controls whether the hyperlink is highlighted when clicked.
## **Remove Hyperlinks from Presentations**
Use [getAnyHyperlinks](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlinkqueries/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/php-java/aspose.slides/hyperlinkmanager/removehyperlinkclick/) or [removeHyperlinkMouseOver](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlinkmanager/removehyperlinkmouseover/); removing a click action does not remove its mouse-over counterpart.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("pres.pptx");
try {
if (java_values($presentation->getSlides()->size()) > 0) {
$containers = [];
foreach ($presentation->getSlides()->get_Item(0)->getHyperlinkQueries()->getAnyHyperlinks() as $container) {
$containers[] = $container;
}
foreach ($containers as $container) {
$container->getHyperlinkManager()->removeHyperlinkClick();
$container->getHyperlinkManager()->removeHyperlinkMouseOver();
}
$presentation->save("pres-removed-hyperlinks.pptx", SaveFormat::Pptx);
} else {
echo "The presentation has no slides to process." . PHP_EOL;
}
} finally {
$presentation->dispose();
}
```
For unconditional removal, [removeAllHyperlinks](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlinkqueries/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/php-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/php-java/aspose.slides/hyperlinkqueries/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 [HyperlinkQueries](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlinkqueries/) class is available through [Presentation::getHyperlinkQueries](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/gethyperlinkqueries/), [IBaseSlide::getHyperlinkQueries](https://reference.aspose.com/slides/java/com.aspose.slides/ibaseslide/#getHyperlinkQueries--), and [TextFrame::getHyperlinkQueries](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/gethyperlinkqueries/). Each scope supports the same queries:
- [getHyperlinkClicks](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlinkqueries/gethyperlinkclicks/) returns containers with a click action.
- [getHyperlinkMouseOvers](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlinkqueries/gethyperlinkmouseovers/) returns containers with a mouse-over action.
- [getAnyHyperlinks](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlinkqueries/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.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
function printQueryCounts($scope, $queries) {
$clickCount = java_values($queries->getHyperlinkClicks()->size());
$mouseOverCount = java_values($queries->getHyperlinkMouseOvers()->size());
$anyCount = java_values($queries->getAnyHyperlinks()->size());
echo "$scope: click=$clickCount, mouse-over=$mouseOverCount, any=$anyCount" . PHP_EOL;
}
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$destination = $presentation->getSlides()->addEmptySlide($slide->getLayoutSlide());
$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");
$portionFormat = $shape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0)->getPortionFormat();
$portionFormat->getHyperlinkManager()->setInternalHyperlinkClick($destination);
$portionFormat->getHyperlinkManager()->setExternalHyperlinkMouseOver("https://example.com/help");
$macroButton = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 120, 200, 60);
$macroButton->getHyperlinkManager()->setMacroHyperlinkClick("ReviewPresentation");
printQueryCounts("Presentation", $presentation->getHyperlinkQueries());
printQueryCounts("Slide 1", $slide->getHyperlinkQueries());
printQueryCounts("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 [Hyperlink::getActionType](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlink/getactiontype/) to interpret an action before interpreting its destination. The [HyperlinkActionType](https://reference.aspose.com/slides/php-java/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/php-java/aspose.slides/hyperlink/getexternalurl/) and specific internal destinations from [getTargetSlide](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlink/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/php-java/aspose.slides/hyperlink/gettooltip/) when available.
### **Report, Sanitize, and Verify Hyperlinks**
The following PHP 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 PHP 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/php-java/aspose.slides/hyperlinkmanager/setexternalhyperlinkclick/), [removeHyperlinkClick](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlinkmanager/removehyperlinkclick/), and [removeHyperlinkMouseOver](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlinkmanager/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/php-java/convert-powerpoint-to-pdf/) and [HTML](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-html/) exports may preserve hyperlinks, depending on the action, export options, and viewer. Raster [images](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-png/) and [video](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-video/) cannot preserve interactive hyperlinks; flag every action when auditing for those outputs.
```php
use aspose\slides\HyperlinkActionType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
class HyperlinkAudit {
public function slideIndex($presentation, $slide) {
if (java_is_null($slide)) return null;
for ($index = 0; $index < java_values($presentation->getSlides()->size()); $index++) {
if (java_values($presentation->getSlides()->get_Item($index)->equals($slide))) return $index + 1;
}
return null;
}
public function isHttps($value) {
if ($value === null || $value === '') return false;
$parts = parse_url($value);
return $parts !== false && isset($parts['scheme'], $parts['host']) && strcasecmp($parts['scheme'], 'https') === 0 && $parts['host'] !== '';
}
public function policyViolation($link) {
if (java_is_null($link)) return null;
$action = java_values($link->getActionType());
if ($action === HyperlinkActionType::JumpSpecificSlide) {
return java_is_null($link->getTargetSlide()) ? 'Missing target slide' : null;
}
if ($action !== HyperlinkActionType::Hyperlink) return 'Action is not allowed';
if (!$this->isHttps(java_values($link->getExternalUrl()))) return 'Normalized URL is not absolute HTTPS';
$original = java_values($link->getExternalUrlOriginal());
if ($original !== null && $original !== '' && !$this->isHttps($original)) return 'Original URL is not absolute HTTPS';
return null;
}
public function addScope(&$found, $slide) {
if (!java_is_null($slide)) {
foreach ($slide->getHyperlinkQueries()->getAnyHyperlinks() as $container) {
$found[] = $container;
}
}
}
public function collectContainers($presentation) {
$found = [];
foreach ($presentation->getHyperlinkQueries()->getAnyHyperlinks() as $container) {
$found[] = $container;
}
$masters = $presentation->getMasters();
for ($index = 0; $index < java_values($masters->size()); $index++) {
$this->addScope($found, $masters->get_Item($index));
}
$layouts = $presentation->getLayoutSlides();
for ($index = 0; $index < java_values($layouts->size()); $index++) {
$this->addScope($found, $layouts->get_Item($index));
}
$slides = $presentation->getSlides();
for ($index = 0; $index < java_values($slides->size()); $index++) {
$this->addScope($found, $slides->get_Item($index)->getNotesSlideManager()->getNotesSlide());
}
$this->addScope($found, $presentation->getMasterNotesSlideManager()->getMasterNotesSlide());
$this->addScope($found, $presentation->getMasterHandoutSlideManager()->getMasterHandoutSlide());
$seen = new Java('java.util.IdentityHashMap');
$unique = [];
foreach ($found as $container) {
if (!java_values($seen->containsKey($container))) {
$seen->put($container, true);
$unique[] = $container;
}
}
return $unique;
}
public function addRow(&$rows, $presentation, $link, $activation, $container, $containerId) {
if (java_is_null($link)) return;
$ownerSlide = java_instanceof($container, java('com.aspose.slides.ISlideComponent')) ? $container->getSlide() : null;
$targetSlide = $link->getTargetSlide();
$violation = $this->policyViolation($link);
$ownerType = java_instanceof($container, java('com.aspose.slides.IShape')) ? 'Shape' : (java_instanceof($container, java('com.aspose.slides.IPortionFormat')) ? 'Text portion' : java_values($container->getClass()->getSimpleName()));
$action = java_values($link->getActionType());
$ordinaryAction = $action === HyperlinkActionType::Hyperlink || $action === HyperlinkActionType::JumpSpecificSlide;
$externalUrl = java_values($link->getExternalUrl());
$originalUrl = java_values($link->getExternalUrlOriginal());
$rows[] = [
'ContainerId' => $containerId,
'SlideIndex' => $this->slideIndex($presentation, $ownerSlide),
'SlideId' => java_is_null($ownerSlide) ? null : java_values($ownerSlide->getSlideId()),
'Scope' => java_is_null($ownerSlide) ? null : java_values($ownerSlide->getClass()->getSimpleName()),
'OwnerType' => $ownerType,
'Activation' => $activation,
'ActionType' => $action,
'ExternalUrl' => $externalUrl,
'TargetSlideIndex' => $this->slideIndex($presentation, $targetSlide),
'TargetSlideId' => java_is_null($targetSlide) ? null : java_values($targetSlide->getSlideId()),
'Tooltip' => java_values($link->getTooltip()),
'OriginalExternalUrl' => $originalUrl === $externalUrl ? null : $originalUrl,
'PotentiallyUnsafe' => $violation !== null,
'PolicyViolation' => $violation,
'TargetExport' => 'PDF',
'PotentiallyUnsupportedByExport' => $activation === 'mouse-over' || !$ordinaryAction
];
}
}
$replaceExternalClicks = true;
$replacementUrl = 'https://example.com/blocked-link';
$audit = new HyperlinkAudit();
$presentation = new Presentation('hyperlink-audit-input.pptx');
try {
$containers = $audit->collectContainers($presentation);
$rows = [];
foreach ($containers as $index => $container) {
$audit->addRow($rows, $presentation, $container->getHyperlinkClick(), 'click', $container, $index + 1);
$audit->addRow($rows, $presentation, $container->getHyperlinkMouseOver(), 'mouse-over', $container, $index + 1);
}
$json = json_encode($rows, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
if ($json === false) {
echo 'Unable to encode the audit report: ' . json_last_error_msg() . PHP_EOL;
} elseif (file_put_contents('hyperlink-audit.json', $json . PHP_EOL) === false) {
echo 'Unable to write the audit report.' . PHP_EOL;
} else {
foreach ($containers as $container) {
$click = $container->getHyperlinkClick();
if ($audit->policyViolation($click) !== null) {
if ($replaceExternalClicks && java_values($click->getActionType()) === HyperlinkActionType::Hyperlink) {
$container->getHyperlinkManager()->setExternalHyperlinkClick($replacementUrl);
} else {
$container->getHyperlinkManager()->removeHyperlinkClick();
}
}
if ($audit->policyViolation($container->getHyperlinkMouseOver()) !== null) {
$container->getHyperlinkManager()->removeHyperlinkMouseOver();
}
}
$presentation->save('hyperlink-sanitized.pptx', SaveFormat::Pptx);
$reopened = new Presentation('hyperlink-sanitized.pptx');
try {
$remainingContainers = $audit->collectContainers($reopened);
$violations = 0;
foreach ($remainingContainers as $container) {
if ($audit->policyViolation($container->getHyperlinkClick()) !== null) $violations++;
if ($audit->policyViolation($container->getHyperlinkMouseOver()) !== null) $violations++;
}
echo 'Audit rows: ' . count($rows) . '; prohibited actions after reopening: ' . $violations . PHP_EOL;
if ($violations !== 0) {
echo 'Verification failed: do not distribute the saved presentation.' . PHP_EOL;
}
} finally {
$reopened->dispose();
}
}
} finally {
$presentation->dispose();
}
```
With the input created above, the report contains five action rows. The file mouse-over link and macro click are removed, while the HTTPS links and internal slide navigation remain. The verification prints zero prohibited actions. An input containing a prohibited external click URL also exercises the replacement branch. A container with an allowed click and a prohibited mouse-over keeps its click action.
This selective cleanup differs from [removeAllHyperlinks](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlinkqueries/removeallhyperlinks/), which removes both activation types throughout the selected scope regardless of policy. Verification here checks hyperlink actions only; it does not remove embedded VBA projects, OLE objects, or other active content, and it does not validate an exported PDF or HTML file.
## **FAQ**
**How can I link to a section or its first slide?**
Sections in PowerPoint group slides, but an internal hyperlink targets an individual slide. To create navigation to a section, link to the first slide in that section.
**Can I attach a hyperlink to master slide elements so it works on all slides?**
Yes. Master slide and layout elements support hyperlinks. Links on these elements are available during the slide show on slides that use the corresponding master or layout.
**Will hyperlinks be preserved when exporting to PDF, HTML, images, or video?**
Supported PDF and HTML exports may preserve hyperlinks; raster images and video cannot. See the export considerations in [Report, Sanitize, and Verify Hyperlinks](https://docs.aspose.com/slides/php-java/manage-hyperlinks/#report-sanitize-and-verify-hyperlinks).
## Related articles
- [Hyperlink](https://docs.aspose.com/slides/php-java/examples/elements/hyperlink/)
# Manage Presentation Ink Objects in PHP
> Manage PowerPoint ink objects, edit traces and brush properties, and control ink appearance during PDF, HTML, SVG, TIFF, and image export with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/manage-ink/
Updated: 2026-08-10
## **Introduction**
PowerPoint provides an ink feature that allows you to draw freeform strokes. Ink can be used to highlight other objects, show connections and processes, and draw attention to specific items on a slide.
Aspose.Slides provides the types needed to work with ink objects. For example, the [Ink](https://reference.aspose.com/slides/php-java/aspose.slides/ink/) class represents an ink object on a slide.
## **Differences between Regular Objects and Ink Objects**
Objects on a PowerPoint slide are typically represented by [Shape](https://reference.aspose.com/slides/php-java/aspose.slides/shape/) objects. In its simplest form, a shape is a container that defines the area of the object itself (its frame) along with properties such as the container size, shape, and background. For more information, see [Shape Layout Format](https://docs.aspose.com/slides/php-java/shape-manipulations/#access-layout-formats-for-shape).
However, when PowerPoint handles an ink object, it ignores all properties of the object frame (container) except its size. The size of the container area is determined by the standard [Shape.getWidth](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#getWidth) and [Shape.getHeight](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#getHeight) methods:

## **Ink Traces**
An ink trace is a basic element used to record the trajectory of a pen as a user writes digital ink. A trace stores a sequence of connected points.
The simplest form of encoding specifies the X and Y coordinates of each sample point. When all connected points are rendered, they produce an image like this:

## **Brush Properties for Drawing**
A brush is used to draw lines that connect the points of an ink trace. The brush has its own color and size, represented by the [InkBrush.getColor](https://reference.aspose.com/slides/php-java/aspose.slides/inkbrush/#getColor) and [InkBrush.getSize](https://reference.aspose.com/slides/php-java/aspose.slides/inkbrush/#getSize) methods.
### **Set Ink Brush Color**
This PHP code shows how to set the color of an ink brush:
```php
$presentation = new Presentation("pres.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$ink = $slide->getShapes()->get_Item(0);
$brush = $ink->getTraces()[0]->getBrush();
$brush->setColor(java("java.awt.Color")->RED);
} finally {
$presentation->dispose();
}
```
### **Set Ink Brush Size**
This PHP code shows how to set the size of an ink brush:
```php
$presentation = new Presentation("pres.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$ink = $slide->getShapes()->get_Item(0);
$brush = $ink->getTraces()[0]->getBrush();
$brushSize = new Java("java.awt.Dimension", 5, 10);
$brush->setSize($brushSize);
} finally {
$presentation->dispose();
}
```
Generally, a brush's width and height do not match, so PowerPoint does not display the brush size (the corresponding data section is grayed out). When the brush width and height match, PowerPoint displays its size this way:

For clarity, let's increase the height of the ink object and review the important dimensions:

The container (frame) does not account for the size of the brushes—it always assumes that the line thickness is zero (see the previous image).
Therefore, to determine the visible area of the entire ink object, the brush size of its traces must be taken into account. Here, the target object (the handwritten text trace) has been scaled to the size of the container (frame). When the size of the container changes, the brush size remains constant, and vice versa.

PowerPoint uses similar behavior for text objects:

## **Control Ink Appearance During Export and Rendering**
Aspose.Slides provides the [InkOptions](https://reference.aspose.com/slides/php-java/aspose.slides/inkoptions/) class to control how ink objects appear in exported or rendered output. You can use its properties to hide ink completely or change how ink brush mask operations are interpreted.
Ink options are available through the export or rendering options for several output types:
| Output | Ink options property |
| --- | --- |
| PDF | [PdfOptions.getInkOptions](https://reference.aspose.com/slides/php-java/aspose.slides/pdfoptions/#getInkOptions) |
| HTML | [HtmlOptions.getInkOptions](https://reference.aspose.com/slides/php-java/aspose.slides/htmloptions/#getInkOptions) |
| SVG | [SVGOptions.getInkOptions](https://reference.aspose.com/slides/php-java/aspose.slides/svgoptions/#getInkOptions) |
| TIFF | [TiffOptions.getInkOptions](https://reference.aspose.com/slides/php-java/aspose.slides/tiffoptions/#getInkOptions) |
| Slide image | [RenderingOptions.getInkOptions](https://reference.aspose.com/slides/php-java/aspose.slides/renderingoptions/#getInkOptions) |
The following [InkOptions](https://reference.aspose.com/slides/php-java/aspose.slides/inkoptions/) methods expose the same two settings:
- [InkOptions.getHideInk](https://reference.aspose.com/slides/php-java/aspose.slides/inkoptions/#getHideInk) determines whether ink objects are included in the output. Its default value is `false`.
- [InkOptions.getInterpretMaskOpAsOpacity](https://reference.aspose.com/slides/php-java/aspose.slides/inkoptions/#getInterpretMaskOpAsOpacity) determines whether a mask operation is interpreted as opacity when rendering an ink brush. Its default value is `true`; call [InkOptions.setInterpretMaskOpAsOpacity](https://reference.aspose.com/slides/php-java/aspose.slides/inkoptions/#setInterpretMaskOpAsOpacity) with `false` to use the ROP operation instead.
### **Hide Ink Objects in PDF Output**
By default, ink objects remain visible during export. To create a clean output without handwritten annotations or other ink content, call [InkOptions.setHideInk](https://reference.aspose.com/slides/php-java/aspose.slides/inkoptions/#setHideInk) with `true`.
The following PHP example exports a presentation to PDF while hiding all ink objects:
```php
$presentation = new Presentation("presentation.pptx");
try {
$pdfOptions = new PdfOptions();
$pdfOptions->getInkOptions()->setHideInk(true);
$presentation->save("presentation_without_ink.pdf", SaveFormat::Pdf, $pdfOptions);
} finally {
$presentation->dispose();
}
```
### **Hide Ink Objects When Rendering a Slide as an Image**
To hide ink objects when rendering slides as bitmap images, configure [RenderingOptions.getInkOptions](https://reference.aspose.com/slides/php-java/aspose.slides/renderingoptions/#getInkOptions) and pass the rendering options to [Slide.getImage](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#getImage).
The following PHP example renders the first slide as a PNG image without ink objects:
```php
$presentation = new Presentation("presentation.pptx");
try {
$renderingOptions = new RenderingOptions();
$renderingOptions->getInkOptions()->setHideInk(true);
$slide = $presentation->getSlides()->get_Item(0);
$image = $slide->getImage($renderingOptions);
try {
$image->save("slide_without_ink.png", ImageFormat::Png);
} finally {
$image->dispose();
}
} finally {
$presentation->dispose();
}
```
### **Control Ink Mask Rendering**
The [InkOptions.getInterpretMaskOpAsOpacity](https://reference.aspose.com/slides/php-java/aspose.slides/inkoptions/#getInterpretMaskOpAsOpacity) setting controls how mask operations are interpreted when rendering ink brushes. The default value is `true`, which uses opacity. To use the ROP operation instead, call [InkOptions.setInterpretMaskOpAsOpacity](https://reference.aspose.com/slides/php-java/aspose.slides/inkoptions/#setInterpretMaskOpAsOpacity) with `false`.
The following PHP example exports a slide to SVG and uses ROP-based rendering for ink mask operations:
```php
$presentation = new Presentation("presentation.pptx");
try {
$svgOptions = new SVGOptions();
$svgOptions->getInkOptions()->setInterpretMaskOpAsOpacity(false);
$outputStream = new Java("java.io.FileOutputStream", "slide.svg");
try {
$slide = $presentation->getSlides()->get_Item(0);
$slide->writeAsSvg($outputStream, $svgOptions);
} finally {
$outputStream->close();
}
} finally {
$presentation->dispose();
}
```
The same setting can be applied through [TiffOptions.getInkOptions](https://reference.aspose.com/slides/php-java/aspose.slides/tiffoptions/#getInkOptions) when exporting a presentation or rendering a slide to TIFF.
### **Choose Whether to Hide or Preserve Ink**
When you need a clean version of an annotated presentation for distribution without review marks, call [InkOptions.setHideInk](https://reference.aspose.com/slides/php-java/aspose.slides/inkoptions/#setHideInk) with `true` during export.
Leave [InkOptions.getHideInk](https://reference.aspose.com/slides/php-java/aspose.slides/inkoptions/#getHideInk) at its default value of `false` when ink annotations are part of the intended content, such as review comments, handwritten notes, highlights, or drawings that should remain visible in the exported result. This allows applications to generate separate review and final outputs from the same presentation without modifying the source ink objects.
## **FAQ**
**Can I change the color or size of an existing ink stroke?**
Yes. Get the trace from [Ink.getTraces](https://reference.aspose.com/slides/php-java/aspose.slides/ink/#getTraces), then change its [InkTrace.getBrush](https://reference.aspose.com/slides/php-java/aspose.slides/inktrace/#getBrush). Call [InkBrush.setColor](https://reference.aspose.com/slides/php-java/aspose.slides/inkbrush/#setColor) or [InkBrush.setSize](https://reference.aspose.com/slides/php-java/aspose.slides/inkbrush/#setSize) to change the brush.
**Does hiding ink change the source presentation?**
No. Calling [InkOptions.setHideInk](https://reference.aspose.com/slides/php-java/aspose.slides/inkoptions/#setHideInk) affects only the rendered or exported result; it does not remove or modify ink objects in the source presentation.
**Which export formats support ink options?**
You can configure ink options for PDF, HTML, SVG, TIFF, and bitmap slide images through the corresponding export or rendering options shown above.
**Further reading**
* To read about shapes in general, see the [PowerPoint Shapes](https://docs.aspose.com/slides/php-java/powerpoint-shapes/) section.
* For more information on effective values, see [Shape Effective Properties](https://docs.aspose.com/slides/php-java/shape-effective-properties/#get-effective-font-height-value).
* For details on PDF export, see [Convert PPT and PPTX to PDF](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-pdf/).
* For details on HTML export, see [Convert PowerPoint Presentations to HTML](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-html/).
* For details on SVG export, see [Render Presentation Slides as SVG Images](https://docs.aspose.com/slides/php-java/render-a-slide-as-an-svg-image/).
* For details on TIFF export, see [Convert PowerPoint Presentations to TIFF](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-tiff/).
* For details on slide-to-image rendering, see [Convert Presentation Slides to Images](https://docs.aspose.com/slides/php-java/convert-slide/).
## Related articles
- [Ink](https://docs.aspose.com/slides/php-java/examples/elements/ink/)
# Manage Bulleted and Numbered Lists in Presentations Using PHP
> Learn how to create and format bulleted, picture, multilevel, and numbered lists in PowerPoint and OpenDocument presentations using Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/manage-lists/
Updated: 2026-11-02
## **Overview**
Aspose.Slides for PHP via Java lets you create and format bulleted and numbered lists in PowerPoint and OpenDocument presentations. A list item is a paragraph whose bullet settings are controlled through its paragraph format.
Use the [Paragraph::getParagraphFormat](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/#getParagraphFormat) method to access paragraph-level list settings. The main entry point is [ParagraphFormat::getBullet](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#getBullet) which returns a [BulletFormat](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/) object. With this object, you can set the bullet type, symbol, picture, color, size, numbering style, and starting number.
This article shows how to:
- create a bulleted list with a custom symbol
- create a picture bullet
- create a multilevel list by setting paragraph depth
- create a numbered list
- inspect and change list formatting in an existing presentation
- read actual list markers and numbers alongside paragraph text
## **Create a Bulleted List**
To create a bulleted list, add [Paragraph](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/) objects to a [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/) and set [BulletFormat::setType](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/#setType) to [BulletType::Symbol](https://reference.aspose.com/slides/php-java/aspose.slides/bullettype/#Symbol). You can then set [BulletFormat::setChar](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/#setChar), [BulletFormat::getColor](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/#getColor), and [BulletFormat::setHeight](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/#setHeight) to control the bullet appearance.
The following PHP code demonstrates how to create a bulleted list in a slide:
```php
use aspose\slides\BulletType;
use aspose\slides\NullableBool;
use aspose\slides\Paragraph;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
function createParagraph($paragraphText)
{
$paragraph = new Paragraph();
$paragraph->getParagraphFormat()->getBullet()->setType(BulletType::Symbol);
$paragraph->getParagraphFormat()->getBullet()->setChar("*");
$paragraph->getParagraphFormat()->setIndent(15);
$paragraph->getParagraphFormat()->getBullet()->setBulletHardColor(NullableBool::True);
$bulletColor = new Java("java.awt.Color", 205, 92, 92);
$paragraph->getParagraphFormat()->getBullet()->getColor()->setColor($bulletColor);
$paragraph->getParagraphFormat()->getBullet()->setHeight(100);
$paragraph->setText($paragraphText);
return $paragraph;
}
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 20, 200, 50);
$textFrame = $autoShape->getTextFrame();
$textFrame->getParagraphs()->clear();
$paragraph1 = createParagraph("The first paragraph");
$textFrame->getParagraphs()->add($paragraph1);
$paragraph2 = createParagraph("The second paragraph");
$textFrame->getParagraphs()->add($paragraph2);
$presentation->save("symbol_bullets.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

## **Create a Numbered List**
Use numbered lists when the order of items matters. Set [BulletFormat::setType](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/#setType) to [BulletType::Numbered](https://reference.aspose.com/slides/php-java/aspose.slides/bullettype/#Numbered). You can also choose a numbering format with [BulletFormat::setNumberedBulletStyle](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/#setNumberedBulletStyle) or set [BulletFormat::setNumberedBulletStartWith](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/#setNumberedBulletStartWith) when the list should start from a value other than 1.
The following PHP code shows how to create a numbered list in a slide:
```php
use aspose\slides\BulletType;
use aspose\slides\Paragraph;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 20, 90, 80);
$textFrame = $autoShape->getTextFrame();
$textFrame->getParagraphs()->clear();
$paragraph1 = new Paragraph();
$paragraph1->getParagraphFormat()->getBullet()->setType(BulletType::Numbered);
$paragraph1->setText("Apple");
$textFrame->getParagraphs()->add($paragraph1);
$paragraph2 = new Paragraph();
$paragraph2->getParagraphFormat()->getBullet()->setType(BulletType::Numbered);
$paragraph2->setText("Orange");
$textFrame->getParagraphs()->add($paragraph2);
$paragraph3 = new Paragraph();
$paragraph3->getParagraphFormat()->getBullet()->setType(BulletType::Numbered);
$paragraph3->setText("Banana");
$textFrame->getParagraphs()->add($paragraph3);
$presentation->save("numbered_bullets.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

## **Create a Picture Bullet**
Aspose.Slides allows you to replace a regular bullet symbol with an image. Picture bullets work best with simple images that remain readable at a small size, such as icons or small transparent PNG files.
Ideally, if you plan to replace the regular bullet symbol with an image, it's best to choose a simple graphic with a transparent background. Such images work well as custom bullet symbols.
Keep in mind that the image will be scaled down to a very small size. For that reason, we strongly recommend selecting an image that remains clear and visually effective when used as a bullet in a list.
To create a picture bullet, add an image to [Presentation::getImages](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getImages) and assign the returned [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) object to [BulletFormat::getPicture](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/#getPicture). Set [BulletFormat::setType](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/#setType) to [BulletType::Picture](https://reference.aspose.com/slides/php-java/aspose.slides/bullettype/#Picture) before assigning the image.
Let's say we have an "image.png":

The following PHP code shows how to create picture bullets in a slide:
```php
use aspose\slides\BulletType;
use aspose\slides\Images;
use aspose\slides\Paragraph;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
function createParagraph($paragraphText, $bulletImage)
{
$paragraph = new Paragraph();
$paragraph->getParagraphFormat()->getBullet()->setType(BulletType::Picture);
$paragraph->getParagraphFormat()->getBullet()->getPicture()->setImage($bulletImage);
$paragraph->getParagraphFormat()->setIndent(15);
$paragraph->getParagraphFormat()->getBullet()->setHeight(100);
$paragraph->setText($paragraphText);
return $paragraph;
}
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 20, 200, 50);
$textFrame = $autoShape->getTextFrame();
$textFrame->getParagraphs()->clear();
$image = Images::fromFile("image.png");
$bulletImage = $presentation->getImages()->addImage($image);
$paragraph1 = createParagraph("The first paragraph", $bulletImage);
$textFrame->getParagraphs()->add($paragraph1);
$paragraph2 = createParagraph("The second paragraph", $bulletImage);
$textFrame->getParagraphs()->add($paragraph2);
$presentation->save("picture_bullets.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

## **Create a Multilevel List**
Use [ParagraphFormat::setDepth](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setDepth) to place list items on different levels. Level 0 is the top level, level 1 is nested below it, and so on.
The following PHP code shows how to create a multilevel bulleted list:
```php
use aspose\slides\Paragraph;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 20, 260, 110);
$textFrame = $autoShape->getTextFrame();
$textFrame->getParagraphs()->clear();
$paragraph1 = new Paragraph();
$paragraph1->getParagraphFormat()->setDepth(0);
$paragraph1->setText("My text - Depth 0");
$textFrame->getParagraphs()->add($paragraph1);
$paragraph2 = new Paragraph();
$paragraph2->getParagraphFormat()->setDepth(1);
$paragraph2->setText("My text - Depth 1");
$textFrame->getParagraphs()->add($paragraph2);
$paragraph3 = new Paragraph();
$paragraph3->getParagraphFormat()->setDepth(2);
$paragraph3->setText("My text - Depth 2");
$textFrame->getParagraphs()->add($paragraph3);
$paragraph4 = new Paragraph();
$paragraph4->getParagraphFormat()->setDepth(3);
$paragraph4->setText("My text - Depth 3");
$textFrame->getParagraphs()->add($paragraph4);
$presentation->save("multilevel_bullets.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

## **Change an Existing List**
To change list formatting in an existing presentation, access the target paragraph and update its [ParagraphFormat::getBullet](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#getBullet) settings. The same properties used to create lists can be used to inspect or modify lists loaded from a PPT, PPTX, or ODP file.
The following PHP code changes the first paragraph in a text frame to use a numbered list style:
```php
use aspose\slides\BulletType;
use aspose\slides\NumberedBulletStyle;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("input.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->get_Item(0);
$paragraph = $autoShape->getTextFrame()->getParagraphs()->get_Item(0);
$paragraph->getParagraphFormat()->getBullet()->setType(BulletType::Numbered);
$paragraph->getParagraphFormat()->getBullet()->setNumberedBulletStyle(NumberedBulletStyle::BulletRomanUCPeriod);
$paragraph->getParagraphFormat()->getBullet()->setNumberedBulletStartWith(1);
$paragraph->getParagraphFormat()->setMarginLeft(30);
$paragraph->getParagraphFormat()->setIndent(-20);
$presentation->save("updated_list.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Read Actual Bullet Values**
When extracting presentation content, keep list markers alongside paragraph text. Call [ParagraphFormat::getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#getEffective) and access [ParagraphFormatEffectiveData::getBullet](https://reference.aspose.com/slides/java/com.aspose.slides/iparagraphformateffectivedata/#getBullet--) to obtain the effective bullet format. Check its [getType](https://reference.aspose.com/slides/java/com.aspose.slides/ibulletformateffectivedata/#getType--) before reading [getActualBulletValue](https://reference.aspose.com/slides/java/com.aspose.slides/ibulletformateffectivedata/#getActualBulletValue--).
For numbered lists, distinguish these three values:
- [getNumberedBulletStyle](https://reference.aspose.com/slides/java/com.aspose.slides/ibulletformateffectivedata/#getNumberedBulletStyle--) determines the format, such as Arabic numbers followed by a period or lowercase letters followed by a period.
- [getNumberedBulletStartWith](https://reference.aspose.com/slides/java/com.aspose.slides/ibulletformateffectivedata/#getNumberedBulletStartWith--) specifies the starting number for a group of numbered paragraphs.
- [getActualBulletValue](https://reference.aspose.com/slides/java/com.aspose.slides/ibulletformateffectivedata/#getActualBulletValue--) returns the formatted marker for a particular paragraph. For example, the second item in a list starting at 5 returns `6.`.
Preserve [getDepth](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#getDepth) with each paragraph to retain its nesting level. The actual marker does not encode the full hierarchy: a nested item can return `c.` rather than a combined label such as `6.c.`.
The following self-contained example creates lists, saves them to a presentation, and reloads the presentation to report each paragraph's text, depth, bullet type, and actual value. The small blue picture marker is created from inline SVG.
```php
use aspose\slides\BulletType;
use aspose\slides\FillType;
use aspose\slides\NullableBool;
use aspose\slides\NumberedBulletStyle;
use aspose\slides\Paragraph;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\SlideSizeScaleType;
use aspose\slides\SvgImage;
$presentation = new Presentation();
try {
$presentation->getSlideSize()->setSize(720, 440, SlideSizeScaleType::DoNotScale);
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 30, 20, 660, 400);
$shape->getFillFormat()->setFillType(FillType::NoFill);
$shape->getLineFormat()->getFillFormat()->setFillType(FillType::NoFill);
$textFrame = $shape->getTextFrame();
$textFrame->getParagraphs()->clear();
// Create a picture marker without an external image file.
$svg = new SvgImage("");
$bulletImage = $presentation->getImages()->addImage($svg);
$black = new Java("java.awt.Color", 0, 0, 0);
$addParagraph = function ($text, $depth, $type, $start, $style) use ($textFrame, $bulletImage, $black) {
$paragraph = new Paragraph();
$paragraph->setText($text);
$format = $paragraph->getParagraphFormat();
$format->setDepth($depth);
$format->setMarginLeft(30 + $depth * 40);
$format->setIndent(-28);
$format->setSpaceAfter(8);
$format->getDefaultPortionFormat()->setFontHeight(22);
$format->getDefaultPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$format->getDefaultPortionFormat()->getFillFormat()->getSolidFillColor()->setColor($black);
$format->getBullet()->setType($type);
$format->getBullet()->setBulletHardColor(NullableBool::True);
$format->getBullet()->getColor()->setColor($black);
if ($type == BulletType::Numbered) {
$format->getBullet()->setNumberedBulletStyle($style);
$format->getBullet()->setNumberedBulletStartWith($start);
} else if ($type == BulletType::Symbol) {
$format->getBullet()->setChar("\u{2022}");
} else if ($type == BulletType::Picture) {
$format->getBullet()->getPicture()->setImage($bulletImage);
}
$textFrame->getParagraphs()->add($paragraph);
};
$addParagraph("First item", 0, BulletType::Numbered, 5, NumberedBulletStyle::BulletArabicPeriod);
$addParagraph("Second item", 0, BulletType::Numbered, 5, NumberedBulletStyle::BulletArabicPeriod);
$addParagraph("Nested item", 1, BulletType::Numbered, 3, NumberedBulletStyle::BulletAlphaLCPeriod);
$addParagraph("Next nested item", 1, BulletType::Numbered, 3, NumberedBulletStyle::BulletAlphaLCPeriod);
$addParagraph("Deep item", 2, BulletType::Numbered, 4, NumberedBulletStyle::BulletRomanLCPeriod);
$addParagraph("Back to top level", 0, BulletType::Numbered, 5, NumberedBulletStyle::BulletArabicPeriod);
$addParagraph("Symbol marker", 0, BulletType::Symbol, 1, NumberedBulletStyle::BulletArabicPeriod);
$addParagraph("No bullet", 0, BulletType::None, 1, NumberedBulletStyle::BulletArabicPeriod);
$addParagraph("Picture marker", 0, BulletType::Picture, 1, NumberedBulletStyle::BulletArabicPeriod);
$presentation->save("actual_bullet_values.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
$loadedPresentation = new Presentation("actual_bullet_values.pptx");
try {
$loadedShape = $loadedPresentation->getSlides()->get_Item(0)->getShapes()->get_Item(0);
echo "Text | Depth | Type | Actual value\n";
$paragraphs = $loadedShape->getTextFrame()->getParagraphs();
for ($i = 0; $i < java_values($paragraphs->getCount()); $i++) {
$paragraph = $paragraphs->get_Item($i);
$bullet = $paragraph->getParagraphFormat()->getEffective()->getBullet();
switch (java_values($bullet->getType())) {
case BulletType::Numbered:
case BulletType::Symbol:
$marker = $bullet->getActualBulletValue();
break;
case BulletType::None:
$marker = "null (no bullet)";
break;
case BulletType::Picture:
$marker = "null (image required)";
break;
default:
$marker = "unsupported bullet type";
break;
}
$typeNames = [BulletType::Numbered => "Numbered", BulletType::Symbol => "Symbol", BulletType::None => "None", BulletType::Picture => "Picture"];
$typeName = $typeNames[java_values($bullet->getType())] ?? "Unknown";
echo $paragraph->getText() . " | " . $paragraph->getParagraphFormat()->getDepth() . " | " . $typeName . " | " . $marker . "\n";
}
} finally {
$loadedPresentation->dispose();
}
```
The source lists are shown below.

The report matches the markers displayed in PowerPoint:
```text
Text | Depth | Type | Actual value
First item | 0 | Numbered | 5.
Second item | 0 | Numbered | 6.
Nested item | 1 | Numbered | c.
Next nested item | 1 | Numbered | d.
Deep item | 2 | Numbered | iv.
Back to top level | 0 | Numbered | 7.
Symbol marker | 0 | Symbol | •
No bullet | 0 | None | null (no bullet)
Picture marker | 0 | Picture | null (image required)
```
For [BulletType::None and BulletType::Picture](https://reference.aspose.com/slides/php-java/aspose.slides/bullettype/), [getActualBulletValue](https://reference.aspose.com/slides/java/com.aspose.slides/ibulletformateffectivedata/#getActualBulletValue--) returns `null`, not an empty string. Handle these types separately: the former has no marker, while the latter requires extracting the bullet image separately. A picture bullet cannot be reproduced solely by extracting a text marker.
## **FAQ**
**Can bulleted and numbered lists be exported to PDF or images?**
Yes. Aspose.Slides preserves list formatting when the target format supports the corresponding text layout and bullet features.
**Can I edit lists in existing presentations?**
Yes. Load the presentation, access the target paragraph, inspect or update its [ParagraphFormat::getBullet](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#getBullet) settings, and save the presentation.
**Can lists contain non-Latin text?**
Yes. List item text can contain Unicode characters, so you can create lists in multilingual presentations. Make sure the fonts used in the presentation support the characters you need.
## Related articles
- [Manage PowerPoint Text Paragraphs in PHP](https://docs.aspose.com/slides/php-java/manage-paragraph/)
- [Manage Presentation Text in PHP](https://docs.aspose.com/slides/php-java/manage-text/)
# Manage Media Files in PHP
> Manage audio and video in Aspose.Slides for PHP via Java: add, extract, replace, and optimize media in PPT, PPTX and ODP files. Step-by-step guides and code.
Source: https://docs.aspose.com/slides/php-java/manage-media-files/
Updated: 2025-11-30
---
lastmod: 2025-11-30T13:47:17+04:00
title: Manage Media Files in PHP
linktitle: Media Files
type: docs
weight: 30
url: /php-java/manage-media-files/
keywords:
- media file
- manage media
- embed audio
- extract flash
- manage image
- add picture
- add video
- PowerPoint
- OpenDocument
- presentation
- PHP
- Aspose.Slides
description: "Manage audio and video in Aspose.Slides for PHP via Java: add, extract, replace, and optimize media in PPT, PPTX and ODP files. Step-by-step guides and code."
---
## Related articles
- [Extract Flash Objects from Presentations in PHP](https://docs.aspose.com/slides/php-java/flash/)
- [Customize Presentation Charts in PHP](https://docs.aspose.com/slides/php-java/chart-types/)
- [Audio](https://docs.aspose.com/slides/php-java/examples/elements/audio/)
# Manage OLE in Presentations Using PHP
> Optimize OLE object management in PowerPoint and OpenDocument files with Aspose.Slides for PHP via Java. Embed, update, and export OLE content seamlessly.
Source: https://docs.aspose.com/slides/php-java/manage-ole/
Updated: 2026-11-08
## **Introduction**
OLE (Object Linking & Embedding) is a Microsoft technology that allows data and objects created in one application to be placed in another application through linking or embedding.
Consider a chart created in MS Excel. The chart is then placed inside a PowerPoint slide. That Excel chart is considered an OLE object.
- An OLE object may appear as an icon. In this case, when you double-click the icon, the chart gets opened in its associated application (Excel), or you are asked to select an application to open or edit the object.
- An OLE object may display its actual contents, such as the contents of a chart. In this case, the chart is activated in PowerPoint, the chart interface loads, and you get to modify the chart's data within PowerPoint.
[Aspose.Slides for PHP via Java](https://products.aspose.com/slides/php-java/) allows you to insert OLE Objects into slides as OLE object frames ([OleObjectFrame](https://reference.aspose.com/slides/php-java/aspose.slides/oleobjectframe/)).
## **Add OLE Object Frames to Slides**
Assuming you have already created a chart in Microsoft Excel and want to embed it in a slide as an OLE object frame using Aspose.Slides for PHP via Java, you can do it this way:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
1. Get a slide's reference through its index.
1. Read the Excel file as a byte array.
1. Add the [OleObjectFrame](https://reference.aspose.com/slides/php-java/aspose.slides/oleobjectframe/) to the slide containing the byte array and other information about the OLE object.
1. Write the modified presentation as a PPTX file.
In the example below, we added a chart from an Excel file to a slide as an OLE object frame using Aspose.Slides for PHP via Java.
**Note** that the [OleEmbeddedDataInfo](https://reference.aspose.com/slides/php-java/aspose.slides/oleembeddeddatainfo/) constructor takes an embeddable object extension as a second parameter. This extension allows PowerPoint to correctly interpret the file type and choose the right application to open this OLE object.
```php
$presentation = new Presentation();
$slideSize = $presentation->getSlideSize()->getSize();
$slide = $presentation->getSlides()->get_Item(0);
// Prepare data for the OLE object.
$fileData = file_get_contents("book.xlsx");
$dataInfo = new OleEmbeddedDataInfo($fileData, "xlsx");
// Add the OLE object frame to the slide.
$slide->getShapes()->addOleObjectFrame(0, 0, $slideSize->getWidth(), $slideSize->getHeight(), $dataInfo);
$presentation->save("output.pptx", SaveFormat::Pptx);
$presentation->dispose();
```
### **Add Linked OLE Object Frames**
Aspose.Slides for PHP via Java allows you to add an [OleObjectFrame](https://reference.aspose.com/slides/php-java/aspose.slides/oleobjectframe/) without embedding data but only with a link to the file.
This PHP code shows you how to add an [OleObjectFrame](https://reference.aspose.com/slides/php-java/aspose.slides/oleobjectframe/) with a linked Excel file to a slide:
```php
$presentation = new Presentation();
$slide = $presentation->getSlides()->get_Item(0);
// Add an OLE object frame with a linked Excel file.
$slide->getShapes()->addOleObjectFrame(20, 20, 200, 150, "Excel.Sheet.12", "book.xlsx");
$presentation->save("output.pptx", SaveFormat::Pptx);
$presentation->dispose();
```
[](https://docs.aspose.com/slides/php-java/manage-ole/visual-ole-preview-and-payload-f38773947dd8.svg)
*An embedded object keeps workbook bytes in the PPTX; a linked object keeps a path to an external workbook. The slide preview, when present, is separate. Opening a linked workbook requires the file and a supporting OLE host.*
## **Access OLE Object Frames**
If an OLE object is already embedded in a slide, you can easily find or access it this way:
1. Load a presentation with the embedded OLE object by creating an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
2. Get the reference of the slide by using its index.
3. Access the [OleObjectFrame](https://reference.aspose.com/slides/php-java/aspose.slides/oleobjectframe/) shape. In our example, we used the previously created PPTX that has only one shape on the first slide.
4. Once the OLE object frame is accessed, you can perform any operation on it.
In the example below, an OLE object frame (an Excel chart object embedded in a slide) and its file data are accessed.
```php
$presentation = new Presentation("sample.pptx");
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->get_Item(0);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.OleObjectFrame"))) {
$oleFrame = $shape;
// Get the embedded file data.
$fileData = $oleFrame->getEmbeddedData()->getEmbeddedFileData();
// Get the extension of the embedded file.
$fileExtension = $oleFrame->getEmbeddedData()->getEmbeddedFileExtension();
// ...
}
```
### **Access Linked OLE Object Frame Properties**
Aspose.Slides allows you to access linked OLE object frame properties.
This PHP code shows you how to check if an OLE object is linked and then obtain the path to the linked file:
```php
$presentation = new Presentation("sample.ppt");
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->get_Item(0);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.OleObjectFrame"))) {
$oleFrame = $shape;
// Check if the OLE object is linked.
if (java_values($oleFrame->isObjectLink()) != 0) {
// Print the full path to the linked file.
echo "OLE object frame is linked to: " . $oleFrame->getLinkPathLong() . PHP_EOL;
// Print the relative path to the linked file if present.
// Only the PPT presentations can contain the relative path.
$relativePath = java_values($oleFrame->getLinkPathRelative());
if (!is_null($relativePath) && $relativePath !== "") {
echo "OLE object frame relative path: " . $oleFrame->getLinkPathRelative() . PHP_EOL;
}
}
}
$presentation->dispose();
```
## **Change OLE Object Data**
In this section, the code example below uses [Aspose.Cells for PHP via Java](https://docs.aspose.com/cells/php-java/).
If an OLE object is already embedded in a slide, you can easily access that object and modify its data this way:
1. Load a presentation with the embedded OLE object by creating an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
2. Get the slide's reference through its index.
3. Access the [OleObjectFrame](https://reference.aspose.com/slides/php-java/aspose.slides/oleobjectframe/) shape. In our example, we used the previously created PPTX that has one shape on the first slide.
4. Once the OLE object frame is accessed, you can perform any operation on it.
5. Create a `Workbook` object and access the OLE data.
6. Access the desired `Worksheet` and amend the data.
7. Save the updated `Workbook` in a stream.
8. Change the OLE object data from the stream.
In the example below, an OLE object frame (an Excel chart object embedded in a slide) is accessed, and its file data is modified to update the chart data.
```php
$presentation = new Presentation("sample.pptx");
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->get_Item(0);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.OleObjectFrame"))) {
$oleFrame = $shape;
$oleStream = new Java("java.io.ByteArrayInputStream", $oleFrame->getEmbeddedData()->getEmbeddedFileData());
// Read the OLE object data as a Workbook object.
$workbook = new Workbook($oleStream);
$newOleStream = new Java("java.io.ByteArrayOutputStream");
// Modify the workbook data.
$workbook->getWorksheets()->get(0)->getCells()->get(0, 4)->putValue("E");
$workbook->getWorksheets()->get(0)->getCells()->get(1, 4)->putValue(12);
$workbook->getWorksheets()->get(0)->getCells()->get(2, 4)->putValue(14);
$workbook->getWorksheets()->get(0)->getCells()->get(3, 4)->putValue(15);
$fileOptions = new OoxmlSaveOptions(SaveFormat::XLSX);
$workbook->save($newOleStream, $fileOptions);
// Change the OLE frame object data.
$newData = new OleEmbeddedDataInfo($newOleStream->toByteArray(), $oleFrame->getEmbeddedData()->getEmbeddedFileExtension());
$oleFrame->setEmbeddedData($newData);
$newOleStream->close();
$oleStream->close();
}
$presentation->save("output.pptx", SaveFormat::Pptx);
$presentation->dispose();
```
## **Embed Other File Types in Slides**
Besides Excel charts, Aspose.Slides for PHP via Java allows you to embed other types of files into slides. For example, you can insert HTML, PDF, and ZIP files as objects. When a user double-clicks the inserted object, it automatically opens in the relevant program, or the user is prompted to select an appropriate program to open it.
This PHP code shows you how to embed HTML and ZIP into a slide:
```php
$presentation = new Presentation("sample.pptx");
$slide = $presentation->getSlides()->get_Item(0);
$htmlData = file_get_contents("sample.html");
$htmlDataInfo = new OleEmbeddedDataInfo($htmlData, "html");
$htmlOleFrame = $slide->getShapes()->addOleObjectFrame(150, 120, 50, 50, $htmlDataInfo);
$htmlOleFrame->setObjectIcon(true);
$zipData = file_get_contents("sample.zip");
$zipDataInfo = new OleEmbeddedDataInfo($zipData, "zip");
$zipOleFrame = $slide->getShapes()->addOleObjectFrame(150, 220, 50, 50, $zipDataInfo);
$zipOleFrame->setObjectIcon(true);
$presentation->save("output.pptx", SaveFormat::Pptx);
$presentation->dispose();
```
## **Set File Types for Embedded Objects**
When working with presentations, you may need to replace old OLE objects with new ones or replace an unsupported OLE object with a supported one. Aspose.Slides for PHP via Java allows you to set the file type for an embedded object, enabling you to update the OLE frame data or its extension.
This PHP code shows you how to set the file type for an embedded OLE object to `zip`:
```php
$presentation = new Presentation("sample.pptx");
$slide = $presentation->getSlides()->get_Item(0);
$oleFrame = $slide->getShapes()->get_Item(0);
$fileExtension = $oleFrame->getEmbeddedData()->getEmbeddedFileExtension();
$fileData = $oleFrame->getEmbeddedData()->getEmbeddedFileData();
echo "Current embedded file extension is: " . $fileExtension . PHP_EOL;
// Change the file type to ZIP.
$oleFrame->setEmbeddedData(new OleEmbeddedDataInfo($fileData, "zip"));
$presentation->save("output.pptx", SaveFormat::Pptx);
$presentation->dispose();
```
## **Set Icon Images and Titles for Embedded Objects**
After embedding an OLE object, a preview consisting of an icon image is added automatically. This preview is what users see before accessing or opening the OLE object. If you want to use a specific image and text as elements in the preview, you can set the icon image and title using Aspose.Slides for PHP via Java.
This PHP code shows you how to set the icon image and title for an embedded object:
```php
$presentation = new Presentation("sample.pptx");
$slide = $presentation->getSlides()->get_Item(0);
$oleFrame = $slide->getShapes()->get_Item(0);
// Add an image to the presentation resources.
$imageData = file_get_contents("image.png");
$oleImage = $presentation->getImages()->addImage($imageData);
// Set a title and the image for the OLE preview.
$oleFrame->setSubstitutePictureTitle("My title");
$oleFrame->getSubstitutePictureFormat()->getPicture()->setImage($oleImage);
$oleFrame->setObjectIcon(true);
$presentation->save("output.pptx", SaveFormat::Pptx);
$presentation->dispose();
```
## **Prevent an OLE Object Frame from Being Resized and Repositioned**
After you add a linked OLE object to a presentation slide, when you open the presentation in PowerPoint, you might see a message asking you to update the links. Clicking the "Update Links" button may change the size and position of the OLE object frame because PowerPoint updates the data from the linked OLE object and refreshes the object preview. To prevent PowerPoint from prompting to update the object's data, call the [setUpdateAutomatic](https://reference.aspose.com/slides/php-java/aspose.slides/oleobjectframe/#setUpdateAutomatic) method of the [OleObjectFrame](https://reference.aspose.com/slides/php-java/aspose.slides/oleobjectframe/) class with `false`:
```php
$presentation = new Presentation("sample.pptx");
$slide = $presentation->getSlides()->get_Item(0);
$oleFrame = $slide->getShapes()->get_Item(0);
$oleFrame->setUpdateAutomatic(false);
$presentation->save("output.pptx", SaveFormat::Pptx);
$presentation->dispose();
```
## **Extract Embedded Files**
Aspose.Slides for PHP via Java allows you to extract the files embedded in slides as OLE objects this way:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class containing the OLE objects you intend to extract.
2. Loop through all the shapes in the presentation and access the [OLEObjectFrame](https://reference.aspose.com/slides/php-java/aspose.slides/oleobjectframe/) shapes.
3. Access the data of embedded files from OLE object frames and write it to disk.
This PHP code shows you how to extract files embedded in a slide as OLE objects:
```php
$presentation = new Presentation("sample.pptx");
$slide = $presentation->getSlides()->get_Item(0);
$shapeCount = java_values($slide->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $slide->getShapes()->get_Item($index);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.OleObjectFrame"))) {
$oleFrame = $shape;
$fileData = $oleFrame->getEmbeddedData()->getEmbeddedFileData();
$fileExtension = $oleFrame->getEmbeddedData()->getEmbeddedFileExtension();
$filePath = "OLE_object_" . $index . $fileExtension;
file_put_contents($filePath, $fileData);
}
}
$presentation->dispose();
```
## **FAQ**
**Will the OLE content be rendered when exporting slides to PDF/images?**
What is visible on the slide is rendered—the icon/substitute image (preview). The "live" OLE content is not executed during rendering. If needed, set your own preview image to ensure the expected appearance in the exported PDF.
To also preserve the embedded file as a PDF attachment, call [setIncludeOleData](https://reference.aspose.com/slides/php-java/aspose.slides/pdfoptions/#setIncludeOleData) with `true`. This option is disabled by default. For an example and instructions for checking the attachment, see [Preserve Embedded OLE Files as PDF Attachments](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-pdf/#preserve-embedded-ole-files-as-pdf-attachments).
**How can I lock an OLE object on a slide so users cannot move/edit it in PowerPoint?**
Lock the shape: Aspose.Slides provides shape-level locks. This is not encryption, but it effectively prevents accidental edits and movement.
**Will relative paths for linked OLE objects be preserved in the PPTX format?**
In PPTX, "relative path" information is not available—only the full path. Relative paths are found in the older PPT format. For portability, prefer reliable absolute paths/accessible URIs or embedding.
## Related articles
- [OleObject](https://docs.aspose.com/slides/php-java/examples/elements/ole-object/)
- [Object Preview Issue When Adding OleObjectFrame](https://docs.aspose.com/slides/php-java/object-preview-issue-when-adding-oleobjectframe/)
# Manage PowerPoint Text Paragraphs in PHP
> Learn how to create and format paragraphs, portions, bullets, numbered lists, indents, HTML content, and paragraph images with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/manage-paragraph/
Updated: 2026-11-11
## **Overview**
Aspose.Slides for PHP via Java represents text as a hierarchy of text frames, paragraphs, and portions:
* [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/) represents the text container in a shape and provides access to its paragraph collection.
* [Paragraph](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/) represents one paragraph in a text frame and provides access to its portions and paragraph-level formatting.
* [Portion](https://reference.aspose.com/slides/php-java/aspose.slides/portion/) represents a text run within a paragraph. Each portion can have its own text and character-level formatting.
A paragraph can therefore contain text with different fonts, colors, sizes, and other formatting by using multiple portions.
## **Create and Format Paragraphs**
Create paragraphs in a shape's text frame and use portions to format individual text runs. This section shows how to combine multiple portions within each paragraph and apply different colors, font sizes, and styles.
### **Create Paragraphs with Multiple Portions**
The following PHP example creates three paragraphs, each containing three text runs in the collection returned by [Paragraph::getPortions](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/#getPortions). It reuses the default paragraph and its empty portion, then adds the remaining paragraphs and portions. Formatting is applied through [Portion::getPortionFormat](https://reference.aspose.com/slides/php-java/aspose.slides/portion/#getPortionFormat): the first portion in each paragraph is red, bold, and 15 points; the second is blue, italic, and 18 points. The third portion retains its default formatting:
```php
use aspose\slides\FillType;
use aspose\slides\NullableBool;
use aspose\slides\Paragraph;
use aspose\slides\Portion;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 150, 300, 150);
$textFrame = $shape->getTextFrame();
$firstParagraph = $textFrame->getParagraphs()->get_Item(0);
$firstParagraph->getPortions()->add(new Portion());
$firstParagraph->getPortions()->add(new Portion());
$secondParagraph = new Paragraph();
$secondParagraph->getPortions()->add(new Portion());
$secondParagraph->getPortions()->add(new Portion());
$secondParagraph->getPortions()->add(new Portion());
$textFrame->getParagraphs()->add($secondParagraph);
$thirdParagraph = new Paragraph();
$thirdParagraph->getPortions()->add(new Portion());
$thirdParagraph->getPortions()->add(new Portion());
$thirdParagraph->getPortions()->add(new Portion());
$textFrame->getParagraphs()->add($thirdParagraph);
$paragraphCount = java_values($textFrame->getParagraphs()->getCount());
for ($paragraphIndex = 0; $paragraphIndex < $paragraphCount; $paragraphIndex++) {
$paragraph = $textFrame->getParagraphs()->get_Item($paragraphIndex);
$portionCount = java_values($paragraph->getPortions()->getCount());
for ($portionIndex = 0; $portionIndex < $portionCount; $portionIndex++) {
$portion = $paragraph->getPortions()->get_Item($portionIndex);
$portion->setText("Portion " . ($paragraphIndex + 1) . "." . ($portionIndex + 1));
if ($portionIndex == 0) {
$portion->getPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$portion->getPortionFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->RED);
$portion->getPortionFormat()->setFontBold(NullableBool::True);
$portion->getPortionFormat()->setFontHeight(15);
} else if ($portionIndex == 1) {
$portion->getPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$portion->getPortionFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLUE);
$portion->getPortionFormat()->setFontItalic(NullableBool::True);
$portion->getPortionFormat()->setFontHeight(18);
}
}
}
$presentation->save("paragraphs_with_portions.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Create Bulleted and Numbered Lists**
Organize paragraph text into lists with symbols, numbers, or custom images. The examples in this section cover bullet formatting, multilevel lists, and custom starting numbers.
### **Create a Bulleted or Numbered List**
Bullets and numbering make related items easier to scan. In Aspose.Slides, list settings are defined through [BulletFormat](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/).
This PHP example adds a symbol bullet and a numbered item to the same text frame. [BulletFormat::setType](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/#setType) selects the bullet type, while [BulletFormat::setChar](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/#setChar) supplies the symbol and [BulletFormat::setNumberedBulletStyle](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/#setNumberedBulletStyle) selects the numbering style. Both items use black bullets with a height of 100 percent and a paragraph indent of 25 points:
```php
use aspose\slides\BulletType;
use aspose\slides\ColorType;
use aspose\slides\NullableBool;
use aspose\slides\NumberedBulletStyle;
use aspose\slides\Paragraph;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 200, 200, 400, 200);
$textFrame = $shape->getTextFrame();
$textFrame->getParagraphs()->clear();
$symbolParagraph = new Paragraph();
$symbolParagraph->setText("Welcome to Aspose.Slides");
$symbolParagraph->getParagraphFormat()->getBullet()->setType(BulletType::Symbol);
$symbolParagraph->getParagraphFormat()->getBullet()->setChar("•");
$symbolParagraph->getParagraphFormat()->setIndent(25);
$symbolParagraph->getParagraphFormat()->getBullet()->getColor()->setColorType(ColorType::RGB);
$symbolParagraph->getParagraphFormat()->getBullet()->getColor()->setColor(java("java.awt.Color")->BLACK);
$symbolParagraph->getParagraphFormat()->getBullet()->setBulletHardColor(NullableBool::True);
$symbolParagraph->getParagraphFormat()->getBullet()->setHeight(100);
$textFrame->getParagraphs()->add($symbolParagraph);
$numberedParagraph = new Paragraph();
$numberedParagraph->setText("This is a numbered item");
$numberedParagraph->getParagraphFormat()->getBullet()->setType(BulletType::Numbered);
$numberedParagraph->getParagraphFormat()->getBullet()->setNumberedBulletStyle(NumberedBulletStyle::BulletCircleNumWDBlackPlain);
$numberedParagraph->getParagraphFormat()->setIndent(25);
$numberedParagraph->getParagraphFormat()->getBullet()->getColor()->setColorType(ColorType::RGB);
$numberedParagraph->getParagraphFormat()->getBullet()->getColor()->setColor(java("java.awt.Color")->BLACK);
$numberedParagraph->getParagraphFormat()->getBullet()->setBulletHardColor(NullableBool::True);
$numberedParagraph->getParagraphFormat()->getBullet()->setHeight(100);
$textFrame->getParagraphs()->add($numberedParagraph);
$presentation->save("bulleted_and_numbered_list.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Use Picture Bullets**
Picture bullets let you use a custom image instead of a symbol or number.
This PHP example adds an image to the presentation's image collection as an [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) and uses it as a paragraph bullet. It calls [BulletFormat::setType](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/#setType) to use a picture bullet and assigns the image through [BulletFormat::getPicture](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/#getPicture). [BulletFormat::setHeight](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/#setHeight) is set to 100 percent to size the bullet relative to the paragraph text:
```php
use aspose\slides\BulletType;
use aspose\slides\Images;
use aspose\slides\Paragraph;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$bulletImage = Images::fromFile("bullets.png");
try {
$presentationImage = $presentation->getImages()->addImage($bulletImage);
} finally {
$bulletImage->dispose();
}
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 200, 200, 400, 200);
$textFrame = $shape->getTextFrame();
$textFrame->getParagraphs()->clear();
$paragraph = new Paragraph();
$paragraph->setText("Welcome to Aspose.Slides");
$paragraph->getParagraphFormat()->getBullet()->setType(BulletType::Picture);
$paragraph->getParagraphFormat()->getBullet()->getPicture()->setImage($presentationImage);
$paragraph->getParagraphFormat()->getBullet()->setHeight(100);
$textFrame->getParagraphs()->add($paragraph);
$presentation->save("picture_bullet.pptx", SaveFormat::Pptx);
$presentation->save("picture_bullet.ppt", SaveFormat::Ppt);
} finally {
$presentation->dispose();
}
```
### **Create a Multilevel List**
Set [ParagraphFormat::setDepth](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setDepth) to place paragraphs at different levels of a list. The top level has a depth of `0`.
This PHP example assigns [ParagraphFormat::setDepth](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setDepth) values from 0 to 3 to four paragraphs, creating a hierarchy within one text frame. Each paragraph uses a symbol bullet, with [BulletFormat::setChar](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/#setChar) alternating between a round bullet and a hyphen to distinguish adjacent levels:
```php
use aspose\slides\BulletType;
use aspose\slides\FillType;
use aspose\slides\Paragraph;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 200, 200, 400, 200);
$textFrame = $shape->getTextFrame();
$textFrame->getParagraphs()->clear();
$firstParagraph = new Paragraph();
$firstParagraph->setText("Content");
$firstParagraph->getParagraphFormat()->getBullet()->setType(BulletType::Symbol);
$firstParagraph->getParagraphFormat()->getBullet()->setChar("•");
$firstParagraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$firstParagraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$firstParagraph->getParagraphFormat()->setDepth(0);
$secondParagraph = new Paragraph();
$secondParagraph->setText("Second level");
$secondParagraph->getParagraphFormat()->getBullet()->setType(BulletType::Symbol);
$secondParagraph->getParagraphFormat()->getBullet()->setChar('-');
$secondParagraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$secondParagraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$secondParagraph->getParagraphFormat()->setDepth(1);
$thirdParagraph = new Paragraph();
$thirdParagraph->setText("Third level");
$thirdParagraph->getParagraphFormat()->getBullet()->setType(BulletType::Symbol);
$thirdParagraph->getParagraphFormat()->getBullet()->setChar("•");
$thirdParagraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$thirdParagraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$thirdParagraph->getParagraphFormat()->setDepth(2);
$fourthParagraph = new Paragraph();
$fourthParagraph->setText("Fourth level");
$fourthParagraph->getParagraphFormat()->getBullet()->setType(BulletType::Symbol);
$fourthParagraph->getParagraphFormat()->getBullet()->setChar('-');
$fourthParagraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$fourthParagraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$fourthParagraph->getParagraphFormat()->setDepth(3);
$textFrame->getParagraphs()->add($firstParagraph);
$textFrame->getParagraphs()->add($secondParagraph);
$textFrame->getParagraphs()->add($thirdParagraph);
$textFrame->getParagraphs()->add($fourthParagraph);
$presentation->save("multilevel_list.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Start Numbered List Items at Custom Values**
Use [BulletFormat::setNumberedBulletStartWith](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/#setNumberedBulletStartWith) to set the initial number displayed for a numbered paragraph.
This PHP example sets [BulletFormat::setType](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/#setType) to use numbering for three paragraphs and assigns [BulletFormat::setNumberedBulletStartWith](https://reference.aspose.com/slides/php-java/aspose.slides/bulletformat/#setNumberedBulletStartWith) values of 2, 3, and 7. The starting value is configured separately for each paragraph, allowing the displayed numbers to skip values:
```php
use aspose\slides\BulletType;
use aspose\slides\Paragraph;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 200, 200, 400, 200);
$textFrame = $shape->getTextFrame();
$textFrame->getParagraphs()->clear();
$firstParagraph = new Paragraph();
$firstParagraph->setText("Start at 2");
$firstParagraph->getParagraphFormat()->getBullet()->setType(BulletType::Numbered);
$firstParagraph->getParagraphFormat()->getBullet()->setNumberedBulletStartWith(2);
$textFrame->getParagraphs()->add($firstParagraph);
$secondParagraph = new Paragraph();
$secondParagraph->setText("Start at 3");
$secondParagraph->getParagraphFormat()->getBullet()->setType(BulletType::Numbered);
$secondParagraph->getParagraphFormat()->getBullet()->setNumberedBulletStartWith(3);
$textFrame->getParagraphs()->add($secondParagraph);
$thirdParagraph = new Paragraph();
$thirdParagraph->setText("Start at 7");
$thirdParagraph->getParagraphFormat()->getBullet()->setType(BulletType::Numbered);
$thirdParagraph->getParagraphFormat()->getBullet()->setNumberedBulletStartWith(7);
$textFrame->getParagraphs()->add($thirdParagraph);
$presentation->save("custom_numbered_list.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Control Paragraph Layout and End Properties**
Adjust paragraph margins and indents to control the position of the first line and wrapped lines. You can also format the paragraph end mark separately from the visible text portions.
### **Set a First-Line Indent**
Use the [ParagraphFormat::setIndent](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setIndent) method to control the first-line indent of a paragraph. This setting moves only the first line relative to the paragraph's left margin. A positive value shifts the first line to the right, while the remaining lines stay aligned to the paragraph body.
Use [ParagraphFormat::setMarginLeft](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setMarginLeft) when you need to move the whole paragraph. Use [ParagraphFormat::setIndent](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setIndent) when you need to move only the first line.
The following example gives three paragraphs the same [ParagraphFormat::setMarginLeft](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setMarginLeft) of 20 points and [ParagraphFormat::setIndent](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setIndent) values of 0, 20, and 40 points. The first lines start at progressively larger offsets, while wrapped lines retain the same left margin:
```php
use aspose\slides\FillType;
use aspose\slides\Paragraph;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\TextAutofitType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 420, 220);
$shape->getFillFormat()->setFillType(FillType::NoFill);
$shape->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$shape->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->GRAY);
$textFrame = $shape->getTextFrame();
$textFrame->getTextFrameFormat()->setAutofitType(TextAutofitType::Shape);
$textFrame->getParagraphs()->clear();
$firstParagraph = new Paragraph();
$firstParagraph->setText("No first-line indent. Wrapped lines start at the same position as the first line.");
$firstParagraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$firstParagraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$firstParagraph->getParagraphFormat()->setMarginLeft(20.0);
$firstParagraph->getParagraphFormat()->setIndent(0.0);
$secondParagraph = new Paragraph();
$secondParagraph->setText("First-line indent of 20 points. The first line moves to the right, while wrapped lines remain aligned to the paragraph body.");
$secondParagraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$secondParagraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$secondParagraph->getParagraphFormat()->setMarginLeft(20.0);
$secondParagraph->getParagraphFormat()->setIndent(20.0);
$thirdParagraph = new Paragraph();
$thirdParagraph->setText("First-line indent of 40 points. This paragraph shows a larger first-line offset to make the effect easier to see.");
$thirdParagraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$thirdParagraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$thirdParagraph->getParagraphFormat()->setMarginLeft(20.0);
$thirdParagraph->getParagraphFormat()->setIndent(40.0);
$textFrame->getParagraphs()->add($firstParagraph);
$textFrame->getParagraphs()->add($secondParagraph);
$textFrame->getParagraphs()->add($thirdParagraph);
$presentation->save("paragraph_indent.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

### **Set a Hanging Indent**
A hanging indent is a paragraph layout in which the first line starts to the left of the remaining lines. In Aspose.Slides, you create this effect with the [ParagraphFormat::setIndent](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setIndent) property. Set `Indent` to a negative value to move the first line to the left relative to the paragraph body.
In practice, [ParagraphFormat::setMarginLeft](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setMarginLeft) defines the left position of the paragraph body, and [ParagraphFormat::setIndent](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setIndent) defines the position of the first line relative to that margin. To create a hanging indent, set a positive `MarginLeft` value and a negative `Indent` value.
This formatting is useful for bibliographies, references, glossary entries, and other paragraphs where wrapped lines must align under the paragraph body rather than under the first character of the first line.
The following PHP example pairs [ParagraphFormat::setMarginLeft](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setMarginLeft) values of 40 and 60 points with [ParagraphFormat::setIndent](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setIndent) values of -20 and -30 points. In each paragraph, the first line starts to the left of the wrapped lines; the second paragraph has a deeper hanging indent:
```php
use aspose\slides\FillType;
use aspose\slides\Paragraph;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\TextAutofitType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 420, 220);
$shape->getFillFormat()->setFillType(FillType::NoFill);
$shape->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$shape->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->GRAY);
$textFrame = $shape->getTextFrame();
$textFrame->getTextFrameFormat()->setAutofitType(TextAutofitType::Shape);
$textFrame->getParagraphs()->clear();
$firstParagraph = new Paragraph();
$firstParagraph->setText("A hanging indent is created by combining a positive left margin with a negative indent. The first line starts to the left, while wrapped lines align with the paragraph body.");
$firstParagraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$firstParagraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$firstParagraph->getParagraphFormat()->setMarginLeft(40.0);
$firstParagraph->getParagraphFormat()->setIndent(-20.0);
$secondParagraph = new Paragraph();
$secondParagraph->setText("This second example uses a deeper hanging indent so the difference between the first line and the wrapped lines is easier to compare.");
$secondParagraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$secondParagraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$secondParagraph->getParagraphFormat()->setMarginLeft(60.0);
$secondParagraph->getParagraphFormat()->setIndent(-30.0);
$textFrame->getParagraphs()->add($firstParagraph);
$textFrame->getParagraphs()->add($secondParagraph);
$presentation->save("hanging_indent.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

### **Set End Paragraph Run Properties**
The [Paragraph::setEndParagraphPortionFormat](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/#setEndParagraphPortionFormat) method controls the formatting of the paragraph end mark. The following example creates a [PortionFormat](https://reference.aspose.com/slides/php-java/aspose.slides/portionformat/) with [BasePortionFormat::setFontHeight](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setFontHeight) set to 48 points and [BasePortionFormat::setLatinFont](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setLatinFont) set to Times New Roman. It assigns this format to the second paragraph's end mark, leaving the visible text portions unchanged:
```php
use aspose\slides\FontData;
use aspose\slides\Paragraph;
use aspose\slides\Portion;
use aspose\slides\PortionFormat;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation("Test.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 10, 10, 200, 250);
$textFrame = $shape->getTextFrame();
$textFrame->getParagraphs()->clear();
$firstParagraph = new Paragraph();
$firstParagraph->getPortions()->add(new Portion("Sample text"));
$secondParagraph = new Paragraph();
$secondParagraph->getPortions()->add(new Portion("Sample text 2"));
$endParagraphFormat = new PortionFormat();
$endParagraphFormat->setFontHeight(48);
$endParagraphFormat->setLatinFont(new FontData("Times New Roman"));
$secondParagraph->setEndParagraphPortionFormat($endParagraphFormat);
$textFrame->getParagraphs()->add($firstParagraph);
$textFrame->getParagraphs()->add($secondParagraph);
$presentation->save("end_paragraph_format.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Count Rendered Lines**
For paragraph rules that affect automatic wrapping and punctuation at line endings, see [Control Line Breaking](https://docs.aspose.com/slides/php-java/text-formatting/#control-line-breaking) and [Control Hanging Punctuation](https://docs.aspose.com/slides/php-java/text-formatting/#control-hanging-punctuation).
Use [Paragraph::getLinesCount](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/#getLinesCount) to count the lines occupied by a paragraph after text layout, including automatic wrapping. This is useful when checking text length and layout in presentation templates.
A paragraph is one item in [TextFrame::getParagraphs](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#getParagraphs), and it can occupy several rendered lines. An explicit line break within a paragraph forces a new line without creating another paragraph. Automatic wrapping creates lines based on the available width without inserting explicit line breaks into the text. Counting paragraphs or line-break characters therefore does not give the rendered line count.
The following example creates a text shape, counts its lines, narrows the shape, and then replaces the text with a shorter string. The example enables wrapping with [TextFrameFormat::setWrapText](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#setWrapText) and disables autofit with [TextFrameFormat::setAutofitType](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#setAutofitType) so that the shape width controls wrapping without automatically shrinking the text or resizing the shape. Each measurement uses [Paragraph::getLinesCount](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/#getLinesCount). Shape dimensions are in points. Finally, the example adds another paragraph and sums the line counts across the text frame.
```php
use aspose\slides\NullableBool;
use aspose\slides\Paragraph;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
use aspose\slides\TextAutofitType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 400, 200);
$textFrame = $shape->getTextFrame();
$textFrame->getTextFrameFormat()->setWrapText(NullableBool::True);
$textFrame->getTextFrameFormat()->setAutofitType(TextAutofitType::None);
$paragraph = $textFrame->getParagraphs()->get_Item(0);
$paragraph->getParagraphFormat()->getDefaultPortionFormat()->setFontHeight(20);
$paragraph->setText("This text demonstrates how automatic wrapping changes the number of rendered lines.");
echo "Original width: " . java_values($paragraph->getLinesCount()) . PHP_EOL;
$shape->setWidth(150);
echo "Narrower shape: " . java_values($paragraph->getLinesCount()) . PHP_EOL;
$paragraph->setText("Short text.");
echo "Shorter text: " . java_values($paragraph->getLinesCount()) . PHP_EOL;
$secondParagraph = new Paragraph();
$secondParagraph->setText("Another paragraph.");
$secondParagraph->getParagraphFormat()->getDefaultPortionFormat()->setFontHeight(20);
$textFrame->getParagraphs()->add($secondParagraph);
$totalLineCount = 0;
for ($i = 0; $i < java_values($textFrame->getParagraphs()->getCount()); $i++) {
$currentParagraph = $textFrame->getParagraphs()->get_Item($i);
$totalLineCount += java_values($currentParagraph->getLinesCount());
}
echo "Total lines in the text frame: " . $totalLineCount . PHP_EOL;
} finally {
$presentation->dispose();
}
```
With this text and these dimensions, narrowing the shape increases the line count, while replacing the text with the short string reduces it. Exact counts can vary with font availability and substitution, font size, margins, indentation, wrapping, and autofit settings. Use the fonts and layout settings intended for the target environment when checking a template.
The line count alone does not determine whether text overflows its container. The available height, line heights, paragraph and line spacing, and autofit behavior also matter; even a single line can exceed the available width when wrapping is disabled.
## **Import and Export Paragraph Content**
Use HTML to bring text into a presentation or export existing paragraphs for use outside it. This section also shows how to render individual paragraphs as images, including paragraphs in table cells.
### **Import HTML Text into Paragraphs**
Use [ParagraphCollection::addFromHtml](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphcollection/#addFromHtml) to convert HTML markup into paragraphs and portions in a text frame.
This PHP example reads HTML from a file and passes the markup to [ParagraphCollection::addFromHtml](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphcollection/#addFromHtml). It clears the text frame's default paragraph so that the frame contains only the imported content. The rectangular shape leaves a 10-point margin on each side of the slide:
```php
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapeWidth = java_values($presentation->getSlideSize()->getSize()->getWidth()) - 20;
$shapeHeight = java_values($presentation->getSlideSize()->getSize()->getHeight()) - 20;
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 10, 10, $shapeWidth, $shapeHeight);
$shape->getFillFormat()->setFillType(FillType::NoFill);
$shape->getTextFrame()->getParagraphs()->clear();
$html = file_get_contents("file.html");
if ($html !== false) {
$shape->getTextFrame()->getParagraphs()->addFromHtml($html);
$presentation->save("html_text.pptx", SaveFormat::Pptx);
} else {
echo "The HTML file could not be read.";
}
} finally {
$presentation->dispose();
}
```
### **Export Paragraph Text to HTML**
Use [ParagraphCollection::exportToHtml](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphcollection/#exportToHtml) to export a selected range of paragraphs as HTML. When reusing presentation text on a website, you may want to preserve local emphasis without carrying over the presentation's font, size, or text box styles. Set [TextToHtmlConversionOptions::setTextInheritanceLimit](https://reference.aspose.com/slides/php-java/aspose.slides/texttohtmlconversionoptions/#setTextInheritanceLimit) to control how far the exporter follows formatting inheritance.
Download [the sample presentation](https://docs.aspose.com/slides/php-java/manage-paragraph/text-inheritance.pptx) and place it in the application's working directory. Its first slide contains one text shape with the text "Inherited text; explicit red 18pt". The input deliberately uses several formatting levels:
- The presentation's default text style supplies Calibri and a size of 28 pt.
- The text frame's first-level text style supplies blue text and italics.
- The paragraph explicitly sets bold text.
- The second portion, "explicit red 18pt", explicitly sets red text and a size of 18 pt.
The following complete example exports the same paragraphs three times. It passes [TextToHtmlConversionOptions](https://reference.aspose.com/slides/php-java/aspose.slides/texttohtmlconversionoptions/) to the export method and writes each result as a separate UTF-8 HTML file:
```php
use aspose\slides\Presentation;
use aspose\slides\TextInheritanceLimit;
use aspose\slides\TextToHtmlConversionOptions;
$presentation = new Presentation("text-inheritance.pptx");
try {
$shape = $presentation->getSlides()->get_Item(0)->getShapes()->get_Item(0);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.AutoShape"))) {
$textFrame = $shape->getTextFrame();
if (!java_is_null($textFrame)) {
$paragraphs = $textFrame->getParagraphs();
$modes = array(TextInheritanceLimit::All, TextInheritanceLimit::TextBox, TextInheritanceLimit::ParagraphOnly);
$fileNames = array("All.html", "TextBox.html", "ParagraphOnly.html");
for ($i = 0; $i < count($modes); $i++) {
$options = new TextToHtmlConversionOptions();
$options->setTextInheritanceLimit($modes[$i]);
$html = $paragraphs->exportToHtml(0, $paragraphs->getCount(), $options);
if (file_put_contents($fileNames[$i], java_values($html)) === false) {
echo "The HTML file could not be written." . PHP_EOL;
}
}
} else {
echo "The first shape does not contain a text frame.";
}
} else {
echo "The first shape is not a text shape.";
}
} finally {
$presentation->dispose();
}
```
The generated HTML contains the following CSS for the first portion, "Inherited text; ". The table lists the relevant declarations; other generated properties are omitted for clarity.
| Output | Relevant CSS for the first portion | Appearance |
| --- | --- | --- |
| `All.html` | `font-family:'Calibri'; font-size:28pt; color:#0000ff; font-style:italic; font-weight:bold` | Blue, bold, italic text at 28 pt in Calibri, if that font is available. |
| `TextBox.html` | `color:#0000ff; font-style:italic; font-weight:bold` | Blue, bold, italic text; the surrounding page or browser supplies the font family and size. |
| `ParagraphOnly.html` | `font-weight:bold` | Bold text; the surrounding page or browser supplies the font family, size, color, and italic style. |
The second portion retains `color:#ff0000`, `font-size:18pt`, and `font-weight:bold` in all three outputs. It also retains italics with `All` and `TextBox`, but not with `ParagraphOnly`. Restricting inheritance therefore does not remove formatting explicitly assigned to a paragraph or portion.
Open the files in the same browser to compare them. In the two restricted modes, omitted CSS properties are resolved by the destination page's styles or browser defaults, so the resulting appearance depends on where the HTML is used.
### **Generate an HTML Clipboard Fragment**
Use [TextToHtmlConversionOptions::setAddClipboardFragmentHeader](https://reference.aspose.com/slides/php-java/aspose.slides/texttohtmlconversionoptions/#setAddClipboardFragmentHeader) to choose the output from [ParagraphCollection::exportToHtml](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphcollection/#exportToHtml). With `false`, the method returns ordinary HTML. With `true`, the returned string starts with a Windows clipboard header. Its `StartHTML` and `EndHTML` fields give the UTF-8 byte offsets of the HTML, while `StartFragment` and `EndFragment` identify the content to paste.
This example exports two formatted paragraphs as ordinary HTML (`$html`) and as an HTML clipboard fragment (`$clipboardHtml`). The application can then write the fragment to the system clipboard. If the clipboard API expects raw bytes, supply the fragment as UTF-8 without a byte order mark (BOM).
```php
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
use aspose\slides\TextToHtmlConversionOptions;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 0, 0, 400, 100);
$paragraphs = $shape->getTextFrame()->getParagraphs();
$paragraphs->clear();
$paragraphs->addFromHtml("
Status: Ready
Next steps
");
$options = new TextToHtmlConversionOptions();
$options->setAddClipboardFragmentHeader(false);
$html = java_values($paragraphs->exportToHtml(0, $paragraphs->getCount(), $options));
$options->setAddClipboardFragmentHeader(true);
$clipboardHtml = java_values($paragraphs->exportToHtml(0, $paragraphs->getCount(), $options));
} finally {
$presentation->dispose();
}
```
### **Render a Paragraph as an Image**
[Paragraph::getImage](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/#getImage) renders an individual paragraph directly and returns an [IImage](https://reference.aspose.com/slides/php-java/aspose.slides/iimage/). Save the result to a file or stream with [IImage::save](https://reference.aspose.com/slides/php-java/aspose.slides/iimage/#save). You do not need to render the containing shape or crop a bitmap manually.
[Paragraph::getImage](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/#getImage) can return `null` if the paragraph cannot be found in its parent collection, has no valid rendering bounds, or cannot be rendered. Check the result before saving it and dispose of the returned image after use.
#### **Render a Paragraph at the Default Scale**
The example uses a presentation with one slide whose first shape is a text box containing three paragraphs.

The following example selects the second paragraph at index 1 and calls [Paragraph::getImage](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/#getImage) without scale parameters. It checks that the shape contains the required paragraph and that rendering returns an image before calling [IImage::save](https://reference.aspose.com/slides/php-java/aspose.slides/iimage/#save) to save it in PNG format. The `finally` block disposes of the image after use.
```php
use aspose\slides\ImageFormat;
use aspose\slides\Presentation;
$presentation = new Presentation("sample.pptx");
try {
$shape = $presentation->getSlides()->get_Item(0)->getShapes()->get_Item(0);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.AutoShape"))) {
$textFrame = $shape->getTextFrame();
if (!java_is_null($textFrame) && java_values($textFrame->getParagraphs()->getCount()) > 1) {
$paragraph = $textFrame->getParagraphs()->get_Item(1);
$paragraphImage = $paragraph->getImage();
if (!java_is_null($paragraphImage)) {
try {
$paragraphImage->save("paragraph.png", ImageFormat::Png);
} finally {
$paragraphImage->dispose();
}
} else {
echo "The paragraph could not be rendered.";
}
} else {
echo "The expected paragraph was not found.";
}
} else {
echo "The first shape is not a text shape.";
}
} finally {
$presentation->dispose();
}
```
The result:

#### **Render a Paragraph in a Table Cell with Scaling**
Use the [Paragraph::getImage](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/#getImage) overload that accepts `$scaleX` and `$scaleY` parameters to set the horizontal and vertical scale factors. The following example creates a table, renders the paragraph in its first cell at twice its default width and height, and saves the result as a PNG image.
```php
use aspose\slides\ImageFormat;
use aspose\slides\Presentation;
$scaleX = 2;
$scaleY = 2;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$table = $slide->getShapes()->addTable(50, 50, array(300), array(80));
$paragraph = $table->get_Item(0, 0)->getTextFrame()->getParagraphs()->get_Item(0);
$paragraph->setText("Text in a table cell");
$paragraphImage = $paragraph->getImage($scaleX, $scaleY);
if (!java_is_null($paragraphImage)) {
try {
$paragraphImage->save("table_paragraph.png", ImageFormat::Png);
} finally {
$paragraphImage->dispose();
}
} else {
echo "The paragraph could not be rendered.";
}
} finally {
$presentation->dispose();
}
```
A scale factor of `1` keeps that axis at its default pixel size. For example, `2` for both factors produces an image whose width and height are approximately twice the default dimensions, resulting in four times as many pixels. Larger factors generally produce sharper text for zooming or high-resolution output, but they also increase memory use and file size. Factors below `1` produce smaller images with less detail. Use equal factors to preserve the paragraph's aspect ratio; different horizontal and vertical factors stretch the output independently.
Rendering a whole shape with [Shape::getImage](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#getImage) remains useful when the output must include the shape's fill, border, or other visual context. For a paragraph-only image, use [Paragraph::getImage](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/#getImage).
## **FAQ**
**Can I completely disable line wrapping inside a text frame?**
Yes. Set [TextFrameFormat::setWrapText](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#setWrapText) to disable wrapping so lines do not break at the text frame's edges.
**How can I get the exact on-slide bounds of a specific paragraph?**
Use [Paragraph::getRect](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/#getRect) to retrieve the paragraph's bounding rectangle. [Portion::getRect](https://reference.aspose.com/slides/php-java/aspose.slides/portion/#getRect) provides the bounds of an individual portion.
**Where is paragraph alignment (left, right, center, or justify) controlled?**
[ParagraphFormat::setAlignment](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setAlignment) is a paragraph-level setting and applies to the whole paragraph regardless of individual portion formatting.
To vertically align portions of different font sizes within each line, see [Align Fonts Within a Line](https://docs.aspose.com/slides/php-java/text-formatting/#align-fonts-within-a-line).
**Can I set the proofing language for part of a paragraph?**
Yes. Set [BasePortionFormat::setLanguageId](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setLanguageId) for individual portions, so one paragraph can contain text in multiple languages.
## Related articles
- [Manage Bulleted and Numbered Lists in Presentations Using PHP](https://docs.aspose.com/slides/php-java/manage-lists/)
# Manage Presentation Placeholders in PHP
> Learn how to inspect and edit text, picture, chart, and content placeholders and understand placeholder inheritance with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/manage-placeholder/
Updated: 2026-11-08
## **Overview**
A placeholder is a shape that reserves a position for a particular kind of content in a presentation template. Common examples are title, body, picture, chart, and general-purpose content placeholders. Unlike an ordinary shape, a placeholder can inherit its position, size, formatting, and other settings from a layout slide or master slide.
Aspose.Slides exposes placeholder information through the [Shape::getPlaceholder](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getplaceholder/) method. The method returns a [Placeholder](https://reference.aspose.com/slides/php-java/aspose.slides/placeholder/) object or `null` for a normal shape. Use [Placeholder::getType](https://reference.aspose.com/slides/php-java/aspose.slides/placeholder/gettype/) to determine what the placeholder is intended to contain.
The shape class still matters after you know the placeholder type:
- An empty text, picture, chart, or content placeholder is commonly represented by an [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/).
- A populated picture placeholder can be represented by a [PictureFrame](https://reference.aspose.com/slides/php-java/aspose.slides/pictureframe/).
- A populated chart placeholder can be represented by a [Chart](https://reference.aspose.com/slides/php-java/aspose.slides/chart/).
- A content placeholder can contain several kinds of content. Check both [Placeholder::getType](https://reference.aspose.com/slides/php-java/aspose.slides/placeholder/gettype/) and the runtime shape class instead of assuming that every placeholder is an [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/).
[Placeholder::getType](https://reference.aspose.com/slides/php-java/aspose.slides/placeholder/gettype/) describes a placeholder's role; it does not guarantee the shape's runtime class. Always use a type check before accessing text, picture, chart, table, or media-specific members.
## **Understand Placeholder Inheritance**
Placeholders form a hierarchy:
1. A master slide defines reusable styles and, in some cases, master-level placeholders.
2. A layout slide defines the arrangement used by one or more normal slides and can inherit from the master.
3. A normal slide contains the placeholders for that slide and can inherit from its layout.
Call [Shape::getBasePlaceholder](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getbaseplaceholder/) to move one level up this hierarchy. A slide placeholder normally returns its layout placeholder; a layout placeholder can return its master placeholder. The method returns `null` when the shape has no base placeholder.
The following example lists placeholders on the first slide and reports their base placeholders:
```php
use aspose\slides\Presentation;
$presentation = new Presentation("template.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapes = $slide->getShapes();
$shapeCountValue = $shapes->size();
$shapeCount = java_values($shapeCountValue);
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $shapes->get_Item($shapeIndex);
$placeholder = $shape->getPlaceholder();
if (java_is_null($placeholder)) {
continue;
}
$placeholderTypeValue = $placeholder->getType();
$placeholderType = java_values($placeholderTypeValue);
$shapeClass = $shape->getClass();
$shapeClassNameValue = $shapeClass->getSimpleName();
$shapeClassName = java_values($shapeClassNameValue);
echo "Slide placeholder: " . $placeholderType . "; shape class: " . $shapeClassName . PHP_EOL;
$layoutPlaceholder = $shape->getBasePlaceholder();
if (!java_is_null($layoutPlaceholder)) {
$layoutPlaceholderInfo = $layoutPlaceholder->getPlaceholder();
if (!java_is_null($layoutPlaceholderInfo)) {
$layoutPlaceholderTypeValue = $layoutPlaceholderInfo->getType();
$layoutPlaceholderType = java_values($layoutPlaceholderTypeValue);
echo " Layout placeholder: " . $layoutPlaceholderType . PHP_EOL;
}
$masterPlaceholder = $layoutPlaceholder->getBasePlaceholder();
if (!java_is_null($masterPlaceholder)) {
$masterPlaceholderInfo = $masterPlaceholder->getPlaceholder();
if (!java_is_null($masterPlaceholderInfo)) {
$masterPlaceholderTypeValue = $masterPlaceholderInfo->getType();
$masterPlaceholderType = java_values($masterPlaceholderTypeValue);
echo " Master placeholder: " . $masterPlaceholderType . PHP_EOL;
}
}
}
}
} finally {
$presentation->dispose();
}
```
Editing a placeholder on a normal slide creates or changes a local override for that slide. Editing the related layout or master can affect all slides that still inherit that setting. A local ordinary shape has no base placeholder and does not begin inheriting merely because it occupies the same coordinates.
## **Remove Placeholder Status**
When adapting a template, use [Shape::removePlaceholder](https://reference.aspose.com/slides/php-java/aspose.slides/shape/removeplaceholder/) to keep an existing object as an ordinary shape. Its [getPlaceholder](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getplaceholder/) method returns `null`, but the shape remains in the slide's collection. In contrast, [ShapeCollection::remove](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/remove/) deletes the shape from that collection.
The following example requires `template.pptx` with at least one slide and a nonempty text placeholder on the first slide. Use a placeholder with formatting inherited from its layout or master to see the effect of removing that relationship. The example checks that the same shape remains, calls the method again on the now ordinary shape, and saves the result.
Removing placeholder status does not automatically preserve inherited appearance settings. The example below deliberately leaves those settings unchanged, so the output may look different. A shape whose position and size are entirely inherited can have zero coordinates and dimensions after the call and become invisible even though it remains in the collection.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("template.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapeCount = java_values($slide->getShapes()->size());
$autoShapeClass = new JavaClass("com.aspose.slides.AutoShape");
$found = false;
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $slide->getShapes()->get_Item($shapeIndex);
if (!java_instanceof($shape, $autoShapeClass)) {
continue;
}
$placeholder = $shape->getPlaceholder();
$textFrame = $shape->getTextFrame();
if (java_is_null($placeholder) || java_is_null($textFrame)) {
continue;
}
$textValue = $textFrame->getText();
if (java_is_null($textValue)) {
continue;
}
$text = java_values($textValue);
if ($text === "") {
continue;
}
$shape->removePlaceholder();
$placeholder = $shape->getPlaceholder();
$retainedShape = $slide->getShapes()->get_Item($shapeIndex);
$sameShapeValue = $shape->equals($retainedShape);
$sameShape = java_values($sameShapeValue);
$remainingCountValue = $slide->getShapes()->size();
$remainingCount = java_values($remainingCountValue);
echo "Placeholder removed: " . (java_is_null($placeholder) ? "true" : "false") . PHP_EOL;
echo "Same shape retained: " . ($sameShape ? "true" : "false") . PHP_EOL;
echo "Shape count unchanged: " . ($remainingCount === $shapeCount ? "true" : "false") . PHP_EOL;
// Calling the method on an ordinary shape has no effect.
$shape->removePlaceholder();
$found = true;
break;
}
if ($found) {
$presentation->save("placeholder-status-removed.pptx", SaveFormat::Pptx);
} else {
echo "No nonempty text placeholder was found on the first slide." . PHP_EOL;
}
} finally {
$presentation->dispose();
}
```
For a matching placeholder, all three checks print `true`. The text remains, but inherited position, size, rotation, font, paragraph alignment, text-frame margins, vertical anchoring, fill, and line settings can change when the placeholder relationship is removed. For example, inherited title formatting can fall back to ordinary text formatting. See [Slide Layout](https://docs.aspose.com/slides/php-java/slide-layout/) for more about layouts.
To preserve the intended appearance, capture the resolved position, size, and rotation before the call, and copy the required effective formatting values into separate variables. Retrieve those values through [PortionFormat::getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/portionformat/geteffective/), [ParagraphFormat::getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/geteffective/), [TextFrameFormat::getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/geteffective/), [FillFormat::getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/geteffective/), and [LineFormat::getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/lineformat/geteffective/). Do not rely on retaining only the effective-format objects, because their text-formatting values can change after the relationship is removed. Explicitly apply the captured values to the ordinary shape afterward, including the font family, size, style, color, paragraph settings, text-frame settings, fill, and line used by your template.
Inherited shape geometry may also need to be assigned explicitly through [GeometryShape::setShapeType](https://reference.aspose.com/slides/php-java/aspose.slides/geometryshape/#setShapeType). For a rectangular text placeholder, this means assigning [ShapeType::Rectangle](https://reference.aspose.com/slides/php-java/aspose.slides/shapetype/); restoring only the fill and line may not restore the visible rectangle. Templates with additional effects or more complex formatting require those settings to be handled as well.
[](https://docs.aspose.com/slides/php-java/manage-placeholder/visual-placeholder-inheritance-e07f1411f7f8.svg)
*Controlled .NET 26.11 fixture: removing placeholder status keeps the object and text but removes the base link; the inherited 648 × 90-point frame becomes zero-sized. This is not shape deletion. Capture resolved values before removal and explicitly reapply the geometry and formatting needed to preserve appearance.*
## **Change Text in a Placeholder**
Title, centered-title, subtitle, body, and text placeholders normally support text. Check for [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/) before using its [getTextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/gettextframe/) method.
This example updates the first title placeholder on the first slide and saves the result:
```php
use aspose\slides\PlaceholderType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("template.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapes = $slide->getShapes();
$shapeCountValue = $shapes->size();
$shapeCount = java_values($shapeCountValue);
$autoShapeClass = new JavaClass("com.aspose.slides.AutoShape");
$titleShape = null;
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $shapes->get_Item($shapeIndex);
if (!java_instanceof($shape, $autoShapeClass)) {
continue;
}
$placeholder = $shape->getPlaceholder();
if (java_is_null($placeholder)) {
continue;
}
$placeholderTypeValue = $placeholder->getType();
$placeholderType = java_values($placeholderTypeValue);
if ($placeholderType === PlaceholderType::Title || $placeholderType === PlaceholderType::CenteredTitle) {
$titleShape = $shape;
break;
}
}
if ($titleShape === null) {
throw new RuntimeException("The first slide does not contain a title placeholder.");
}
$titleShape->getTextFrame()->setText("Quarterly Business Review");
$presentation->save("title-placeholder-updated.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
This pattern avoids treating picture, chart, table, or media placeholders as [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/) objects. It also identifies the placeholder by purpose instead of relying on a fragile shape index.
## **Set Prompt Text on a Layout**
Prompt text is the design-time instruction displayed in an empty placeholder, such as *Click to add title*. Set custom prompt text on the layout placeholder rather than trying to reach it through a normal slide's shape collection. Access the layout through [Slide::getLayoutSlide](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#getLayoutSlide) and iterate over the collection returned by [BaseSlide::getShapes](https://reference.aspose.com/slides/php-java/aspose.slides/baseslide/#getShapes).
The following example changes the title and subtitle prompts on the layout used by the first slide:
```php
use aspose\slides\PlaceholderType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("template.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$layoutSlide = $slide->getLayoutSlide();
$shapes = $layoutSlide->getShapes();
$shapeCountValue = $shapes->size();
$shapeCount = java_values($shapeCountValue);
$autoShapeClass = new JavaClass("com.aspose.slides.AutoShape");
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $shapes->get_Item($shapeIndex);
if (!java_instanceof($shape, $autoShapeClass)) {
continue;
}
$placeholder = $shape->getPlaceholder();
if (java_is_null($placeholder)) {
continue;
}
$placeholderTypeValue = $placeholder->getType();
$placeholderType = java_values($placeholderTypeValue);
if ($placeholderType === PlaceholderType::Title || $placeholderType === PlaceholderType::CenteredTitle) {
$shape->getTextFrame()->setText("Enter a concise slide title");
} elseif ($placeholderType === PlaceholderType::Subtitle) {
$shape->getTextFrame()->setText("Enter a subtitle or reporting period");
}
}
$presentation->save("custom-placeholder-prompts.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Prompt text is not normal slide content. It is intended for empty placeholders in editing applications such as PowerPoint. Once a user or program supplies real content, the prompt is no longer displayed. Changing a prompt also does not replace existing text on slides that use the layout.
## **Update a Picture Placeholder**
There are two cases to handle:
- If the picture placeholder is already populated and represented by a [PictureFrame](https://reference.aspose.com/slides/php-java/aspose.slides/pictureframe/), replace the image through [PictureFillFormat::getPicture](https://reference.aspose.com/slides/php-java/aspose.slides/picturefillformat/getpicture/) and [Picture::setImage](https://reference.aspose.com/slides/php-java/aspose.slides/picture/#setImage).
- If it is still an empty placeholder, add a picture frame at the placeholder's coordinates with [ShapeCollection::addPictureFrame](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/addpictureframe/) and remove the empty placeholder.
The next example supports both cases and saves the presentation:
```php
use aspose\slides\PlaceholderType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation("picture-template.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapes = $slide->getShapes();
$shapeCountValue = $shapes->size();
$shapeCount = java_values($shapeCountValue);
$pictureFrameClass = new JavaClass("com.aspose.slides.PictureFrame");
$picturePlaceholder = null;
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $shapes->get_Item($shapeIndex);
$placeholder = $shape->getPlaceholder();
if (java_is_null($placeholder)) {
continue;
}
$placeholderTypeValue = $placeholder->getType();
$placeholderType = java_values($placeholderTypeValue);
if ($placeholderType === PlaceholderType::Picture) {
$picturePlaceholder = $shape;
break;
}
}
if ($picturePlaceholder === null) {
throw new RuntimeException("The first slide does not contain a picture placeholder.");
}
$imageData = file_get_contents("replacement.png");
$image = $presentation->getImages()->addImage($imageData);
if (java_instanceof($picturePlaceholder, $pictureFrameClass)) {
$picture = $picturePlaceholder->getPictureFormat()->getPicture();
$picture->setImage($image);
} else {
$x = $picturePlaceholder->getX();
$y = $picturePlaceholder->getY();
$width = $picturePlaceholder->getWidth();
$height = $picturePlaceholder->getHeight();
$shapes->addPictureFrame(ShapeType::Rectangle, $x, $y, $width, $height, $image);
$shapes->remove($picturePlaceholder);
}
$presentation->save("picture-placeholder-updated.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The replacement created for an empty placeholder is a local picture frame, not a new placeholder, because [Shape::getPlaceholder](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getplaceholder/) does not provide a setter. It keeps the reserved position but no longer inherits placeholder-specific behavior. If retaining the placeholder relationship is essential, prepare and populate the placeholder in PowerPoint first, then update the resulting [PictureFrame](https://reference.aspose.com/slides/php-java/aspose.slides/pictureframe/) with Aspose.Slides.
For image transparency, cropping, and other picture-specific effects, see [Manage Picture Frames](https://docs.aspose.com/slides/php-java/picture-frame/). Those operations belong to the picture frame or picture fill, not to placeholder metadata.
## **Work with Chart and Content Placeholders**
A populated chart placeholder can be represented by a [Chart](https://reference.aspose.com/slides/php-java/aspose.slides/chart/). This example finds such a chart by both placeholder type and runtime class, changes its title, and saves the file:
```php
use aspose\slides\PlaceholderType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("chart-template.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapes = $slide->getShapes();
$shapeCountValue = $shapes->size();
$shapeCount = java_values($shapeCountValue);
$chartClass = new JavaClass("com.aspose.slides.Chart");
$placeholderChart = null;
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $shapes->get_Item($shapeIndex);
if (!java_instanceof($shape, $chartClass)) {
continue;
}
$placeholder = $shape->getPlaceholder();
if (java_is_null($placeholder)) {
continue;
}
$placeholderTypeValue = $placeholder->getType();
$placeholderType = java_values($placeholderTypeValue);
if ($placeholderType === PlaceholderType::Chart) {
$placeholderChart = $shape;
break;
}
}
if ($placeholderChart === null) {
throw new RuntimeException("The first slide does not contain a populated chart placeholder.");
}
$placeholderChart->setTitle(true);
$placeholderChart->getChartTitle()->addTextFrameForOverriding("Quarterly Revenue");
$presentation->save("chart-placeholder-updated.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
A general content placeholder usually has [PlaceholderType::Object](https://reference.aspose.com/slides/php-java/aspose.slides/placeholdertype/). In PowerPoint it acts as a launcher for several content types, including charts, tables, diagrams, pictures, and media. After it has been populated, inspect the actual shape class to learn what it contains. Specialized layouts can also expose [PlaceholderType::Chart](https://reference.aspose.com/slides/php-java/aspose.slides/placeholdertype/), [PlaceholderType::Table](https://reference.aspose.com/slides/php-java/aspose.slides/placeholdertype/), [PlaceholderType::Picture](https://reference.aspose.com/slides/php-java/aspose.slides/placeholdertype/), [PlaceholderType::Media](https://reference.aspose.com/slides/php-java/aspose.slides/placeholdertype/), or [PlaceholderType::Diagram](https://reference.aspose.com/slides/php-java/aspose.slides/placeholdertype/).
Aspose.Slides does not convert an empty [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/) placeholder into a [Chart](https://reference.aspose.com/slides/php-java/aspose.slides/chart/) merely by changing [Placeholder::getType](https://reference.aspose.com/slides/php-java/aspose.slides/placeholder/gettype/); the type cannot be changed through the class. To fill an empty chart or content area programmatically, add the required object at the placeholder's coordinates and then remove the empty placeholder. The following example does that for a chart:
```php
use aspose\slides\ChartType;
use aspose\slides\PlaceholderType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("content-template.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapes = $slide->getShapes();
$shapeCountValue = $shapes->size();
$shapeCount = java_values($shapeCountValue);
$targetPlaceholder = null;
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $shapes->get_Item($shapeIndex);
$placeholder = $shape->getPlaceholder();
if (java_is_null($placeholder)) {
continue;
}
$placeholderTypeValue = $placeholder->getType();
$placeholderType = java_values($placeholderTypeValue);
if ($placeholderType === PlaceholderType::Chart || $placeholderType === PlaceholderType::Object) {
$targetPlaceholder = $shape;
break;
}
}
if ($targetPlaceholder === null) {
throw new RuntimeException("The first slide does not contain a chart or content placeholder.");
}
$x = $targetPlaceholder->getX();
$y = $targetPlaceholder->getY();
$width = $targetPlaceholder->getWidth();
$height = $targetPlaceholder->getHeight();
$chart = $shapes->addChart(ChartType::ClusteredColumn, $x, $y, $width, $height);
$chart->setTitle(true);
$chart->getChartTitle()->addTextFrameForOverriding("Quarterly Revenue");
$shapes->remove($targetPlaceholder);
$presentation->save("content-placeholder-replaced-with-chart.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The added chart is an ordinary local chart. It occupies the placeholder's area but does not inherit from the layout placeholder. Use the dedicated [chart management articles](https://docs.aspose.com/slides/php-java/powerpoint-charts/) when you need to replace its categories, series, or workbook data.
## **Complete Example: Update Text or Image Content**
The following end-to-end example opens a template, searches the first slide for either a title or picture placeholder, checks the placeholder and shape types, updates the appropriate content, and saves the output. The example deliberately avoids assuming a shape index or treating every placeholder as the same class.
```php
use aspose\slides\PlaceholderType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation("template.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapes = $slide->getShapes();
$shapeCountValue = $shapes->size();
$shapeCount = java_values($shapeCountValue);
$autoShapeClass = new JavaClass("com.aspose.slides.AutoShape");
$pictureFrameClass = new JavaClass("com.aspose.slides.PictureFrame");
$updated = false;
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $shapes->get_Item($shapeIndex);
$placeholder = $shape->getPlaceholder();
if (java_is_null($placeholder)) {
continue;
}
$placeholderTypeValue = $placeholder->getType();
$placeholderType = java_values($placeholderTypeValue);
if (($placeholderType === PlaceholderType::Title || $placeholderType === PlaceholderType::CenteredTitle) && java_instanceof($shape, $autoShapeClass)) {
$shape->getTextFrame()->setText("Quarterly Business Review");
$updated = true;
break;
}
if ($placeholderType === PlaceholderType::Picture) {
$imageData = file_get_contents("replacement.png");
$image = $presentation->getImages()->addImage($imageData);
if (java_instanceof($shape, $pictureFrameClass)) {
$picture = $shape->getPictureFormat()->getPicture();
$picture->setImage($image);
} else {
$x = $shape->getX();
$y = $shape->getY();
$width = $shape->getWidth();
$height = $shape->getHeight();
$shapes->addPictureFrame(ShapeType::Rectangle, $x, $y, $width, $height, $image);
$shapes->remove($shape);
}
$updated = true;
break;
}
}
if (!$updated) {
throw new RuntimeException("No supported title or picture placeholder was found on the first slide.");
}
$presentation->save("placeholder-content-updated.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **FAQ**
**What is a base placeholder?**
A base placeholder is the corresponding shape on the layout or master from which another placeholder inherits. Use [Shape::getBasePlaceholder](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getbaseplaceholder/) to retrieve it. An ordinary local shape returns `null` because it is not part of the placeholder hierarchy.
**Can I change all slide titles by editing a layout placeholder?**
You can change inherited formatting or prompt text through a layout, but existing title content is stored on the normal slides. To replace actual title text across a presentation, iterate over the slides and update each title placeholder.
**How do I manage date, slide-number, header, and footer placeholders?**
Use the header and footer managers at the appropriate slide, layout, master, notes, or handout scope. See [Manage Presentation Header and Footer](https://docs.aspose.com/slides/php-java/presentation-header-and-footer/) for complete examples.
## Related articles
- [HeaderFooter](https://docs.aspose.com/slides/php-java/examples/elements/header-footer/)
- [Manage Presentation Headers and Footers in PHP](https://docs.aspose.com/slides/php-java/presentation-header-and-footer/)
# Manage Presentations in PHP
> Manage PowerPoint PPT, PPTX and ODP presentations with Aspose.Slides for PHP via Java: create, load, edit, clone slides and control content programmatically.
Source: https://docs.aspose.com/slides/php-java/manage-presentation/
Updated: 2025-11-30
---
lastmod: 2025-11-30T13:47:17+04:00
title: Manage Presentations in PHP
linktitle: Manage Presentation
type: docs
weight: 10
url: /php-java/manage-presentation/
keywords:
- manage presentation
- manage PPT
- manage PPTX
- manage ODP
- create presentation
- open presentation
- examine presentation
- merge presentations
- convert presentation
- save presentation
- manage slide show
- PowerPoint
- OpenDocument
- PHP
- Aspose.Slides
description: "Manage PowerPoint PPT, PPTX and ODP presentations with Aspose.Slides for PHP via Java: create, load, edit, clone slides and control content programmatically."
---
# Manage Rows and Columns in PowerPoint Tables Using PHP
> Manage table rows and columns in PowerPoint with Aspose.Slides for PHP via Java and speed up presentation editing and data updates.
Source: https://docs.aspose.com/slides/php-java/manage-rows-and-columns/
Updated: 2026-11-16
## **Introduction**
Aspose.Slides for PHP via Java lets you manage table structure and formatting in PowerPoint presentations through the [Table](https://reference.aspose.com/slides/php-java/aspose.slides/table/) class. You can designate a header row, clone or remove rows and columns, and apply text formatting to an entire row or column.
This article explains these operations with PHP examples. It also shows how to retrieve a table's style preset so you can reuse it. Table row and column indices are zero-based.
## **Control Row Height**
Use [Row::setMinimalHeight](https://reference.aspose.com/slides/php-java/aspose.slides/row/setminimalheight/) to set a row's minimum height in points. It is a lower bound, not a fixed height. [Row::getHeight](https://reference.aspose.com/slides/php-java/aspose.slides/row/getheight/) returns the actual height. Access the row through [Table::getRows](https://reference.aspose.com/slides/php-java/aspose.slides/table/getrows/).
The example loads [row-height-input.pptx](https://docs.aspose.com/slides/php-java/manage-rows-and-columns/row-height-input.pptx), which has a table as the first shape on the first slide. Its first row starts at 70 points. The cells use 18-point Arial text, wrapping, and 6-point top and bottom margins; the longer text in the second column wraps onto multiple lines. The example increases the minimum to 100 points, then decreases it to 20 points, prints the actual height after each change, and saves both results.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("row-height-input.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$table = $slide->getShapes()->get_Item(0);
$row = $table->getRows()->get_Item(0);
$row->setMinimalHeight(100);
printf("Increased: minimum = %.1f, actual = %.1f pt\n", java_values($row->getMinimalHeight()), java_values($row->getHeight()));
$presentation->save("row-height-increased.pptx", SaveFormat::Pptx);
$row->setMinimalHeight(20);
printf("Decreased: minimum = %.1f, actual = %.1f pt\n", java_values($row->getMinimalHeight()), java_values($row->getHeight()));
$presentation->save("row-height-decreased.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
With the supplied presentation, increasing the minimum adds space to the row. Decreasing it removes that extra space, but the actual height remains greater than 20 points because the text and cell margins need more room. Reducing the minimum alone cannot force the row below the space required by its content.
Several factors affect the actual height:
- **Text and font size:** longer text, explicit line breaks, or a larger font can require more vertical space.
- **Wrapping and column width:** with wrapping enabled, reducing the column width with [Column::setWidth](https://reference.aspose.com/slides/php-java/aspose.slides/column/setwidth/) can produce more lines. A wider column can reduce the space required vertically.
- **Cell margins:** [Cell::setMarginTop](https://reference.aspose.com/slides/php-java/aspose.slides/cell/setmargintop/) and [Cell::setMarginBottom](https://reference.aspose.com/slides/php-java/aspose.slides/cell/setmarginbottom/) add vertical space. [Cell::setMarginLeft](https://reference.aspose.com/slides/php-java/aspose.slides/cell/setmarginleft/) and [Cell::setMarginRight](https://reference.aspose.com/slides/php-java/aspose.slides/cell/setmarginright/) reduce the width available for text and can cause additional wrapping.
For this table without merged cells, the cell that needs the most vertical space determines the content-driven lower limit for the entire row. To make the row shorter, you may also need to shorten the text, reduce the font size or margins, or widen a column.
The images below show the same table at the same scale. In the illustrated results, the actual heights were 70, 100, and 55.2 points: the final row remained taller than its 20-point minimum. Exact text measurements can vary with the fonts available in your environment. Download the saved results: [increased minimum](https://docs.aspose.com/slides/php-java/manage-rows-and-columns/row-height-increased.pptx) and [decreased minimum](https://docs.aspose.com/slides/php-java/manage-rows-and-columns/row-height-decreased.pptx).
| Original: minimum 70 pt, actual 70 pt | Increased: minimum 100 pt, actual 100 pt | Decreased: minimum 20 pt, actual 55.2 pt |
| --- | --- | --- |
|  |  |  |
## **Set the First Row as a Header**
Use the [setFirstRow](https://reference.aspose.com/slides/php-java/aspose.slides/table/setfirstrow/) method to mark the first row for header formatting. Its appearance depends on the table style applied to the table.
1. Load the presentation with the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
2. Access the first slide.
3. Access the table stored as the first shape on the slide.
4. Enable header formatting for its first row.
5. Save the modified presentation.
The example requires `table.pptx` with a table as the first shape on the first slide. It enables header formatting for the first row and saves `First_row_header.pptx`.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("table.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$table = $slide->getShapes()->get_Item(0);
$table->setFirstRow(true);
$presentation->save("First_row_header.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Clone a Table Row or Column**
Clone rows or columns to reuse their content and formatting. You can append a copy to the end of the table or insert it at a specific position.
1. Load the presentation with the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
2. Access the first slide.
3. Define the column widths and row heights.
4. Add a table with the [addTable](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/addtable/) method.
5. Clone the required rows.
6. Clone the required columns.
7. Save the modified presentation.
The example requires `Test.pptx` with at least one slide. It creates a table with three columns and five rows, with dimensions specified in points. It appends copies of the first row and column, then inserts copies of the second row and column at index 3 (the fourth position). The resulting table has seven rows and five columns. The `false` argument disables cloning into adjacent merged rows or columns; this table has no merged cells.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("Test.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$columnWidths = [50, 50, 50];
$rowHeights = [50, 30, 30, 30, 30];
$table = $slide->getShapes()->addTable(100, 50, $columnWidths, $rowHeights);
$table->get_Item(0, 0)->getTextFrame()->setText("Row 1 Cell 1");
$table->get_Item(1, 0)->getTextFrame()->setText("Row 1 Cell 2");
$table->getRows()->addClone($table->getRows()->get_Item(0), false);
$table->get_Item(0, 1)->getTextFrame()->setText("Row 2 Cell 1");
$table->get_Item(1, 1)->getTextFrame()->setText("Row 2 Cell 2");
$table->getRows()->insertClone(3, $table->getRows()->get_Item(1), false);
$table->getColumns()->addClone($table->getColumns()->get_Item(0), false);
$table->getColumns()->insertClone(3, $table->getColumns()->get_Item(1), false);
$presentation->save("table_out.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Remove a Row or Column from a Table**
Remove rows or columns that are no longer needed in a table. Removing an item shifts the indices of the rows or columns that follow it.
1. Create a presentation with the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
2. Access the first slide.
3. Define the column widths and row heights.
4. Add a table with the [addTable](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/addtable/) method.
5. Remove the second row and second column.
6. Save the modified presentation.
This example creates a three-by-three table and removes the row and column at index 1, leaving a two-by-two table in `TestTable_out.pptx`. The dimensions are in points. The `false` argument disables removal of adjacent merged rows or columns; this table has no merged cells.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$columnWidths = [100, 50, 30];
$rowHeights = [30, 50, 30];
$table = $slide->getShapes()->addTable(100, 100, $columnWidths, $rowHeights);
$table->getRows()->removeAt(1, false);
$table->getColumns()->removeAt(1, false);
$presentation->save("TestTable_out.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Set Text Formatting on the Table Row Level**
Apply text formatting to an entire row to keep its cells consistent. You can set font properties, paragraph formatting, and text direction without formatting each cell individually.
1. Load the presentation with the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
2. Access the table on the first slide.
3. Use [setFontHeight](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setFontHeight) for the first row.
4. Use [setAlignment](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/setalignment/) and [setMarginRight](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/setmarginright/) for the first row.
5. Use [setTextVerticalType](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/settextverticaltype/) for the second row.
6. Save the modified presentation.
The example requires `table.pptx` with a table as the first shape on the first slide and at least two rows. It applies 25-point text, right alignment, and a 20-point right paragraph margin to the first row, then sets vertical text in the second row.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\PortionFormat;
use aspose\slides\ParagraphFormat;
use aspose\slides\TextFrameFormat;
use aspose\slides\TextAlignment;
use aspose\slides\TextVerticalType;
$presentation = new Presentation("table.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$table = $slide->getShapes()->get_Item(0);
$portionFormat = new PortionFormat();
$portionFormat->setFontHeight(25);
$table->getRows()->get_Item(0)->setTextFormat($portionFormat);
$paragraphFormat = new ParagraphFormat();
$paragraphFormat->setAlignment(TextAlignment::Right);
$paragraphFormat->setMarginRight(20);
$table->getRows()->get_Item(0)->setTextFormat($paragraphFormat);
$textFrameFormat = new TextFrameFormat();
$textFrameFormat->setTextVerticalType(TextVerticalType::Vertical);
$table->getRows()->get_Item(1)->setTextFormat($textFrameFormat);
$presentation->save("row_formatting.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Set Text Formatting on the Table Column Level**
Apply text formatting to an entire column to keep its cells consistent. You can set font properties, paragraph formatting, and text direction without formatting each cell individually.
1. Load the presentation with the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
2. Access the table on the first slide.
3. Use [setFontHeight](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setFontHeight) for the first column.
4. Use [setAlignment](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/setalignment/) and [setMarginRight](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/setmarginright/) for the first column.
5. Use [setTextVerticalType](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/settextverticaltype/) for the second column.
6. Save the modified presentation.
The example requires `table.pptx` with a table as the first shape on the first slide and at least two columns. It applies 25-point text, right alignment, and a 20-point right paragraph margin to the first column, then sets vertical text in the second column.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\PortionFormat;
use aspose\slides\ParagraphFormat;
use aspose\slides\TextFrameFormat;
use aspose\slides\TextAlignment;
use aspose\slides\TextVerticalType;
$presentation = new Presentation("table.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$table = $slide->getShapes()->get_Item(0);
$portionFormat = new PortionFormat();
$portionFormat->setFontHeight(25);
$table->getColumns()->get_Item(0)->setTextFormat($portionFormat);
$paragraphFormat = new ParagraphFormat();
$paragraphFormat->setAlignment(TextAlignment::Right);
$paragraphFormat->setMarginRight(20);
$table->getColumns()->get_Item(0)->setTextFormat($paragraphFormat);
$textFrameFormat = new TextFrameFormat();
$textFrameFormat->setTextVerticalType(TextVerticalType::Vertical);
$table->getColumns()->get_Item(1)->setTextFormat($textFrameFormat);
$presentation->save("column_formatting.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Get Table Style Properties**
Use the [getStylePreset](https://reference.aspose.com/slides/php-java/aspose.slides/table/getstylepreset/) method to retrieve the preset applied to a table and reuse it on another table. This identifies the preset rather than individual cell formatting overrides.
The example creates a table, applies [TableStylePreset::DarkStyle1](https://reference.aspose.com/slides/php-java/aspose.slides/tablestylepreset/#DarkStyle1), and reads the preset back. It prints the integer value corresponding to `DarkStyle1` and saves the table in `table.pptx`.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TableStylePreset;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$columnWidths = [100, 150];
$rowHeights = [5, 5, 5];
$table = $slide->getShapes()->addTable(10, 10, $columnWidths, $rowHeights);
$table->setStylePreset(TableStylePreset::DarkStyle1);
$stylePreset = $table->getStylePreset();
echo java_values($stylePreset) . PHP_EOL;
$presentation->save("table.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Apply Row or Column Banding**
Use [Table::setHorizontalBanding](https://reference.aspose.com/slides/php-java/aspose.slides/table/sethorizontalbanding/) to alternate row fills or [Table::setVerticalBanding](https://reference.aspose.com/slides/php-java/aspose.slides/table/setverticalbanding/) to alternate column fills. The table style supplies the band colors. To keep a particular cell the same color in every configuration, use [CellFormat::getFillFormat](https://reference.aspose.com/slides/php-java/aspose.slides/cellformat/getfillformat/) to apply a solid fill.
The example saves three versions of the same table. Only the two banding flags change between saves.
```php
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TableStylePreset;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$columnWidths = [100, 100, 100, 100];
$rowHeights = [50, 50, 50, 50];
$table = $slide->getShapes()->addTable(40, 40, $columnWidths, $rowHeights);
$table->setStylePreset(TableStylePreset::MediumStyle2Accent1);
$table->setFirstRow(false);
$table->setFirstCol(false);
$table->setLastRow(false);
$table->setLastCol(false);
foreach ($rowHeights as $row => $height) {
foreach ($columnWidths as $column => $width) {
$table->get_Item($column, $row)->getTextFrame()->setText(($row + 1) . "," . ($column + 1));
}
}
$fill = $table->get_Item(1, 1)->getCellFormat()->getFillFormat();
$fill->setFillType(FillType::Solid);
$orange = new Java("java.awt.Color", 255, 165, 0);
$fill->getSolidFillColor()->setColor($orange);
$table->setHorizontalBanding(true);
$table->setVerticalBanding(false);
$presentation->save("rows.pptx", SaveFormat::Pptx);
$table->setHorizontalBanding(false);
$table->setVerticalBanding(true);
$presentation->save("columns.pptx", SaveFormat::Pptx);
$table->setVerticalBanding(false);
$presentation->save("off.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
In PowerPoint, cell `2,2` stays orange in all three versions. Its neighbors alternate in color by row or by column and share a single fill when both flags are off.
| Row banding | Column banding | Both off |
| --- | --- | --- |
|  |  |  |
## **FAQ**
**Can I apply PowerPoint themes/styles to a table that's already created?**
Yes. The table inherits the slide/layout/master theme, and you can still override fills, borders, and text colors on top of that theme.
**Can I sort table rows like in Excel?**
No, Aspose.Slides tables don't have built-in sorting or filters. Sort your data in memory first, then repopulate the table rows in that order.
**Can I have banded (striped) columns while keeping custom colors on specific cells?**
Yes. Enable banded columns and apply a local fill to the cells you want to highlight. See [Apply Row or Column Banding](https://docs.aspose.com/slides/php-java/manage-rows-and-columns/#apply-row-or-column-banding).
## Related articles
- [Manage Presentation Tables in PHP](https://docs.aspose.com/slides/php-java/manage-table/)
- [Create and Customize PowerPoint Tables in PHP](https://docs.aspose.com/slides/php-java/powerpoint-table/)
# Manage Slide Show in PHP
> Learn how to manage slide shows in Aspose.Slides for PHP via Java. Control slide transitions, timings and more across PPT, PPTX and ODP formats with ease.
Source: https://docs.aspose.com/slides/php-java/manage-slide-show/
Updated: 2026-08-02
## **Introduction**
In Microsoft PowerPoint, the **Slide Show** settings are a key tool for preparing and delivering professional presentations. One of the most important features in this section is **Set Up Show**, which allows you to tailor your presentation to specific conditions and audiences, ensuring flexibility and convenience. With this feature, you can select the show type (e.g., presented by a speaker, browsed by an individual, or browsed at a kiosk), enable or disable looping, choose specific slides to display, and use timings. This step in preparation is crucial for making your presentation more effective and professional.
`getSlideShowSettings` is a method of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class that returns an object of type [SlideShowSettings](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowsettings/), which allows you to manage the slide show settings in a PowerPoint presentation. In this article, we will explore how to use this method to configure and control various aspects of slide show settings.
## **Select Show Type**
`SlideShowSettings->setSlideShowType` defines the type of slide show, which can be an instance of the following classes: [PresentedBySpeaker](https://reference.aspose.com/slides/php-java/aspose.slides/presentedbyspeaker/), [BrowsedByIndividual](https://reference.aspose.com/slides/php-java/aspose.slides/browsedbyindividual/), or [BrowsedAtKiosk](https://reference.aspose.com/slides/php-java/aspose.slides/browsedatkiosk/). Using this method allows you to adapt the presentation for different usage scenarios, such as automated kiosks or manual presentations.
The code example below creates a new presentation and sets the show type to "Browsed by an individual" without displaying the scrollbar.
```php
$presentation = new Presentation();
$showType = new BrowsedByIndividual();
$showType->setShowScrollbar(false);
$presentation->getSlideShowSettings()->setSlideShowType($showType);
$presentation->save("output.pptx", SaveFormat::Pptx);
$presentation->dispose();
```
## **Enable Show Options**
`SlideShowSettings->setLoop` determines whether the slide show should repeat in a loop until manually stopped. This is useful for automated presentations that need to run continuously. `SlideShowSettings->setShowNarration` determines whether voice narrations should be played during the slide show. It is useful for automated presentations that contain voice guidance for the audience. `SlideShowSettings->setShowAnimation` determines whether animations added to slide objects should be played. This is useful for providing the full visual effect of the presentation.
The following code example creates a new presentation and loops the slide show.
```php
$presentation = new Presentation();
$presentation->getSlideShowSettings()->setLoop(true);
$presentation->save("output.pptx", SaveFormat::Pptx);
$presentation->dispose();
```
## **Select Slides to Show**
`SlideShowSettings->setSlides` method allows you to select a range of slides to be shown during the presentation. This is useful when you need to show only part of the presentation rather than all slides. The following code example creates a new presentation and sets the slide range to display from slides `2` to `9`.
```php
$presentation = new Presentation();
$slideRange = new SlidesRange();
$slideRange->setStart(2);
$slideRange->setEnd(9);
$presentation->getSlideShowSettings()->setSlides($slideRange);
$presentation->save("output.pptx", SaveFormat::Pptx);
$presentation->dispose();
```
## **Use Advance Slides**
`SlideShowSettings->setUseTimings` method allows you to enable or disable the use of preset timings for each slide. This is useful for automatically showing slides with pre-defined display durations. The code example below creates a new presentation and disables the use of timings.
```php
$presentation = new Presentation();
$presentation->getSlideShowSettings()->setUseTimings(false);
$presentation->save("output.pptx", SaveFormat::Pptx);
$presentation->dispose();
```
## **Show Media Controls**
`SlideShowSettings->setShowMediaControls` method determines whether media controls (such as play, pause, and stop) should be displayed during the slide show when multimedia content (e.g., video or audio) is played. This is useful when you want to give the presenter control over media playback during the presentation.
The following code example creates a new presentation and enables media controls to be displayed.
```php
$presentation = new Presentation();
$presentation->getSlideShowSettings()->setShowMediaControls(true);
$presentation->save("output.pptx", SaveFormat::Pptx);
$presentation->dispose();
```
## **FAQ**
### Can I save a presentation so it opens directly in slide show mode?
Yes. Save the file as PPSX or PPSM; these formats launch directly in slide show when opened in PowerPoint. In Aspose.Slides, choose the corresponding save format [during export](https://docs.aspose.com/slides/php-java/save-presentation/).
### Can I exclude individual slides from the show without deleting them from the file?
Yes. Mark a slide as [hidden](https://reference.aspose.com/slides/php-java/aspose.slides/slide/sethidden/). Hidden slides remain in the presentation but are not displayed during the slide show.
### Can Aspose.Slides play a slide show or control a live presentation on screen?
No. Aspose.Slides edits, analyzes, and converts presentation files; the actual playback is handled by a viewer application such as PowerPoint.
# Manage SmartArt Shape Nodes in Presentations Using PHP
> Manage SmartArt shape nodes in PPT and PPTX with Aspose.Slides for PHP via Java. Get clear code samples and tips to streamline your presentations.
Source: https://docs.aspose.com/slides/php-java/manage-smartart-shape-node/
Updated: 2026-08-13
## **Overview**
SmartArt graphics in PowerPoint presentations are organized through nodes that contain text and define the structure of the diagram. Aspose.Slides allows you to work with these SmartArt nodes programmatically: add new nodes and child nodes, insert child nodes at a specific position, access existing nodes, and read their text, level, and position.
This article explains how to manage SmartArt shape nodes. It shows how to remove nodes, work with child nodes by index or position, change an assistant node to a normal node, adjust the position, size, and rotation of SmartArt node shapes, set node fill formats, and generate a thumbnail image for a SmartArt child node.
## **Add a SmartArt Node**
Aspose.Slides for PHP via Java has provided the simplest API to manage the SmartArt shapes in an easiest way. The following sample code will help to add node and child node inside SmartArt shape.
1. Create an instance of [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation) class and load the presentation with SmartArt Shape.
1. Obtain the reference of first slide by using its Index.
1. Traverse through every shape inside first slide.
1. Check if shape is of [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/) type and Typecast selected shape to [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/) if it is SmartArt.
1. [Add a new Node](https://reference.aspose.com/slides/php-java/aspose.slides/smartartnodecollection/#addNode) in SmartArt shape [**NodeCollection**](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/#getAllNodes) and set the text in TextFrame.
1. Now, [Add](https://reference.aspose.com/slides/php-java/aspose.slides/smartartnodecollection/#addNode) a [**Child Node**](https://reference.aspose.com/slides/php-java/aspose.slides/smartartnode/#getChildNodes) in newly added [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/) Node and set the text in TextFrame
1. Save the Presentation.
```php
# Load the desired the presentation
$pres = new Presentation("SimpleSmartArt.pptx");
try {
# Traverse through every shape inside first slide
$shapes = $pres->getSlides()->get_Item(0)->getShapes();
foreach ($shapes as $shape) {
# Check if shape is of SmartArt type
if (java_instanceof($shape, new JavaClass("com.aspose.slides.SmartArt"))) {
# Typecast shape to SmartArt
$smart = $shape;
# Adding a new SmartArt Node
$TemNode = $smart->getAllNodes()->addNode();
# Adding text
$TemNode->getTextFrame()->setText("Test");
# Adding new child node in parent node. It will be added in the end of collection
$newNode = $TemNode->getChildNodes()->addNode();
# Adding text
$newNode->getTextFrame()->setText("New Node Added");
}
}
# Saving Presentation
$pres->save("AddSmartArtNode.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Add a SmartArt Node at a Specific Position**
In the following sample code we have explained how to add the child nodes belonging to respective nodes of SmartArt shape at particular position.
1. Create an instance of Presentation class.
1. Obtain the reference of first slide by using its Index.
1. Add a [**StackedList**](https://reference.aspose.com/slides/php-java/aspose.slides/SmartArtLayoutType#StackedList) type [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/SmartArt) shape in accessed slide.
1. Access the first node in added SmartArt shape
1. Now, add the [**Child Node**](https://reference.aspose.com/slides/php-java/aspose.slides/smartartnode/#getChildNodes) for selected [**Node**](https://reference.aspose.com/slides/php-java/aspose.slides/SmartArtNode) at position 2 and set its text.
1. Save the Presentation
```php
# Creating a presentation instance
$pres = new Presentation();
try {
# Access the presentation slide
$slide = $pres->getSlides()->get_Item(0);
# Add Smart Art IShape
$smart = $slide->getShapes()->addSmartArt(0, 0, 400, 400, SmartArtLayoutType::StackedList);
# Accessing the SmartArt node at index 0
$node = $smart->getAllNodes()->get_Item(0);
# Adding new child node at position 2 in parent node
$chNode = $node->getChildNodes()->addNodeByPosition(2);
# Add Text
$chNode->getTextFrame()->setText("Sample Text Added");
# Save Presentation
$pres->save("AddSmartArtNodeByPosition.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Access a SmartArt Node**
The following sample code will help to access nodes inside SmartArt shape. Please note that you cannot change the LayoutType of the SmartArt as it is read only and is set only when the SmartArt shape is added.
1. Create an instance of [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation) class and load the presentation with SmartArt Shape.
1. Obtain the reference of first slide by using its Index.
1. Traverse through every shape inside first slide.
1. Check if shape is of [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/) type and Typecast selected shape to [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/) if it is SmartArt.
1. Traverse through all [**Nodes**](https://reference.aspose.com/slides/php-java/aspose.slides/SmartArt#getAllNodes--) inside SmartArt Shape.
1. Access and display information like SmartArt Node position, level and Text.
```php
# Instantiate Presentation Class
$pres = new Presentation("SmartArtShape.pptx");
try {
# Get first slide
$slide = $pres->getSlides()->get_Item(0);
# Traverse through every shape inside first slide
$shapes = $slide->getShapes();
foreach ($shapes as $shape) {
# Check if shape is of SmartArt type
if (java_instanceof($shape, new JavaClass("com.aspose.slides.SmartArt"))) {
# Typecast shape to SmartArt
$smart = $shape;
# Traverse through all nodes inside SmartArt
for($i = 0; $i < java_values($smart->getAllNodes()->size()) ; $i++) {
# Accessing SmartArt node at index i
$node = $smart->getAllNodes()->get_Item($i);
# Printing the SmartArt node parameters
echo($node->getTextFrame()->getText() . " " . $node->getLevel() . " " . $node->getPosition());
}
}
}
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Access a SmartArt Child Node**
The following sample code will help to access the child nodes belonging to respective nodes of SmartArt shape.
1. Create an instance of [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation) class and load the presentation with SmartArt Shape.
1. Obtain the reference of first slide by using its Index.
1. Traverse through every shape inside first slide.
1. Check if shape is of [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/) type and Typecast selected shape to [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/) if it is SmartArt.
1. Traverse through all [**Nodes**](https://reference.aspose.com/slides/php-java/aspose.slides/SmartArt#getAllNodes--) inside SmartArt Shape.
1. For every selected SmartArt shape [**Node**](https://reference.aspose.com/slides/php-java/aspose.slides/SmartArtNode), traverse through all [**Child Nodes**](https://reference.aspose.com/slides/php-java/aspose.slides/SmartArtNode#getChildNodes--) inside particular node.
1. Access and display information like [**Child Node**](https://reference.aspose.com/slides/php-java/aspose.slides/smartartnode/#getChildNodes) position, level and Text.
```php
# Instantiate Presentation Class
$pres = new Presentation("AccessChildNodes.pptx");
try {
# Get first slide
$slide = $pres->getSlides()->get_Item(0);
# Traverse through every shape inside first slide
$shapes = $slide->getShapes();
foreach ($shapes as $shape) {
# Check if shape is of SmartArt type
if (java_instanceof($shape, new JavaClass("com.aspose.slides.SmartArt"))) {
# Typecast shape to SmartArt
$smart = $shape;
# Traverse through all nodes inside SmartArt
for($i = 0; $i < java_values($smart->getAllNodes()->size()) ; $i++) {
# Accessing SmartArt node at index i
$node0 = $smart->getAllNodes()->get_Item($i);
# Traversing through the child nodes in SmartArt node at index i
for($j = 0; $j < java_values($node0->getChildNodes()->size()) ; $j++) {
# Accessing the child node in SmartArt node
$node = $node0->getChildNodes()->get_Item($j);
# Printing the SmartArt child node parameters
echo("j = " . $j . ", Text = " . $node->getTextFrame()->getText() . ", Level = " . $node->getLevel() . ", Position = " . $node->getPosition());
}
}
}
}
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Access a SmartArt Child Node at a Specific Position**
In this example, we will learn to access the child nodes at some particular position belonging to respective nodes of SmartArt shape.
1. Create an instance of [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation) class.
1. Obtain the reference of first slide by using its Index.
1. Add a [**StackedList**](https://reference.aspose.com/slides/php-java/aspose.slides/SmartArtLayoutType#StackedList) type SmartArt shape.
1. Access the added SmartArt shape.
1. Access the node at index 0 for accessed SmartArt shape.
1. Now, access the [**Child Node**](https://reference.aspose.com/slides/php-java/aspose.slides/smartartnode/#getChildNodes) at position 1 for accessed SmartArt node using **get_Item()** method.
1. Access and display information like [**Child Node**](https://reference.aspose.com/slides/php-java/aspose.slides/smartartnode/#getChildNodes) position, level and Text.
```php
# Instantiate the presentation
$pres = new Presentation();
try {
# Accessing the first slide
$slide = $pres->getSlides()->get_Item(0);
# Adding the SmartArt shape in first slide
$smart = $slide->getShapes()->addSmartArt(0, 0, 400, 400, SmartArtLayoutType::StackedList);
# Accessing the SmartArt node at index 0
$node = $smart->getAllNodes()->get_Item(0);
# Accessing the child node at position 1 in parent node
$position = 1;
$chNode = $node->getChildNodes()->get_Item($position);
# Printing the SmartArt child node parameters
System->out->print("Text = " . $chNode->getTextFrame()->getText() . ", Level = " . $chNode->getLevel() . ", Position = " . $chNode->getPosition());
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Remove a SmartArt Node**
In this example, we will learn to remove the nodes inside SmartArt shape.
1. Create an instance of [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation) class and load the presentation with SmartArt Shape.
1. Obtain the reference of first slide by using its Index.
1. Traverse through every shape inside first slide.
1. Check if shape is of [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/) type and Typecast selected shape to [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/) if it is SmartArt.
1. Check if the [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/) has more than 0 nodes.
1. Select the SmartArt node to be deleted.
1. Now, remove the selected node using [**removeNode**](https://reference.aspose.com/slides/php-java/aspose.slides/smartartnodecollection/#removeNode) method.
1. Save the Presentation.
```php
# Load the desired the presentation
$pres = new Presentation("AddSmartArtNode.pptx");
try {
# Traverse through every shape inside first slide
$shapes = $pres->getSlides()->get_Item(0)->getShapes();
foreach ($shapes as $shape) {
# Check if shape is of SmartArt type
if (java_instanceof($shape, new JavaClass("com.aspose.slides.SmartArt"))) {
# Typecast shape to SmartArt
$smart = $shape;
if (java_values($smart->getAllNodes()->size()) > 0) {
# Accessing SmartArt node at index 0
$node = $smart->getAllNodes()->get_Item(0);
# Removing the selected node
$smart->getAllNodes()->removeNode($node);
}
}
}
# Save Presentation
$pres->save("RemoveSmartArtNode.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Remove a SmartArt Node from a Specific Position**
In this example, we will learn to remove the nodes inside SmartArt shape at particular position.
1. Create an instance of [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation) class and load the presentation with SmartArt Shape.
1. Obtain the reference of first slide by using its Index.
1. Traverse through every shape inside first slide.
1. Check if shape is of [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/) type and Typecast selected shape to [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/) if it is SmartArt.
1. Select the SmartArt shape node at index 0.
1. Now, check if the selected SmartArt node has more than 2 child nodes.
1. Now, remove the node at **Position 1** using [**removeNode**](https://reference.aspose.com/slides/php-java/aspose.slides/smartartnodecollection/#removeNode) method.
1. Save the Presentation.
```php
# Load the desired the presentation
$pres = new Presentation("AddSmartArtNode.pptx");
try {
# Traverse through every shape inside first slide
$shapes = $pres->getSlides()->get_Item(0)->getShapes();
foreach ($shapes as $shape) {
# Check if shape is of SmartArt type
if (java_instanceof($shape, new JavaClass("com.aspose.slides.SmartArt"))) {
# Typecast shape to SmartArt
$smart = $shape;
if (java_values($smart->getAllNodes()->size()) > 0) {
# Accessing SmartArt node at index 0
$node = $smart->getAllNodes()->get_Item(0);
if (java_values($node->getChildNodes()->size()) >= 2) {
# Removing the child node at position 1
$node->getChildNodes()->removeNode(1);
}
}
}
}
# Save Presentation
$pres->save("RemoveSmartArtNodeByPosition.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Set a Custom Position for a Child Node in a SmartArt Object**
Aspose.Slides for PHP via Java support for setting [SmartArtShape](https://reference.aspose.com/slides/php-java/aspose.slides/SmartArtShape) [X](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#setX) and [Y](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#setY) properties. The code snippet below shows how to set custom SmartArtShape position, size and rotation also please note that adding new nodes causes a recalculation of the positions and sizes of all nodes. Also with custom position settings, user may set the nodes as per requirements.
```php
# Instantiate Presentation Class
$pres = new Presentation("SimpleSmartArt.pptx");
try {
$smart = $pres->getSlides()->get_Item(0)->getShapes()->addSmartArt(20, 20, 600, 500, SmartArtLayoutType::OrganizationChart);
# Move SmartArt shape to new position
$node = $smart->getAllNodes()->get_Item(1);
$shape = $node->getShapes()->get_Item(1);
$shape->setX($shape->getX() . $shape->getWidth() * 2);
$shape->setY($shape->getY() - $shape->getHeight() * 2);
# Change SmartArt shape's widths
$node = $smart->getAllNodes()->get_Item(2);
$shape = $node->getShapes()->get_Item(1);
$shape->setWidth($shape->getWidth() . $shape->getWidth() * 2);
# Change SmartArt shape's height
$node = $smart->getAllNodes()->get_Item(3);
$shape = $node->getShapes()->get_Item(1);
$shape->setHeight($shape->getHeight() . $shape->getHeight() * 2);
# Change SmartArt shape's rotation
$node = $smart->getAllNodes()->get_Item(4);
$shape = $node->getShapes()->get_Item(1);
$shape->setRotation(90);
$pres->save("SmartArt.pptx", SaveFormat::Pptx);
} finally {
$pres->dispose();
}
```
## **Check an Assistant Node**
In this article we will further investigate features of SmartArt shapes added in presentation slides programmatically using Aspose.Slides for PHP via Java.
We will use the following source SmartArt shape for our investigation in different sections of this article.
||
| :- |
|**Figure: Source SmartArt shape in slide**|
In the following sample code we will investigate how to identify **Assistant Nodes** in the SmartArt nodes collection and changing them.
1. Create an instance of [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation) class and load the presentation with SmartArt Shape.
1. Obtain the reference of second slide by using its Index.
1. Traverse through every shape inside first slide.
1. Check if shape is of [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/) type and Typecast selected shape to [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/) if it is SmartArt.
1. Traverse through all nodes inside SmartArt shape and check if they are [**Assistant Nodes**](https://reference.aspose.com/slides/php-java/aspose.slides/SmartArtNode#isAssistant--).
1. Change the status of Assistant Node to normal node.
1. Save the Presentation.
```php
# Creating a presentation instance
$pres = new Presentation("AddNodes.pptx");
try {
# Traverse through every shape inside first slide
$shapes = $pres->getSlides()->get_Item(0)->getShapes();
foreach ($shapes as $shape) {
# Check if shape is of SmartArt type
if (java_instanceof($shape, new JavaClass("com.aspose.slides.SmartArt"))) {
# Typecast shape to SmartArt
$smart = $shape;
# Traversing through all nodes of SmartArt shape
for($i = 0; $i < java_values($smart->getAllNodes()->size()) ; $i++) {
$node = $smart->getAllNodes()->get_Item($i);
# Check if node is Assistant node
if ($node->isAssistant()) {
# Setting Assistant node to false and making it normal node
$node->setAssistant(false);
}
}
}
}
# Save Presentation
$pres->save("ChangeAssitantNode.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
||
| :- |
|**Figure: Assistant Nodes Changed in SmartArt shape inside slide**|
## **Set a Node's Fill Format**
Aspose.Slides for PHP via Java makes it possible to add custom SmartArt shapes and set their fill format. This article explains how to create and access SmartArt shapes and set their fill format using Aspose.Slides for PHP via Java.
Please follow the steps below:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation) class.
1. Obtain the reference of a slide using its index.
1. Add a [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/) shape by setting its [**LayoutType**](https://reference.aspose.com/slides/php-java/aspose.slides/SmartArtLayoutType#ClosedChevronProcess).
1. Set the [**Fill Format**](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#getFillFormat) for the SmartArt shape nodes.
1. Write the modified presentation as a PPTX file.
```php
# Instantiate the presentation
$pres = new Presentation();
try {
# Accessing the slide
$slide = $pres->getSlides()->get_Item(0);
# Adding SmartArt shape and nodes
$chevron = $slide->getShapes()->addSmartArt(10, 10, 800, 60, SmartArtLayoutType::ClosedChevronProcess);
$node = $chevron->getAllNodes()->addNode();
$node->getTextFrame()->setText("Some text");
# Setting node fill color
$nodeShapes = $node->getShapes();
foreach ($nodeShapes as $item) {
$item->getFillFormat()->setFillType(FillType::Solid);
$item->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->RED);
}
# Save the presentation
$pres->save("TestSmart.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Generate a Thumbnail of a SmartArt Child Node**
Developers can generate a thumbnail of Child node of a SmartArt by following the steps below:
1. Create an instance of [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation) class.
1. [Add SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/smartartnodecollection/#addNode).
1. Obtain the reference of a node by using its Index
1. Get the thumbnail image.
1. Save the thumbnail image in any desired image format.
```php
# Instantiate Presentation class that represents the PPTX file
$pres = new Presentation();
try {
# Add SmartArt
$smart = $pres->getSlides()->get_Item(0)->getShapes()->addSmartArt(10, 10, 400, 300, SmartArtLayoutType::BasicCycle);
# Obtain the reference of a node by using its Index
$node = $smart->getNodes()->get_Item(1);
# Get thumbnail
$slideImage = $node->getShapes()->get_Item(0)->getImage();
# Save thumbnail
try {
$slideImage->save("SmartArt_ChildNote_Thumbnail.png", ImageFormat::Png);
} finally {
if (!java_is_null($slideImage)) {
$slideImage->dispose();
}
}
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **FAQ**
### Is SmartArt animation supported?
Yes. SmartArt is treated as a regular shape, so you can [apply standard animations](https://docs.aspose.com/slides/php-java/shape-animation/) (entrance, exit, emphasis, motion paths) and adjust timing. You can also animate shapes inside SmartArt nodes when needed.
### How can I reliably locate a specific SmartArt on a slide if its internal ID is unknown?
Assign and search by [alternative text](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getalternativetext/). Setting a distinctive AltText on the SmartArt lets you find it programmatically without relying on internal identifiers.
### Will the SmartArt appearance be preserved when converting the presentation to PDF?
Yes. Aspose.Slides renders SmartArt with high visual fidelity during [PDF export](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-pdf/), preserving layout, colors, and effects.
### Can I extract an image of the entire SmartArt (for previews or reports)?
Yes. You can render a SmartArt shape to [raster formats](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#getImage) or to [SVG](https://reference.aspose.com/slides/php-java/aspose.slides/shape/writeassvg/) for scalable vector output, making it suitable for thumbnails, reports, or web use.
## Related articles
- [Manage SmartArt Graphics in Presentations Using PHP](https://docs.aspose.com/slides/php-java/manage-smartart-shape/)
- [Manage SmartArt in PowerPoint Presentations Using PHP](https://docs.aspose.com/slides/php-java/manage-smartart/)
- [Create and Customize PowerPoint SmartArt in PHP](https://docs.aspose.com/slides/php-java/powerpoint-smartart/)
# Manage SmartArt Graphics in Presentations Using PHP
> Automate PowerPoint SmartArt creation, editing, and styling in PHP using Aspose.Slides, featuring concise code examples and performance-focused guidance.
Source: https://docs.aspose.com/slides/php-java/manage-smartart-shape/
Updated: 2026-08-05
## **Overview**
Aspose.Slides allows you to create and manage SmartArt graphics in PowerPoint presentations programmatically. This article explains how to add a SmartArt shape to a slide, access existing SmartArt shapes, find SmartArt by a specific layout type, and update its visual appearance by changing the SmartArt style or color style.
The examples show how to work with SmartArt shapes through the presentation slide’s shape collection, check whether a shape is SmartArt and then modify or inspect its properties.
## **Create a SmartArt Shape**
Aspose.Slides for PHP via Java has provided an API to create SmartArt shapes. To create a SmartArt shape in a slide, please follow the steps below:
1. Create an instance of [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation) class.
1. Obtain the reference of a slide by using its Index.
1. [Add a SmartArt shape](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/#addSmartArt) by setting it [LayoutType](https://reference.aspose.com/slides/php-java/aspose.slides/SmartArtLayoutType).
1. Save the modified presentation as a PPTX file.
```php
# Instantiate Presentation Class
$pres = new Presentation();
try {
# Get first slide
$slide = $pres->getSlides()->get_Item(0);
# Add Smart Art Shape
$smart = $slide->getShapes()->addSmartArt(0, 0, 400, 400, SmartArtLayoutType::BasicBlockList);
# Saving presentation
$pres->save("SimpleSmartArt.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
||
| :- |
|**Figure: SmartArt shape added to the slide**|
## **Access a SmartArt Shape on a Slide**
The following code will be used to access the SmartArt shapes added in presentation slide. In sample code we will traverse through every shape inside the slide and check if it is a [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/SmartArt) shape. If shape is of SmartArt type then we will typecast that to [**SmartArt**](https://reference.aspose.com/slides/php-java/aspose.slides/SmartArt) instance.
```php
# Load the desired the presentation
$pres = new Presentation("AccessSmartArtShape.pptx");
try {
# Traverse through every shape inside first slide
$shapes = $pres->getSlides()->get_Item(0)->getShapes();
foreach ($shapes as $shape) {
# Check if shape is of SmartArt type
if (java_instanceof($shape, new JavaClass("com.aspose.slides.SmartArt"))) {
# Typecast shape to SmartArtEx
$smart = $shape;
echo("Shape Name:" . $smart->getName());
}
}
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Access a SmartArt Shape with a Particular Layout Type**
The following sample code will help to access the [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/SmartArt) shape with particular LayoutType:: Please note that you cannot change the LayoutType of the SmartArt as it is read only and is set only when the [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/SmartArt) shape is added.
1. Create an instance of [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation) class and load the presentation with SmartArt Shape.
1. Obtain the reference of first slide by using its Index.
1. Traverse through every shape inside first slide.
1. Check if shape is of [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/SmartArt) type and Typecast selected shape to SmartArt if it is SmartArt.
1. Check the SmartArt shape with particular LayoutType and perform what is required to be done afterwards.
```php
$pres = new Presentation("AccessSmartArtShape.pptx");
try {
# Traverse through every shape inside first slide
$shapes = $pres->getSlides()->get_Item(0)->getShapes();
foreach ($shapes as $shape) {
# Check if shape is of SmartArt type
if (java_instanceof($shape, new JavaClass("com.aspose.slides.SmartArt"))) {
# Typecast shape to SmartArtEx
$smart = $shape;
# Checking SmartArt Layout
if ($smart->getLayout() == SmartArtLayoutType::BasicBlockList) {
echo("Do some thing here....");
}
}
}
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Change a SmartArt Shape Style**
In this example, we will learn to change the quick style for any SmartArt shape.
1. Create an instance of [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation) class and load the presentation with SmartArt Shape.
1. Obtain the reference of first slide by using its Index.
1. Traverse through every shape inside first slide.
1. Check if shape is of [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/SmartArt) type and Typecast selected shape to SmartArt if it is SmartArt.
1. Find the SmartArt shape with particular Style.
1. Set the new Style for the SmartArt shape.
1. Save the Presentation.
```php
# Instantiate Presentation Class
$pres = new Presentation("SimpleSmartArt.pptx");
try {
# Get first slide
$slide = $pres->getSlides()->get_Item(0);
# Traverse through every shape inside first slide
$shapes = $slide->getShapes();
foreach ($shapes as $shape) {
# Check if shape is of SmartArt type
if (java_instanceof($shape, new JavaClass("com.aspose.slides.SmartArt"))) {
# Typecast shape to SmartArtEx
$smart = $shape;
# Checking SmartArt style
if ($smart->getQuickStyle() == SmartArtQuickStyleType::SimpleFill) {
# Changing SmartArt Style
$smart->setQuickStyle(SmartArtQuickStyleType::Cartoon);
}
}
}
# Saving presentation
$pres->save("ChangeSmartArtStyle.pptx", SaveFormat::Pptx);
} finally {
$pres->dispose();
}
```
||
| :- |
|**Figure: SmartArt shape with changed Style**|
## **Change a SmartArt Shape Color Style**
In this example, we will learn to change the color style for any SmartArt shape. In the following sample code will access the SmartArt shape with particular color style and will change its style.
1. Create an instance of [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation) class and load the presentation with SmartArt Shape.
1. Obtain the reference of first slide by using its Index.
1. Traverse through every shape inside first slide.
1. Check if shape is of [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/SmartArt) type and Typecast selected shape to SmartArt if it is SmartArt.
1. Find the SmartArt shape with particular Color Style.
1. Set the new Color Style for the SmartArt shape.
1. Save the Presentation.
```php
# Instantiate Presentation Class
$pres = new Presentation("SimpleSmartArt.pptx");
try {
# Get first slide
$slide = $pres->getSlides()->get_Item(0);
# Traverse through every shape inside first slide
$shapes = $slide->getShapes();
foreach ($shapes as $shape) {
# Check if shape is of SmartArt type
if (java_instanceof($shape, new JavaClass("com.aspose.slides.SmartArt"))) {
# Typecast shape to SmartArtEx
$smart = $shape;
# Checking SmartArt color type
if ($smart->getColorStyle() == SmartArtColorType::ColoredFillAccent1) {
# Changing SmartArt color type
$smart->setColorStyle(SmartArtColorType::ColorfulAccentColors);
}
}
}
# Saving presentation
$pres->save("ChangeSmartArtColorStyle.pptx", SaveFormat::Pptx);
} finally {
$pres->dispose();
}
```
||
| :- |
|**Figure: SmartArt shape with changed Color Style**|
## **FAQ**
### Can I animate SmartArt as a single object?
Yes. SmartArt is a shape, so you can apply [standard animations](https://docs.aspose.com/slides/php-java/powerpoint-animation/) via the animations API (entrance, exit, emphasis, motion paths) just like for other shapes.
### How can I find a specific SmartArt on a slide if I don’t know its internal ID?
Set and use the Alternative Text (AltText) and search for the shape by that value—this is a recommended way to locate the target shape.
### Can I group SmartArt with other shapes?
Yes. You can group SmartArt with other shapes (pictures, tables, etc.) and then [manipulate the group](https://docs.aspose.com/slides/php-java/group/).
### How do I get an image of a specific SmartArt (e.g., for a preview or report)?
Export a thumbnail/image of the shape; the library can [render individual shapes](https://docs.aspose.com/slides/php-java/create-shape-thumbnails/) to raster files (PNG/JPG/TIFF).
### Will the SmartArt appearance be preserved when converting the whole presentation to PDF?
Yes. The rendering engine targets high fidelity for [PDF export](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-pdf/), with a range of quality and compatibility options.
## Related articles
- [Manage SmartArt Shape Nodes in Presentations Using PHP](https://docs.aspose.com/slides/php-java/manage-smartart-shape-node/)
- [SmartArt](https://docs.aspose.com/slides/php-java/examples/elements/smartart/)
# Manage SmartArt in PowerPoint Presentations Using PHP
> Learn to build and edit PowerPoint SmartArt with Aspose.Slides for PHP via Java using clear code samples that speed up slide design and automation.
Source: https://docs.aspose.com/slides/php-java/manage-smartart/
Updated: 2026-11-08
## **Overview**
SmartArt is a PowerPoint diagram made from nodes, node shapes, and a layout. With Aspose.Slides for PHP via Java, you can create SmartArt, read text from its nodes, change its layout, inspect hidden nodes, configure organization chart layouts, and create picture organization charts.
## **Get Text from a SmartArt Object**
A SmartArt node can contain one or more shapes. To read text from the node shapes, iterate through [SmartArt::getAllNodes](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/getallnodes/), then read the [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/) returned by [SmartArtShape::getTextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/smartartshape/gettextframe/).
The example requires a presentation with at least one slide and a SmartArt object as the first shape on that slide. It prints each available text frame to the console.
```php
use aspose\slides\Presentation;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$smartArt = $slide->getShapes()->get_Item(0);
for ($i = 0; $i < java_values($smartArt->getAllNodes()->size()); $i++) {
$node = $smartArt->getAllNodes()->get_Item($i);
for ($j = 0; $j < java_values($node->getShapes()->size()); $j++) {
$nodeShape = $node->getShapes()->get_Item($j);
if (!java_is_null($nodeShape->getTextFrame())) {
echo $nodeShape->getTextFrame()->getText() . PHP_EOL;
}
}
}
} finally {
$presentation->dispose();
}
```
## **Change the Layout Type of a SmartArt Object**
The SmartArt layout controls how nodes are arranged and connected. The following example creates a SmartArt object with the [SmartArtLayoutType](https://reference.aspose.com/slides/php-java/aspose.slides/smartartlayouttype/) `BasicBlockList` value, changes it to the `BasicProcess` value, and saves the presentation. The position and size passed to [ShapeCollection::addSmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/addsmartart/) are measured in points. Use [SmartArt::setLayout](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/setlayout/) to change the layout.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SmartArtLayoutType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$smartArt = $slide->getShapes()->addSmartArt(10, 10, 400, 300, SmartArtLayoutType::BasicBlockList);
$smartArt->setLayout(SmartArtLayoutType::BasicProcess);
$presentation->save("ChangeSmartArtLayout.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Check Whether a SmartArt Node Is Hidden**
[SmartArtNode::isHidden](https://reference.aspose.com/slides/php-java/aspose.slides/smartartnode/ishidden/) indicates whether the node is hidden in the SmartArt data model. Hidden nodes can exist in the structure even when the selected layout does not display them as visible diagram elements.
The following example adds a node to a SmartArt object that uses the [SmartArtLayoutType](https://reference.aspose.com/slides/php-java/aspose.slides/smartartlayouttype/) `RadialCycle` value and checks the added node's hidden state. It prints a message if the node is hidden and saves the diagram.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SmartArtLayoutType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$smartArt = $slide->getShapes()->addSmartArt(10, 10, 400, 300, SmartArtLayoutType::RadialCycle);
$node = $smartArt->getAllNodes()->addNode();
$isHidden = java_values($node->isHidden());
if ($isHidden) {
echo "The node is hidden in the SmartArt data model." . PHP_EOL;
}
$presentation->save("CheckSmartArtHiddenProperty.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Get or Set the Organization Chart Layout**
For SmartArt diagrams that use an organization chart layout, [SmartArtNode::getOrganizationChartLayout](https://reference.aspose.com/slides/php-java/aspose.slides/smartartnode/getorganizationchartlayout/) and [SmartArtNode::setOrganizationChartLayout](https://reference.aspose.com/slides/php-java/aspose.slides/smartartnode/setorganizationchartlayout/) define how child nodes are arranged under a parent node. For example, you can set child nodes to hang from the left, right, or both sides, depending on the selected [OrganizationChartLayoutType](https://reference.aspose.com/slides/php-java/aspose.slides/organizationchartlayouttype/).
The following example creates an organization chart and sets the layout for the first node to the [OrganizationChartLayoutType](https://reference.aspose.com/slides/php-java/aspose.slides/organizationchartlayouttype/) `LeftHanging` value. The zero-based index `0` selects the first top-level node; its child nodes use the selected arrangement. The modified presentation is then saved.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SmartArtLayoutType;
use aspose\slides\OrganizationChartLayoutType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$smartArt = $slide->getShapes()->addSmartArt(10, 10, 400, 300, SmartArtLayoutType::OrganizationChart);
$rootNode = $smartArt->getNodes()->get_Item(0);
$rootNode->setOrganizationChartLayout(OrganizationChartLayoutType::LeftHanging);
$presentation->save("OrganizationChartLayout.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
[](https://docs.aspose.com/slides/php-java/manage-smartart/visual-smartart-layouts-3487c8138eeb.svg)
*Illustrative .NET 26.11 fixture with labels added for identification. LeftHanging changes the child arrangement of the selected top-level parent; it is distinct from changing the whole SmartArt layout type.*
## **Create a Picture Organization Chart**
A picture organization chart is a SmartArt layout designed for hierarchy diagrams that include image placeholders. Use the [SmartArtLayoutType](https://reference.aspose.com/slides/php-java/aspose.slides/smartartlayouttype/) `PictureOrganizationChart` value when adding the SmartArt object to a slide. This example saves a diagram with image placeholders; it does not populate the placeholders with images.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SmartArtLayoutType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$smartArt = $slide->getShapes()->addSmartArt(0, 0, 400, 400, SmartArtLayoutType::PictureOrganizationChart);
$presentation->save("PictureOrganizationChart.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Convert Legacy Diagrams to Groups of Shapes**
When modernizing an existing presentation, you may need to update an organization chart originally created in PowerPoint 97–2003. Aspose.Slides represents these legacy diagrams as [LegacyDiagram](https://reference.aspose.com/slides/php-java/aspose.slides/legacydiagram/) objects. Use [LegacyDiagram::convertToGroupShape](https://reference.aspose.com/slides/php-java/aspose.slides/legacydiagram/converttogroupshape/) to convert a diagram into a group of shapes so that you can edit individual visual elements. See the [LegacyDiagram API Reference](https://reference.aspose.com/slides/php-java/aspose.slides/legacydiagram/) for details.
Conversion adds a new group to the shape collection without removing the original diagram. After successful conversion, remove the original with [ShapeCollection::remove](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/remove/) to avoid duplicate content. Collect the legacy diagrams into a list before converting them so that adding and removing shapes does not disrupt iteration.
The following example opens a presentation, searches every slide, converts the diagrams to groups of shapes, and saves the updated presentation as PPTX.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("legacy-diagrams.ppt");
try {
$legacyDiagramType = new JavaClass("com.aspose.slides.ILegacyDiagram");
for ($i = 0; $i < java_values($presentation->getSlides()->size()); $i++) {
$slide = $presentation->getSlides()->get_Item($i);
$legacyDiagrams = [];
for ($j = 0; $j < java_values($slide->getShapes()->size()); $j++) {
$shape = $slide->getShapes()->get_Item($j);
if (java_instanceof($shape, $legacyDiagramType)) {
$legacyDiagrams[] = $shape;
}
}
foreach ($legacyDiagrams as $legacyDiagram) {
$groupShape = $legacyDiagram->convertToGroupShape();
if (!java_is_null($groupShape)) {
$slide->getShapes()->remove($legacyDiagram);
}
}
}
$presentation->save("modernized.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The saved presentation contains editable groups of shapes in place of the converted legacy diagrams, with no original diagrams left alongside them. Open the PPTX in PowerPoint to edit individual elements within each group, such as their text, fill, or position.
## **FAQ**
**Does SmartArt support mirroring or reversing for RTL languages?**
Yes. The [SmartArt::setReversed](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/setreversed/) method switches the diagram direction from left-to-right to right-to-left, or back, when the selected SmartArt layout supports reversal.
**How can I copy SmartArt to the same slide or to another presentation while preserving formatting?**
You can [clone the SmartArt shape](https://docs.aspose.com/slides/php-java/shape-manipulations/) with [ShapeCollection::addClone](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/addclone/) or [clone the whole slide](https://docs.aspose.com/slides/php-java/clone-slides/) that contains the SmartArt. Both approaches preserve size, position, and formatting.
**How do I render SmartArt to a raster image for preview or web export?**
[Render the slide](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-png/) or the whole presentation to PNG or JPEG. SmartArt is rendered as part of the slide.
**How can I find a specific SmartArt object on a slide if there are several?**
Use [Shape::setAlternativeText](https://reference.aspose.com/slides/php-java/aspose.slides/shape/setalternativetext/) or [Shape::setName](https://reference.aspose.com/slides/php-java/aspose.slides/shape/setname/) to assign a distinctive alternative text or name to the SmartArt shape, search for that value in [BaseSlide::getShapes](https://reference.aspose.com/slides/php-java/aspose.slides/baseslide/#getShapes), and then check that the matching shape is a [SmartArt](https://reference.aspose.com/slides/php-java/aspose.slides/smartart/).
## Related articles
- [Manage SmartArt Shape Nodes in Presentations Using PHP](https://docs.aspose.com/slides/php-java/manage-smartart-shape-node/)
- [Create and Customize PowerPoint SmartArt in PHP](https://docs.aspose.com/slides/php-java/powerpoint-smartart/)
- [SmartArt](https://docs.aspose.com/slides/php-java/examples/elements/smartart/)
# Manage Presentation Tables in PHP
> Create & edit tables in PowerPoint slides with Aspose.Slides for PHP via Java. Discover simple code examples to streamline your table workflows.
Source: https://docs.aspose.com/slides/php-java/manage-table/
Updated: 2026-09-30
## **Introduction**
Tables in PowerPoint organize information into rows and columns, making it easier to read and compare values.
Aspose.Slides provides the [Table](https://reference.aspose.com/slides/php-java/aspose.slides/table/) class, [Cell](https://reference.aspose.com/slides/php-java/aspose.slides/cell/) class, and other types to allow you to create, update, and manage tables in presentations.
## **Create a Table from Scratch**
Create a table by specifying its position, column widths, and row heights. After adding it to a slide, you can format cell borders, merge cells, and insert text.
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
2. Get a reference to the slide by its index.
3. Define an array of column widths in points.
4. Define an array of row heights in points.
5. Add a [Table](https://reference.aspose.com/slides/php-java/aspose.slides/table/) object to the slide through the [addTable](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/addtable/) method.
6. Iterate through each [Cell](https://reference.aspose.com/slides/php-java/aspose.slides/cell/) to apply formatting to the top, bottom, right, and left borders.
7. Merge the first two cells of the table's first row.
8. Access the merged cell through its [getTextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/cell/gettextframe/) method.
9. Set the text in the merged cell.
10. Save the modified presentation.
The example below creates a table with three columns and five rows at (100, 50) points. It applies red borders with a width of 5 points, merges the first two cells in the first row, and saves the result as `table.pptx`.
```php
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$red = java("java.awt.Color")->RED;
$slide = $presentation->getSlides()->get_Item(0);
$columnWidths = [ 50, 50, 50 ];
$rowHeights = [ 50, 30, 30, 30, 30 ];
$table = $slide->getShapes()->addTable(100, 50, $columnWidths, $rowHeights);
for ($rowIndex = 0; $rowIndex < java_values($table->getRows()->size()); $rowIndex++) {
$row = $table->getRows()->get_Item($rowIndex);
for ($columnIndex = 0; $columnIndex < java_values($row->size()); $columnIndex++) {
$cell = $row->get_Item($columnIndex);
$cellFormat = $cell->getCellFormat();
$cellFormat->getBorderTop()->getFillFormat()->setFillType(FillType::Solid);
$cellFormat->getBorderTop()->getFillFormat()->getSolidFillColor()->setColor($red);
$cellFormat->getBorderTop()->setWidth(5);
$cellFormat->getBorderBottom()->getFillFormat()->setFillType(FillType::Solid);
$cellFormat->getBorderBottom()->getFillFormat()->getSolidFillColor()->setColor($red);
$cellFormat->getBorderBottom()->setWidth(5);
$cellFormat->getBorderLeft()->getFillFormat()->setFillType(FillType::Solid);
$cellFormat->getBorderLeft()->getFillFormat()->getSolidFillColor()->setColor($red);
$cellFormat->getBorderLeft()->setWidth(5);
$cellFormat->getBorderRight()->getFillFormat()->setFillType(FillType::Solid);
$cellFormat->getBorderRight()->getFillFormat()->getSolidFillColor()->setColor($red);
$cellFormat->getBorderRight()->setWidth(5);
}
}
$table->mergeCells($table->get_Item(0, 0), $table->get_Item(1, 0), false);
$table->get_Item(0, 0)->getTextFrame()->setText("Merged Cells");
$presentation->save("table.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Numbering in a Standard Table**
In a standard table, cell indices are zero-based and use the order (column, row). The first cell is indexed as (0, 0).
For example, the cells in a table with 4 columns and 4 rows are numbered this way:
| (0, 0) | (1, 0) | (2, 0) | (3, 0) |
| :----- | :----- | :----- | :----- |
| (0, 1) | (1, 1) | (2, 1) | (3, 1) |
| (0, 2) | (1, 2) | (2, 2) | (3, 2) |
| (0, 3) | (1, 3) | (2, 3) | (3, 3) |
This example creates the 4 × 4 table illustrated above, with column widths and row heights of 70 points and red cell borders with a width of 5 points. The coordinates illustrate cell indices; the example leaves the cells empty and saves the table as `StandardTables_out.pptx`.
```php
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$red = java("java.awt.Color")->RED;
$slide = $presentation->getSlides()->get_Item(0);
$columnWidths = [ 70, 70, 70, 70 ];
$rowHeights = [ 70, 70, 70, 70 ];
$table = $slide->getShapes()->addTable(100, 50, $columnWidths, $rowHeights);
for ($rowIndex = 0; $rowIndex < java_values($table->getRows()->size()); $rowIndex++) {
$row = $table->getRows()->get_Item($rowIndex);
for ($columnIndex = 0; $columnIndex < java_values($row->size()); $columnIndex++) {
$cell = $row->get_Item($columnIndex);
$cellFormat = $cell->getCellFormat();
$cellFormat->getBorderTop()->getFillFormat()->setFillType(FillType::Solid);
$cellFormat->getBorderTop()->getFillFormat()->getSolidFillColor()->setColor($red);
$cellFormat->getBorderTop()->setWidth(5);
$cellFormat->getBorderBottom()->getFillFormat()->setFillType(FillType::Solid);
$cellFormat->getBorderBottom()->getFillFormat()->getSolidFillColor()->setColor($red);
$cellFormat->getBorderBottom()->setWidth(5);
$cellFormat->getBorderLeft()->getFillFormat()->setFillType(FillType::Solid);
$cellFormat->getBorderLeft()->getFillFormat()->getSolidFillColor()->setColor($red);
$cellFormat->getBorderLeft()->setWidth(5);
$cellFormat->getBorderRight()->getFillFormat()->setFillType(FillType::Solid);
$cellFormat->getBorderRight()->getFillFormat()->getSolidFillColor()->setColor($red);
$cellFormat->getBorderRight()->setWidth(5);
}
}
$presentation->save("StandardTables_out.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Access an Existing Table**
Tables are stored in a slide's shape collection. Iterate through the shapes to locate a table, then use the [Table](https://reference.aspose.com/slides/php-java/aspose.slides/table/) class to read or update its cells.
1. Load the presentation using the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
2. Get a reference to the slide containing the table by its index.
3. Iterate through the [Shape](https://reference.aspose.com/slides/php-java/aspose.slides/shape/) objects and stop when a table is found. If the slide contains several tables, use [getAlternativeText](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getalternativetext/) to identify the one you need.
4. Update the text in the target cell.
5. Save the modified presentation.
The example below opens `UpdateExistingTable.pptx` and finds the first table on the first slide. It sets the cell at column 0, row 1 to `New` and saves the result as `table1_out.pptx`. The input must contain at least one slide, and the first table on that slide must have at least one column and two rows.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("UpdateExistingTable.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$table = null;
$tableClass = new JavaClass("com.aspose.slides.Table");
$shapeCount = java_values($slide->getShapes()->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $slide->getShapes()->get_Item($shapeIndex);
if (java_instanceof($shape, $tableClass)) {
$table = $shape;
break;
}
}
if ($table !== null) {
$table->get_Item(0, 1)->getTextFrame()->setText("New");
$presentation->save("table1_out.pptx", SaveFormat::Pptx);
}
} finally {
$presentation->dispose();
}
```
To resize a row in an existing table and understand why its actual height can exceed the requested minimum, see [Control Row Height](https://docs.aspose.com/slides/php-java/manage-rows-and-columns/#control-row-height).
## **Find the Cell That Owns a Text Frame**
When generic text-processing code receives a [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/) from a table, use the [TextFrame::getParentCell](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#getParentCell) method to retrieve the owning [Cell](https://reference.aspose.com/slides/php-java/aspose.slides/cell/). For a table-cell text frame, [TextFrame::getParentCell](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#getParentCell) returns the owner and [TextFrame::getParentShape](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#getParentShape) returns `null`, even though the table itself is a shape.
The cell coordinates are available through the read-only [Cell::getFirstColumnIndex](https://reference.aspose.com/slides/php-java/aspose.slides/cell/getfirstcolumnindex/) and [Cell::getFirstRowIndex](https://reference.aspose.com/slides/php-java/aspose.slides/cell/getfirstrowindex/) methods. [TextFrame::getParentCell](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#getParentCell) also provides read-only navigation: it returns the owner but does not change ownership. Always check the returned cell with `java_is_null` before using it.
For a complete example that identifies table-cell and shape owners, including shapes associated with SmartArt nodes, see [Search and Replace Text](https://docs.aspose.com/slides/php-java/search-and-replace-text/).
## **Align Text in a Table**
You can control the vertical anchoring and text direction of individual table cells. The example in this section centers text within the first cell and rotates it by 270 degrees.
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
2. Get a reference to the slide by its index.
3. Add a [Table](https://reference.aspose.com/slides/php-java/aspose.slides/table/) object to the slide.
4. Access a [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/) object from the table.
5. Access the first [Paragraph](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/) and set its text and color.
6. Set the cell's vertical anchoring and text direction using [setTextAnchorType](https://reference.aspose.com/slides/php-java/aspose.slides/cell/settextanchortype/) and [setTextVerticalType](https://reference.aspose.com/slides/php-java/aspose.slides/cell/settextverticaltype/).
7. Save the modified presentation.
This example creates a 4 × 4 table with column widths of 120 points and row heights of 100 points. It formats the text in cell (0, 0), adds values to the remaining cells in the first row, and saves the result as `Vertical_Align_Text_out.pptx`.
```php
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TextAnchorType;
use aspose\slides\TextVerticalType;
$presentation = new Presentation();
try {
$black = java("java.awt.Color")->BLACK;
$slide = $presentation->getSlides()->get_Item(0);
$columnWidths = [ 120, 120, 120, 120 ];
$rowHeights = [ 100, 100, 100, 100 ];
$table = $slide->getShapes()->addTable(100, 50, $columnWidths, $rowHeights);
$table->get_Item(1, 0)->getTextFrame()->setText("10");
$table->get_Item(2, 0)->getTextFrame()->setText("20");
$table->get_Item(3, 0)->getTextFrame()->setText("30");
$textFrame = $table->get_Item(0, 0)->getTextFrame();
$paragraph = $textFrame->getParagraphs()->get_Item(0);
$portion = $paragraph->getPortions()->get_Item(0);
$portion->setText("Text here");
$portion->getPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$portion->getPortionFormat()->getFillFormat()->getSolidFillColor()->setColor($black);
$cell = $table->get_Item(0, 0);
$cell->setTextAnchorType(TextAnchorType::Center);
$cell->setTextVerticalType(TextVerticalType::Vertical270);
$presentation->save("Vertical_Align_Text_out.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Set Text Formatting on the Table Level**
Use [setTextFormat](https://reference.aspose.com/slides/php-java/aspose.slides/table/settextformat/) to apply text formatting to all cells in a table. Its overloads accept portion, paragraph, and text frame formatting, so you can set these properties without iterating through individual cells.
1. Load the presentation using the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
2. Get a reference to the slide by its index.
3. Access a [Table](https://reference.aspose.com/slides/php-java/aspose.slides/table/) object from the slide.
4. Set the font size using [setFontHeight](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setFontHeight) for the text.
5. Set paragraph alignment and the right margin using [setAlignment](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/setalignment/) and [setMarginRight](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/setmarginright/).
6. Set the text direction using [setTextVerticalType](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/settextverticaltype/).
7. Save the modified presentation.
The example below opens `table.pptx`, which must contain at least one slide with a table as its first shape. It sets the font size to 25 points, right-aligns paragraphs with a right margin of 20 points, and makes the text vertical. The formatted presentation is saved as `result.pptx`.
```php
use aspose\slides\ParagraphFormat;
use aspose\slides\PortionFormat;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TextAlignment;
use aspose\slides\TextFrameFormat;
use aspose\slides\TextVerticalType;
$presentation = new Presentation("table.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$table = $slide->getShapes()->get_Item(0);
$portionFormat = new PortionFormat();
$portionFormat->setFontHeight(25);
$table->setTextFormat($portionFormat);
$paragraphFormat = new ParagraphFormat();
$paragraphFormat->setAlignment(TextAlignment::Right);
$paragraphFormat->setMarginRight(20);
$table->setTextFormat($paragraphFormat);
$textFrameFormat = new TextFrameFormat();
$textFrameFormat->setTextVerticalType(TextVerticalType::Vertical);
$table->setTextFormat($textFrameFormat);
$presentation->save("result.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Get Table Style Properties**
Use [getStylePreset](https://reference.aspose.com/slides/php-java/aspose.slides/table/getstylepreset/) to read a table's preset style and [setStylePreset](https://reference.aspose.com/slides/php-java/aspose.slides/table/setstylepreset/) to assign it. This example applies [TableStylePreset::DarkStyle1](https://reference.aspose.com/slides/php-java/aspose.slides/tablestylepreset/) to one table, prints the preset value, and assigns the same preset to a second table. Both tables are saved in `table-style.pptx`.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TableStylePreset;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$columnWidths = [ 100, 150 ];
$rowHeights = [ 5, 5, 5 ];
$table = $slide->getShapes()->addTable(10, 10, $columnWidths, $rowHeights);
$table->setStylePreset(TableStylePreset::DarkStyle1);
$stylePreset = java_values($table->getStylePreset());
echo "Table style preset: " . $stylePreset . PHP_EOL;
$anotherTable = $slide->getShapes()->addTable(10, 100, $columnWidths, $rowHeights);
$anotherTable->setStylePreset($stylePreset);
$presentation->save("table-style.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Lock Aspect Ratio of a Table**
A table's aspect ratio is the ratio of its width to its height. Use [setAspectRatioLocked](https://reference.aspose.com/slides/php-java/aspose.slides/graphicalobjectlock/setaspectratiolocked/) to lock this ratio for a table.
The example below opens `pres.pptx`, which must contain at least one slide with a table as its first shape. It prints the current lock state, enables the aspect ratio lock, prints the updated state (`true`), and saves the result as `pres-out.pptx`.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("pres.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$table = $slide->getShapes()->get_Item(0);
echo "Lock aspect ratio set: " . (java_values($table->getGraphicalObjectLock()->getAspectRatioLocked()) ? "true" : "false") . PHP_EOL;
$table->getGraphicalObjectLock()->setAspectRatioLocked(true);
echo "Lock aspect ratio set: " . (java_values($table->getGraphicalObjectLock()->getAspectRatioLocked()) ? "true" : "false") . PHP_EOL;
$presentation->save("pres-out.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **FAQ**
**Can I enable right-to-left (RTL) reading direction for an entire table and the text in its cells?**
Yes. The table exposes a [setRightToLeft](https://reference.aspose.com/slides/php-java/aspose.slides/table/setrighttoleft/) method, and paragraphs have [ParagraphFormat::setRightToLeft](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/setrighttoleft/). Using both ensures the correct RTL order and rendering inside cells.
**How can I prevent users from moving or resizing a table in the final file?**
Use [shape locks](https://reference.aspose.com/slides/php-java/aspose.slides/graphicalobjectlock/) to disable moving, resizing, selection, etc. These locks apply to tables as well.
**Is inserting an image inside a cell as a background supported?**
Yes. You can set a [picture fill](https://reference.aspose.com/slides/php-java/aspose.slides/picturefillformat/) for a cell; the image will cover the cell area according to the chosen mode (stretch or tile).
## Related articles
- [Manage Rows and Columns in PowerPoint Tables Using PHP](https://docs.aspose.com/slides/php-java/manage-rows-and-columns/)
- [Manage Table Cells in Presentations Using PHP](https://docs.aspose.com/slides/php-java/manage-cells/)
- [Create and Customize PowerPoint Tables in PHP](https://docs.aspose.com/slides/php-java/powerpoint-table/)
# Manage Presentation Text in PHP
> Learn to manage text in Aspose.Slides for PHP: edit placeholders, fonts, paragraphs, bullets, and more with clear code examples for PPT, PPTX, and ODP.
Source: https://docs.aspose.com/slides/php-java/manage-text/
Updated: 2025-11-30
---
lastmod: 2025-11-30T13:47:17+04:00
title: Manage Presentation Text in PHP
linktitle: Manage Text
type: docs
weight: 50
url: /php-java/manage-text/
keywords:
- text
- placeholder
- text box
- autofit
- paragraph
- format text
- animate text
- bulleted list
- numbered list
- superscript
- subscript
- text extration
- localization
- WordArt
- PowerPoint
- OpenDocument
- presentation
- PHP
- Aspose.Slides
description: "Learn to manage text in Aspose.Slides for PHP: edit placeholders, fonts, paragraphs, bullets, and more with clear code examples for PPT, PPTX, and ODP."
---
## Related articles
- [Manage Bulleted and Numbered Lists in Presentations Using PHP](https://docs.aspose.com/slides/php-java/manage-lists/)
- [Manage Superscript and Subscript in Presentations Using PHP](https://docs.aspose.com/slides/php-java/superscript-and-subscript/)
# Manage Text Boxes in Presentations Using PHP
> Create, identify, format, and update text boxes in PowerPoint and OpenDocument presentations using Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/manage-textbox/
Updated: 2026-09-03
## **Introduction**
In Aspose.Slides for PHP via Java, slide text is stored in text frames that belong to shapes. The [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/) class represents the most common text-bearing shape and exposes its text through the [AutoShape::getTextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/#getTextFrame) method.
Every auto shape derives from [Shape](https://reference.aspose.com/slides/php-java/aspose.slides/shape/), but not every shape is an auto shape or supports a text frame. When processing an existing presentation, use `java_instanceof` to check that a shape is an [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/) before accessing its text.
## **Create a Text Box on a Slide**
To create a text box, add an auto shape to a slide, add text to its text frame, and save the presentation. The following example creates a rectangular text box:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$textBox = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 150, 75, 300, 50);
$textBox->addTextFrame("Aspose TextBox");
$presentation->save("TextBox.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The coordinates and dimensions passed to [ShapeCollection::addAutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/#addAutoShape) are measured in points. [AutoShape::addTextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/#addTextFrame) initializes the text frame with the supplied text.
## **Check for a Text Box Shape**
Use the [AutoShape::isTextBox](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/#isTextBox) method to determine whether an auto shape is treated as a text box. This is useful when a presentation contains both text-bearing and purely graphical auto shapes.

The following example inspects every auto shape in a presentation:
```php
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$textBox = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 10, 10, 120, 40);
$textBox->addTextFrame("Text box");
$slide->getShapes()->addAutoShape(ShapeType::Ellipse, 150, 10, 40, 40);
$autoShapeClass = new JavaClass("com.aspose.slides.AutoShape");
for ($slideIndex = 0; $slideIndex < java_values($presentation->getSlides()->size()); $slideIndex++) {
$currentSlide = $presentation->getSlides()->get_Item($slideIndex);
for ($shapeIndex = 0; $shapeIndex < java_values($currentSlide->getShapes()->size()); $shapeIndex++) {
$shape = $currentSlide->getShapes()->get_Item($shapeIndex);
if (java_instanceof($shape, $autoShapeClass)) {
echo (java_is_true($shape->isTextBox()) ? "The shape is a text box." : "The shape is not a text box.") . PHP_EOL;
}
}
}
} finally {
$presentation->dispose();
}
```
A newly added auto shape is not considered a text box until it contains non-empty text. You can supply that text through [AutoShape::addTextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/#addTextFrame) or [TextFrame::setText](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#setText). Adding or assigning an empty string leaves [AutoShape::isTextBox](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/#isTextBox) returning `false`:
```php
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape1 = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 10, 10, 100, 40);
$shape1->addTextFrame("Shape 1");
echo (java_is_true($shape1->isTextBox()) ? "true" : "false") . PHP_EOL;
$shape2 = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 10, 70, 100, 40);
$shape2->getTextFrame()->setText("Shape 2");
echo (java_is_true($shape2->isTextBox()) ? "true" : "false") . PHP_EOL;
$shape3 = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 10, 130, 100, 40);
$shape3->addTextFrame("");
echo (java_is_true($shape3->isTextBox()) ? "true" : "false") . PHP_EOL;
$shape4 = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 10, 190, 100, 40);
$shape4->getTextFrame()->setText("");
echo (java_is_true($shape4->isTextBox()) ? "true" : "false") . PHP_EOL;
} finally {
$presentation->dispose();
}
```
The first two calls print `true`; the last two print `false`.
## **Find the Shape That Owns a Text Frame**
Generic text-processing code may receive a [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/) without knowing which presentation object contains it. Use the read-only [TextFrame::getParentShape](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#getParentShape) method to navigate back to its owning [Shape](https://reference.aspose.com/slides/php-java/aspose.slides/shape/).
For a text frame owned by an auto shape or another text-bearing shape, [TextFrame::getParentShape](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#getParentShape) returns the owner and [TextFrame::getParentCell](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#getParentCell) returns `null`. Check the returned value with `java_is_null` before accessing it. To identify both shape and table-cell owners, including shapes associated with SmartArt nodes, see [Search and Replace Text](https://docs.aspose.com/slides/php-java/search-and-replace-text/).
## **Add Columns to a Text Box**
The [TextFrameFormat::setColumnCount](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#setColumnCount) method divides the text frame into columns, while [TextFrameFormat::setColumnSpacing](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#setColumnSpacing) sets the gap between columns in points. Both settings belong to [TextFrameFormat](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/) and can be changed through the text frame of an existing text box. Text reflows between columns inside the same shape; it does not continue into another shape.
The following example creates a three-column text box with 10 points between columns, saves the presentation, and reads the stored settings back from the output file:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$textBox = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 300, 200);
$textBox->addTextFrame("This text is distributed automatically across all columns in the text box.");
$textFrameFormat = $textBox->getTextFrame()->getTextFrameFormat();
$textFrameFormat->setColumnCount(3);
$textFrameFormat->setColumnSpacing(10);
$presentation->save("TextBoxColumns.pptx", SaveFormat::Pptx);
$savedPresentation = new Presentation("TextBoxColumns.pptx");
try {
$savedTextBox = $savedPresentation->getSlides()->get_Item(0)->getShapes()->get_Item(0);
$savedFormat = $savedTextBox->getTextFrame()->getTextFrameFormat();
echo "Columns: " . java_values($savedFormat->getColumnCount()) . "; spacing: " . java_values($savedFormat->getColumnSpacing()) . " points" . PHP_EOL;
} finally {
$savedPresentation->dispose();
}
} finally {
$presentation->dispose();
}
```
## **Extract Text from Individual Columns**
Use [TextFrame::splitTextByColumns](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#splitTextByColumns) to retrieve the text assigned to each visual column in an existing text frame. The method returns one string for each column, in column-based reading order. A single-column text frame produces an array with one element, and an empty column is represented by an empty string. The strings contain plain text only; portion-level formatting is not preserved.
This is useful when you need to:
- Extract text while preserving its column-based reading order.
- Index or compare the content of multi-column slides.
- Export each column to a separate file, database field, or other destination.
- Inspect how text is redistributed after changing the column count with [TextFrameFormat::setColumnCount](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#setColumnCount), the spacing with [TextFrameFormat::setColumnSpacing](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#setColumnSpacing), the font, or the text-frame size.
The method reports the text distributed within the current [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/); it does not automatically flow text between separate shapes or text boxes. Column distribution can depend on available fonts and other text-layout settings, so make sure that the required fonts are available when consistent results are important.
The following example loads a presentation, finds the first multi-column auto shape with a text frame, reads its configured column count, and writes the text from every column to a separate file. Shapes that do not provide a text frame are skipped.
```php
use aspose\slides\Presentation;
$presentation = new Presentation("MultiColumnText.pptx");
try {
$textBox = null;
$autoShapeClass = new JavaClass("com.aspose.slides.AutoShape");
$shapes = $presentation->getSlides()->get_Item(0)->getShapes();
for ($shapeIndex = 0; $shapeIndex < java_values($shapes->size()); $shapeIndex++) {
$shape = $shapes->get_Item($shapeIndex);
if (java_instanceof($shape, $autoShapeClass)) {
$textFrame = $shape->getTextFrame();
if (!java_is_null($textFrame)) {
$columnCount = java_values($textFrame->getTextFrameFormat()->getColumnCount());
if ($columnCount > 1) {
$textBox = $shape;
break;
}
}
}
}
if ($textBox === null) {
echo "No multi-column text frame was found." . PHP_EOL;
} else {
$textFrame = $textBox->getTextFrame();
$configuredColumnCount = java_values($textFrame->getTextFrameFormat()->getColumnCount());
$columnTexts = java_values($textFrame->splitTextByColumns());
echo "Configured columns: " . $configuredColumnCount . PHP_EOL;
foreach ($columnTexts as $columnIndex => $columnText) {
$columnNumber = $columnIndex + 1;
echo "Column " . $columnNumber . ": " . $columnText . PHP_EOL;
$outputPath = "Column-" . $columnNumber . ".txt";
$bytesWritten = file_put_contents($outputPath, $columnText);
if ($bytesWritten === false) {
echo "Could not write column " . $columnNumber . " to " . $outputPath . PHP_EOL;
}
}
}
} finally {
$presentation->dispose();
}
```
## **Update Text**
To update text throughout a presentation, iterate through the slides and shapes, select auto shapes, and then edit their text portions. Working at the portion level lets you change both text and character formatting.
The following example replaces every occurrence of `years` with `months` in auto-shape text and makes each affected portion bold:
```php
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("Text.pptx");
try {
$autoShapeClass = new JavaClass("com.aspose.slides.AutoShape");
for ($slideIndex = 0; $slideIndex < java_values($presentation->getSlides()->size()); $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
for ($shapeIndex = 0; $shapeIndex < java_values($slide->getShapes()->size()); $shapeIndex++) {
$shape = $slide->getShapes()->get_Item($shapeIndex);
if (!java_instanceof($shape, $autoShapeClass)) {
continue;
}
$textFrame = $shape->getTextFrame();
if (java_is_null($textFrame)) {
continue;
}
for ($paragraphIndex = 0; $paragraphIndex < java_values($textFrame->getParagraphs()->getCount()); $paragraphIndex++) {
$paragraph = $textFrame->getParagraphs()->get_Item($paragraphIndex);
for ($portionIndex = 0; $portionIndex < java_values($paragraph->getPortions()->getCount()); $portionIndex++) {
$portion = $paragraph->getPortions()->get_Item($portionIndex);
$text = java_values($portion->getText());
if ($text !== null && strpos($text, "years") !== false) {
$updatedText = str_replace("years", "months", $text);
$portion->setText($updatedText);
$portion->getPortionFormat()->setFontBold(NullableBool::True);
}
}
}
}
}
$presentation->save("TextChanged.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
This traversal updates text only in auto shapes. Text stored in tables, charts, SmartArt, or grouped shapes requires traversal of those objects' own collections.
## **Add a Text Box with a Hyperlink**
A hyperlink can be assigned to a specific text portion, so only that text acts as the clickable link. Use [HyperlinkManager::setExternalHyperlinkClick](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlinkmanager/#setExternalHyperlinkClick) to associate the portion with an external URL.
The following example creates linked text and saves it to a presentation:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$textBox = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 150, 150, 200, 50);
$textBox->addTextFrame("Aspose.Slides");
$textPortion = $textBox->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
$textPortion->getPortionFormat()->getHyperlinkManager()->setExternalHyperlinkClick("https://www.aspose.com/");
$presentation->save("Hyperlink.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **FAQ**
**What is the difference between a text box and a text placeholder on a master or layout slide?**
A [placeholder](https://docs.aspose.com/slides/php-java/manage-placeholder/) can inherit its position and formatting from a [master slide](https://reference.aspose.com/slides/php-java/aspose.slides/masterslide/) or [layout slide](https://reference.aspose.com/slides/php-java/aspose.slides/layoutslide/). A regular text box is an independent shape on the slide where it was created and does not acquire placeholder behavior when the layout changes.
**How can I replace text without changing text in charts, tables, or SmartArt?**
Limit the traversal to [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/) objects, as shown in the Update Text example. Charts, tables, and SmartArt store text in their own object models, so they are not modified by that loop.
# Manage Presentation Zoom in PHP
> Create and customize Zoom with Aspose.Slides for PHP via Java — jump between sections, add thumbnails and transitions in PowerPoint presentations.
Source: https://docs.aspose.com/slides/php-java/manage-zoom/
Updated: 2026-11-10
## **Introduction**
PowerPoint zooms let you navigate between specific slides and sections during a slide show. With Aspose.Slides for PHP via Java, you can create slide, section, and summary zooms and customize their previews, borders, and transitions.

* To summarize an entire presentation on a single slide, use a [Summary Zoom](https://docs.aspose.com/slides/php-java/manage-zoom/#summary-zoom).
* To show selected slides only, use a [Slide Zoom](https://docs.aspose.com/slides/php-java/manage-zoom/#slide-zoom).
* To show a single section only, use a [Section Zoom](https://docs.aspose.com/slides/php-java/manage-zoom/#section-zoom).
## **Slide Zoom**
A slide zoom can make your presentation more dynamic, allowing you to navigate freely between slides in any order you choose without interrupting the flow of your presentation. Slide zooms are great for short presentations without many sections, but you can still use them in different presentation scenarios.
Slide zooms let you explore related information from a single overview slide.

For slide zoom objects, Aspose.Slides provides the [ZoomImageType](https://reference.aspose.com/slides/php-java/aspose.slides/zoomimagetype/) enumeration, the [ZoomFrame](https://reference.aspose.com/slides/php-java/aspose.slides/zoomframe/) class, and methods on the [ShapeCollection](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/) class.
### **Create Zoom Frames**
Use [ShapeCollection::addZoomFrame](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/#addZoomFrame) to place links to individual slides on an overview slide. This example creates two target slides with distinct backgrounds and labels, then adds a preview of each to the first slide and saves the presentation as PPTX. Frame positions and dimensions are specified in points.
```php
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$overviewSlide = $presentation->getSlides()->get_Item(0);
$secondSlide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$thirdSlide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$secondSlide->getBackground()->setType(BackgroundType::OwnBackground);
$secondSlide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$secondSlide->getBackground()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->CYAN);
$textBox = $secondSlide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 200, 500, 200);
$textBox->getTextFrame()->setText("Second Slide");
$thirdSlide->getBackground()->setType(BackgroundType::OwnBackground);
$thirdSlide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 189, 183, 107);
$thirdSlide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$textBox = $thirdSlide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 200, 500, 200);
$textBox->getTextFrame()->setText("Third Slide");
$overviewSlide->getShapes()->addZoomFrame(20, 20, 250, 200, $secondSlide);
$overviewSlide->getShapes()->addZoomFrame(200, 250, 250, 200, $thirdSlide);
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Create Zoom Frames with Custom Images**
Pass a custom image to [ShapeCollection::addZoomFrame](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/#addZoomFrame) to replace the target slide's default preview. This example requires a local image, loads it with [Images::fromFile](https://reference.aspose.com/slides/php-java/aspose.slides/images/#fromFile), and adds it to the presentation using [ImageCollection::addImage](https://reference.aspose.com/slides/php-java/aspose.slides/imagecollection/#addImage). The resulting frame displays that image while still linking to the second slide.
```php
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\Images;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$overviewSlide = $presentation->getSlides()->get_Item(0);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->CYAN);
$textBox = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 200, 500, 200);
$textBox->getTextFrame()->setText("Second Slide");
$image = Images::fromFile("image.png");
try {
$previewImage = $presentation->getImages()->addImage($image);
} finally {
$image->dispose();
}
$overviewSlide->getShapes()->addZoomFrame(20, 20, 300, 200, $slide, $previewImage);
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Format Zoom Frames**
This example customizes two slide zoom frames. It assigns a local image to the first frame through [ZoomObject::setZoomImage](https://reference.aspose.com/slides/php-java/aspose.slides/zoomobject/#setZoomImage), and gives the second frame a five-point, dash-dot pink border through [Shape::getLineFormat](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#getLineFormat). Passing `false` to [ZoomObject::setShowBackground](https://reference.aspose.com/slides/php-java/aspose.slides/zoomobject/#setShowBackground) hides the second frame's background. A local image is required for the custom preview; both frames retain their slide targets in the saved PPTX.
```php
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\Images;
use aspose\slides\LineDashStyle;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$overviewSlide = $presentation->getSlides()->get_Item(0);
$secondSlide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$thirdSlide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$secondSlide->getBackground()->setType(BackgroundType::OwnBackground);
$secondSlide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$secondSlide->getBackground()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->CYAN);
$textBox = $secondSlide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 200, 500, 200);
$textBox->getTextFrame()->setText("Second Slide");
$thirdSlide->getBackground()->setType(BackgroundType::OwnBackground);
$thirdSlide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 189, 183, 107);
$thirdSlide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$textBox = $thirdSlide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 200, 500, 200);
$textBox->getTextFrame()->setText("Third Slide");
$firstZoomFrame = $overviewSlide->getShapes()->addZoomFrame(20, 20, 250, 200, $secondSlide);
$secondZoomFrame = $overviewSlide->getShapes()->addZoomFrame(200, 250, 250, 200, $thirdSlide);
$image = Images::fromFile("image.png");
try {
$previewImage = $presentation->getImages()->addImage($image);
} finally {
$image->dispose();
}
$firstZoomFrame->setZoomImage($previewImage);
$secondZoomFrame->getLineFormat()->setWidth(5);
$secondZoomFrame->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 255, 105, 180);
$secondZoomFrame->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor($color);
$secondZoomFrame->getLineFormat()->setDashStyle(LineDashStyle::DashDot);
$secondZoomFrame->setShowBackground(false);
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Section Zoom**
A section zoom links to a section in your presentation. Use it to revisit a topic or show how different parts of the presentation connect.

For section zoom objects, Aspose.Slides provides the [SectionZoomFrame](https://reference.aspose.com/slides/php-java/aspose.slides/sectionzoomframe/) class and methods on the [ShapeCollection](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/) class.
### **Create Section Zoom Frames**
Create a section with [SectionCollection::addSection](https://reference.aspose.com/slides/php-java/aspose.slides/sectioncollection/#addSection), then pass the returned section to [ShapeCollection::addSectionZoomFrame](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/#addSectionZoomFrame). This example places a section zoom on the first slide and links it to a section beginning with a colored slide. The frame's position and dimensions are specified in points, and the presentation is saved as PPTX.
```php
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$overviewSlide = $presentation->getSlides()->get_Item(0);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 154, 205, 50);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$section = $presentation->getSections()->addSection("Section 1", $slide);
$sectionZoomFrame = $overviewSlide->getShapes()->addSectionZoomFrame(20, 20, 300, 200, $section);
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Create Section Zoom Frames with Custom Images**
The image overload of [ShapeCollection::addSectionZoomFrame](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/#addSectionZoomFrame) lets you display a custom preview without changing the destination section. This example requires a local image, which is loaded with [Images::fromFile](https://reference.aspose.com/slides/php-java/aspose.slides/images/#fromFile) and added through [ImageCollection::addImage](https://reference.aspose.com/slides/php-java/aspose.slides/imagecollection/#addImage). The saved presentation contains a section zoom on the first slide linked to the newly created section.
```php
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\Images;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$overviewSlide = $presentation->getSlides()->get_Item(0);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 154, 205, 50);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$image = Images::fromFile("image.png");
try {
$previewImage = $presentation->getImages()->addImage($image);
} finally {
$image->dispose();
}
$section = $presentation->getSections()->addSection("Section 1", $slide);
$sectionZoomFrame = $overviewSlide->getShapes()->addSectionZoomFrame(20, 20, 300, 200, $section, $previewImage);
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Change a Section Zoom's Target Section**
Use [SectionZoomFrame::setTargetSection](https://reference.aspose.com/slides/php-java/aspose.slides/sectionzoomframe/#setTargetSection) to redirect an existing section zoom without recreating it. Choose a populated section from the same presentation's [Presentation::getSections](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getSections) collection. Assigning an empty section leaves the current target unchanged, so check [Section::getSlidesListOfSection](https://reference.aspose.com/slides/php-java/aspose.slides/section/#getSlidesListOfSection) before assigning it. See [Manage Slide Sections](https://docs.aspose.com/slides/php-java/slide-section/) for more about sections.
The following example loads a presentation file, which must contain multiple populated sections, an existing section zoom named `Section navigation`, and a section with the unique name `Results`. It searches all slides for the zoom and finds the destination by name rather than by a collection index that can change when sections are reordered. If names are not unique, use [Section::getSectionId](https://reference.aspose.com/slides/php-java/aspose.slides/section/#getSectionId) to identify the destination instead.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("section-zoom.pptx");
try {
$zoom = null;
$slideCount = java_values($presentation->getSlides()->size());
for ($i = 0; $i < $slideCount; $i++) {
$slide = $presentation->getSlides()->get_Item($i);
$shapeCount = java_values($slide->getShapes()->size());
for ($j = 0; $j < $shapeCount; $j++) {
$shape = $slide->getShapes()->get_Item($j);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.ISectionZoomFrame")) && java_values($shape->getName()) === "Section navigation") {
$zoom = $shape;
break;
}
}
if ($zoom != null) {
break;
}
}
$targetSection = null;
$sectionCount = java_values($presentation->getSections()->size());
for ($i = 0; $i < $sectionCount; $i++) {
$section = $presentation->getSections()->get_Item($i);
if (java_values($section->getName()) === "Results") {
$targetSection = $section;
break;
}
}
if ($zoom == null || $targetSection == null) {
echo "The section zoom or destination section was not found.", PHP_EOL;
} else if (java_values($targetSection->getSlidesListOfSection()->size()) == 0) {
echo "The destination section is empty.", PHP_EOL;
} else {
$currentSection = $zoom->getTargetSection();
echo "Current section: " . (java_is_null($currentSection) ? "" : java_values($currentSection->getName())), PHP_EOL;
$zoom->setTargetSection($targetSection);
$presentation->save("section-zoom-updated.pptx", SaveFormat::Pptx);
}
} finally {
$presentation->dispose();
}
```
### **Format Section Zoom Frames**
This example moves and resizes a section zoom to 100 by 75 points, assigns a local image through [ZoomObject::setZoomImage](https://reference.aspose.com/slides/php-java/aspose.slides/zoomobject/#setZoomImage), and applies a 2.5-point, dash-dot brown border. It enables [ZoomObject::setReturnToParent](https://reference.aspose.com/slides/php-java/aspose.slides/zoomobject/#setReturnToParent) to return to the originating slide after the section, disables [ZoomObject::setShowBackground](https://reference.aspose.com/slides/php-java/aspose.slides/zoomobject/#setShowBackground), and sets [ZoomObject::setTransitionDuration](https://reference.aspose.com/slides/php-java/aspose.slides/zoomobject/#setTransitionDuration) to 1.5 seconds. A local image is required for the custom preview.
```php
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\Images;
use aspose\slides\LineDashStyle;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$overviewSlide = $presentation->getSlides()->get_Item(0);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 154, 205, 50);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$section = $presentation->getSections()->addSection("Section 1", $slide);
$sectionZoomFrame = $overviewSlide->getShapes()->addSectionZoomFrame(20, 20, 300, 200, $section);
$sectionZoomFrame->setX(100);
$sectionZoomFrame->setY(300);
$sectionZoomFrame->setWidth(100);
$sectionZoomFrame->setHeight(75);
$image = Images::fromFile("image.png");
try {
$previewImage = $presentation->getImages()->addImage($image);
} finally {
$image->dispose();
}
$sectionZoomFrame->setZoomImage($previewImage);
$sectionZoomFrame->setReturnToParent(true);
$sectionZoomFrame->setShowBackground(false);
$sectionZoomFrame->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 165, 42, 42);
$sectionZoomFrame->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor($color);
$sectionZoomFrame->getLineFormat()->setDashStyle(LineDashStyle::DashDot);
$sectionZoomFrame->getLineFormat()->setWidth(2.5);
$sectionZoomFrame->setTransitionDuration(1.5);
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Summary Zoom**
A summary zoom provides an overview of presentation sections. During a slide show, you can use it to jump to a section, skip ahead, or revisit a topic without following the slide order.

For summary zoom objects, Aspose.Slides provides the [SummaryZoomFrame](https://reference.aspose.com/slides/php-java/aspose.slides/summaryzoomframe/), [SummaryZoomSection](https://reference.aspose.com/slides/php-java/aspose.slides/summaryzoomsection/), and [SummaryZoomSectionCollection](https://reference.aspose.com/slides/php-java/aspose.slides/summaryzoomsectioncollection/) classes and methods on the [ShapeCollection](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/) class.
### **Create a Summary Zoom**
Use [ShapeCollection::addSummaryZoomFrame](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/#addSummaryZoomFrame) to create an overview of the presentation's sections. This example creates four sections with distinct slide backgrounds and adds a summary zoom to the first slide. The frame's position and dimensions are specified in points, and the resulting overview is saved in a PPTX presentation.
```php
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$overviewSlide = $presentation->getSlides()->get_Item(0);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 165, 42, 42);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$presentation->getSections()->addSection("Section 1", $slide);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->CYAN);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$presentation->getSections()->addSection("Section 2", $slide);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 127, 255, 0);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$presentation->getSections()->addSection("Section 3", $slide);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 0, 100, 0);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$presentation->getSections()->addSection("Section 4", $slide);
$summaryZoomFrame = $overviewSlide->getShapes()->addSummaryZoomFrame(150, 50, 300, 200);
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Add and Remove a Summary Zoom Section**
A summary zoom stores its [SummaryZoomSection](https://reference.aspose.com/slides/php-java/aspose.slides/summaryzoomsection/) objects in [SummaryZoomFrame::getSummaryZoomCollection](https://reference.aspose.com/slides/php-java/aspose.slides/summaryzoomframe/#getSummaryZoomCollection). This example creates an overview of two sections, adds a third section using [SummaryZoomSectionCollection::addSummaryZoomSection](https://reference.aspose.com/slides/php-java/aspose.slides/summaryzoomsectioncollection/#addSummaryZoomSection), and removes the first section's entry using [SummaryZoomSectionCollection::removeSummaryZoomSection](https://reference.aspose.com/slides/php-java/aspose.slides/summaryzoomsectioncollection/#removeSummaryZoomSection). Removing the entry leaves the presentation section and its slides intact.
```php
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$overviewSlide = $presentation->getSlides()->get_Item(0);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 165, 42, 42);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$firstSection = $presentation->getSections()->addSection("Section 1", $slide);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->CYAN);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$presentation->getSections()->addSection("Section 2", $slide);
$summaryZoomFrame = $overviewSlide->getShapes()->addSummaryZoomFrame(150, 50, 300, 200);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 127, 255, 0);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$thirdSection = $presentation->getSections()->addSection("Section 3", $slide);
$summaryZoomFrame->getSummaryZoomCollection()->addSummaryZoomSection($thirdSection);
$summaryZoomFrame->getSummaryZoomCollection()->removeSummaryZoomSection($firstSection);
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Format Summary Zoom Sections**
This example formats the first entry in [SummaryZoomFrame::getSummaryZoomCollection](https://reference.aspose.com/slides/php-java/aspose.slides/summaryzoomframe/#getSummaryZoomCollection), using the zero-based index `0`. It requires a local image for [ZoomObject::setZoomImage](https://reference.aspose.com/slides/php-java/aspose.slides/zoomobject/#setZoomImage), applies a 1.5-point, dash-dot black border, and sets [ZoomObject::setTransitionDuration](https://reference.aspose.com/slides/php-java/aspose.slides/zoomobject/#setTransitionDuration) to 1.5 seconds. Passing `false` to [ZoomObject::setReturnToParent](https://reference.aspose.com/slides/php-java/aspose.slides/zoomobject/#setReturnToParent) disables the automatic return to the summary slide for this entry.
```php
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\Images;
use aspose\slides\LineDashStyle;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$overviewSlide = $presentation->getSlides()->get_Item(0);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 165, 42, 42);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$presentation->getSections()->addSection("Section 1", $slide);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->CYAN);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$presentation->getSections()->addSection("Section 2", $slide);
$summaryZoomFrame = $overviewSlide->getShapes()->addSummaryZoomFrame(150, 50, 300, 200);
$summarySection = $summaryZoomFrame->getSummaryZoomCollection()->get_Item(0);
$image = Images::fromFile("image.png");
try {
$previewImage = $presentation->getImages()->addImage($image);
} finally {
$image->dispose();
}
$summarySection->setZoomImage($previewImage);
$summarySection->setReturnToParent(false);
$summarySection->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$summarySection->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$summarySection->getLineFormat()->setDashStyle(LineDashStyle::DashDot);
$summarySection->getLineFormat()->setWidth(1.5);
$summarySection->setTransitionDuration(1.5);
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **FAQ**
**Can I control returning to the 'parent' slide after showing the target?**
Yes. Call [ZoomObject::setReturnToParent](https://reference.aspose.com/slides/php-java/aspose.slides/zoomobject/#setReturnToParent) with `true` to return to the originating slide after the target content is shown.
**Can I adjust the 'speed' or duration of the Zoom transition?**
Yes. Use [ZoomObject::setTransitionDuration](https://reference.aspose.com/slides/php-java/aspose.slides/zoomobject/#setTransitionDuration) to control the transition duration in seconds.
**Are there limits on how many Zoom objects a presentation can contain?**
There is no hard API limit documented. Practical limits depend on overall presentation complexity and the viewer's performance. You can add many Zoom frames, but consider file size and rendering time.
# Manage Tags and Custom Data in Presentations Using PHP
> Learn how to manage tags and custom XML data in PowerPoint presentations with Aspose.Slides for PHP via Java, including adding, reading, updating, auditing, and removing custom XML parts.
Source: https://docs.aspose.com/slides/php-java/managing-tags-and-custom-data/
Updated: 2026-08-13
## **Overview**
This article explains how Aspose.Slides works with tags and custom data in PowerPoint presentations. Presentation-specific data can be stored as tags or custom XML parts. Tags are simple key-value string pairs, while custom XML parts can store structured metadata and application-specific XML payloads.
Aspose.Slides provides APIs for adding, reading, updating, auditing, and removing custom XML parts at the presentation, slide, and shape levels. Custom XML parts are useful for integrations that store information such as document-management identifiers, workflow state, compliance metadata, template-binding data, or other structured application data inside a presentation.
## **Data Storage in Presentation Files**
PPTX files—files with the `.pptx` extension—are stored in the PresentationML format, which is part of the Office Open XML specification. Office Open XML defines the package structure and relationships used to store presentation content and related data.
A presentation contains multiple parts connected by relationships. For example, a slide part contains the content of a single slide and can have explicit relationships to other parts defined by ISO/IEC 29500.
Custom data can be stored as tags ([TagCollection](https://reference.aspose.com/slides/php-java/aspose.slides/tagcollection/)) or custom XML parts ([CustomXmlPartCollection](https://reference.aspose.com/slides/php-java/aspose.slides/customxmlpartcollection/)). Both are available through the [`CustomData`](https://reference.aspose.com/slides/php-java/aspose.slides/customdata/) class.
Tags store simple string key-value pairs. Custom XML parts store structured XML data and can be associated with a presentation, slide, or shape.
## **Work with Custom XML Parts**
The [`CustomData::getCustomXmlParts()`](https://reference.aspose.com/slides/php-java/aspose.slides/customdata/#getCustomXmlParts) method returns the collection of custom XML parts associated with a particular presentation object. For example:
- `$presentation->getCustomData()->getCustomXmlParts()` contains custom XML parts associated with the presentation itself.
- `$slide->getCustomData()->getCustomXmlParts()` contains custom XML parts associated with a specific slide.
- `$shape->getCustomData()->getCustomXmlParts()` contains custom XML parts associated with a specific shape.
Use [`Presentation::getAllCustomXmlParts()`](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getAllCustomXmlParts) when you need to inspect all custom XML parts in the presentation regardless of where they are associated.
### **Add a Custom XML Part to a Presentation**
Use [`CustomXmlPartCollection::add`](https://reference.aspose.com/slides/php-java/aspose.slides/customxmlpartcollection/#add) to add XML data to a custom XML part collection. The XML must be valid and non-empty.
The following example adds structured metadata to the presentation-level custom data collection:
```php
$customXmlContent =
'' .
'' .
'DOC-1001' .
'Draft' .
'';
$presentation = new Presentation();
try {
$customXmlPart = $presentation->getCustomData()->getCustomXmlParts()->add($customXmlContent);
// add assigns an identifier automatically. Set a specific UUID only when required.
$UUID = new JavaClass("java.util.UUID");
$customXmlPart->setItemId($UUID->randomUUID());
$presentation->save("presentation_with_custom_xml.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The `add` method can also accept XML as a byte array or input stream, which is useful when XML content is already available in binary form.
### **Add a Custom XML Part to a Slide or Shape**
Custom XML data can be associated with a specific slide or shape instead of the whole presentation. This is useful when metadata describes only one object, such as a template key, external record identifier, or binding information.
The following example adds one custom XML part to a slide and another to a shape:
```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$slide->getCustomData()->getCustomXmlParts()->add(
'' .
'TitleSlide' .
''
);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 250, 80);
$shape->getTextFrame()->setText("Customer data");
$shape->getCustomData()->getCustomXmlParts()->add(
'' .
'CRM-4281' .
''
);
$presentation->save("object_custom_xml.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The level at which a part is added determines which object's `getCustomData()->getCustomXmlParts()` collection contains the relationship to that part. Presentation-level data is appropriate for document-wide metadata, slide-level data for information that belongs to a particular slide, and shape-level data for metadata tied to an individual shape.
### **List and Audit All Custom XML Parts**
Use [`Presentation::getAllCustomXmlParts()`](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getAllCustomXmlParts) to retrieve all custom XML parts from a presentation. Each [`CustomXmlPart`](https://reference.aspose.com/slides/php-java/aspose.slides/customxmlpart/) exposes its identifier, XML content, and associated namespace schemas.
The following example lists all custom XML parts and their namespace schemas:
```php
$presentation = new Presentation("presentation.pptx");
try {
foreach ($presentation->getAllCustomXmlParts() as $customXmlPart) {
echo "ItemId: " . $customXmlPart->getItemId() . PHP_EOL;
echo "XML:" . PHP_EOL;
echo $customXmlPart->getXmlAsString() . PHP_EOL;
foreach ($customXmlPart->getNamespaceSchemas() as $namespaceSchema) {
echo "Namespace schema: " . $namespaceSchema . PHP_EOL;
}
echo PHP_EOL;
}
} finally {
$presentation->dispose();
}
```
[`CustomXmlPart::getNamespaceSchemas()`](https://reference.aspose.com/slides/php-java/aspose.slides/customxmlpart/#getNamespaceSchemas) returns the XML schemas associated with the custom XML part. This information can be useful when auditing presentations that contain XML produced by external systems.
### **Read and Update XML Content and ItemId**
Use [`CustomXmlPart::getXmlAsString()`](https://reference.aspose.com/slides/php-java/aspose.slides/customxmlpart/#getXmlAsString) and [`setXmlAsString()`](https://reference.aspose.com/slides/php-java/aspose.slides/customxmlpart/#setXmlAsString) to work with XML as a UTF-8 string, or [`getXmlData()`](https://reference.aspose.com/slides/php-java/aspose.slides/customxmlpart/#getXmlData) and [`setXmlData()`](https://reference.aspose.com/slides/php-java/aspose.slides/customxmlpart/#setXmlData) to work with the raw XML bytes.
The [`CustomXmlPart::getItemId()`](https://reference.aspose.com/slides/php-java/aspose.slides/customxmlpart/#getItemId) method returns the UUID that identifies the custom XML part in the Office Open XML document. Use [`setItemId()`](https://reference.aspose.com/slides/php-java/aspose.slides/customxmlpart/#setItemId) when an integration requires a new identifier.
The following example updates the XML content and the identifier:
```php
$presentation = new Presentation("presentation.pptx");
try {
$customXmlPart = $presentation->getAllCustomXmlParts()[0];
// Read the current XML as text.
$currentXmlContent = $customXmlPart->getXmlAsString();
echo $currentXmlContent . PHP_EOL;
// Update the XML as a UTF-8 string.
$customXmlPart->setXmlAsString(
'' .
'DOC-1001' .
'Approved' .
''
);
// getXmlData provides the same XML content as raw bytes.
$customXmlData = $customXmlPart->getXmlData();
// Replace the identifier when required by the integration.
$UUID = new JavaClass("java.util.UUID");
$customXmlPart->setItemId($UUID->randomUUID());
$presentation->save("updated_custom_xml.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
When calling `setXmlAsString` or `setXmlData`, provide valid, non-empty XML. Use one representation or the other depending on whether the application works primarily with strings or byte data.
### **Remove a Custom XML Part**
Aspose.Slides provides several ways to remove custom XML data:
- [`CustomXmlPart::remove`](https://reference.aspose.com/slides/php-java/aspose.slides/customxmlpart/#remove) removes the custom XML part from the presentation.
- [`CustomXmlPartCollection::remove`](https://reference.aspose.com/slides/php-java/aspose.slides/customxmlpartcollection/#remove) removes a specific part from a custom XML part collection.
- [`CustomXmlPartCollection::removeAt`](https://reference.aspose.com/slides/php-java/aspose.slides/customxmlpartcollection/#removeAt) removes the part at a specified collection index.
- [`CustomXmlPartCollection::clear`](https://reference.aspose.com/slides/php-java/aspose.slides/customxmlpartcollection/#clear) removes all parts from a specific collection.
The following example removes one presentation-level custom XML part by reference:
```php
$presentation = new Presentation("presentation.pptx");
try {
$customXmlParts = $presentation->getCustomData()->getCustomXmlParts();
if (java_values($customXmlParts->size()) > 0) {
$customXmlPart = $customXmlParts->get_Item(0);
$customXmlParts->remove($customXmlPart);
}
$presentation->save("custom_xml_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
If you already have a `CustomXmlPart` and want to remove that part from the presentation rather than addressing a particular collection, call `$customXmlPart->remove()`.
You can also remove an item by index:
```php
$presentation->getCustomData()->getCustomXmlParts()->removeAt(0);
```
### **Clear All Custom XML Parts from a Collection**
Use `clear` when all custom XML parts associated with a particular presentation object should be removed.
```php
$presentation = new Presentation("presentation.pptx");
try {
$presentation->getSlides()->get_Item(0)->getCustomData()->getCustomXmlParts()->clear();
$presentation->save("slide_custom_xml_cleared.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
`clear` affects only the selected collection. For example, clearing a slide's collection does not clear the presentation-level or shape-level collections.
To remove every custom XML part in the presentation, iterate through `getAllCustomXmlParts()` and remove each part:
```php
$presentation = new Presentation("presentation.pptx");
try {
foreach ($presentation->getAllCustomXmlParts() as $customXmlPart) {
$customXmlPart->remove();
}
$presentation->save("all_custom_xml_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Handle Linked or Shared Custom XML Parts**
In an Office Open XML presentation, the same custom XML part can be referenced from more than one presentation object. For example, an existing file can contain relationships from multiple slides or shapes to the same underlying custom XML part.
A shared part should be treated as one data object with multiple references:
- Updating it with `setXmlAsString`, `setXmlData`, or `setItemId` changes the underlying custom XML part, so the change applies wherever that part is referenced.
- `getItemId()` can be used to identify the same custom XML part while auditing object-level collections.
- Removing a part from a specific `getCustomXmlParts()` collection removes it from that collection. Use `CustomXmlPart::remove()` when the part itself should be removed from the presentation.
- Before deleting or replacing a shared part, inspect the object-level collections to determine whether other slides or shapes still reference it.
The `add` overloads create a new custom XML part from XML content; they do not accept an existing `CustomXmlPart`. Therefore, shared relationships are most commonly encountered when loading presentations that already contain them.
The following example audits presentation-, slide-, and shape-level collections by `ItemId` and reports parts referenced from more than one place:
```php
function registerCustomXmlParts($ownerName, $customXmlParts, &$referencesByItemId) {
$partCount = java_values($customXmlParts->size());
for ($i = 0; $i < $partCount; $i++) {
$customXmlPart = $customXmlParts->get_Item($i);
$itemId = java_values($customXmlPart->getItemId()->toString());
if (!isset($referencesByItemId[$itemId])) {
$referencesByItemId[$itemId] = [];
}
$referencesByItemId[$itemId][] = $ownerName;
}
}
$presentation = new Presentation("presentation.pptx");
try {
$referencesByItemId = [];
registerCustomXmlParts(
"Presentation",
$presentation->getCustomData()->getCustomXmlParts(),
$referencesByItemId
);
$slideCount = java_values($presentation->getSlides()->size());
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
registerCustomXmlParts(
"Slide " . ($slideIndex + 1),
$slide->getCustomData()->getCustomXmlParts(),
$referencesByItemId
);
$shapeCount = java_values($slide->getShapes()->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $slide->getShapes()->get_Item($shapeIndex);
registerCustomXmlParts(
"Slide " . ($slideIndex + 1) . ", shape " . $shapeIndex,
$shape->getCustomData()->getCustomXmlParts(),
$referencesByItemId
);
}
}
foreach ($referencesByItemId as $itemId => $owners) {
if (count($owners) > 1) {
echo "Shared custom XML part: " . $itemId . PHP_EOL;
foreach ($owners as $ownerName) {
echo " Referenced by: " . $ownerName . PHP_EOL;
}
}
}
} finally {
$presentation->dispose();
}
```
This type of audit is useful before modifying or deleting custom XML data in presentations created by external systems, because the same metadata part may participate in more than one relationship.
## **Get Values of Tags**
In slides, a tag corresponds to the `DocumentProperties::getKeywords()` method. This sample code shows how to get a tag value with Aspose.Slides for PHP via Java for [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/):
```php
$presentation = new Presentation("presentation.pptx");
try {
$keywords = $presentation->getDocumentProperties()->getKeywords();
} finally {
$presentation->dispose();
}
```
## **Add Tags to Presentations**
Aspose.Slides allows you to add tags to presentations. A tag typically consists of two items:
- the name of a custom property, for example, `MyTag`;
- the value of the custom property, for example, `My Tag Value`.
If you need to classify presentations based on a specific rule or property, you can add tags for that purpose. For example, if you want to categorize presentations from North American countries, you can create a North American tag and assign the relevant country as its value.
This sample code shows how to add a tag to a [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) using Aspose.Slides for PHP via Java:
```php
$presentation = new Presentation("presentation.pptx");
try {
$tags = $presentation->getCustomData()->getTags();
$tags->set_Item("MyTag", "My Tag Value");
} finally {
$presentation->dispose();
}
```
Tags can also be set for a [Slide](https://reference.aspose.com/slides/php-java/aspose.slides/slide/):
```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$slide->getCustomData()->getTags()->set_Item("tag", "value");
} finally {
$presentation->dispose();
}
```
Or for an individual [Shape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/):
```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 10, 10, 100, 50);
$shape->getTextFrame()->setText("My text");
$shape->getCustomData()->getTags()->set_Item("tag", "value");
} finally {
$presentation->dispose();
}
```
### **Limitations**
Tags added through the `getCustomData()->getTags()` collection are stored only in the PowerPoint file. They are **not** transferred to the PDF tag structure when the presentation is exported to PDF. Consequently, a custom identifier assigned as a tag cannot be retrieved from the tagged PDF.
**Workaround**: You can store a custom identifier in the object's **Alt Text** (for example, `$shape->setAlternativeText("MyId")`). After exporting to PDF, the Alt Text may appear in the PDF tag structure.
## **FAQ**
**Can I remove all tags from a presentation, slide, or shape in one operation?**
Yes. The [tag collection](https://reference.aspose.com/slides/php-java/aspose.slides/tagcollection/) supports a [clear](https://reference.aspose.com/slides/php-java/aspose.slides/tagcollection/#clear) operation that deletes all key-value pairs at once.
**How do I delete a single tag by its name without iterating over the whole collection?**
Use [remove(name)](https://reference.aspose.com/slides/php-java/aspose.slides/tagcollection/#remove) on the [tag collection](https://reference.aspose.com/slides/php-java/aspose.slides/tagcollection/) to delete the tag by its key.
**How can I retrieve the complete list of tag names for analytics or filtering?**
Use [getNamesOfTags](https://reference.aspose.com/slides/php-java/aspose.slides/tagcollection/#getNamesOfTags) on the [tag collection](https://reference.aspose.com/slides/php-java/aspose.slides/tagcollection/); it returns an array of all tag names.
**How can I find all custom XML parts regardless of where they are stored?**
Use [`Presentation::getAllCustomXmlParts()`](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getAllCustomXmlParts) to retrieve all custom XML parts in the presentation.
**Should I use `getXmlAsString`/`setXmlAsString` or `getXmlData`/`setXmlData` to update a custom XML part?**
Use `getXmlAsString` and `setXmlAsString` when the application works with UTF-8 XML text. Use `getXmlData` and `setXmlData` when the XML is already available as a byte array or when binary-oriented processing is more convenient. Both representations refer to the XML content of the same custom XML part.
# Efficiently Merge Presentations in PHP
> Learn how to merge PowerPoint and OpenDocument presentations in PHP by cloning slides, controlling masters and layouts, resizing slide content, preserving sections, and handling protected or large files.
Source: https://docs.aspose.com/slides/php-java/merge-presentation/
Updated: 2026-11-08
## **Overview**
Aspose.Slides for PHP via Java merges presentations by cloning slides from one [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) into another. The main operation is [SlideCollection::addClone()](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/addclone/), which can preserve the source slide's formatting or attach the cloned slide to a master or layout in the destination presentation.
This article covers the most common merging workflows:
- merge all slides while preserving their source formatting;
- merge selected slides;
- apply a master from the destination presentation;
- apply a specific layout from the destination presentation;
- normalize different slide sizes before merging;
- add cloned slides to a section;
- merge several presentations in one end-to-end workflow;
- handle masters, resources, notes, comments, media, fonts, passwords, large files, and multithreading concerns.
## **How Slide Cloning Affects Masters and Layouts**
A slide inherits much of its appearance from its layout and master. For that reason, the cloning overload you choose determines how the merged slide is integrated into the destination presentation.
Use [SlideCollection::addClone()](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/addclone/) in one of these ways:
- `addClone(sourceSlide)` — preserve the source slide's layout and formatting. When required, the source master can be cloned into the destination presentation automatically. Aspose.Slides tracks automatically cloned masters so repeated slides that use the same source master do not cause that master to be cloned repeatedly.
- `addClone(sourceSlide, destinationMaster, allowCloneMissingLayout)` — attach the cloned slide to a specific destination [MasterSlide](https://reference.aspose.com/slides/php-java/aspose.slides/masterslide/). Aspose.Slides looks for a matching layout under that master by layout type or name.
- `addClone(sourceSlide, destinationLayout)` — attach the cloned slide directly to a specific destination [LayoutSlide](https://reference.aspose.com/slides/php-java/aspose.slides/layoutslide/).
The master or layout passed to an `addClone` overload must belong to the **destination** presentation, not the source presentation.
[](https://docs.aspose.com/slides/php-java/merge-presentation/visual-merge-presentation-9d5f131d779a.svg)
*Illustrative .NET 26.11 fixture comparing source design, a selected destination master with a matching layout, and an explicit destination layout. The panel retains its explicit geometry and looks the same in this fixture. The selected master or layout must belong to the destination; changing inheritance does not redesign every object.*
## **Merge Entire Presentations and Preserve Source Formatting**
The simplest merge copies every slide from the source presentation to the destination presentation. This is the appropriate choice when the imported slides should keep their original theme, master, and layout relationships.
```php
require_once("Java.inc");
require_once("lib/aspose.slides.php");
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$destination = new Presentation("destination.pptx");
try {
$source = new Presentation("source.pptx");
try {
foreach ($source->getSlides() as $slide) {
$destination->getSlides()->addClone($slide);
}
} finally {
$source->dispose();
}
$destination->save("merged.pptx", SaveFormat::Pptx);
} finally {
$destination->dispose();
}
```
The resulting presentation may contain multiple masters when the source and destination use different designs. This is expected when source formatting is intentionally preserved.
## **Merge Selected Slides**
You do not have to clone every slide. The following example imports only selected slide indexes from the source presentation.
```php
require_once("Java.inc");
require_once("lib/aspose.slides.php");
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$destination = new Presentation("destination.pptx");
try {
$source = new Presentation("source.pptx");
try {
$slideIndexes = [0, 2, 4];
foreach ($slideIndexes as $index) {
$destination->getSlides()->addClone($source->getSlides()->get_Item($index));
}
} finally {
$source->dispose();
}
$destination->save("merged-selected-slides.pptx", SaveFormat::Pptx);
} finally {
$destination->dispose();
}
```
Validate slide indexes before cloning when they come from user input or external configuration.
## **Merge Slides Using a Destination Master**
Use the [addClone(Slide, MasterSlide, boolean)](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/addclone/) overload when imported slides should follow a master that already belongs to the destination presentation.
```php
require_once("Java.inc");
require_once("lib/aspose.slides.php");
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$destination = new Presentation("destination.pptx");
try {
$source = new Presentation("source.pptx");
try {
$destinationMaster = $destination->getMasters()->get_Item(0);
foreach ($source->getSlides() as $slide) {
$destination->getSlides()->addClone($slide, $destinationMaster, true);
}
} finally {
$source->dispose();
}
$destination->save("merged-with-destination-master.pptx", SaveFormat::Pptx);
} finally {
$destination->dispose();
}
```
Aspose.Slides selects an appropriate layout under the specified master by matching the source layout's type or name. If no suitable layout exists and `allowCloneMissingLayout` is `true`, the source layout is cloned so the slide can be added. If it is `false`, a [PptxEditException](https://reference.aspose.com/slides/php-java/aspose.slides/pptxeditexception/) is thrown.
Use `false` when you want the merge to fail instead of introducing an additional layout into the destination master.
## **Merge Slides Using a Specific Destination Layout**
Use the [addClone(Slide, LayoutSlide)](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/addclone/) overload when you know exactly which destination layout the imported slides should use.
```php
require_once("Java.inc");
require_once("lib/aspose.slides.php");
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$destination = new Presentation("destination.pptx");
try {
$source = new Presentation("source.pptx");
try {
$destinationLayout = $destination->getLayoutSlides()->get_Item(0);
foreach ($source->getSlides() as $slide) {
$destination->getSlides()->addClone($slide, $destinationLayout);
}
} finally {
$source->dispose();
}
$destination->save("merged-with-destination-layout.pptx", SaveFormat::Pptx);
} finally {
$destination->dispose();
}
```
Applying a destination layout changes the inherited layout relationship; it does not redesign the source slide content. If the source and destination layouts have different placeholder structures, inspect the result to confirm that the inherited formatting and placeholder behavior are appropriate.
## **Merge Presentations with Different Slide Sizes**
Presentations with different slide dimensions can be merged, but cloning a slide into a presentation with another slide size does not automatically redesign its content for the new canvas. Shapes may therefore appear shifted, scaled unexpectedly, or outside the visible slide area.
A practical approach is to resize the source presentation before cloning. The [SlideSize::setSize()](https://reference.aspose.com/slides/php-java/aspose.slides/slidesize/setsize/) method can scale existing content while changing the slide dimensions. [SlideSizeScaleType::EnsureFit](https://reference.aspose.com/slides/php-java/aspose.slides/slidesizescaletype/) scales content to fit within the requested size.
```php
require_once("Java.inc");
require_once("lib/aspose.slides.php");
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SlideSizeScaleType;
$destination = new Presentation("destination.pptx");
try {
$source = new Presentation("source.pptx");
try {
$sourceWidth = java_values($source->getSlideSize()->getSize()->getWidth());
$sourceHeight = java_values($source->getSlideSize()->getSize()->getHeight());
$destinationWidth = java_values($destination->getSlideSize()->getSize()->getWidth());
$destinationHeight = java_values($destination->getSlideSize()->getSize()->getHeight());
if ($sourceWidth != $destinationWidth || $sourceHeight != $destinationHeight) {
$source->getSlideSize()->setSize($destinationWidth, $destinationHeight, SlideSizeScaleType::EnsureFit);
}
foreach ($source->getSlides() as $slide) {
$destination->getSlides()->addClone($slide);
}
} finally {
$source->dispose();
}
$destination->save("merged-same-slide-size.pptx", SaveFormat::Pptx);
} finally {
$destination->dispose();
}
```
Resizing changes the source presentation object in memory. If you need the original source presentation unchanged for other operations, open a separate instance for the merge.
## **Merge Slides into a Presentation Section**
The basic slide-cloning loop does not recreate the source presentation's section hierarchy. If sections matter in the output, create or select sections in the destination presentation and clone slides into them explicitly with [addClone(Slide, Section)](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/addclone/).
```php
require_once("Java.inc");
require_once("lib/aspose.slides.php");
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$destination = new Presentation("destination.pptx");
try {
$source = new Presentation("source.pptx");
try {
$importedSection = $destination->getSections()->appendEmptySection("Imported slides");
foreach ($source->getSlides() as $slide) {
$destination->getSlides()->addClone($slide, $importedSection);
}
} finally {
$source->dispose();
}
$destination->save("merged-with-section.pptx", SaveFormat::Pptx);
} finally {
$destination->dispose();
}
```
The cloned slides are appended to the specified destination section. To preserve several source sections, enumerate [Presentation::getSections](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation/#getSections), retrieve each source section's current slides with [Section::getSlidesListOfSection](https://reference.aspose.com/slides/php-java/aspose.slides/Section/#getSlidesListOfSection), recreate the sections in the destination, and clone each returned slide into its corresponding destination section. See [Manage Slide Sections](https://docs.aspose.com/slides/php-java/slide-section/) for a complete section-enumeration example, including empty sections and structural changes.
## **Merge Multiple Presentations Safely**
The following end-to-end example uses the first presentation as the destination, normalizes the slide size of each additional source, keeps each source open only while it is being copied, and saves the final file once.
```php
require_once("Java.inc");
require_once("lib/aspose.slides.php");
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SlideSizeScaleType;
$inputFiles = ["part1.pptx", "part2.pptx", "part3.pptx"];
$merged = new Presentation($inputFiles[0]);
try {
$mergedWidth = java_values($merged->getSlideSize()->getSize()->getWidth());
$mergedHeight = java_values($merged->getSlideSize()->getSize()->getHeight());
for ($fileIndex = 1; $fileIndex < count($inputFiles); $fileIndex++) {
$source = new Presentation($inputFiles[$fileIndex]);
try {
$sourceWidth = java_values($source->getSlideSize()->getSize()->getWidth());
$sourceHeight = java_values($source->getSlideSize()->getSize()->getHeight());
if ($sourceWidth != $mergedWidth || $sourceHeight != $mergedHeight) {
$source->getSlideSize()->setSize($mergedWidth, $mergedHeight, SlideSizeScaleType::EnsureFit);
}
foreach ($source->getSlides() as $slide) {
$merged->getSlides()->addClone($slide);
}
} finally {
$source->dispose();
}
}
$merged->save("merged.pptx", SaveFormat::Pptx);
} finally {
$merged->dispose();
}
```
This is a useful baseline for preserving the source formatting of imported slides. If your output must use a single destination theme, replace the simple `addClone($slide)` call with the appropriate destination-master or destination-layout overload shown earlier.
## **Practical Considerations**
### **Masters, Layouts, and Formatting Fidelity**
Default slide cloning can automatically bring a required source master into the destination presentation. Aspose.Slides keeps an internal registry for automatically cloned masters to avoid cloning the same master repeatedly. Manually cloned masters are not tracked by that registry, so avoid pre-cloning masters unless you need explicit control over the master structure.
Do not assume that two masters or layouts with the same name are visually equivalent. If a corporate template must control the final appearance, choose a destination master or layout explicitly and verify the result after merging.
### **Notes and Comments**
Speaker notes and slide comments are associated with slide content and are copied when a slide is cloned. Aspose.Slides also exposes dedicated APIs for [presentation notes](https://docs.aspose.com/slides/php-java/presentation-notes/) and [presentation comments](https://docs.aspose.com/slides/php-java/presentation-comments/).
If notes-page formatting is important, verify the merged presentation because notes masters are presentation-level objects and may differ between source files. For review workflows, also verify comment authors and threaded comments after combining files from different authors or templates.
### **Images, Audio, Video, OLE Objects, and External Links**
Slides can reference presentation-level resources such as images, embedded audio, embedded video, and OLE data. Clone the slide itself rather than copying only its visible shapes so Aspose.Slides can maintain the slide's relationships to its resources.
Embedded and linked resources should be treated differently. A linked audio, video, OLE object, or hyperlink remains dependent on its external target; cloning a slide does not turn an external link into embedded content. Test linked-resource paths and URLs in the environment where the merged presentation will be opened.
Aspose.Slides explicitly tracks automatically cloned masters, but this should not be treated as a general guarantee that identical binary resources from unrelated source presentations will always be deduplicated. If output file size is important, inspect the merged package and measure the result instead of relying on implicit deduplication.
### **Embedded Fonts and Font Availability**
Fonts are managed at the presentation level. If typography must remain consistent across machines, do not assume that cloning slides alone guarantees that every required font is available in the destination environment. You can inspect embedded fonts with [FontsManager::getEmbeddedFonts()](https://reference.aspose.com/slides/php-java/aspose.slides/fontsmanager/getembeddedfonts/) and manage embedding explicitly as described in [Embed Fonts in Presentations](https://docs.aspose.com/slides/php-java/embedded-font/).
Also verify that you are permitted to embed the fonts used by the source files. Font licenses can restrict embedding.
### **Password-Protected Presentations**
A password-protected source must be opened successfully before its slides can be cloned. Supply the password through [LoadOptions::setPassword()](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/setpassword/).
```php
require_once("Java.inc");
require_once("lib/aspose.slides.php");
use aspose\slides\LoadOptions;
use aspose\slides\Presentation;
$loadOptions = new LoadOptions();
$loadOptions->setPassword("YOUR_PASSWORD");
$source = new Presentation("protected.pptx", $loadOptions);
try {
// Work with the decrypted presentation.
} finally {
$source->dispose();
}
```
Opening an encrypted source does not automatically apply the same protection to the destination presentation. Configure output protection separately when required.
### **Large Presentations and Memory Use**
Large presentations containing high-resolution images, audio, video, or other large binary objects can consume significant memory. [LoadOptions::getBlobManagementOptions()](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/getblobmanagementoptions/) provides controls for BLOB handling and temporary-file usage. See [Open Presentations](https://docs.aspose.com/slides/php-java/open-presentation/#open-large-presentations) for a PHP via Java large-file example.
For large files, prefer loading from file paths when possible, dispose each source presentation as soon as it has been merged, and avoid repeatedly saving intermediate results unless the workflow requires checkpoints.
### **Thread Safety**
Do not load, modify, save, or clone [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) instances in multiple threads. These operations are not supported for multithreaded use in PHP via Java. If you need parallel merge jobs, run them in separate single-threaded processes, with each process using its own presentation instances, and follow the [Aspose.Slides multithreading guidance](https://docs.aspose.com/slides/php-java/multithreading/).
## **FAQ**
**How do I keep each source presentation's original design?**
Use [SlideCollection::addClone](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/addclone/) without supplying a destination master or layout. Aspose.Slides can automatically clone the source master when it is needed by the imported slide.
**How do I make imported slides use the destination theme?**
Use the overload that accepts a destination master. Pass a master from the destination presentation, not from the source. Aspose.Slides will try to map each source slide to an appropriate layout under that master.
**When should I use a specific destination layout instead of a destination master?**
Use a specific layout when every imported slide should use one known layout. Use a master when you want Aspose.Slides to select among that master's layouts based on the source layout type or name.
**Can presentations with different slide sizes be merged?**
Yes, but slide content is not automatically redesigned for the destination dimensions. Resize the source presentation first when you need predictable placement, for example with [SlideSize::setSize()](https://reference.aspose.com/slides/php-java/aspose.slides/slidesize/setsize/) and [SlideSizeScaleType::EnsureFit](https://reference.aspose.com/slides/php-java/aspose.slides/slidesizescaletype/).
**Can I merge PPT, PPTX, and ODP presentations into one file?**
Yes. Load each source presentation, clone the required slides into one destination, and save the destination in a supported output format. Because presentation formats do not support exactly the same feature set, verify complex content after cross-format merges. See [Supported File Formats](https://docs.aspose.com/slides/php-java/supported-file-formats/).
**Are source sections preserved automatically?**
Not by a basic loop that only clones slides. Recreate the required sections in the destination and use the section overload of [addClone](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/addclone/) when section structure must be preserved.
**Are speaker notes and comments preserved?**
They are copied with the cloned slide. For workflows that depend on notes-master styling, comment authors, or threaded review data, verify the merged result because those scenarios involve presentation-level structures as well as slide-level content.
**What happens to audio, video, OLE objects, and hyperlinks?**
Embedded content is carried as part of the cloned slide's resource relationships. External links remain external, so their target files or URLs must still be available after the merge.
**Are embedded fonts from every source guaranteed to be available in the merged presentation?**
Do not rely on slide cloning alone for font deployment. Inspect the destination's embedded fonts and explicitly manage font embedding or external font availability when typography is important.
**How do I merge a password-protected file?**
Open it with the correct [LoadOptions::setPassword()](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/setpassword/), then clone its slides normally. Output protection is configured separately.
**How should I handle very large presentations?**
Use BLOB management when large binary objects dominate memory usage, prefer file-path loading for very large files, dispose source presentations promptly, and save the final result only when needed.
**Can I merge slides from multiple threads?**
Loading, saving, or cloning presentations in multiple threads is not supported in PHP via Java. For parallel work, use separate single-threaded processes and keep presentation instances isolated within each process.
# Metered Licensing
> Learn how Aspose.Slides for PHP via Java metered licensing lets you process PowerPoint and OpenDocument files flexibly, paying only for what you use.
Source: https://docs.aspose.com/slides/php-java/metered-licensing/
Updated: 2026-08-02
## **Introduction**
Metered licensing is a licensing mechanism that can be used alongside existing licensing methods. If you want to be billed based on your usage of Aspose.Slides API features, you choose metered licensing.
## **Apply Metered Keys**
When you purchase a metered license, you get keys (and not a license file). This metered key can be applied using the [Metered](https://reference.aspose.com/slides/php-java/aspose.slides/metered/) class Aspose provided for metering operations. For more details, see [Metered Licensing FAQ](https://purchase.aspose.com/faqs/licensing/metered).
1. Create an instance of the [Metered](https://reference.aspose.com/slides/php-java/aspose.slides/metered/) class.
1. Pass your public and private keys to the [setMeteredKey](https://reference.aspose.com/slides/php-java/aspose.slides/metered/#setMeteredKey-java.lang.String-java.lang.String-) method.
1. Do some processing (perform tasks).
1. Call the [getConsumptionQuantity](https://reference.aspose.com/slides/php-java/aspose.slides/metered/#getConsumptionQuantity--) method of the `Metered` class.
You should see the amount/quantity of API requests you have consumed so far.
This sample code shows you how to use metered licensing:
```php
// Creates an instance of the Metered class
$metered = new Metered();
try {
// Passes the public and private keys to the Metered object
$metered->setMeteredKey("", "");
// Gets the consumed quantity value before API calls
$amountBefore = Metered::getConsumptionQuantity();
echo("Amount consumed before: " . $amountBefore);
// Do something with Aspose.Slides API here
// ...
// Gets the consumed quantity value after API calls
$amountAfter = Metered::getConsumptionQuantity();
echo("Amount consumed after: " . $amountAfter);
} catch (JavaException $ex) {
$ex->printStackTrace();
}
```
To use metered licensing, you need a stable internet connection because the licensing mechanism uses the internet to constantly interact with our services and perform calculations.
## **FAQ**
### Can I use a metered license together with a regular one (perpetual or temporary) in the same application?
Yes. Metered is an additional licensing mechanism that can be used alongside existing [licensing methods](https://docs.aspose.com/slides/php-java/licensing/). You choose which mechanism to apply when the application starts.
### What exactly counts as consumption under a metered license: operations or files?
API usage is counted, meaning the number of requests or operations. You can obtain the current consumption via [consumption-tracking methods](https://reference.aspose.com/slides/php-java/aspose.slides/metered/).
### Is metered suitable for microservices and serverless environments where instances restart frequently?
Yes. Since accounting is done at the API-call level, scenarios with frequent cold starts are compatible, provided there is stable network access for metered calculations.
### Does the library’s functionality differ when using a metered license compared to a perpetual license?
No. This is only about the licensing and billing mechanism; the product’s capabilities are the same.
### How does metered relate to the trial version and the temporary license?
The trial version has limitations and watermarks, the [temporary license](https://purchase.aspose.com/temporary-license/) removes limitations for 30 days, and metered removes limitations and charges based on actual usage.
### Can I control the budget by automatically reacting when a consumption threshold is exceeded?
Yes. A common practice is to periodically read current consumption via [tracking methods](https://reference.aspose.com/slides/php-java/aspose.slides/metered/) and implement your own limits or alerts at the application or monitoring level.
# Microsoft PowerPoint (PPT)
>
Source: https://docs.aspose.com/slides/php-java/microsoft-powerpoint-ppt/
Updated: 2026-08-13
[PPT](https://en.wikipedia.org/wiki/Microsoft_PowerPoint) is the presentation document file format that can be created, read, manipulated and written by different versions of Microsoft PowerPoint. This is the binary format for presentation documents developed by Microsoft.
## **PPT in Aspose.Slides for PHP via Java**
Aspose.Slides for PHP via Java can read PPT files created by the software listed below.
- Microsoft PowerPoint 97
- Microsoft PowerPoint 2000
- Microsoft PowerPoint XP
- Microsoft PowerPoint 2003
Similarly, PPT files created by Aspose.Slides for PHP via Java can be read by the above set of software.
## **Comprehensive Support for PPT**
Aspose.Slides for PHP via Java provides support for almost all the features supported by the PPT document file format. It not only covers the basic and advanced features provided by different Microsoft PowerPoint versions for PPT document manipulations, but also features that are not even supported by Microsoft PowerPoint. The main advantage of using the Aspose.Slides for PHP via Java API library is the ease of use for handling such features.
In addition to the basic tasks related to creating, reading and writing PPT document files, there are several features that are provided by Aspose.Slides for PHP via Java:
- Import other Microsoft Office file formats as [OLE objects into PPT documents](https://docs.aspose.com/slides/php-java/manage-ole/).
- [Export PPT documents to PDF](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-pdf/).
- Export slides in the PPT documents to SVG formats.
- Render slides to any image format supported by the Java Framework.
- Set the size of slides in PPT documents.
- Manage animations on shapes.
- Manage slide shows.
- [Format text on slides](https://docs.aspose.com/slides/php-java/text-formatting/).
- Extract text from PPT documents.
- [Handle tables on slides](https://docs.aspose.com/slides/php-java/powerpoint-table/).
- Automatically copy masters using [the cloning feature](https://docs.aspose.com/slides/php-java/clone-slides/).
**A PPT file generated by Aspose.Slides for PHP via Java and opened in Microsoft PowerPoint**

## Related articles
- [PresentationML (PPTX, XML)](https://docs.aspose.com/slides/php-java/presentationml-pptx-xml/)
# Enhance Image Processing with the Modern API
> Modernize slide image processing by replacing deprecated imaging APIs with the PHP Modern API for seamless PowerPoint and OpenDocument automation.
Source: https://docs.aspose.com/slides/php-java/modern-api/
Updated: 2026-08-05
## **Introduction**
Historically, Aspose Slides has a dependency on java.awt and has in the public API the following classes from there:
- [Graphics2D](https://docs.oracle.com/javase/8/docs/api/java/awt/Graphics2D.html)
- [BufferedImage](https://docs.oracle.com/javase/8/docs/api/java/awt/image/BufferedImage.html)
As of version 24.4, this public API is declared deprecated.
In order to get rid of dependencies on these classes, we added the so-called "Modern API" - i.e. the API that should be used instead of the deprecated one, whose signatures contain dependencies on [BufferedImage](https://docs.oracle.com/javase/8/docs/api/java/awt/image/BufferedImage.html). [Graphics2D](https://docs.oracle.com/javase/8/docs/api/java/awt/Graphics2D.html) is declared deprecated and its support is removed from the public Slides API.
In current versions, treat the public API that depends on java.awt types as legacy/deprecated. Use the Modern API for new code and when migrating existing image-processing workflows.
## **Modern API**
Added the following classes and enums to the public API:
- [IImage](https://reference.aspose.com/slides/php-java/aspose.slides/iimage/) - represents the raster or vector image.
- [ImageFormat](https://reference.aspose.com/slides/php-java/aspose.slides/imageformat/) - represents the file format of the image.
- [Images](https://reference.aspose.com/slides/php-java/aspose.slides/images/) - methods to instantiate and work with the [IImage](https://reference.aspose.com/slides/php-java/aspose.slides/iimage/) class.
Note that [IImage](https://reference.aspose.com/slides/php-java/aspose.slides/iimage/) is disposable (it should be disposed of after use).
Use `getImage` to render a single slide or shape. Use `getImages` to render several presentation slides. Use [Images](https://reference.aspose.com/slides/php-java/aspose.slides/images/) methods to load images, `addImage` with [IImage](https://reference.aspose.com/slides/php-java/aspose.slides/iimage/) to add them to a presentation, and `replaceImage` with [IImage](https://reference.aspose.com/slides/php-java/aspose.slides/iimage/) to update an existing presentation image.
A typical scenario of using the new API may look as follows:
``` php
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
use aspose\slides\ImageFormat;
use aspose\slides\Images;
$pres = new Presentation();
# instantiate a disposable instance of IImage from the file on the disk.
$image = Images::fromFile("image.png");
# create a PowerPoint image by adding an instance of IImage to the presentation's images.
$ppImage = $pres->getImages()->addImage($image);
$image->dispose();
# add a picture shape on the slide #1
$pres->getSlides()->get_Item(0)->getShapes()->addPictureFrame(ShapeType::Rectangle, 10, 10, 100, 100, $ppImage);
$dimension = new Java("java.awt.Dimension", 1920, 1080);
# get an instance of the IImage representing slide #1.
$slideImage = $pres->getSlides()->get_Item(0)->getImage($dimension);
# save the image on the disk.
$slideImage->save("slide1.jpeg", ImageFormat::Jpeg);
$slideImage->dispose();
$pres->dispose();
```
## **Replacing Old Code with Modern API**
In general, you will need to replace calls that use [BufferedImage](https://docs.oracle.com/javase/8/docs/api/java/awt/image/BufferedImage.html) and [ImageIO](https://docs.oracle.com/javase/8/docs/api/javax/imageio/ImageIO.html) with the new methods that use [IImage](https://reference.aspose.com/slides/php-java/aspose.slides/iimage/).
Legacy/deprecated API:
``` php
$pres = new Presentation("pres.pptx");
$dimension = new Java("java.awt.Dimension", 1920, 1080);
$slideImage = $pres->getSlides()->get_Item(0)->getThumbnail($dimension);
$imageio = new Java("javax.imageio.ImageIO");
$javafile = new Java("java.io.File", "image.png");
$imageio->write($slideImage, "PNG", $javafile);
$pres->dispose();
```
Modern API:
``` php
$pres = new Presentation("pres.pptx");
$dimension = new Java("java.awt.Dimension", 1920, 1080);
$slideImage = $pres->getSlides()->get_Item(0)->getImage($dimension);
$slideImage->save("image.png", ImageFormat::Png);
$slideImage->dispose();
$pres->dispose();
```
### **Getting a Slide Thumbnail**
Legacy/deprecated API:
``` php
use aspose\slides\Presentation;
$pres = new Presentation("pres.pptx");
$slideImage = $pres->getSlides()->get_Item(0)->getThumbnail();
$imageio = new Java("javax.imageio.ImageIO");
$javafile = new Java("java.io.File", "slide1.png");
$imageio->write($slideImage, "PNG", $javafile);
$pres->dispose();
```
Modern API:
``` php
use aspose\slides\Presentation;
use aspose\slides\ImageFormat;
$pres = new Presentation("pres.pptx");
$slideImage = $pres->getSlides()->get_Item(0)->getImage();
$slideImage->save("slide1.png", ImageFormat::Png);
$slideImage->dispose();
$pres->dispose();
```
### **Getting a Shape Thumbnail**
Legacy/deprecated API:
``` php
use aspose\slides\Presentation;
$pres = new Presentation("pres.pptx");
$shapeImage = $pres->getSlides()->get_Item(0)->getShapes()->get_Item(0)->getThumbnail();
$imageio = new Java("javax.imageio.ImageIO");
$javafile = new Java("java.io.File", "shape.png");
$imageio->write($shapeImage, "PNG", $javafile);
$pres->dispose();
```
Modern API:
``` php
use aspose\slides\Presentation;
use aspose\slides\ImageFormat;
$pres = new Presentation("pres.pptx");
$shapeImage = $pres->getSlides()->get_Item(0)->getShapes()->get_Item(0)->getImage();
$shapeImage->save("shape.png");
$shapeImage->dispose();
$pres->dispose();
```
### **Getting a Presentation Thumbnail**
Legacy/deprecated API:
``` php
use aspose\slides\Presentation;
use aspose\slides\RenderingOptions;
$pres = new Presentation("pres.pptx");
$renderingOptions = new RenderingOptions();
$dimension = new Java("java.awt.Dimension", 1920, 1080);
$bitmaps = $pres->getThumbnails($renderingOptions, $dimension);
for ($i = 0; $i < count(java_values($bitmaps)); $i++)
{
$thumbnail = $bitmaps[$i];
$imageio = new Java("javax.imageio.ImageIO");
$javafile = new Java("java.io.File", "slide" . $i . ".png");
$imageio->write($thumbnail, "PNG", $javafile);
}
$pres->dispose();
```
Modern API:
``` php
use aspose\slides\Presentation;
use aspose\slides\ImageFormat;
use aspose\slides\RenderingOptions;
$pres = new Presentation("pres.pptx");
$renderingOptions = new RenderingOptions();
$dimension = new Java("java.awt.Dimension", 1920, 1080);
$images = $pres->getImages($renderingOptions, $dimension);
for ($i = 0; $i < count(java_values($images)); $i++)
{
$thumbnail = $images[$i];
$thumbnail->save("slide" . $i . ".png", ImageFormat::Png);
}
$pres->dispose();
```
### **Adding a Picture to a Presentation**
Legacy/deprecated API:
``` php
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$pres = new Presentation();
$imageio = new Java("javax.imageio.ImageIO");
$javafile = new Java("java.io.File", "image.png");
$bufferedImages = $imageio->read($javafile);
$ppImage = $pres->getImages()->addImage($bufferedImages);
$pres->getSlides()->get_Item(0)->getShapes()->addPictureFrame(ShapeType::Rectangle, 10, 10, 100, 100, $ppImage);
$pres->dispose();
```
Modern API:
``` php
use aspose\slides\Presentation;
use aspose\slides\Images;
use aspose\slides\ShapeType;
$pres = new Presentation();
$image = Images::fromFile("image.png");
$ppImage = $pres->getImages()->addImage($image);
$image->dispose();
$pres->getSlides()->get_Item(0)->getShapes()->addPictureFrame(ShapeType::Rectangle, 10, 10, 100, 100, $ppImage);
$pres->dispose();
```
## **Deprecated Methods and Their Replacement in Modern API**
### **Presentation**
| Method Signature | Replacement Method Signature |
|-----------------------------------------------|---------------------------------------------------------|
| public final BufferedImage[] getThumbnails(IRenderingOptions options) | public final IImage[] getImages(IRenderingOptions options) |
| public final BufferedImage[] getThumbnails(IRenderingOptions options, float scaleX, float scaleY) | public final IImage[] getImages(IRenderingOptions options, float scaleX, float scaleY) |
| public final BufferedImage[] getThumbnails(IRenderingOptions options, int[] slides) | public final IImage[] getImages(IRenderingOptions options, int[] slides) |
| public final BufferedImage[] getThumbnails(IRenderingOptions options, int[] slides, float scaleX, float scaleY) | public final IImage[] getImages(IRenderingOptions options, int[] slides, float scaleX, float scaleY) |
| public final BufferedImage[] getThumbnails(IRenderingOptions options, int[] slides, Dimension imageSize) | public final IImage[] getImages(IRenderingOptions options, int[] slides, Dimension imageSize) |
| public final BufferedImage[] getThumbnails(IRenderingOptions options, Dimension imageSize) | public final IImage[] getImages(IRenderingOptions options, Dimension imageSize) |
### **Shape**
| Method Signature | Replacement Method Signature |
|----------------------------------------------------------------------|-------------------------------------------------------------------|
| public final BufferedImage getThumbnail() | public final IImage getImage() |
| public final BufferedImage getThumbnail(int bounds, float scaleX, float scaleY) | public final IImage getImage(int bounds, float scaleX, float scaleY) |
### **Slide**
| Method Signature | Replacement Method Signature |
|----------------------------------------------------------------------|-----------------------------------------------------------------------|
| public final BufferedImage getThumbnail() | public final IImage getImage() |
| public final BufferedImage getThumbnail(float scaleX, float scaleY) | public final IImage getImage(float scaleX, float scaleY) |
| public final BufferedImage getThumbnail(IRenderingOptions options) | public final IImage getImage(IRenderingOptions options) |
| public final BufferedImage getThumbnail(IRenderingOptions options, float scaleX, float scaleY) | public final IImage getImage(IRenderingOptions options) |
| public final BufferedImage getThumbnail(IRenderingOptions options, Dimension imageSize) | public final IImage getImage(IRenderingOptions options, Dimension imageSize) |
| public final BufferedImage getThumbnail(ITiffOptions options) | public final IImage getImage(ITiffOptions options) |
| public final BufferedImage getThumbnail(Dimension imageSize) | public final IImage getImage(Dimension imageSize) |
| public final void renderToGraphics(IRenderingOptions options, Graphics2D graphics) | No Modern API replacement |
| public final void renderToGraphics(IRenderingOptions options, Graphics2D graphics, float scaleX, float scaleY) | No Modern API replacement |
| public final void renderToGraphics(IRenderingOptions options, Graphics2D graphics, Dimension renderingSize) | No Modern API replacement |
### **Output**
| Method Signature | Replacement Method Signature |
|-----------------------------------------------------------------|-------------------------------------------------------------|
| public final IOutputFile add(String path, BufferedImage image) | public final IOutputFile add(String path, IImage image) |
### **ImageCollection**
| Method Signature | Replacement Method Signature |
|-------------------------------------------|--------------------------------------------|
| public final IPPImage addImage(BufferedImage image) | public final IPPImage addImage(IImage image) |
### **PPImage**
| Method Signature | Replacement Method Signature |
|--------------------------------------|-----------------------------------------|
| public final BufferedImage getSystemImage() | public final IImage getImage() |
### **PatternFormat**
| Method Signature | Replacement Method Signature |
|-----------------------------------------------------------|-----------------------------------------------------|
| public final BufferedImage getTileImage(Color styleColor) | public final IImage getTile(Color styleColor) |
| public final BufferedImage getTileImage(Color background, Color foreground) |public final IImage getTile(Color background, Color foreground) |
### **PatternFormatEffectiveData**
| Method Signature | Replacement Method Signature |
|-----------------------------------------------------------|-----------------------------------------------------|
| public final java.awt.image.BufferedImage getTileImage(Color background, Color foreground) | public final IImage getTileIImage(Color background, Color foreground) |
## **API Support for Graphics2D**
Methods with [Graphics2D](https://docs.oracle.com/javase/8/docs/api/java/awt/Graphics2D.html) are declared deprecated and have no direct Modern API replacement.
Use the Modern API image-rendering methods instead of the API that renders to [Graphics2D](https://docs.oracle.com/javase/8/docs/api/java/awt/Graphics2D.html):
[Slide](https://reference.aspose.com/slides/php-java/aspose.slides/slide/)
- [public final void renderToGraphics(IRenderingOptions options, Graphics2D graphics)](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#renderToGraphics-aspose.slides.IRenderingOptions-java.awt.Graphics2D-)
- [public final void renderToGraphics(IRenderingOptions options, Graphics2D graphics, float scaleX, float scaleY)](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#renderToGraphics-aspose.slides.IRenderingOptions-java.awt.Graphics2D-float-float-)
- [public final void renderToGraphics(IRenderingOptions options, Graphics2D graphics, Dimension renderingSize)](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#renderToGraphics-aspose.slides.IRenderingOptions-java.awt.Graphics2D-java.awt.Dimension-)
## **FAQ**
### Why was [Graphics2D](https://docs.oracle.com/javase/8/docs/api/java/awt/Graphics2D.html) dropped?
Support for [Graphics2D](https://docs.oracle.com/javase/8/docs/api/java/awt/Graphics2D.html) is deprecated in the public API to unify work with rendering and images, eliminate ties to platform-specific dependencies, and switch to a cross-platform approach with [IImage](https://reference.aspose.com/slides/php-java/aspose.slides/iimage/). Use `getImage` or `getImages` instead of rendering to [Graphics2D](https://docs.oracle.com/javase/8/docs/api/java/awt/Graphics2D.html).
### What is the practical benefit of [IImage](https://reference.aspose.com/slides/php-java/aspose.slides/iimage/) compared to [BufferedImage](https://docs.oracle.com/javase/8/docs/api/java/awt/image/BufferedImage.html)?
[IImage](https://reference.aspose.com/slides/php-java/aspose.slides/iimage/) unifies working with both raster and vector images and simplifies saving to various formats via [ImageFormat](https://reference.aspose.com/slides/php-java/aspose.slides/imageformat/).
### Will the Modern API affect the performance of generating thumbnails?
Switching from `getThumbnail` to `getImage` does not worsen scenarios: the new methods provide the same capabilities for producing images with options and sizes, while retaining support for rendering options. The specific gain or drop depends on the scenario, but functionally the replacements are equivalent.
# Multithreading in Aspose.Slides for PHP via Java
> Aspose.Slides for PHP via Java multithreading boosts PowerPoint and OpenDocument processing. Discover best practices for efficient presentation workflows.
Source: https://docs.aspose.com/slides/php-java/multithreading/
Updated: 2026-08-02
## **Introduction**
While parallel work with presentations is possible (besides parsing/loading/cloning) and everything goes well (most times), there is a small chance you might get incorrect results when you use the library in multiple threads.
We strongly recommend that you do **not** use a single [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation) instance in a multi-threading environment because it might result in unpredictable errors or failures that are not easily detected.
It is **not** safe to load, save, and/or clone an instance of a [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation) class in multiple threads. Such operations are **not** supported. If you need to perform such tasks, you have to parallel the operations using several single-threaded processes—and each of these processes should use its own presentation instance.
We do not guarantee multithreading in PHP when using extensions. If you use them, do so at your own risk.
## **FAQ**
### Do I need to call license setup in every thread?
No. It’s enough to do it once per process/app domain before threads start. If [license setup](https://docs.aspose.com/slides/php-java/licensing/) might be invoked concurrently (for example, during lazy initialization), synchronize that call because the license setup method itself is not thread-safe.
### Can I pass `Presentation` or `Slide` objects between threads?
Passing "live" presentation objects between threads is not recommended: use independent instances per thread or precreate separate presentations/slide containers for each thread. This approach follows the general recommendation not to share a single presentation instance across threads.
### Is it safe to parallelize export to different formats (PDF, HTML, images) provided each thread has its own `Presentation` instance?
Yes. With independent instances and separate output paths, such tasks typically parallelize correctly; avoid any shared presentation objects and shared I/O streams.
### What should I do with global font settings (folders, substitutions) in multithreading?
Initialize all global [font settings](https://docs.aspose.com/slides/php-java/powerpoint-fonts/) before starting the threads and do not change them during parallel work. This eliminates races when accessing shared font resources.
# Change Notes Page Size and Orientation in PHP
> Read and change notes page dimensions in Aspose.Slides for PHP via Java, switch orientation, verify saved sizes, and export notes or handouts to PDF and images.
Source: https://docs.aspose.com/slides/php-java/notes-size/
Updated: 2026-11-08
## **Overview**
Use [Presentation::getNotesSize](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/getnotessize/) to access the presentation's notes page settings. It returns a [NotesSize](https://reference.aspose.com/slides/php-java/aspose.slides/notessize/) object whose [setSize](https://reference.aspose.com/slides/php-java/aspose.slides/notessize/setsize/) method sets the page dimensions. Although the settings object itself cannot be replaced, you can assign new dimensions through this method.
Width and height are specified in **points**, with 72 points per inch. For example, 900 × 600 points is 12.5 × 8⅓ inches. These settings apply to the presentation, rather than to an individual slide's notes.
| Setting | Purpose |
| --- | --- |
| [Presentation::getNotesSize](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/getnotessize/) | Controls notes page dimensions and the page dimensions used for handout export. |
| [Presentation::getSlideSize](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/getslidesize/) | Controls regular presentation slide dimensions through [SlideSize](https://reference.aspose.com/slides/php-java/aspose.slides/slidesize/). |
Changing either setting does not automatically change the other. Changing the notes page orientation also does not rotate the regular slides. See [Slide Size](https://docs.aspose.com/slides/php-java/slide-size/) to resize regular slides.
The examples below use an existing `sample.pptx`. For the export examples, use a presentation with at least one slide containing speaker notes. Each example can be run independently after loading the PHP/Java Bridge and the Aspose.Slides PHP wrapper. Numeric values returned by Java are converted to PHP values with `java_values` before comparison or calculation.
## **Read the Notes Page Size and Orientation**
Read the width and height and compare them to determine the orientation: a wider page is landscape, a taller page is portrait, and equal dimensions describe a square page. This example prints the actual dimensions in points, without assuming a standard paper size.
```php
use aspose\slides\Presentation;
$presentation = new Presentation("sample.pptx");
try {
$size = $presentation->getNotesSize()->getSize();
$orientation = "Square";
if (java_values($size->getWidth()) > java_values($size->getHeight())) {
$orientation = "Landscape";
} else if (java_values($size->getWidth()) < java_values($size->getHeight())) {
$orientation = "Portrait";
}
echo "Notes page: " . java_values($size->getWidth()) . " x " . java_values($size->getHeight()) . " points" . PHP_EOL;
echo "Orientation: " . $orientation . PHP_EOL;
} finally {
$presentation->dispose();
}
```
## **Switch to Landscape Without Changing the Paper Size**
To change only the orientation, swap the existing width and height. This preserves the lengths of both sides, including those of a custom paper size. The condition below prevents an already-landscape page from being switched back to portrait and leaves a square page unchanged.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("sample.pptx");
try {
$size = $presentation->getNotesSize()->getSize();
if (java_values($size->getWidth()) < java_values($size->getHeight())) {
$width = java_values($size->getWidth());
$size->setSize(java_values($size->getHeight()), $width);
$presentation->getNotesSize()->setSize($size);
}
$presentation->save("landscape-notes.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
For portrait orientation, use the same assignment when `java_values($size->getWidth()) > java_values($size->getHeight())`. Do not substitute A4 or Letter dimensions unless you also want to change the paper size.
[](https://docs.aspose.com/slides/php-java/notes-size/visual-notes-size-dff02bd439bd.svg)
*Swapping the stored notes dimensions gives 600 × 900 and 900 × 600-point PDF pages in this example. The regular slide keeps its 16:9 proportions.*
## **Set and Verify a Custom Notes Page Size**
Assign both dimensions together, then use [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/save/) to write the presentation. This example sets a 900 × 600-point landscape page, saves it as PPTX, and opens the saved file again to check the persisted values. The comparison allows a 0.01-point tolerance for floating-point values; it is not a guarantee of precision for every file format.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("sample.pptx");
try {
$expectedSize = new Java("java.awt.Dimension", 900, 600);
$presentation->getNotesSize()->setSize($expectedSize);
$presentation->save("custom-notes.pptx", SaveFormat::Pptx);
$reopened = new Presentation("custom-notes.pptx");
try {
$actualSize = $reopened->getNotesSize()->getSize();
$widthMatches = abs(java_values($actualSize->getWidth()) - java_values($expectedSize->getWidth())) < 0.01;
$heightMatches = abs(java_values($actualSize->getHeight()) - java_values($expectedSize->getHeight())) < 0.01;
$preserved = $widthMatches && $heightMatches;
echo "Stored notes page: " . java_values($actualSize->getWidth()) . " x " . java_values($actualSize->getHeight()) . " points" . PHP_EOL;
echo "Size preserved: " . ($preserved ? "true" : "false") . PHP_EOL;
} finally {
$reopened->dispose();
}
} finally {
$presentation->dispose();
}
```
The expected result is `900 x 600 points` and `Size preserved: true`. Checking a newly opened presentation verifies the saved file, rather than only the in-memory settings.
## **Export Notes and Handouts**
The page dimensions define the available area for notes or handout layouts. They do not enable those layouts by themselves: configure the export options as well. Regular slide export continues to use the slide dimensions.
### **Export Notes to PDF and PNG**
Assign [NotesCommentsLayoutingOptions](https://reference.aspose.com/slides/php-java/aspose.slides/notescommentslayoutingoptions/) to [PdfOptions::setSlidesLayoutOptions](https://reference.aspose.com/slides/php-java/aspose.slides/pdfoptions/#setSlidesLayoutOptions) to include notes in the PDF. This example also renders the first slide with notes to PNG using [Slide::getImage](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#getImage) and [RenderingOptions](https://reference.aspose.com/slides/php-java/aspose.slides/renderingoptions/).
The [BottomTruncated](https://reference.aspose.com/slides/php-java/aspose.slides/notespositions/) mode keeps the notes on one page; notes that do not fit can be truncated. The PDF uses 900 × 600-point pages. At the image scale of 1 × 1 used below, the PNG is 900 × 600 pixels. Points describe the page geometry; pixels describe the raster output, whose dimensions also depend on the rendering scale.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\NotesCommentsLayoutingOptions;
use aspose\slides\NotesPositions;
use aspose\slides\PdfOptions;
use aspose\slides\RenderingOptions;
use aspose\slides\ImageFormat;
$presentation = new Presentation("sample.pptx");
try {
$size = new Java("java.awt.Dimension", 900, 600);
$presentation->getNotesSize()->setSize($size);
$layout = new NotesCommentsLayoutingOptions();
$layout->setNotesPosition(NotesPositions::BottomTruncated);
$pdfOptions = new PdfOptions();
$pdfOptions->setSlidesLayoutOptions($layout);
$presentation->save("notes.pdf", SaveFormat::Pdf, $pdfOptions);
$renderingOptions = new RenderingOptions();
$renderingOptions->setSlidesLayoutOptions($layout);
$image = $presentation->getSlides()->get_Item(0)->getImage($renderingOptions, 1, 1);
try {
$image->save("first-slide-notes.png", ImageFormat::Png);
} finally {
$image->dispose();
}
} finally {
$presentation->dispose();
}
```
For PDF export with long notes, [BottomFull](https://reference.aspose.com/slides/php-java/aspose.slides/notespositions/) allows additional pages as needed. Do not use that mode with the single-slide image call above, which does not support it. After resizing, inspect the output for clipped notes and the placement of existing notes-master objects; changing page dimensions alone should not be treated as a guarantee that all content will fit. See [Convert PowerPoint to PDF with Notes](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-pdf-with-notes/) for more about notes export.
### **Export Handouts to PDF**
Use [HandoutLayoutingOptions](https://reference.aspose.com/slides/php-java/aspose.slides/handoutlayoutingoptions/) for multiple slide thumbnails on one page. The following example sets a 900 × 600-point page and uses [HandoutType::Handouts4Horizontal](https://reference.aspose.com/slides/php-java/aspose.slides/handouttype/) to arrange up to four slides per page. The horizontal preset controls slide ordering; the page orientation comes from its width and height.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\PdfOptions;
use aspose\slides\HandoutLayoutingOptions;
use aspose\slides\HandoutType;
$presentation = new Presentation("sample.pptx");
try {
$size = new Java("java.awt.Dimension", 900, 600);
$presentation->getNotesSize()->setSize($size);
$layout = new HandoutLayoutingOptions();
$layout->setHandout(HandoutType::Handouts4Horizontal);
$pdfOptions = new PdfOptions();
$pdfOptions->setSlidesLayoutOptions($layout);
$presentation->save("handouts.pdf", SaveFormat::Pdf, $pdfOptions);
} finally {
$presentation->dispose();
}
```
Changing the page size changes the area available for the handout grid without changing the source slides' dimensions. For handout images, use [Presentation::getImages](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/getimages/) with the handout layout, rather than an individual slide's image method. In Aspose.Slides, presentation-level handout rendering uses the notes page dimensions, while the individual slide image call does not produce the handout page. See [Handout Mode](https://docs.aspose.com/slides/php-java/convert-powerpoint-in-handout-mode/) for layout options.
## **Page Size in Viewers, Export, and Printing**
Keep the stored presentation size, the exported page size, and the printed paper size distinct:
- **Presentation viewers:** A viewer can display or print notes using its own layout rules. If another application saves the file, reopen it and check the dimensions again; that application's format conversion may normalize them.
- **Export formats:** The notes and handout PDF examples above use the configured page dimensions. Raster images use integer pixel dimensions and a rendering scale, so fractional point values can be rounded in the image output. Exporting regular slides does not apply the notes page size.
- **Printer drivers:** Paper selection, automatic rotation, and fit-to-page settings can change the physical output without changing the dimensions stored in the presentation or PDF. For a specific paper size, match the printer settings and inspect the print preview.
## **FAQ**
**Can I set the notes size for just one slide?**
The notes page size is a presentation-level setting. Individual slides can have different notes content, but this property does not provide a separate page size for each slide.
**Why did changing notes orientation not change my slides?**
Notes pages and regular slides have independent dimensions. Use the regular slide size settings when you want to resize the slides themselves.
**Why does my saved or printed result have a different size?**
First reopen the saved presentation and compare its notes dimensions. If those changed, check whether saving or converting the file in another application changed the page settings. If they did not, check the export layout, image scale, viewer settings, and printer paper selection.
# Object Preview Issue When Adding OleObjectFrame
> Learn why EMBEDDED OLE OBJECT appears when adding OleObjectFrame in Aspose.Slides for PHP and how to fix preview issues in PPT, PPTX and ODP presentations.
Source: https://docs.aspose.com/slides/php-java/object-preview-issue-when-adding-oleobjectframe/
Updated: 2025-11-30
## **Introduction**
Using Aspose.Slides for PHP via Java, when you add [OleObjectFrame](https://reference.aspose.com/slides/php-java/aspose.slides/oleobjectframe/) to a slide, an "EMBEDDED OLE OBJECT" message is shown on the output slide. This message is intentional and NOT a bug.
For more information on working with OLE objects, see [Manage OLE](https://docs.aspose.com/slides/php-java/manage-ole/).
## **Explanation and Solution**
Aspose.Slides displays the "EMBEDDED OLE OBJECT" message to notify you that the OLE object has been changed and the preview image has to be updated.
For example, if you add a Microsoft Excel сhart as an [OleObjectFrame](https://reference.aspose.com/slides/php-java/aspose.slides/oleobjectframe/) to a slide (for more details, see the "Manage OLE" article) and then open the presentation in the Microsoft PowerPoint, you will see this image on the slide:

If you want to check and confirm that your OLE object was added to the slide, you have to double-click on the "EMBEDDED OLE OBJECT" message, or you can right-click on it and go through **Object > Edit** option.

PowerPoint then opens the embedded OLE object.

The slide may retain the "EMBEDDED OLE OBJECT" message. Once you click the OLE object, the slide preview gets updated and the "EMBEDDED OLE OBJECT" message is replaced by the actual image for the OLE object.

Now, you may want to save your presentation to ensure the image for the OLE Object gets updated correctly. This way, after saving the presentation, when you open the presentation again, you will NOT see the "EMBEDDED OLE OBJECT" message.
## **Other Solutions**
### **Solution 1: Replace the "Embedded OLE Object" Message with an Image**
If you do not want to remove the "EMBEDDED OLE OBJECT" message by opening the presentation in PowerPoint and then saving it, you can replace the message with your preferred preview image. These lines of code demonstrate the process:
```php
$presentation = new Presentation("embeddedOLE.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$oleFrame = $slide->getShapes()->get_Item(0);
// Add an image to presentation resources.
$image = Images::fromFile("myImage.png");
$oleImage = $presentation->getImages()->addImage($image);
$image->dispose();
// Set a title and the image for the OLE object preview.
$oleFrame->setSubstitutePictureTitle("My title");
$oleFrame->getSubstitutePictureFormat()->getPicture()->setImage($oleImage);
$oleFrame->setObjectIcon(false);
$presentation->save("embeddedOLE-newImage.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
The slide containing the `OleObjectFrame` then changes to this:

### **Solution 2: Create an Add-On for PowerPoint**
You can also create an add-on for Microsoft PowerPoint that updates all OLE objects when you open presentations in the program.
## Related articles
- [Manage OLE in Presentations Using PHP](https://docs.aspose.com/slides/php-java/manage-ole/)
# Open Presentations in PHP
> Learn how to open PowerPoint and OpenDocument presentations in PHP, supply opening passwords, control resource loading, and reduce memory use with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/open-presentation/
Updated: 2026-09-22
## **Introduction**
[Aspose.Slides for PHP via Java](https://products.aspose.com/slides/php-java/) can load PowerPoint and OpenDocument presentations from files and streams. After a presentation is loaded, you can inspect its structure, edit slides, manage resources, and save it in the original or another supported format.
Loading behavior can be customized through the [LoadOptions](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/) class. For example, you can supply an opening password, keep large binary objects outside Java heap memory, control external resources, or omit embedded binary data.
## **Open Presentations**
After loading a file or stream, you can [determine its original presentation format](https://docs.aspose.com/slides/php-java/detect-presentation-source-format/) to choose how your application processes it.
To open an existing presentation, pass its file path to the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) constructor. Dispose the presentation after use so that file handles, temporary data, and other resources are released promptly.
The following PHP example shows how to open a presentation and get its slide count:
```php
use aspose\slides\Presentation;
$presentation = new Presentation("sample.pptx");
try {
echo("Slide count: " . java_values($presentation->getSlides()->size()) . "\n");
} finally {
$presentation->dispose();
}
```
## **Open Password-Protected Presentations**
An opening password encrypts presentation content. To load the complete presentation, pass the correct password to [LoadOptions::setPassword](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/#setPassword) and provide the options to the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) constructor. Loading fails when the password is missing or incorrect.
```php
use aspose\slides\LoadOptions;
use aspose\slides\Presentation;
$loadOptions = new LoadOptions();
$loadOptions->setPassword("open_password");
$presentation = new Presentation("encrypted-presentation.pptx", $loadOptions);
try {
echo("Slide count: " . java_values($presentation->getSlides()->size()) . "\n");
} finally {
$presentation->dispose();
}
```
For password detection, validation, and encryption workflows, see [Password-Protect Presentations](https://docs.aspose.com/slides/php-java/password-protected-presentation/). If an encrypted presentation was deliberately saved with public document properties, those properties can be read without a password; see [Manage Presentation Properties](https://docs.aspose.com/slides/php-java/presentation-properties/).
## **Open Large Presentations**
[LoadOptions::getBlobManagementOptions](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/#getBlobManagementOptions) returns options that control how Aspose.Slides handles binary large objects such as images, audio, and video. You can keep the source file locked, allow temporary files, and limit the amount of BLOB data retained in memory.
The following PHP code demonstrates loading a large presentation (for example, 2 GB):
```php
use aspose\slides\LoadOptions;
use aspose\slides\Presentation;
use aspose\slides\PresentationLockingBehavior;
use aspose\slides\SaveFormat;
$filePath = "large-presentation.pptx";
$loadOptions = new LoadOptions();
$loadOptions->getBlobManagementOptions()->setPresentationLockingBehavior(PresentationLockingBehavior::KeepLocked);
$loadOptions->getBlobManagementOptions()->setTemporaryFilesAllowed(true);
$loadOptions->getBlobManagementOptions()->setMaxBlobsBytesInMemory(10 * 1024 * 1024);
$presentation = new Presentation($filePath, $loadOptions);
try {
$presentation->getSlides()->get_Item(0)->setName("Large presentation");
$presentation->save("large-presentation-copy.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
With [PresentationLockingBehavior::KeepLocked](https://reference.aspose.com/slides/php-java/aspose.slides/presentationlockingbehavior/#KeepLocked), the source file remains locked until the presentation instance is disposed. Do not move, overwrite, or delete the source file while that instance is alive.
Aspose.Slides may copy the contents of an input stream while loading it. For large presentations, a file path is therefore generally more efficient than a stream. See [Manage BLOBs](https://docs.aspose.com/slides/php-java/manage-blob/) for additional storage and memory-management options.
## **Control External Resources**
[LoadOptions::setResourceLoadingCallback](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/#setResourceLoadingCallback) accepts an implementation of the Java [IResourceLoadingCallback](https://reference.aspose.com/slides/java/com.aspose.slides/iresourceloadingcallback/) interface through PHP/Java Bridge. The callback can supply replacement data, redirect a resource, use the default loader, or skip the resource. This is useful when presentations contain external images that must be resolved according to application-specific security or storage rules.
```php
use aspose\slides\LoadOptions;
use aspose\slides\Presentation;
use aspose\slides\ResourceLoadingAction;
class ImageLoadingHandler {
function resourceLoading($args) {
$originalUri = strtolower(java_values($args->getOriginalUri()));
$approvedImagePath = "approved-image.jpg";
$isJpeg = substr($originalUri, -4) === ".jpg";
if (!$isJpeg || !file_exists($approvedImagePath)) {
return ResourceLoadingAction::Skip;
}
$imageData = file_get_contents($approvedImagePath);
if ($imageData === false) {
echo("The approved replacement image could not be read.\n");
return ResourceLoadingAction::Skip;
}
$args->setData(java_values($imageData));
return ResourceLoadingAction::UserProvided;
}
}
$loadingHandler = java_closure(new ImageLoadingHandler(), null, java("com.aspose.slides.IResourceLoadingCallback"));
$loadOptions = new LoadOptions();
$loadOptions->setResourceLoadingCallback($loadingHandler);
$presentation = new Presentation("presentation-with-external-images.pptx", $loadOptions);
try {
echo("Slide count: " . java_values($presentation->getSlides()->size()) . "\n");
} finally {
$presentation->dispose();
}
```
## **Load Presentations without Embedded Binary Objects**
A presentation may contain embedded binary data that an application does not need or does not want to retain. Examples include:
- VBA projects, available through [Presentation::getVbaProject](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getVbaProject);
- embedded OLE data, available through [OleEmbeddedDataInfo::getEmbeddedFileData](https://reference.aspose.com/slides/php-java/aspose.slides/oleembeddeddatainfo/#getEmbeddedFileData);
- ActiveX control data, available through [Control::getActiveXControlBinary](https://reference.aspose.com/slides/php-java/aspose.slides/control/#getActiveXControlBinary).
Set [LoadOptions::setDeleteEmbeddedBinaryObjects](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/#setDeleteEmbeddedBinaryObjects) to `true` to remove this binary data while loading. Save the loaded presentation to persist the sanitized result.
This option reduces exposure to unwanted embedded payloads, but it is not a complete malware-detection or content-sanitization system.
```php
use aspose\slides\LoadOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$loadOptions = new LoadOptions();
$loadOptions->setDeleteEmbeddedBinaryObjects(true);
$presentation = new Presentation("presentation-with-embedded-data.pptx", $loadOptions);
try {
$presentation->save("presentation-without-embedded-data.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **FAQ**
**How can I tell that a file is corrupted and cannot be opened?**
Aspose.Slides throws a parsing or format exception during loading. Handle that failure separately from an incorrect-password error so that the application can report the cause accurately.
**What happens if required fonts are missing?**
The presentation can still load, but rendering and export may substitute fonts. You can [configure font substitution](https://docs.aspose.com/slides/php-java/font-substitution/) or [provide custom fonts](https://docs.aspose.com/slides/php-java/custom-font/) to make output more predictable.
**Does loading a presentation also load its embedded media?**
Embedded audio and video become available through the presentation object model. External resources are resolved according to the configured resource-loading behavior and may be unavailable if their locations cannot be accessed.
# Get Paragraph Bounds from Presentations in PHP
> Learn how to retrieve paragraph bounds in Aspose.Slides for PHP via Java to optimize text positioning in PowerPoint presentations.
Source: https://docs.aspose.com/slides/php-java/paragraph-bounds/
Updated: 2026-08-02
## **Overview**
This article explains how to get the bounds, size, and coordinates of paragraphs in Aspose.Slides. It shows how to retrieve a paragraph rectangle from a [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/) by using [Paragraph::getRect](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/getrect/), how to get paragraph coordinates inside a table cell text frame, and highlights important details such as measurement units, the effect of text wrapping on bounds, pixel conversion, and effective paragraph formatting values.
## **Get Rectangular Coordinates of a Paragraph**
Use [Paragraph::getRect](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/getrect/) to get the bounding rectangle of a paragraph.
```php
$presentation = new Presentation("Shapes.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->get_Item(0);
$paragraph = $shape->getTextFrame()->getParagraphs()->get_Item(0);
$rectangle = $paragraph->getRect();
} finally {
$presentation->dispose();
}
```
## **Get the Size of a Paragraph Inside a Table Cell TextFrame**
To get the size and coordinates of a [Paragraph](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/) in a table cell text frame, use [Paragraph::getRect](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/getrect/). The returned rectangle is relative to the table cell text frame, so add the table position and cell offset when you need slide-level coordinates.
The following example gets paragraph bounds inside a table cell and draws rectangles on the slide to visualize those bounds:
```php
$presentation = new Presentation("source.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$table = $slide->getShapes()->get_Item(0);
$cell = $table->getRows()->get_Item(1)->get_Item(1);
$cellX = java_values($table->getX()) + java_values($cell->getOffsetX());
$cellY = java_values($table->getY()) + java_values($cell->getOffsetY());
foreach ($cell->getTextFrame()->getParagraphs() as $paragraph) {
if ($paragraph->getText() == "") {
continue;
}
$paragraphRectangle = $paragraph->getRect();
$paragraphRectangleX = java_values($paragraphRectangle->getX()) + $cellX;
$paragraphRectangleY = java_values($paragraphRectangle->getY()) + $cellY;
$paragraphRectangleWidth = java_values($paragraphRectangle->getWidth());
$paragraphRectangleHeight = java_values($paragraphRectangle->getHeight());
$paragraphBoundsShape = $slide->getShapes()->addAutoShape(
ShapeType::Rectangle,
$paragraphRectangleX,
$paragraphRectangleY,
$paragraphRectangleWidth,
$paragraphRectangleHeight
);
$paragraphBoundsShape->getFillFormat()->setFillType(FillType::NoFill);
$paragraphBoundsShape->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->YELLOW);
$paragraphBoundsShape->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
}
$presentation->save("output.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **FAQ**
### In what units are paragraph coordinates measured?
They are measured in points, where 1 inch equals 72 points. This applies to all coordinates and dimensions on the slide.
### Does word wrapping affect a paragraph's bounds?
Yes. If [TextFrameFormat::setWrapText](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/setwraptext/) is enabled for the [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/), the text breaks to fit the area width, which changes the paragraph's actual bounds.
### Can paragraph coordinates be reliably mapped to pixels in the exported image?
Yes. Convert points to pixels using this formula: pixels = points x (DPI / 72). The result depends on the DPI chosen for rendering or export.
### How do I get the "effective" paragraph formatting parameters, taking style inheritance into account?
Use the [effective paragraph formatting data structure](https://docs.aspose.com/slides/php-java/shape-effective-properties/); it returns the final consolidated values for indents, spacing, wrapping, RTL, and more.
## Related articles
- [Get Text Portion Bounds from Presentations in PHP](https://docs.aspose.com/slides/php-java/portion-bounds/)
# Password-Protect Presentations in PHP
> Encrypt, detect, validate, open, and decrypt password-protected PowerPoint PPT and PPTX presentations in PHP with Aspose.Slides.
Source: https://docs.aspose.com/slides/php-java/password-protected-presentation/
Updated: 2026-09-04
## **Overview**
An opening password encrypts a presentation. The correct password is required to load and view the presentation content, so this protection provides confidentiality.
An opening password is different from a write-protection password. Write protection restricts modification but does not encrypt the content or prevent the presentation from being loaded. To manage passwords for modifying presentations, see [Write-Protect Presentations](https://docs.aspose.com/slides/php-java/write-protected-presentation/).
The workflows below apply to both PPT and PPTX presentations. The examples use both formats where their file-based and stream-based behavior is important.
## **Encrypt a Presentation with an Opening Password**
Use [ProtectionManager::encrypt](https://reference.aspose.com/slides/php-java/aspose.slides/protectionmanager/#encrypt) to assign an opening password. Then use [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#save) to persist the encrypted presentation.
The following example encrypts a PPTX presentation:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("pres.pptx");
try {
$presentation->getProtectionManager()->encrypt("open_password");
$presentation->save("encrypted-pres.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Keep Document Properties Public**
By default, Aspose.Slides includes document properties in presentation encryption. The [ProtectionManager::setEncryptDocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/protectionmanager/#setEncryptDocumentProperties) method controls this behavior independently of slide-content encryption. Pass `false` before calling [ProtectionManager::encrypt](https://reference.aspose.com/slides/php-java/aspose.slides/protectionmanager/#encrypt) when an indexing, classification, search, or document-management system must read metadata without the opening password.
The following example creates an encrypted PPTX presentation while leaving its built-in document properties public:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$properties = $presentation->getDocumentProperties();
$properties->setAuthor("Contoso Knowledge Management");
$properties->setTitle("Quarterly Product Roadmap");
$properties->setKeywords("roadmap, planning, internal");
$presentation->getSlides()->get_Item(0)->setName("Encrypted presentation content");
$presentation->getProtectionManager()->setEncryptDocumentProperties(false);
$presentation->getProtectionManager()->encrypt("open_password");
$presentation->save("public-properties-encrypted.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Passing `false` to [ProtectionManager::setEncryptDocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/protectionmanager/#setEncryptDocumentProperties) does not make slides, masters, layouts, shapes, media, or other presentation content public. It affects only document properties. To read those properties without loading the encrypted content, see [Manage Presentation Properties](https://docs.aspose.com/slides/php-java/presentation-properties/).
## **Load an Encrypted Presentation**
Set [LoadOptions::setPassword](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/#setPassword) to the opening password and pass the options to [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) when loading the file. Loading fails when an opening password is required but the supplied password is missing or incorrect.
```php
use aspose\slides\LoadOptions;
use aspose\slides\Presentation;
$loadOptions = new LoadOptions();
$loadOptions->setPassword("open_password");
$presentation = new Presentation("encrypted-pres.pptx", $loadOptions);
try {
# Work with the decrypted presentation.
} finally {
$presentation->dispose();
}
```
## **Remove Encryption from a Presentation**
Load the presentation with its opening password, call [ProtectionManager::removeEncryption](https://reference.aspose.com/slides/php-java/aspose.slides/protectionmanager/#removeEncryption), and save the result. The saved presentation can then be loaded without a password.
```php
use aspose\slides\LoadOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$loadOptions = new LoadOptions();
$loadOptions->setPassword("open_password");
$presentation = new Presentation("encrypted-pres.pptx", $loadOptions);
try {
$presentation->getProtectionManager()->removeEncryption();
$presentation->save("encryption-removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Validate an Opening Password Before Loading**
Use [PresentationFactory::getPresentationInfo](https://reference.aspose.com/slides/php-java/aspose.slides/presentationfactory/#getPresentationInfo) to obtain [PresentationInfo](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/) without creating a complete presentation instance. Check [PresentationInfo::isPasswordProtected](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/#isPasswordProtected) before requesting or validating a password. When protection is present, validate the supplied value with [PresentationInfo::checkPassword](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/#checkPassword).
### **File-Path Workflow**
The following example validates an opening password for a PPTX file, passes the validated value to [LoadOptions::setPassword](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/#setPassword), and then loads the complete presentation:
```php
use aspose\slides\LoadOptions;
use aspose\slides\Presentation;
use aspose\slides\PresentationFactory;
$filePath = "protected-presentation.pptx";
$password = "open_password";
$presentationInfo = PresentationFactory::getInstance()->getPresentationInfo($filePath);
if (!$presentationInfo->isPasswordProtected()) {
echo("The presentation does not have an opening password.\n");
} elseif (!$presentationInfo->checkPassword($password)) {
echo("The opening password is incorrect.\n");
} else {
$loadOptions = new LoadOptions();
$loadOptions->setPassword($password);
$presentation = new Presentation($filePath, $loadOptions);
try {
echo("The presentation was validated and loaded successfully.\n");
} finally {
$presentation->dispose();
}
}
```
### **Stream Workflow**
The stream overload of [PresentationFactory::getPresentationInfo](https://reference.aspose.com/slides/php-java/aspose.slides/presentationfactory/#getPresentationInfo) provides the same workflow. Reset the position of a seekable stream before loading the complete presentation from that stream.
The following example uses a PPT file:
```php
use aspose\slides\LoadOptions;
use aspose\slides\Presentation;
use aspose\slides\PresentationFactory;
$password = "open_password";
$presentationStream = new Java("java.io.FileInputStream", "protected-presentation.ppt");
try {
$presentationInfo = PresentationFactory::getInstance()->getPresentationInfo($presentationStream);
if (!$presentationInfo->isPasswordProtected()) {
echo("The presentation does not have an opening password.\n");
} elseif (!$presentationInfo->checkPassword($password)) {
echo("The opening password is incorrect.\n");
} else {
$presentationStream->getChannel()->position(0);
$loadOptions = new LoadOptions();
$loadOptions->setPassword($password);
$presentation = new Presentation($presentationStream, $loadOptions);
try {
echo("The presentation was validated and loaded successfully.\n");
} finally {
$presentation->dispose();
}
}
} finally {
$presentationStream->close();
}
```
### **checkPassword Return Values**
[PresentationInfo::checkPassword](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/#checkPassword) returns `true` only when the presentation has an opening password and the supplied password is correct. It returns `false` in each of these cases:
- The password is incorrect.
- The presentation does not have an opening password.
- The supplied password is `null` or empty.
The behavior is the same for PPT and PPTX presentations.
## **Check Whether a Loaded Presentation Is Encrypted**
After loading a presentation with the correct password, inspect [ProtectionManager::isEncrypted](https://reference.aspose.com/slides/php-java/aspose.slides/protectionmanager/#isEncrypted) to confirm that the source presentation was encrypted. To detect opening-password protection before loading, use [PresentationInfo::isPasswordProtected](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/#isPasswordProtected) as shown above.
```php
use aspose\slides\LoadOptions;
use aspose\slides\Presentation;
$loadOptions = new LoadOptions();
$loadOptions->setPassword("open_password");
$presentation = new Presentation("encrypted-pres.pptx", $loadOptions);
try {
$isEncrypted = $presentation->getProtectionManager()->isEncrypted();
echo("The presentation is encrypted: " . ($isEncrypted ? "true" : "false") . "\n");
} finally {
$presentation->dispose();
}
```
## **Security Recommendations**
Do not log opening passwords or include them in diagnostic messages. Avoid unnecessary repeated validation attempts, keep passwords in memory only as long as needed, and reuse a successful validation result when immediately loading the presentation.
Public document properties may disclose author names, titles, subjects, keywords, company information, comments, and custom values even though the presentation content is encrypted. Encrypt sensitive metadata together with the presentation. Leaving properties public should be an explicit decision made only when systems must index, classify, search, or manage the file without an opening password.
## **Password-Protect a Presentation Online**
1. Open the [Aspose.Slides Lock](https://products.aspose.app/slides/lock) application.
1. Select or upload the presentation.
1. Enter a password for view protection.
1. Optionally enter a separate password for edit protection.
1. Apply the protection and download the resulting file.
- [Write-Protect Presentations](https://docs.aspose.com/slides/php-java/write-protected-presentation/)
- [Digital Signature in PowerPoint](https://docs.aspose.com/slides/php-java/digital-signature-in-powerpoint/)
## **FAQ**
**What is the difference between an opening password and a write-protection password?**
An opening password encrypts the presentation and is required to load its content. A write-protection password restricts modification without encrypting the content.
**Can I validate an opening password without loading all slides?**
Yes. Obtain presentation information, check whether opening-password protection is present, and validate the password before creating a complete presentation instance.
**Can an application read metadata without the opening password?**
Yes, but only when the presentation was encrypted with document-property encryption disabled. The application must then use the document-properties-only loading mode described in [Manage Presentation Properties](https://docs.aspose.com/slides/php-java/presentation-properties/).
**Do the password-checking workflows support both PPT and PPTX?**
Yes. File-path and stream-based password detection and validation behave the same for PPT and PPTX presentations.
## Related articles
- [Secure Presentations in PHP](https://docs.aspose.com/slides/php-java/presentation-security/)
# Manage Picture Frames in Presentations Using PHP
> Create, format, link, crop, extract, and compress picture frames in presentations with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/picture-frame/
Updated: 2026-11-08
## **Overview**
A picture frame is a slide shape that displays an image. In Aspose.Slides, the image resource and the shape that displays it are separate objects: a [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) owns embedded image resources through its [ImageCollection](https://reference.aspose.com/slides/php-java/aspose.slides/imagecollection/), while a [PictureFrame](https://reference.aspose.com/slides/php-java/aspose.slides/pictureframe/) controls the image's position, size, line formatting, rotation, cropping, picture effects, and other frame-level settings.
This separation is useful when the same image is shown more than once. Add the image to the presentation once, keep the returned [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/), and use that image resource when creating picture frames.
Picture frames can contain raster images such as PNG or JPEG and vector SVG images. They can also refer to linked images instead of storing the image bytes in the presentation. The choice affects portability, file size, extraction, and export behavior, so it is useful to decide how the image should be stored before applying formatting or optimization.
## **Add and Format an Embedded Image**
For an embedded image, add the image data to the presentation and create a picture frame with [ShapeCollection::addPictureFrame](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/addpictureframe/). The image becomes part of the presentation package, so the presentation remains self-contained when it is moved to another computer.
The following example adds a JPEG image, creates a frame at the image's native dimensions, and applies line formatting and rotation:
```php
use aspose\slides\FillType;
use aspose\slides\Images;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$sourceImage = Images::fromFile("photo.jpg");
try {
$image = $presentation->getImages()->addImage($sourceImage);
} finally {
if (!java_is_null($sourceImage)) {
$sourceImage->dispose();
}
}
$pictureFrame = $slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 50, 100, $image->getWidth(), $image->getHeight(), $image);
$pictureFrame->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$pictureFrame->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLUE);
$pictureFrame->getLineFormat()->setWidth(3);
$pictureFrame->setRotation(15);
$presentation->save("picture-frame.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The picture frame controls the displayed geometry; changing the frame size does not change the original pixel dimensions stored in the embedded image resource. This distinction becomes important when cropping or compressing an image later.
## **Use Relative Scale**
[PictureFrame](https://reference.aspose.com/slides/php-java/aspose.slides/pictureframe/) exposes relative width and height scaling for the frame through [setRelativeScaleWidth](https://reference.aspose.com/slides/php-java/aspose.slides/pictureframe/setrelativescalewidth/) and [setRelativeScaleHeight](https://reference.aspose.com/slides/php-java/aspose.slides/pictureframe/setrelativescaleheight/). A value of `1.0` corresponds to 100% of the original picture size. Relative scale is useful when a workflow needs to preserve a relationship to the source image size instead of calculating final dimensions manually.
```php
use aspose\slides\Images;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$sourceImage = Images::fromFile("photo.jpg");
try {
$image = $presentation->getImages()->addImage($sourceImage);
} finally {
if (!java_is_null($sourceImage)) {
$sourceImage->dispose();
}
}
$pictureFrame = $slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 50, 50, 100, 100, $image);
$pictureFrame->setRelativeScaleWidth(1.35);
$pictureFrame->setRelativeScaleHeight(0.8);
$presentation->save("relative-scale.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Relative scale changes the frame's scale settings; it does not resample or compress the embedded image.
## **Embedded and Linked Images**
An embedded picture stores image data inside the presentation and is therefore the safest choice for portability and predictable rendering. A linked picture stores an external location through the [Picture::setLinkPathLong](https://reference.aspose.com/slides/php-java/aspose.slides/picture/setlinkpathlong/) method instead of embedding the image data in the same way.
Linked images can reduce the amount of image data stored in the PPTX, but they introduce an external dependency. The linked file must remain accessible to the application that opens or renders the presentation. If the path changes, the file is moved, or the resource is unavailable, the linked picture may not be displayed as expected. For presentations that must be emailed, archived, or rendered in isolated environments, embedded images are usually more reliable.
### **Add a Linked Image**
The following example creates a picture frame and points it to a local image file. It deals only with image linking; video linking is a separate media workflow and is intentionally not mixed into this example.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$pictureFrame = $slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 50, 50, 320, 180, null);
$linkedImageFile = new Java("java.io.File", "linked-image.jpg");
$pictureFrame->getPictureFormat()->getPicture()->setLinkPathLong($linkedImageFile->getAbsolutePath());
$presentation->save("linked-image.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Use links when external file management is intentional. Do not use them merely as a replacement for compression: a small PPTX with broken image dependencies is usually less useful than a larger self-contained presentation.
## **Extract Images from Picture Frames**
Before extracting an image from an existing presentation, check that a shape is actually a [PictureFrame](https://reference.aspose.com/slides/php-java/aspose.slides/pictureframe/) and that it contains an embedded image. Linked picture frames may not contain image bytes that can be extracted in the same way.
### **Extract a Raster Image**
The modern image API uses [IImage](https://reference.aspose.com/slides/php-java/aspose.slides/iimage/) directly. The following example finds the first embedded raster picture on a slide and saves it as PNG:
```php
use aspose\slides\ImageFormat;
use aspose\slides\Presentation;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapeCount = java_values($slide->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $slide->getShapes()->get_Item($index);
if (!java_instanceof($shape, new JavaClass("com.aspose.slides.PictureFrame"))) {
continue;
}
$embeddedImage = $shape->getPictureFormat()->getPicture()->getImage();
if (java_is_null($embeddedImage) || !java_is_null($embeddedImage->getSvgImage())) {
continue;
}
$rasterImage = $embeddedImage->getImage();
try {
$rasterImage->save("extracted-image.png", ImageFormat::Png);
} finally {
if (!java_is_null($rasterImage)) {
$rasterImage->dispose();
}
}
break;
}
} finally {
$presentation->dispose();
}
```
Saving through [IImage::save](https://reference.aspose.com/slides/php-java/aspose.slides/iimage/#save) converts the extracted image to the requested output format. If you need the encoded bytes stored in the presentation rather than a converted raster file, use the image resource's binary data instead.
### **Extract an SVG Image**
For an SVG picture, the [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) exposes an [SvgImage](https://reference.aspose.com/slides/php-java/aspose.slides/svgimage/) object. This lets you retrieve the SVG data directly instead of rasterizing the picture first.
```php
use aspose\slides\Presentation;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapeCount = java_values($slide->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $slide->getShapes()->get_Item($index);
if (!java_instanceof($shape, new JavaClass("com.aspose.slides.PictureFrame"))) {
continue;
}
$embeddedImage = $shape->getPictureFormat()->getPicture()->getImage();
$svgImage = java_is_null($embeddedImage) ? null : $embeddedImage->getSvgImage();
if ($svgImage === null || java_is_null($svgImage)) {
continue;
}
$outputStream = new Java("java.io.FileOutputStream", "extracted-image.svg");
try {
$outputStream->write($svgImage->getSvgData());
} finally {
$outputStream->close();
}
break;
}
} finally {
$presentation->dispose();
}
```
Keeping SVG content as SVG preserves the vector source inside the presentation. Raster exports such as PNG or JPEG necessarily render that vector content to pixels. PDF or SVG slide export is also a rendering operation, so the exported graphics should not be treated as a byte-for-byte copy of the original embedded SVG; use the embedded [SvgImage::getSvgData](https://reference.aspose.com/slides/php-java/aspose.slides/svgimage/getsvgdata/) data when the original vector resource itself is required.
## **Crop an Image**
Cropping changes which part of an image is visible inside the frame. The crop values on [PictureFillFormat](https://reference.aspose.com/slides/php-java/aspose.slides/picturefillformat/) are percentages of the source image dimensions. Cropping does not initially delete the hidden pixels from the embedded image; it only changes the visible region.
The following example finds a picture frame safely and applies crop values:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$pictureFrame = null;
$shapeCount = java_values($slide->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $slide->getShapes()->get_Item($index);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.PictureFrame"))) {
$pictureFrame = $shape;
break;
}
}
if ($pictureFrame !== null) {
$pictureFrame->getPictureFormat()->setCropLeft(23.6);
$pictureFrame->getPictureFormat()->setCropRight(21.5);
$pictureFrame->getPictureFormat()->setCropTop(3);
$pictureFrame->getPictureFormat()->setCropBottom(31);
$presentation->save("cropped-image.pptx", SaveFormat::Pptx);
}
} finally {
$presentation->dispose();
}
```
Because the hidden image data is still present, the crop can be changed later without losing the original pixels. If file size matters more than reversibility, the cropped regions can be physically removed as described in the next section.
## **Remove Cropped Image Data**
[PictureFillFormat::deletePictureCroppedAreas](https://reference.aspose.com/slides/php-java/aspose.slides/picturefillformat/#deletePictureCroppedAreas) removes image data outside the current crop rectangle and returns the resulting image resource. This can reduce file size, but it is a destructive optimization: after the presentation is saved, the removed pixels are no longer available for a later uncrop operation.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("cropped-image.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$pictureFrame = null;
$shapeCount = java_values($slide->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $slide->getShapes()->get_Item($index);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.PictureFrame"))) {
$pictureFrame = $shape;
break;
}
}
if ($pictureFrame !== null) {
$croppedImage = $pictureFrame->getPictureFormat()->deletePictureCroppedAreas();
if (!java_is_null($croppedImage)) {
$presentation->save("cropped-data-removed.pptx", SaveFormat::Pptx);
}
}
} finally {
$presentation->dispose();
}
```
The method may add a new image resource to the presentation. If the original image is also used by other picture frames, those frames still need their existing resource, so deleting cropped areas does not necessarily reduce the total number of images. Cropping WMF or EMF content with this method rasterizes the cropped result to PNG.
## **Compress Raster Images**
[PictureFillFormat::compressImage](https://reference.aspose.com/slides/php-java/aspose.slides/picturefillformat/#compressImage_boolean_int_) reduces raster image resolution relative to the size at which the picture is displayed. It can also remove cropped regions in the same operation. The method returns `true` when the image was resized or cropped and `false` when no change was necessary.
Use a predefined [PicturesCompression](https://reference.aspose.com/slides/php-java/aspose.slides/picturescompression/) value when a standard target resolution is sufficient:
```php
use aspose\slides\PicturesCompression;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$pictureFrame = null;
$shapeCount = java_values($slide->getShapes()->size());
for ($index = 0; $index < $shapeCount; $index++) {
$shape = $slide->getShapes()->get_Item($index);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.PictureFrame"))) {
$pictureFrame = $shape;
break;
}
}
if ($pictureFrame !== null) {
$compressed = $pictureFrame->getPictureFormat()->compressImage(true, PicturesCompression::Dpi150);
echo $compressed ? "The image was compressed." : "No compression was necessary.";
$presentation->save("compressed-image.pptx", SaveFormat::Pptx);
}
} finally {
$presentation->dispose();
}
```
A custom positive DPI value can be passed instead of a predefined value when a specific target is required.
Compression is intended for raster images. SVG and metafile content is not reduced by this raster compression workflow. Also remember that lower resolution and deleted cropped regions cannot be recovered from the optimized presentation. Choose a target resolution based on the largest size at which the image will actually be viewed or exported rather than applying the lowest DPI globally.
## **Manage Image Transform Effects**
For a complete workflow covering brightness, contrast, color transformations, blur, alpha effects, ordered chains, inspection, removal, and round-trip verification, see [Image Transform Effects](https://docs.aspose.com/slides/php-java/image-transform-effects/).
## **Lock Picture Frame Geometry**
The [PictureFrameLock](https://reference.aspose.com/slides/php-java/aspose.slides/pictureframelock/) settings control which editing operations are disabled for a picture frame. For example, [setAspectRatioLocked](https://reference.aspose.com/slides/php-java/aspose.slides/pictureframelock/setaspectratiolocked/) preserves the shape's proportions while it is resized.
```php
use aspose\slides\Images;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$sourceImage = Images::fromFile("photo.jpg");
try {
$image = $presentation->getImages()->addImage($sourceImage);
} finally {
if (!java_is_null($sourceImage)) {
$sourceImage->dispose();
}
}
$pictureFrame = $slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 50, 100, $image->getWidth(), $image->getHeight(), $image);
$pictureFrame->getPictureFrameLock()->setAspectRatioLocked(true);
$presentation->save("locked-picture-frame.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The lock applies to the picture frame shape. It does not force the source image to be resampled or permanently changed to the same aspect ratio.
## **Adjust the StretchOffset Values**
When the picture fill mode is stretch, the stretch-offset values on [PictureFillFormat](https://reference.aspose.com/slides/php-java/aspose.slides/picturefillformat/) define the fill rectangle relative to the picture frame's bounding box. Positive percentages create an inset from an edge, while negative percentages create an outset.
This is different from cropping. Crop values select which part of the source image is visible; stretch offsets change the rectangle into which the visible picture fill is stretched.
```php
use aspose\slides\Images;
use aspose\slides\PictureFillMode;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$sourceImage = Images::fromFile("photo.png");
try {
$image = $presentation->getImages()->addImage($sourceImage);
} finally {
if (!java_is_null($sourceImage)) {
$sourceImage->dispose();
}
}
$pictureFrame = $slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 10, 10, 400, 300, $image);
$pictureFrame->getPictureFormat()->setPictureFillMode(PictureFillMode::Stretch);
$pictureFrame->getPictureFormat()->setStretchOffsetLeft(12);
$pictureFrame->getPictureFormat()->setStretchOffsetRight(12);
$pictureFrame->getPictureFormat()->setStretchOffsetTop(8);
$pictureFrame->getPictureFormat()->setStretchOffsetBottom(8);
$presentation->save("stretch-offsets.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Use stretch offsets for fill placement. Use crop properties when the goal is to hide source-image edges.
[](https://docs.aspose.com/slides/php-java/picture-frame/visual-image-crop-and-fit-8eb4e26c4fa1.svg)
*The solid outline marks the frame and the dashed outline marks the offset fill. The same image and frame are used in all three renders.*
## **Storage, File Size, and Export Considerations**
The main tradeoffs are easier to manage when image storage and picture-frame formatting are treated separately:
- **Embedded images** make the presentation self-contained and are the most reliable for sharing and server-side rendering, but large raster images increase PPTX size and memory use.
- **Linked images** can keep the package smaller, but the presentation depends on external files remaining available at the stored paths or locations.
- **Cropping** is initially non-destructive. The hidden pixels remain embedded until cropped areas are explicitly deleted or removed during compression.
- **Compression** can reduce file size substantially for oversized raster images, but it trades away source resolution. It should be applied after the intended on-slide size is known.
- **SVG images** should remain as SVG when vector preservation is important. Extract the embedded SVG directly when you need the vector resource itself. Raster slide exports always convert the rendered slide to pixels.
- **Repeated images** should reuse an existing [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) resource when possible instead of repeatedly loading the same file into the presentation workflow.
For large presentations, image optimization is usually most effective when performed selectively: keep logos and diagrams as vector content, compress photographs according to their real display size, remove cropped pixels only when later editing is not required, and avoid external links unless dependency management is part of the deployment design.
## **FAQ**
**What is the difference between a picture frame and an image resource?**
A [PPImage](https://reference.aspose.com/slides/php-java/aspose.slides/ppimage/) represents an image resource associated with the presentation. A [PictureFrame](https://reference.aspose.com/slides/php-java/aspose.slides/pictureframe/) is a shape on a slide that displays an image and stores frame-level geometry and formatting such as size, rotation, crop values, effects, and locks.
**Should I embed or link images?**
Embed images when the presentation must be portable, archived, or rendered without access to external resources. Link images only when keeping image files outside the PPTX is intentional and the external locations can be maintained reliably.
**Does cropping reduce PPTX file size?**
Not by itself. Normal crop settings hide parts of the source image but keep the underlying pixels. Use [PictureFillFormat::deletePictureCroppedAreas](https://reference.aspose.com/slides/php-java/aspose.slides/picturefillformat/#deletePictureCroppedAreas) or image compression with cropped-area removal when those pixels can be discarded permanently.
**Can I restore image quality after compression?**
No. Compression can reduce stored raster resolution, and removing cropped regions discards image data. Keep the original source image outside the presentation if later high-resolution editing may be required.
**How should SVG images be handled?**
Keep SVG content as SVG when vector fidelity matters. The embedded [SvgImage](https://reference.aspose.com/slides/php-java/aspose.slides/svgimage/) can be extracted directly. Rendering a slide to a raster format such as PNG or JPEG rasterizes the SVG as part of the slide image.
**How can I avoid unsafe casts when reading existing slides?**
Check the shape type before using picture-frame-specific members. A `java_instanceof` check against [PictureFrame](https://reference.aspose.com/slides/php-java/aspose.slides/pictureframe/) avoids invalid casts and lets the code handle slides that do not contain picture frames.
# Customize Pie Charts in Presentations Using PHP
> Create and customize pie charts in PHP with Aspose.Slides. Configure secondary plots, display data labels, and apply automatic slice colors in PowerPoint.
Source: https://docs.aspose.com/slides/php-java/pie-chart/
Updated: 2026-10-26
## **Overview**
This article explains how to work with pie charts in Aspose.Slides. It shows how to configure secondary plot options for Pie of Pie and Bar of Pie charts, and how to enable automatic slice coloring for a standard pie chart.
The examples focus on chart customization tasks such as adding a chart to a slide, adjusting series and label settings, replacing default chart data with custom categories and values, and saving the updated presentation.
## **Second Plot Options for Pie of Pie and Bar of Pie Charts**
Aspose.Slides for PHP via Java supports secondary plot options for Pie of Pie and Bar of Pie charts. These options control the size of the secondary plot and how data points are split between the two plots.
The following example creates a Pie of Pie chart in a new presentation and displays data point values as labels. The [setSecondPieSize](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/setsecondpiesize/) method sets the secondary plot size to 149% of the main plot. [setPieSplitBy](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/setpiesplitby/) selects percentage-based splitting, and [setPieSplitPosition](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/setpiesplitposition/) sets the threshold to 53%.
```php
use aspose\slides\ChartType;
use aspose\slides\PieSplitType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::PieOfPie, 50, 50, 500, 400);
$series = $chart->getChartData()->getSeries()->get_Item(0);
// Display values and configure the secondary plot.
$series->getLabels()->getDefaultDataLabelFormat()->setShowValue(true);
$seriesGroup = $series->getParentSeriesGroup();
$seriesGroup->setSecondPieSize(149);
$seriesGroup->setPieSplitBy(PieSplitType::ByPercentage);
$seriesGroup->setPieSplitPosition(53);
$presentation->save("pie_of_pie.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
To show or hide the lines connecting the main and secondary plots in Pie of Pie and Bar of Pie charts, see [Show or Hide Series Lines](https://docs.aspose.com/slides/php-java/chart-series/#show-or-hide-series-lines). The setting applies to the entire series group.
### **Select Categories for the Secondary Plot**
Use custom splitting when you want to group specific categories in the secondary plot regardless of their percentage values. For example, a sales report might show Online and Events together so readers can compare these two channels, even though they account for 35% and 10% of total sales.
Call [setPieSplitBy](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/setpiesplitby/) with [PieSplitType::Custom](https://reference.aspose.com/slides/php-java/aspose.slides/piesplittype/) and select the points through [getPieSplitCustomPoints](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/getpiesplitcustompoints/). The collection's [add](https://reference.aspose.com/slides/php-java/aspose.slides/piesplitcustompointcollection/add/) method accepts a zero-based index in the series; use [addItem](https://reference.aspose.com/slides/php-java/aspose.slides/piesplitcustompointcollection/additem/) to add a data point object. In this example, index 1 selects Online, and the point at index 3 selects Events. Partners is also added temporarily, then excluded using [removeItem](https://reference.aspose.com/slides/php-java/aspose.slides/piesplitcustompointcollection/removeitem/).
```php
use aspose\slides\ChartType;
use aspose\slides\PieSplitType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::PieOfPie, 50, 50, 600, 200);
// Replace the default data with sales by channel.
$workbook = $chart->getChartData()->getChartDataWorkbook();
$chart->getChartData()->getSeries()->clear();
$chart->getChartData()->getCategories()->clear();
$categoryNames = [ "Retail", "Online", "Partners", "Events" ];
$values = [ 40, 35, 15, 10 ];
$seriesNameCell = $workbook->getCell(0, 0, 1, "Sales");
$series = $chart->getChartData()->getSeries()->add($seriesNameCell, $chart->getType());
for ($i = 0; $i < count($categoryNames); $i++) {
$categoryCell = $workbook->getCell(0, $i + 1, 0, $categoryNames[$i]);
$chart->getChartData()->getCategories()->add($categoryCell);
$valueCell = $workbook->getCell(0, $i + 1, 1, $values[$i]);
$series->getDataPoints()->addDataPointForPieSeries($valueCell);
}
$series->getLabels()->getDefaultDataLabelFormat()->setShowValue(true);
$seriesGroup = $series->getParentSeriesGroup();
$seriesGroup->setPieSplitBy(PieSplitType::Custom);
$seriesGroup->setColorVaried(true);
// Select Online by its zero-based index and Events by its data point object.
$seriesGroup->getPieSplitCustomPoints()->add(1);
$seriesGroup->getPieSplitCustomPoints()->addItem($series->getDataPoints()->get_Item(3));
// Exclude Partners from the selection without deleting its source data.
$seriesGroup->getPieSplitCustomPoints()->add(2);
$seriesGroup->getPieSplitCustomPoints()->removeItem($series->getDataPoints()->get_Item(2));
$presentation->save("pie_of_pie_custom.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Online (35) and Events (10) appear as separate slices in the secondary plot. In the primary plot, they are represented by one combined slice with a value of 45, alongside Retail (40) and Partners (15). Removing Partners from the custom selection keeps it in the primary plot; it does not remove the category or its value from the chart's source data.
The following image shows the saved presentation in PowerPoint:

## **Set Automatic Pie Chart Slice Colors**
Aspose.Slides for PHP via Java can automatically assign different colors to pie chart slices. The following example creates a pie chart with a centered title and replaces the default data with three quarterly categories and their values. The [setShowValue](https://reference.aspose.com/slides/php-java/aspose.slides/datalabelformat/setshowvalue/) method displays the values 20, 50, and 30 as labels, while [setColorVaried](https://reference.aspose.com/slides/php-java/aspose.slides/chartseriesgroup/setcolorvaried/) enables a distinct color for each slice.
```php
use aspose\slides\ChartType;
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::Pie, 100, 100, 400, 400);
// Add a centered chart title.
$chart->getChartTitle()->addTextFrameForOverriding("Sample Title");
$chart->getChartTitle()->getTextFrameForOverriding()->getTextFrameFormat()->setCenterText(NullableBool::True);
$chart->getChartTitle()->setHeight(20);
$chart->setTitle(true);
// Replace the default data using the first worksheet.
$workbook = $chart->getChartData()->getChartDataWorkbook();
$worksheetIndex = 0;
$chart->getChartData()->getSeries()->clear();
$chart->getChartData()->getCategories()->clear();
$categoryNames = [ "First Qtr", "2nd Qtr", "3rd Qtr" ];
$values = [ 20, 50, 30 ];
$seriesNameCell = $workbook->getCell($worksheetIndex, 0, 1, "Series 1");
$series = $chart->getChartData()->getSeries()->add($seriesNameCell, $chart->getType());
for ($i = 0; $i < count($categoryNames); $i++) {
$categoryCell = $workbook->getCell($worksheetIndex, $i + 1, 0, $categoryNames[$i]);
$chart->getChartData()->getCategories()->add($categoryCell);
$valueCell = $workbook->getCell($worksheetIndex, $i + 1, 1, $values[$i]);
$series->getDataPoints()->addDataPointForPieSeries($valueCell);
}
// Show values and assign different colors to the slices.
$series->getLabels()->getDefaultDataLabelFormat()->setShowValue(true);
$series->getParentSeriesGroup()->setColorVaried(true);
$presentation->save("pie.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **FAQ**
**Are the Pie of Pie and Bar of Pie variations supported?**
Yes, the library [supports](https://reference.aspose.com/slides/php-java/aspose.slides/charttype/) a secondary plot for pie charts, including the Pie of Pie and Bar of Pie types.
**Can I export just the chart as an image (for example, PNG)?**
Yes, you can [export the chart itself as an image](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#getImage) (such as PNG) without exporting the entire presentation.
# Portable Document Format (PDF)
>
Source: https://docs.aspose.com/slides/php-java/portable-document-format-pdf/
Updated: 2026-08-13
The [Portable Document Format](https://en.wikipedia.org/wiki/PDF) is a file format created by Adobe Systems for exchanging documents between organizations. The purpose of the format was to keep content and layout the same, regardless of the platform it was viewed on. Aspose.Slides for PHP via Java lets you convert presentation files to PDF.
## **PDF in Aspose.Slides for PHP via Java**
Any presentation that can be loaded into Aspose.Slides for PHP via Java can be converted to a PDF that conforms to [PDF 1.5](https://en.wikipedia.org/wiki/PDF/A), [PDF/A-1a](https://en.wikipedia.org/wiki/PDF/A), [PDF/A-1b](https://en.wikipedia.org/wiki/PDF/A) or [PDF/UA](https://en.wikipedia.org/wiki/PDF/UA) depending on your choice. Aspose.Slides for PHP via Java exports presentations to PDF and in most cases, the output PDF looks exactly like the original presentation.
Aspose.Slides supports the following presentation features when converting to PDF:
- Images, text boxes and other shapes.
- Text and formatting.
- Paragraphs and formatting.
- Hyperlinks.
- Headers and footers.
- Bullets.
- Tables.
You can export presentations to PDFs directly using Aspose.Slides for PHP via Java: you do not need any other component. Further, you can customize the presentation to PDF export with various options as explained in [Converting to PDF](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-pdf/).
**The input presentation**

**A presentation converted to PDF using Aspose.Slides for PHP via Java**

# Get Text Portion Bounds from Presentations in PHP
> Learn how to retrieve text portion bounds in PowerPoint presentations using Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/portion-bounds/
Updated: 2026-08-05
## **Overview**
A text portion represents a specific fragment of text inside a paragraph and allows you to work with that fragment independently from surrounding content. In Aspose.Slides, portions can be used when you need to retrieve the bounds of a text fragment, apply formatting to only part of a paragraph, or control text behavior at a more detailed level.
This article shows how to get the bounding rectangle of a portion by using [Portion::getRect](https://reference.aspose.com/slides/php-java/aspose.slides/portion/getrect/). It also shows how to get the coordinates of the beginning of a portion by using [Portion::getCoordinates](https://reference.aspose.com/slides/php-java/aspose.slides/portion/getcoordinates/). In addition, it highlights common portion-related scenarios, such as applying a hyperlink to a single text fragment, understanding how formatting is resolved through portion, paragraph, text frame, and theme inheritance, and handling cases where a specified font is unavailable.
## **Get Bounds of a Text Portion**
Use [Portion::getRect](https://reference.aspose.com/slides/php-java/aspose.slides/portion/getrect/) to retrieve the bounding rectangle of a text portion:
```php
$presentation = new Presentation("Shapes.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->get_Item(0);
$paragraphs = $shape->getTextFrame()->getParagraphs();
foreach ($paragraphs as $paragraph) {
$portions = $paragraph->getPortions();
foreach ($portions as $portion) {
$rectangle = $portion->getRect();
$rectangleX = java_values($rectangle->getX());
$rectangleY = java_values($rectangle->getY());
$rectangleWidth = java_values($rectangle->getWidth());
$rectangleHeight = java_values($rectangle->getHeight());
echo("X = " . $rectangleX . "; Y = " . $rectangleY . "; Width = " . $rectangleWidth . "; Height = " . $rectangleHeight);
}
}
} finally {
$presentation->dispose();
}
```
## **Get Coordinates of a Text Portion**
Use [Portion::getCoordinates](https://reference.aspose.com/slides/php-java/aspose.slides/portion/getcoordinates/) to retrieve the coordinates of the beginning of a text portion:
```php
$presentation = new Presentation("Shapes.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->get_Item(0);
$paragraphs = $shape->getTextFrame()->getParagraphs();
foreach ($paragraphs as $paragraph) {
$portions = $paragraph->getPortions();
foreach ($portions as $portion) {
$point = $portion->getCoordinates();
$pointX = java_values($point->getX());
$pointY = java_values($point->getY());
echo("X = " . $pointX . "; Y = " . $pointY);
}
}
} finally {
$presentation->dispose();
}
```
## **FAQ**
### Can I apply a hyperlink to only part of the text within a single paragraph?
Yes, you can [assign a hyperlink](https://docs.aspose.com/slides/php-java/manage-hyperlinks/) to an individual portion; only that fragment will be clickable, not the entire paragraph.
### How does style inheritance work: what does a portion override, and what is taken from a paragraph or text frame?
Portion-level properties have the highest precedence. If a property is not set on the [Portion](https://reference.aspose.com/slides/php-java/aspose.slides/portion/), Aspose.Slides takes it from the [Paragraph](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/). If it is not set there either, Aspose.Slides uses the [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/) or [theme](https://reference.aspose.com/slides/php-java/aspose.slides/theme/) style.
### What happens if the font specified for a portion is missing on the target machine or server?
[Font substitution rules](https://docs.aspose.com/slides/php-java/font-selection-sequence/) apply. The text may reflow: metrics, hyphenation, and width can change, which matters for precise positioning.
### Can I set portion-specific text fill transparency or a gradient independently of the rest of the paragraph?
Yes, text color, fill, and transparency at the [Portion](https://reference.aspose.com/slides/php-java/aspose.slides/portion/) level can differ from neighboring fragments.
## Related articles
- [Get Paragraph Bounds from Presentations in PHP](https://docs.aspose.com/slides/php-java/paragraph-bounds/)
# Enhance PowerPoint Presentations with Animations in PHP
> Explore the capabilities of Aspose.Slides for PHP via Java in handling PowerPoint animations. Key features and insights to enhance your presentations.
Source: https://docs.aspose.com/slides/php-java/powerpoint-animation/
Updated: 2026-09-18
## **Introduction**
Since presentations are meant to present something, their visual appearance and interactive behavior are always taken into account during creation.
**PowerPoint animation** plays an important role in making a presentation eye-catching and engaging for viewers. Aspose.Slides for PHP via Java provides a wide range of options to add animations to PowerPoint presentations:
- Apply various types of PowerPoint animation effects to shapes, charts, tables, OLE objects, and other presentation elements.
- Use multiple PowerPoint animation effects on a single shape.
- Utilize the animation timeline to control animation effects.
- Create custom animations.
In Aspose.Slides for PHP via Java, various animation effects can be applied to shapes. Since every element on a slide, including text, pictures, OLE objects, and tables, is considered a shape, animation effects can be applied to any element on the slide.
## **Animation Effects**
Aspose.Slides supports **150+ animation effects**, including basic effects such as Bounce, PathFootball, and Zoom, and specific effects such as OLEObjectShow and OLEObjectOpen. You can find a full listing in the [EffectType](https://reference.aspose.com/slides/php-java/aspose.slides/effecttype/) class.
Additionally, these animation effects can be used in combination with the following behaviors:
- [ColorEffect](https://reference.aspose.com/slides/php-java/aspose.slides/ColorEffect)
- [CommandEffect](https://reference.aspose.com/slides/php-java/aspose.slides/CommandEffect)
- [FilterEffect](https://reference.aspose.com/slides/php-java/aspose.slides/FilterEffect)
- [MotionEffect](https://reference.aspose.com/slides/php-java/aspose.slides/MotionEffect)
- [PropertyEffect](https://reference.aspose.com/slides/php-java/aspose.slides/PropertyEffect)
- [RotationEffect](https://reference.aspose.com/slides/php-java/aspose.slides/RotationEffect)
- [ScaleEffect](https://reference.aspose.com/slides/php-java/aspose.slides/ScaleEffect)
- [SetEffect](https://reference.aspose.com/slides/php-java/aspose.slides/SetEffect)
## **Custom Animation**
For complete PHP examples that create, inspect, and modify behaviors and editable motion paths, see [Custom Animation](https://docs.aspose.com/slides/php-java/custom-animation/).
It is possible to create your own **custom animations** in Aspose.Slides. This can be achieved by combining several behaviors into a new custom animation.
[Behavior](https://reference.aspose.com/slides/php-java/aspose.slides/behavior/) is a building block of a PowerPoint animation effect. Combine behaviors to customize an effect, or add a behavior to extend a predefined effect. Repetition is configured through timing settings rather than a separate repeat behavior.
[Animation Point](https://reference.aspose.com/slides/php-java/aspose.slides/point/) is a point at which a behavior should be applied.
## **Animation Time Line**
[Sequence](https://reference.aspose.com/slides/php-java/aspose.slides/sequence/) is a collection of animation effects that can target different shapes.
[Timeline](https://reference.aspose.com/slides/php-java/aspose.slides/animationtimeline/) is a set of sequences used in a specific slide. It is an animation engine introduced in PowerPoint 2002. In earlier versions of PowerPoint, adding animation effects to presentations was challenging and could only be achieved with various workarounds. The timeline provides a clearer object model for PowerPoint animations. A slide can have only one animation timeline.
## **Interactive Animation**
[Trigger](https://reference.aspose.com/slides/php-java/aspose.slides/effecttriggertype/) allows you to define user actions, such as a button click, that start a particular animation.
## **Shape Animation**
Aspose.Slides allows you to apply animations to shapes, which can include text, rectangles, lines, frames, OLE objects, and more.
Read more [**About Shape Animation**](https://docs.aspose.com/slides/php-java/shape-animation/).
## **Animated Charts**
To create animated charts, you should use the same classes as for shapes. However, PowerPoint animations can only be applied to chart categories or chart series. You can also apply animation effects to a category element or a series element.
Read more [**About Animated Charts**](https://docs.aspose.com/slides/php-java/animated-charts/).
## **Animated Text**
In addition to animating text, you can apply animation to a paragraph.
Read more [**About Animated Text**](https://docs.aspose.com/slides/php-java/animated-text/).
## **FAQ**
**Will animations be preserved when exporting to PDF?**
No. PDF is a static format, so animations and [slide transitions](https://docs.aspose.com/slides/php-java/slide-transition/) don’t play. If you need motion, export to [HTML5](https://docs.aspose.com/slides/php-java/export-to-html5/), [animated GIF](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-animated-gif/), or [video](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-video/) instead.
**Can I turn an animated presentation into a video and control the frame rate and frame size?**
Yes. You can [render the presentation as frames](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-video/) and encode them into a video (e.g., via ffmpeg), choosing the FPS and resolution. Animations and slide transitions are played during rendering.
**Will animations remain intact when working with ODP (not just PPTX)?**
PPT, PPTX, and ODP are supported for [reading](https://docs.aspose.com/slides/php-java/open-presentation/) and [writing](https://docs.aspose.com/slides/php-java/save-presentation/), but this does not guarantee animation preservation. Custom animation data can be lost when converting to ODP. See [Custom Animation](https://docs.aspose.com/slides/php-java/custom-animation/) for examples and guidance on checking format compatibility.
## Related articles
- [Animate PowerPoint Charts in PHP](https://docs.aspose.com/slides/php-java/animated-charts/)
- [Animate PowerPoint Text in PHP](https://docs.aspose.com/slides/php-java/animated-text/)
# Create and Customize PowerPoint Charts in PHP
> Create and customize PowerPoint charts with Aspose.Slides for PHP via Java — work with data, styles, and chart types in PPT and PPTX using clear code examples.
Source: https://docs.aspose.com/slides/php-java/powerpoint-charts/
Updated: 2025-11-30
---
lastmod: 2025-11-30T13:47:17+04:00
title: Create and Customize PowerPoint Charts in PHP
linktitle: PowerPoint Charts
type: docs
weight: 70
url: /php-java/powerpoint-charts/
keywords:
- add chart
- create chart
- update chart
- change chart
- modify chart
- customize chart
- chart type
- chart entities
- format chart
- chart workbook
- animated chart
- export chart
- PowerPoint
- presentation
- PHP
- Aspose.Slides
description: "Create and customize PowerPoint charts with Aspose.Slides for PHP via Java — work with data, styles, and chart types in PPT and PPTX using clear code examples."
---
## Related articles
- [Chart](https://docs.aspose.com/slides/php-java/examples/elements/chart/)
- [Customize Presentation Charts in PHP](https://docs.aspose.com/slides/php-java/chart-types/)
- [Customize Presentation Chart Entities in PHP](https://docs.aspose.com/slides/php-java/chart-entities/)
# Master PowerPoint Fonts in PHP
> Learn to control PowerPoint fonts in Aspose.Slides for PHP via Java: embed, substitute, load custom fonts, and resolve missing glyphs with concise code.
Source: https://docs.aspose.com/slides/php-java/powerpoint-fonts/
Updated: 2025-11-30
---
lastmod: 2025-11-30T13:47:17+04:00
title: Master PowerPoint Fonts in PHP
linktitle: PowerPoint Fonts
type: docs
weight: 30
url: /php-java/powerpoint-fonts/
keywords:
- PowerPoint font
- customize font
- default font
- embed font
- fallback font
- font replacement
- font substitution
- font selection
- PowerPoint
- OpenDocument
- presentation
- PHP
- Aspose.Slides
description: "Learn to control PowerPoint fonts in Aspose.Slides for PHP via Java: embed, substitute, load custom fonts, and resolve missing glyphs with concise code."
---
## Related articles
- [Manage Fallback Fonts for Presentations in PHP](https://docs.aspose.com/slides/php-java/fallback-font/)
- [Streamline Font Replacement in Presentations Using PHP](https://docs.aspose.com/slides/php-java/font-replacement/)
- [Font Selection Sequence in Aspose.Slides for PHP](https://docs.aspose.com/slides/php-java/font-selection-sequence/)
# Add Math Equations to PowerPoint Presentations in PHP
> Insert and edit math equations in PowerPoint PPT and PPTX with Aspose.Slides for PHP via Java, supporting OMML, formatting controls, and clear PHP code samples.
Source: https://docs.aspose.com/slides/php-java/powerpoint-math-equations/
Updated: 2026-11-18
## **Overview**
PowerPoint stores equations as Office Math Markup Language (OMML). With Aspose.Slides for PHP via Java, you can create the same kind of math content programmatically: fractions, radicals, functions, limits, N-ary operators, matrices, arrays, and formatted math blocks.
In PowerPoint, users normally add equations from **Insert > Equation**:

The result is editable math text on the slide:

Aspose.Slides builds that math text through three main objects:
- A math shape, created with [addMathShape](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/#addMathShape), is the shape that contains the equation.
- [MathPortion](https://reference.aspose.com/slides/php-java/aspose.slides/mathportion/) stores math content inside the shape text frame.
- [MathParagraph](https://reference.aspose.com/slides/php-java/aspose.slides/mathparagraph/) contains one or more [MathBlock](https://reference.aspose.com/slides/php-java/aspose.slides/mathblock/) objects.
Most examples below use [MathematicalText](https://reference.aspose.com/slides/php-java/aspose.slides/mathematicaltext/) and the fluent methods from [MathElementBase](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/) to keep the code short and readable.
For MathML export scenarios, see [Export Math Equations from Presentations in PHP via Java](https://docs.aspose.com/slides/php-java/exporting-math-equations/).
## **Create an Equation**
This example uses [addMathShape](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/#addMathShape) to create a math shape and adds the Pythagorean theorem:

```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$mathShape = $slide->getShapes()->addMathShape(20, 20, 700, 120);
$mathParagraph = $mathShape->getTextFrame()->getParagraphs()
->get_Item(0)->getPortions()->get_Item(0)->getMathParagraph();
$equation = (new MathematicalText("c"))
->setSuperscript("2")
->join("=")
->join((new MathematicalText("a"))->setSuperscript("2"))
->join("+")
->join((new MathematicalText("b"))->setSuperscript("2"));
$mathParagraph->add($equation);
$presentation->save("pythagorean-theorem.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
[addMathShape](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/#addMathShape) creates a shape that already contains a math paragraph. Access the first [MathPortion](https://reference.aspose.com/slides/php-java/aspose.slides/mathportion/), call [getMathParagraph](https://reference.aspose.com/slides/php-java/aspose.slides/mathportion/#getMathParagraph), and add math blocks or math elements to it.
## **Add Fractions**
Use [divide](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/#divide) to create a fraction. You can choose a fraction style with [MathFractionTypes](https://reference.aspose.com/slides/php-java/aspose.slides/mathfractiontypes/).

```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$mathShape = $slide->getShapes()->addMathShape(20, 20, 700, 100);
$mathParagraph = $mathShape->getTextFrame()->getParagraphs()
->get_Item(0)->getPortions()->get_Item(0)->getMathParagraph();
$fraction = (new MathematicalText("1"))
->divide("x", MathFractionTypes::Skewed);
$mathParagraph->add(new MathBlock($fraction));
$presentation->save("fraction.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
For a stacked fraction, use [MathFractionTypes::Bar](https://reference.aspose.com/slides/php-java/aspose.slides/mathfractiontypes/#Bar):
```php
$stackedFraction = (new MathematicalText("x + 1"))->divide("y - 1", MathFractionTypes::Bar);
```
## **Add Radicals**
Use [radical](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/#radical) to create a square root, cube root, or other root. The current element becomes the base, and the argument becomes the degree.

```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$mathShape = $slide->getShapes()->addMathShape(20, 20, 700, 100);
$mathParagraph = $mathShape->getTextFrame()->getParagraphs()
->get_Item(0)->getPortions()->get_Item(0)->getMathParagraph();
$radical = (new MathematicalText("x"))
->radical("n");
$mathParagraph->add(new MathBlock($radical));
$presentation->save("radical.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
### **Show or Hide the Degree of a Square Root**
A square root can display an explicit 2 or use the conventional √x notation. The [setHideDegree](https://reference.aspose.com/slides/php-java/aspose.slides/mathradical/#setHideDegree) method of [MathRadical](https://reference.aspose.com/slides/php-java/aspose.slides/mathradical/) controls which form appears. Both forms retain the degree 2 and the radicand x in the editable equation.

The example saves the same square root twice. In `visible-degree.pptx`, the 2 is visible. In `hidden-degree.pptx`, it is hidden.
```php
use aspose\slides\MathBlock;
use aspose\slides\MathematicalText;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$radical = (new MathematicalText("x"))->radical("2");
$shape = $slide->getShapes()->addMathShape(20, 20, 200, 100);
$portion = $shape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
$portion->getMathParagraph()->add(new MathBlock($radical));
$radical->setHideDegree(false);
$presentation->save("visible-degree.pptx", SaveFormat::Pptx);
$radical->setHideDegree(true);
$presentation->save("hidden-degree.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Add Functions and Limits**
Use [asArgumentOfFunction](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/#asArgumentOfFunction) or [function](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/#function) for functions such as `sin(x)`, `log(x)`, or custom function names. For limits, put `lim` in a [MathLimit](https://reference.aspose.com/slides/php-java/aspose.slides/mathlimit/) or use [setLowerLimit](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/#setLowerLimit).

```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$mathShape = $slide->getShapes()->addMathShape(20, 20, 700, 100);
$mathParagraph = $mathShape->getTextFrame()->getParagraphs()
->get_Item(0)->getPortions()->get_Item(0)->getMathParagraph();
$limit = (new MathematicalText("lim"))
->setLowerLimit("x\u{2192}\u{221E}")
->function("x");
$mathParagraph->add(new MathBlock($limit));
$presentation->save("functions-and-limits.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
For a custom function name, make the function name the current element and call [function](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/#function) with its argument:
```php
$customFunction = (new MathematicalText("f"))->function("x + 1");
```
## **Add N-ary Operators and Integrals**
Use [nary](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/#nary) for summations, unions, intersections, and other large operators. Use [integral](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/#integral) for integrals. Both methods let you set lower and upper limits.

```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$mathShape = $slide->getShapes()->addMathShape(20, 20, 700, 120);
$mathParagraph = $mathShape->getTextFrame()->getParagraphs()
->get_Item(0)->getPortions()->get_Item(0)->getMathParagraph();
$summationBase = (new MathematicalText("x"))
->setSuperscript("k")
->join((new MathematicalText("a"))->setSuperscript("n-k"));
$summation = $summationBase->nary(MathNaryOperatorTypes::Summation, "k=0", "n");
$mathParagraph->add(new MathBlock($summation));
$presentation->save("nary-operators.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
N-ary operators are for large operators with optional limits. Simple operators such as `+`, `-`, and `=` are usually added as [MathematicalText](https://reference.aspose.com/slides/php-java/aspose.slides/mathematicaltext/) and joined into the expression.
For an integral, use [integral](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/#integral):
```php
$integralBase = (new MathematicalText("x"))->join((new MathematicalText("dx"))->toBox());
$integral = $integralBase->integral(MathIntegralTypes::Simple, "0", "1");
```
## **Add Matrices**
Use [MathMatrix](https://reference.aspose.com/slides/php-java/aspose.slides/mathmatrix/) for rows and columns. Matrices do not include brackets by default, so enclose the matrix when you need parentheses, brackets, or braces.

```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$mathShape = $slide->getShapes()->addMathShape(20, 20, 700, 120);
$mathParagraph = $mathShape->getTextFrame()->getParagraphs()
->get_Item(0)->getPortions()->get_Item(0)->getMathParagraph();
$matrix = new MathMatrix(2, 3);
$matrix->set_Item(0, 0, new MathematicalText("1"));
$matrix->set_Item(0, 1, new MathematicalText("x"));
$matrix->set_Item(1, 0, new MathematicalText("x"));
$matrix->set_Item(1, 1, new MathematicalText("2"));
$matrix->set_Item(1, 2, new MathematicalText("y"));
$mathParagraph->add(new MathBlock($matrix));
$presentation->save("matrix.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
### **Edit an Existing Matrix**
Suppose a linear algebra lesson starts with the coefficient matrix in `matrix.pptx`, saved by the preceding example. For the next exercise, keep the first equation, replace the second with two new equations, and revise the set of variables. Open the existing matrix through [MathMatrix](https://reference.aspose.com/slides/php-java/aspose.slides/mathmatrix/) to keep the coefficients that still apply.

Row and column indices start at zero and refer to the matrix as it stands at each call. Inserting a row before index 1 moves the original second row to index 2. Inserting after index 2 then appends a row. Deleting row 2 removes the original second equation and moves the appended row up one position. Columns shift in the same way.
```php
use aspose\slides\MathematicalText;
use aspose\slides\MathHorizontalAlignment;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("matrix.pptx");
try {
$shape = $presentation->getSlides()->get_Item(0)->getShapes()->get_Item(0);
$portion = $shape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
$block = $portion->getMathParagraph()->get_Item(0);
$matrix = $block->get_Item(0);
$matrix->insertRowBefore(1);
$matrix->insertRowAfter(2);
$matrix->deleteRow(2);
$matrix->insertColumnBefore(1);
$matrix->insertColumnAfter(3);
$matrix->deleteColumn(3);
// New cells are initially null. Set the nonzero coefficients first.
$matrix->set_Item(1, 0, new MathematicalText("12"));
$matrix->set_Item(1, 1, new MathematicalText("1"));
$matrix->set_Item(2, 2, new MathematicalText("10"));
$matrix->set_Item(2, 3, new MathematicalText("1"));
$rowCount = java_values($matrix->getRowCount());
$columnCount = java_values($matrix->getColumnCount());
for ($row = 0; $row < $rowCount; $row++) {
for ($column = 0; $column < $columnCount; $column++) {
$coefficient = $matrix->get_Item($row, $column);
if (java_is_null($coefficient)) {
$matrix->set_Item($row, $column, new MathematicalText("0"));
}
}
}
$matrix->setColumnAlignment(0, MathHorizontalAlignment::Left);
$matrix->setColumnsAlignment(1, 3, MathHorizontalAlignment::Right);
$presentation->save("updated-matrix.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
[setColumnAlignment](https://reference.aspose.com/slides/php-java/aspose.slides/mathmatrix/#setColumnAlignment) aligns the first column to the left. [setColumnsAlignment](https://reference.aspose.com/slides/php-java/aspose.slides/mathmatrix/#setColumnsAlignment) aligns three consecutive columns to the right, starting at index 1. In `updated-matrix.pptx`, the matrix has three equations and four variables. The original first-row coefficients `1` and `x` now appear in the first and third columns.

## **Add Equation Arrays**
Use [toMathArray](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/#toMathArray) when you need aligned equations or a vertical stack of expressions.

```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$mathShape = $slide->getShapes()->addMathShape(20, 20, 700, 140);
$mathParagraph = $mathShape->getTextFrame()->getParagraphs()
->get_Item(0)->getPortions()->get_Item(0)->getMathParagraph();
$equationArray = (new MathematicalText("x"))
->join("y")
->toMathArray();
$mathParagraph->add(new MathBlock($equationArray));
$presentation->save("equation-array.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
### **Align an Array with Surrounding Elements**
[setBaseJustification](https://reference.aspose.com/slides/php-java/aspose.slides/matharray/#setBaseJustification) controls the vertical alignment of an array relative to the mathematical elements beside it. The example below compares alignment with the first row, the center of the array, and the last row.
The following example creates three identical arrays, each with three rows and the neighboring elements `A=` and `=B`. All mathematical text uses Cambria Math at 24 points. Only the array alignment changes.
```php
use aspose\slides\FillType;
use aspose\slides\FontData;
use aspose\slides\MathArray;
use aspose\slides\MathBlock;
use aspose\slides\MathJustification;
use aspose\slides\MathVerticalAlignment;
use aspose\slides\MathematicalText;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\SlideSizeScaleType;
use aspose\slides\TextAnchorType;
$createText = static function (string $value) {
$text = new MathematicalText($value);
$text->getFormat()->setFontHeight(24);
$text->getFormat()->setLatinFont(new FontData("Cambria Math"));
return $text;
};
$alignments = ["Top" => MathVerticalAlignment::Top, "Center" => MathVerticalAlignment::Center, "Bottom" => MathVerticalAlignment::Bottom];
$presentation = new Presentation();
try {
$presentation->getSlideSize()->setSize(780, 200, SlideSizeScaleType::DoNotScale);
$slide = $presentation->getSlides()->get_Item(0);
$x = 20;
foreach ($alignments as $name => $alignment) {
$label = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, $x, 10, 240, 30);
$label->getFillFormat()->setFillType(FillType::NoFill);
$label->getLineFormat()->getFillFormat()->setFillType(FillType::NoFill);
$label->getTextFrame()->setText($name);
$labelFormat = $label->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0)->getPortionFormat();
$labelFormat->setFontHeight(16);
$labelFormat->getFillFormat()->setFillType(FillType::Solid);
$labelFormat->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$mathShape = $slide->getShapes()->addMathShape($x, 60, 240, 130);
$mathShape->getTextFrame()->getTextFrameFormat()->setAnchoringType(TextAnchorType::Top);
$paragraph = $mathShape->getTextFrame()->getParagraphs()->get_Item(0);
$mathParagraph = $paragraph->getPortions()->get_Item(0)->getMathParagraph();
$mathParagraph->setJustification(MathJustification::LeftJustified);
$firstRow = $createText("x+y=3");
$equationArray = new MathArray($firstRow);
foreach (["x-y=1", "x=2"] as $value) {
$row = $createText($value);
$equationArray->getArguments()->add($row);
}
$equationArray->setBaseJustification($alignment);
$leftText = $createText("A=");
$rightText = $createText("=B");
$equation = (new MathBlock($leftText))->join($equationArray)->join($rightText);
$mathParagraph->add($equation);
$x += 260;
}
$presentation->save("equation-array-alignment.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The following comparison shows the saved presentation in PowerPoint. Notice the position of `A=` and `=B` beside each array.

### **Configure Row Spacing**
[setRowSpacingRule](https://reference.aspose.com/slides/php-java/aspose.slides/matharray/#setRowSpacingRule) selects the spacing rule for rows within the array. [setRowSpacing](https://reference.aspose.com/slides/php-java/aspose.slides/matharray/#setRowSpacing) supplies a numeric value for an explicit spacing rule and is ignored by the preset rules.
For exact spacing, the value is measured in points. For proportional spacing, it is measured in half-lines: the value `3` in the example specifies 1.5 lines. Set both properties when specifying an explicit value; changing the numeric value alone does not select a spacing rule.
The example below saves five presentations with the same equations, alignment, and font settings. The first three use presets; the last two show explicit values.
```php
use aspose\slides\FontData;
use aspose\slides\MathArray;
use aspose\slides\MathBlock;
use aspose\slides\MathJustification;
use aspose\slides\MathRowSpacingRule;
use aspose\slides\MathVerticalAlignment;
use aspose\slides\MathematicalText;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$createText = static function (string $value) {
$text = new MathematicalText($value);
$text->getFormat()->setFontHeight(24);
$text->getFormat()->setLatinFont(new FontData("Cambria Math"));
return $text;
};
$settings = [
"SingleLineGap" => [MathRowSpacingRule::SingleLineGap, 0],
"OneAndAHalfLineGap" => [MathRowSpacingRule::OneAndAHalfLineGap, 0],
"TwoLineGap" => [MathRowSpacingRule::TwoLineGap, 0],
"Exactly" => [MathRowSpacingRule::Exactly, 20],
"Multiple" => [MathRowSpacingRule::Multiple, 3],
];
foreach ($settings as $name => [$rule, $spacing]) {
$presentation = new Presentation();
try {
$mathShape = $presentation->getSlides()->get_Item(0)->getShapes()->addMathShape(20, 20, 600, 300);
$paragraph = $mathShape->getTextFrame()->getParagraphs()->get_Item(0);
$paragraph->getParagraphFormat()->setSpaceBefore(0);
$paragraph->getParagraphFormat()->setSpaceAfter(0);
$mathParagraph = $paragraph->getPortions()->get_Item(0)->getMathParagraph();
$mathParagraph->setJustification(MathJustification::LeftJustified);
$firstRow = $createText("x+y=3");
$equationArray = new MathArray($firstRow);
foreach (["x-y=1", "x=2"] as $value) {
$row = $createText($value);
$equationArray->getArguments()->add($row);
}
$equationArray->setBaseJustification(MathVerticalAlignment::Center);
$equationArray->setRowSpacingRule($rule);
$equationArray->setRowSpacing($spacing);
$leftText = $createText("A=");
$rightText = $createText("=B");
$equation = (new MathBlock($leftText))->join($equationArray)->join($rightText);
$mathParagraph->add($equation);
$presentation->save("equation-array-$name.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
```
Array row spacing is separate from paragraph spacing. [setSpaceBefore](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setSpaceBefore) and [setSpaceAfter](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setSpaceAfter) add space around the containing paragraph, not between array rows. Likewise, [MathParagraph::setJustification](https://reference.aspose.com/slides/php-java/aspose.slides/mathparagraph/#setJustification) positions the whole math paragraph horizontally; it does not replace the array's vertical alignment setting.
## **Add Trigonometric Functions**
Use [asArgumentOfFunction](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/#asArgumentOfFunction) when the argument is the current element and the function name is known.

```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$mathShape = $slide->getShapes()->addMathShape(20, 20, 700, 100);
$mathParagraph = $mathShape->getTextFrame()->getParagraphs()
->get_Item(0)->getPortions()->get_Item(0)->getMathParagraph();
$cosine = (new MathematicalText("2x"))
->asArgumentOfFunction(MathFunctionsOfOneArgument::Cos);
$mathParagraph->add(new MathBlock($cosine));
$presentation->save("trigonometric-function.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
## **Add Subscripts and Superscripts**
Use the subscript and superscript helpers for indexes and powers. When the indexes must appear on the left side of the base, use [setSubSuperscriptOnTheLeft](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/#setSubSuperscriptOnTheLeft).

```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$mathShape = $slide->getShapes()->addMathShape(20, 20, 700, 100);
$mathParagraph = $mathShape->getTextFrame()->getParagraphs()
->get_Item(0)->getPortions()->get_Item(0)->getMathParagraph();
$scripts = (new MathematicalText("Y"))
->setSubSuperscriptOnTheLeft("1", "n");
$mathParagraph->add(new MathBlock($scripts));
$presentation->save("subscript-superscript.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
## **Add Delimiters**
Use [enclose](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/#enclose) to put an expression inside delimiters. You can also set a separator character for delimiter expressions that contain several elements.

```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$mathShape = $slide->getShapes()->addMathShape(20, 20, 700, 100);
$mathParagraph = $mathShape->getTextFrame()->getParagraphs()
->get_Item(0)->getPortions()->get_Item(0)->getMathParagraph();
$delimiter = (new MathematicalText("x"))
->join("y")
->join("z")
->enclose(new Java("java.lang.Character", "<"), new Java("java.lang.Character", ">"));
$delimiter->setSeparatorCharacter(new Java("java.lang.Character", "|"));
$mathParagraph->add(new MathBlock($delimiter));
$presentation->save("delimiters.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
### **Size and Align Delimiters**
Pass `true` to [setGrowToMatchOperandHeight](https://reference.aspose.com/slides/php-java/aspose.slides/mathdelimiter/#setGrowToMatchOperandHeight) to let the parentheses grow around a tall operand, or pass `false` to keep them at their normal size. Use [setDelimiterShape](https://reference.aspose.com/slides/php-java/aspose.slides/mathdelimiter/#setDelimiterShape) with one of two [MathDelimiterShape](https://reference.aspose.com/slides/php-java/aspose.slides/mathdelimitershape/) values. `Centered` centers the parentheses on the math axis, which runs through the middle of the equals sign. `Match` aligns them with the enclosed content. Both settings affect only the delimiters. The expression inside stays the same.
The example places a fraction in the exponent of `x` so the expression extends farther above the baseline than below it. All four equations use the same parentheses and font settings.
```php
use aspose\slides\MathDelimiterShape;
use aspose\slides\MathematicalText;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$opening = new Java("java.lang.Character", "(");
$closing = new Java("java.lang.Character", ")");
for ($row = 0; $row < 2; $row++) {
for ($column = 0; $column < 2; $column++) {
$fraction = (new MathematicalText("a + b"))->divide("c + d");
$power = (new MathematicalText("x"))->setSuperscript($fraction);
$delimiter = $power->enclose($opening, $closing);
$delimiter->setGrowToMatchOperandHeight($row === 0);
$delimiter->setDelimiterShape($column === 0 ? MathDelimiterShape::Centered : MathDelimiterShape::Match);
$mathShape = $slide->getShapes()->addMathShape(20 + 330 * $column, 20 + 120 * $row, 300, 100);
$portion = $mathShape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
$portion->getPortionFormat()->setFontHeight(32);
$equation = (new MathematicalText("y = "))->join($delimiter);
$portion->getMathParagraph()->add($equation);
}
}
$presentation->save("delimiter-sizing.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
In PowerPoint, compare the rows to see the effect of growth. In the top row, the parentheses grow to enclose the exponent and look alike for both shapes. In the bottom row, growth is off. The smaller parentheses on the left (`Centered`) align with the equals sign, while those on the right (`Match`) sit higher around the expression.

## **Add a Border Box**
Call [toBorderBox](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/#toBorderBox) on a fraction to frame the entire expression. The returned [MathBorderBox](https://reference.aspose.com/slides/php-java/aspose.slides/mathborderbox/) shows all four sides by default. Use [setHideTop](https://reference.aspose.com/slides/php-java/aspose.slides/mathborderbox/#setHideTop), [setHideBottom](https://reference.aspose.com/slides/php-java/aspose.slides/mathborderbox/#setHideBottom), [setHideLeft](https://reference.aspose.com/slides/php-java/aspose.slides/mathborderbox/#setHideLeft), and [setHideRight](https://reference.aspose.com/slides/php-java/aspose.slides/mathborderbox/#setHideRight) to remove individual sides.
The example places six copies of the same fraction on one slide. To show cancellation, hide all four sides and pass `true` to [setStrikethroughBottomLeftToTopRight](https://reference.aspose.com/slides/php-java/aspose.slides/mathborderbox/#setStrikethroughBottomLeftToTopRight) for a rising diagonal (↗) or [setStrikethroughTopLeftToBottomRight](https://reference.aspose.com/slides/php-java/aspose.slides/mathborderbox/#setStrikethroughTopLeftToBottomRight) for a falling diagonal (↘). You can also use [setStrikethroughHorizontal](https://reference.aspose.com/slides/php-java/aspose.slides/mathborderbox/#setStrikethroughHorizontal) or [setStrikethroughVertical](https://reference.aspose.com/slides/php-java/aspose.slides/mathborderbox/#setStrikethroughVertical) with any combination of visible sides.
```php
use aspose\slides\MathBlock;
use aspose\slides\MathematicalText;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SlideSizeScaleType;
$presentation = new Presentation();
try {
$presentation->getSlideSize()->setSize(540, 220, SlideSizeScaleType::DoNotScale);
$slide = $presentation->getSlides()->get_Item(0);
$addFraction = function ($x, $y, $hideBorder) use ($slide) {
$fraction = (new MathematicalText("x+1"))->divide("y+2");
$box = $fraction->toBorderBox();
$box->setHideTop($hideBorder);
$box->setHideBottom($hideBorder);
$box->setHideLeft($hideBorder);
$box->setHideRight($hideBorder);
$shape = $slide->getShapes()->addMathShape($x, $y, 160, 90);
$portion = $shape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
$portion->getPortionFormat()->setFontHeight(28);
$mathBlock = new MathBlock($box);
$portion->getMathParagraph()->add($mathBlock);
return $box;
};
$addFraction(10, 10, false);
$partial = $addFraction(190, 10, false);
$partial->setHideTop(true);
$partial->setHideRight(true);
$addFraction(370, 10, true)->setStrikethroughBottomLeftToTopRight(true);
$addFraction(10, 120, true)->setStrikethroughTopLeftToBottomRight(true);
$addFraction(190, 120, true)->setStrikethroughHorizontal(true);
$addFraction(370, 120, false)->setStrikethroughVertical(true);
$presentation->save("border-box.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```

On this fraction, the horizontal strike overlaps the fraction bar. The vertical strike crosses both the numerator and the denominator while the surrounding border stays visible. These lines decorate the whole expression. Ordinary text strikethrough applies to characters in a text run. After reopening the presentation in PowerPoint, you can still edit the numerator and denominator independently.
## **Control Visibility and Layout with Phantom Elements**
Wrap an expression in [MathPhantom](https://reference.aspose.com/slides/php-java/aspose.slides/mathphantom/) to control its visibility and the space it contributes to an equation independently. The [MathPhantom](https://reference.aspose.com/slides/php-java/aspose.slides/mathphantom/) methods control the following:
| Method | Effect |
| --- | --- |
| [setShow](https://reference.aspose.com/slides/php-java/aspose.slides/mathphantom/#setShow) | Pass `false` to hide the expression. Its dimensions still contribute to layout unless the corresponding methods below receive `true`. |
| [setZeroWidth](https://reference.aspose.com/slides/php-java/aspose.slides/mathphantom/#setZeroWidth) | Treat the expression's horizontal width as zero, allowing neighboring elements to move closer together. |
| [setZeroAsc](https://reference.aspose.com/slides/php-java/aspose.slides/mathphantom/#setZeroAsc) | Treat its ascent, the height above the baseline, as zero. This can reduce the space reserved above neighboring elements. |
| [setZeroDesc](https://reference.aspose.com/slides/php-java/aspose.slides/mathphantom/#setZeroDesc) | Treat its descent, the depth below the baseline, as zero. This can move a fraction bar or other content below the expression closer to its neighbors. |
The baseline is the reference line on which ordinary mathematical letters sit. Hiding content does not remove its dimensions, and treating a dimension as zero does not delete the expression. The underlying expression remains available through [getBase](https://reference.aspose.com/slides/php-java/aspose.slides/mathphantom/#getBase). Pass `true` to [setShow](https://reference.aspose.com/slides/php-java/aspose.slides/mathphantom/#setShow) to display it again; the dimension settings remain unchanged.
The example below creates five side-by-side variants: a visible fraction, a hidden fraction that reserves space, and three hidden fractions with one dimension treated as zero. Each variant uses the same surrounding expression and Cambria Math at 24 points. All equation shapes have the same top position, marked by the gray guide. Placing the phantom in the numerator of an outer fraction makes the vertical layout changes easier to see.
```php
use aspose\slides\FillType;
use aspose\slides\FontData;
use aspose\slides\MathBlock;
use aspose\slides\MathFraction;
use aspose\slides\MathPhantom;
use aspose\slides\MathematicalText;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\SlideSizeScaleType;
use aspose\slides\TextAnchorType;
$createText = static function (string $value) {
$text = new MathematicalText($value);
$text->getFormat()->setFontHeight(24);
$text->getFormat()->setLatinFont(new FontData("Cambria Math"));
return $text;
};
$presentation = new Presentation();
try {
$presentation->getSlideSize()->setSize(1000, 180, SlideSizeScaleType::DoNotScale);
$slide = $presentation->getSlides()->get_Item(0);
$labels = ["Visible", "Hidden: reserves space", "Hidden: ZeroWidth", "Hidden: ZeroAsc", "Hidden: ZeroDesc"];
$guide = $slide->getShapes()->addAutoShape(ShapeType::Line, 10, 60, 980, 0);
$guide->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$guide->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->LIGHT_GRAY);
foreach ($labels as $i => $labelText) {
$left = 10 + $i * 200;
$label = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, $left, 10, 190, 30);
$label->getFillFormat()->setFillType(FillType::NoFill);
$label->getLineFormat()->getFillFormat()->setFillType(FillType::NoFill);
$label->getTextFrame()->setText($labelText);
$labelFormat = $label->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0)->getPortionFormat();
$labelFormat->setFontHeight(14);
$labelFormat->getFillFormat()->setFillType(FillType::Solid);
$labelFormat->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$fractionNumerator = $createText("a+b");
$fractionDenominator = $createText("c+d");
$fraction = new MathFraction($fractionNumerator, $fractionDenominator);
$phantom = new MathPhantom($fraction);
$phantom->setShow($i === 0);
$phantom->setZeroWidth($i === 2);
$phantom->setZeroAsc($i === 3);
$phantom->setZeroDesc($i === 4);
$leftText = $createText("x+");
$rightText = $createText("+y");
$numerator = (new MathBlock($leftText))->join($phantom)->join($rightText);
$denominator = $createText("z");
$equation = new MathFraction($numerator, $denominator);
$shape = $slide->getShapes()->addMathShape($left, 60, 190, 100);
$shape->getTextFrame()->getTextFrameFormat()->setAnchoringType(TextAnchorType::Top);
$mathPortion = $shape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
$mathParagraph = $mathPortion->getMathParagraph();
$mathBlock = new MathBlock($equation);
$mathParagraph->add($mathBlock);
}
$presentation->save("math-phantom.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```

## **Group Terms**
Use [group](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/#group) to place a grouping character above or below an expression. Add a limit to label the grouped terms.

```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$mathShape = $slide->getShapes()->addMathShape(20, 20, 700, 120);
$mathParagraph = $mathShape->getTextFrame()->getParagraphs()
->get_Item(0)->getPortions()->get_Item(0)->getMathParagraph();
$grouped = (new MathematicalText("x + y"))
->group(new Java("java.lang.Character", "\u{23DF}"), MathTopBotPositions::Bottom, MathTopBotPositions::Top)
->setLowerLimit("any text");
$mathParagraph->add(new MathBlock($grouped));
$presentation->save("grouped-terms.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
## **Format Math Elements**
Use formatting helpers only where they clarify the formula. For example, [overbar](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/#overbar) places a bar above a math element.

```php
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$mathShape = $slide->getShapes()->addMathShape(20, 20, 700, 100);
$mathParagraph = $mathShape->getTextFrame()->getParagraphs()
->get_Item(0)->getPortions()->get_Item(0)->getMathParagraph();
$overbar = (new MathematicalText("ABC"))->overbar();
$mathParagraph->add(new MathBlock($overbar));
$presentation->save("overbar.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
```
### **Format Text in an Existing Equation**
To format text throughout an existing equation, traverse each math block's element tree. [MathElementBase::getChildren](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/#getChildren) returns only the immediate children, so call it recursively to reach text inside fractions, scripts, radicals, and other nested structures. Check the current element as well as its children to include the starting element when it is [MathematicalText](https://reference.aspose.com/slides/php-java/aspose.slides/mathematicaltext/).
This example assumes that `input.pptx` contains an equation such as `z = xᵢ / ∛y`, with a fraction containing a subscript in its numerator and a radical in its denominator. Processing only the block's top-level elements would miss the text inside the fraction. The example finds mathematical portions in slide text frames, accesses their blocks through [MathPortion::getMathParagraph](https://reference.aspose.com/slides/php-java/aspose.slides/mathportion/#getMathParagraph), and uses [setFontHeight](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setFontHeight) to set the font size to 28 points through each text element's [getFormat](https://reference.aspose.com/slides/php-java/aspose.slides/mathematicaltext/#getFormat) method.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
function formatMathText($element, $mathematicalTextClass) {
if (java_instanceof($element, $mathematicalTextClass)) {
$element->getFormat()->setFontHeight(28);
}
foreach ($element->getChildren() as $child) {
formatMathText($child, $mathematicalTextClass);
}
}
$mathematicalTextClass = new JavaClass("com.aspose.slides.MathematicalText");
$autoShapeClass = new JavaClass("com.aspose.slides.IAutoShape");
$mathPortionClass = new JavaClass("com.aspose.slides.IMathPortion");
$presentation = new Presentation("input.pptx");
try {
for ($slideIndex = 0; $slideIndex < java_values($presentation->getSlides()->size()); $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
for ($shapeIndex = 0; $shapeIndex < java_values($slide->getShapes()->size()); $shapeIndex++) {
$shape = $slide->getShapes()->get_Item($shapeIndex);
if (!java_instanceof($shape, $autoShapeClass)) {
continue;
}
$textFrame = $shape->getTextFrame();
if (java_is_null($textFrame)) {
continue;
}
for ($paragraphIndex = 0; $paragraphIndex < java_values($textFrame->getParagraphs()->getCount()); $paragraphIndex++) {
$paragraph = $textFrame->getParagraphs()->get_Item($paragraphIndex);
for ($portionIndex = 0; $portionIndex < java_values($paragraph->getPortions()->getCount()); $portionIndex++) {
$portion = $paragraph->getPortions()->get_Item($portionIndex);
if (java_instanceof($portion, $mathPortionClass)) {
for ($blockIndex = 0; $blockIndex < java_values($portion->getMathParagraph()->getCount()); $blockIndex++) {
$block = $portion->getMathParagraph()->get_Item($blockIndex);
formatMathText($block, $mathematicalTextClass);
}
}
}
}
}
}
$presentation->save("formatted-equations.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The saved presentation contains the updated text formatting at every level of each processed equation, while preserving its text content and mathematical structure.
## **Quick Reference**
| Task | Main API |
| --- | --- |
| Create math text | [MathematicalText](https://reference.aspose.com/slides/php-java/aspose.slides/mathematicaltext/) |
| Combine elements | [join](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/) |
| Create fractions | [divide](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/) |
| Add superscript or subscript | [setSuperscript](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/), [setSubscript](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/) |
| Add functions | [function](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/), [asArgumentOfFunction](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/) |
| Add radicals | [radical](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/) |
| Add limits | [setLowerLimit](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/), [setUpperLimit](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/) |
| Add left-side scripts | [setSubSuperscriptOnTheLeft](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/) |
| Add summations and integrals | [nary](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/), [integral](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/) |
| Add matrices | [MathMatrix](https://reference.aspose.com/slides/php-java/aspose.slides/mathmatrix/) |
| Add equation arrays | [toMathArray](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/) |
| Add delimiters | [enclose](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/) |
| Add bars and borders | [overbar](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/), [toBorderBox](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/) |
| Group terms | [group](https://reference.aspose.com/slides/php-java/aspose.slides/mathelementbase/) |
## **FAQ**
**Can I edit an existing PowerPoint equation?**
Yes. Open the presentation, find the shape that contains a [MathPortion](https://reference.aspose.com/slides/php-java/aspose.slides/mathportion/), call [getMathParagraph](https://reference.aspose.com/slides/php-java/aspose.slides/mathportion/#getMathParagraph), and update the math blocks in that paragraph.
**Are equations saved as editable PowerPoint math?**
Yes. When you save to PPTX, Aspose.Slides writes the equation as editable Office math content.
**Can I export equations to LaTeX?**
Yes. Get the equation's [MathParagraph](https://reference.aspose.com/slides/php-java/aspose.slides/mathparagraph/) from its [MathPortion](https://reference.aspose.com/slides/php-java/aspose.slides/mathportion/), and call [MathParagraph::toLatex](https://reference.aspose.com/slides/php-java/aspose.slides/mathparagraph/#toLatex) to export it directly. For a complete example, see [Export Math Equations from Presentations in PHP via Java](https://docs.aspose.com/slides/php-java/exporting-math-equations/#export-math-equations-to-latex).
## Related articles
- [MathText](https://docs.aspose.com/slides/php-java/examples/elements/math-text/)
- [Export Math Equations from Presentations in PHP](https://docs.aspose.com/slides/php-java/exporting-math-equations/)
# Manage PowerPoint Shapes in PHP
> Learn how to create, edit, format, and manipulate shapes in Aspose.Slides for PHP via Java, with code examples for PPT and PPTX presentations.
Source: https://docs.aspose.com/slides/php-java/powerpoint-shapes/
Updated: 2025-11-30
---
lastmod: 2025-11-30T13:47:17+04:00
title: Manage PowerPoint Shapes in PHP
linktitle: PowerPoint Shapes
type: docs
weight: 90
url: /php-java/powerpoint-shapes/
keywords:
- shape
- format shape
- shape effect
- manage shape
- effective properties
- animation
- rendering
- ActiveX
- PowerPoint
- presentation
- PHP
- Aspose.Slides
description: "Learn how to create, edit, format, and manipulate shapes in Aspose.Slides for PHP via Java, with code examples for PPT and PPTX presentations."
---
## Related articles
- [ActiveX](https://docs.aspose.com/slides/php-java/examples/elements/activex/)
- [Animation](https://docs.aspose.com/slides/php-java/examples/elements/animation/)
- [Shape Types in Aspose.Slides for PHP via Java](https://docs.aspose.com/slides/php-java/shape-types/)
# Create and Customize PowerPoint SmartArt in PHP
> Learn how to create and edit PowerPoint SmartArt in PHP via Aspose.Slides API: layouts, nodes, styles, with step-by-step examples to automate slides fast.
Source: https://docs.aspose.com/slides/php-java/powerpoint-smartart/
Updated: 2025-11-30
---
lastmod: 2025-11-30T13:47:17+04:00
title: Create and Customize PowerPoint SmartArt in PHP
linktitle: PowerPoint SmartArt
type: docs
weight: 100
url: /php-java/powerpoint-smartart/
keywords:
- SmartArt
- manage SmartArt
- SmartArt graphic
- SmartArt node
- PowerPoint
- presentation
- PHP
- Aspose.Slides
description: "Learn how to create and edit PowerPoint SmartArt in PHP via Aspose.Slides API: layouts, nodes, styles, with step-by-step examples to automate slides fast."
---
## Related articles
- [SmartArt](https://docs.aspose.com/slides/php-java/examples/elements/smartart/)
- [Manage SmartArt in PowerPoint Presentations Using PHP](https://docs.aspose.com/slides/php-java/manage-smartart/)
- [Manage SmartArt Shape Nodes in Presentations Using PHP](https://docs.aspose.com/slides/php-java/manage-smartart-shape-node/)
# Create and Customize PowerPoint Tables in PHP
> Create and format tables in PowerPoint PPT and PPTX using Aspose.Slides for PHP via Java — insert rows and columns, merge cells, set borders, import data.
Source: https://docs.aspose.com/slides/php-java/powerpoint-table/
Updated: 2025-11-30
---
lastmod: 2025-11-30T13:47:17+04:00
title: Create and Customize PowerPoint Tables in PHP
linktitle: PowerPoint Table
type: docs
weight: 110
url: /php-java/powerpoint-table/
keywords:
- create table
- add row
- add column
- customize table
- customize row
- customize column
- customize cell
- PowerPoint
- presentation
- PHP
- Aspose.Slides
description: "Create and format tables in PowerPoint PPT and PPTX using Aspose.Slides for PHP via Java — insert rows and columns, merge cells, set borders, import data."
---
## Related articles
- [Table](https://docs.aspose.com/slides/php-java/examples/elements/table/)
- [Manage Rows and Columns in PowerPoint Tables Using PHP](https://docs.aspose.com/slides/php-java/manage-rows-and-columns/)
- [Manage Table Cells in Presentations Using PHP](https://docs.aspose.com/slides/php-java/manage-cells/)
# PPT to PPTX conversion
>
Source: https://docs.aspose.com/slides/php-java/ppt-to-pptx-conversion/
Updated: 2026-08-13
PPT to PPTX conversion is supported from Aspose.Slides for PHP via Java. Most presentation features - master slides, structure and so on - are retained when converted from one format to the other, but there are [a few limitations](https://docs.aspose.com/slides/php-java/ppt-to-pptx-conversion/).
## **Features Supported in Conversion**
Aspose.Slides for PHP via Java provides partial support for converting the PPT file format to PPTX. Support for conversion has just been introduced to Aspose.Slides for PHP via Java, so it has a few limitations and works best for simple presentations. The main advantage that Aspose.Slides for PHP via Java provides when converting PPT to PPTX is how easy the API is to use. To see examples of the code, read about [Converting PPT to PPTX](). Below, lists explain which features are supported and which are not for PPT to PPTX conversion.
**Source PPT presentation**

**After conversion to PPTX**

## **Supported Features**
The following features are supported for conversion:
- Converting the structure of masters, layouts and slides.
- Converting charts.
- Group shapes.
- Converting autoshapes including rectangles and ellipses.
- Shapes with custom geometry.
- Textures and pictures fill styles for autoshapes.
- Converting placeholders.
- Converting lines and polylines.
- Line and fill formats.
- Gradient fill styles.
- OLE frames, tables, video and audio frames, etc.
- Animation and slideshow properties.
- Converting text in text frames and text holders.
## Related articles
- [Convert PPT to PPTX in PHP](https://docs.aspose.com/slides/php-java/convert-ppt-to-pptx/)
# Understanding the Difference: PPT vs PPTX
> Compare PPT vs PPTX for PowerPoint with Aspose.Slides for PHP via Java, exploring format differences, benefits, compatibility, and conversion tips.
Source: https://docs.aspose.com/slides/php-java/ppt-vs-pptx/
Updated: 2026-08-13
## **Overview**
This article explains the differences between the PPT and PPTX formats. It describes PPT as the legacy binary format used in PowerPoint 97–2003, while PPTX is presented as the modern Office Open XML-based format that offers greater flexibility and is better suited for extending presentation capabilities. The article also outlines key aspects of converting between these formats, including compatibility considerations, and shows how Aspose.Slides can be used to perform such conversions. In general, PPTX is recommended whenever possible.
## **What Is PPT?**
[**PPT**](https://docs.fileformat.com/presentation/ppt/) is a binary file format, i.e. it is impossible to view its content without special tools. The first PowerPoint 97-2003 versions worked with PPT file format, however its expandability is limited.
## **What Is PPTX?**
[**PPTX**](https://docs.fileformat.com/presentation/pptx/) is a new presentation file format, based on the Office Open XML (ISO 29500:2008-2016, ECMA-376) standard. PPTX is an archived set of XML and media files. PPTX format is easily expandable. For example, it is easy to add support for a new chart type or shape type, without changing PPTX format in every new PowerPoint version. PPTX format is used starting from PowerPoint 2007.
## **PPT vs PPTX**
Although PPTX provides much broader functionality, PPT remains quite popular. The necessity to convert from PPT to PPTX and vice versa is highy demanded.
However, conversion between old PPT and new PPTX format is the most complicated challenge among other Microsoft Office formats. Although the specification of PPT format is open, it is difficult to work with it. PowerPoint can create special parts (MetroBlob) in PPT files to store information from PPTX that is not supported by PPT format and can't be displayed in old PowerPoint versions. This information can be restored when a PPT file is loaded in a modern PowerPoint version or converted to PPTX format.
Aspose.Slides provides a common API to work with all presentation formats. It allows converting from PPT to PPTX and PPTX to PPT in a very simple way. Aspose.Slides completely supports conversion from PPT to PPTX and also supports conversion from PPTX to PPT with some restrictions. We recommend using PPTX format wherever possible.
Check the quality of PPT to PPTX and PPTX to PPT conversions with online [**Aspose.Slides Conversion app**](https://products.aspose.app/slides/conversion/).
```php
# Instantiate a Presentation object that represents a PPT file
$pres = new Presentation("PPTtoPPTX.ppt");
try {
# Saving the PPT presentation to PPTX format
$pres->save("PPTtoPPTX_out.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
Read more [**How to Convert Presentations PPT to PPTX**.](https://docs.aspose.com/slides/php-java/convert-ppt-to-pptx/)
## **FAQ**
### Is there any point in keeping old presentations in PPT if they open without errors?
If a presentation opens reliably and doesn't need collaboration or newer features, you can keep it in PPT. But for future compatibility and extensibility, it's better to [convert to PPTX](https://docs.aspose.com/slides/php-java/convert-ppt-to-pptx/): the format is based on the open OOXML standard and is more easily supported by modern tools.
### How can I decide which files are critical to convert to PPTX first?
Convert first the presentations that: are edited by multiple people; contain complex [charts](https://docs.aspose.com/slides/php-java/create-chart/)/[shapes](https://docs.aspose.com/slides/php-java/shape-manipulations/); are used in external communications; or trigger warnings when [opened](https://docs.aspose.com/slides/php-java/open-presentation/).
### Will password protection be preserved when converting from PPT to PPTX and back?
The presence of a password carries over only with a correct conversion and encryption support in the tool you use. It's more reliable to [remove protection](https://docs.aspose.com/slides/php-java/password-protected-presentation/), [convert](https://docs.aspose.com/slides/php-java/convert-ppt-to-pptx/), then reapply protection according to your security policy.
### Why do some effects disappear or get simplified when converting PPTX back to PPT?
Because PPT doesn't support some newer objects/properties. PowerPoint and tools can store "traces" of this information in special blocks for later restoration, but older versions of PowerPoint won't render them.
# Manage Presentation Accessibility in PHP
> Discover how Aspose.Slides for PHP via Java helps automate presentation accessibility checks in PPT, PPTX and ODP files—enhance screen reader experience and boost compliance.
Source: https://docs.aspose.com/slides/php-java/presentation-accessibility/
Updated: 2026-09-25
## **Introduction**
Alternative text helps people using assistive technologies understand the meaning of images, charts, and other informative shapes. This article explains how to read and update alternative text titles and descriptions with Aspose.Slides for PHP via Java, distinguish accessibility descriptions from shape names used in code, and check whether a shape is marked as decorative.
These features support presentation accessibility, but do not guarantee it. Reading order, color contrast, text readability, and other accessibility requirements also need review.
## **Manage Alternative Text Titles and Descriptions**
Use alternative text to explain the meaning of images, charts, and other informative shapes to people who cannot see them. The following methods and content serve different purposes:
| Method or content | Purpose |
| --- | --- |
| [getAlternativeTextTitle](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getalternativetexttitle/) | A short title for the alternative description. |
| [getAlternativeText](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getalternativetext/) | A meaningful description of the shape's content or purpose in the context of the slide. |
| [getName](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getname/) | The shape's name, which code can use to find a specific shape in the presentation. |
| Visible text | Content displayed on the slide, such as a shape's text or a chart's title and labels. Updating alternative text does not change this content. |
When a presentation is reused as a template, code may find a shape by the name returned by [getName](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getname/) before updating it. This name serves a different purpose from alternative text, which explains what the visual communicates to the reader. Searching by name allows authors to improve or translate descriptions without changing how code finds the shape. Names can be edited and are not guaranteed to be unique, so check that the name matches the intended shape; see [Identify and Find Shapes](https://docs.aspose.com/slides/php-java/shape-manipulations/#identify-and-find-shapes).
The following example requires `input.pptx` with an image of an office entrance as the first shape on the first slide. The image should not be marked as decorative. The example reads and prints its current alternative text title and description, updates both values, and saves the presentation as `output.pptx`. Adapt the wording to the actual image and the information it conveys.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("input.pptx");
try {
$shape = $presentation->getSlides()->get_Item(0)->getShapes()->get_Item(0);
echo "Alternative text title: " . java_values($shape->getAlternativeTextTitle()) . PHP_EOL;
echo "Alternative text description: " . java_values($shape->getAlternativeText()) . PHP_EOL;
$shape->setAlternativeTextTitle("Office entrance");
$shape->setAlternativeText("The office entrance has a wheelchair ramp to the right of the steps.");
$presentation->save("output.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Adding alternative text alone does not guarantee presentation accessibility or compliance with accessibility standards. Review the descriptions for accuracy and relevance, and also check reading order, color contrast, readable text, and other accessibility requirements. Informative visuals should not be marked as decorative; the next section shows how to check `isDecorative`.
## **Mark as Decorative**
Mark as decorative flags purely ornamental visuals so screen readers skip them, reducing noise and keeping focus on meaningful content. Apply it to backgrounds, flourishes, and spacers—never to charts, icons, or images that convey information. Aspose.Slides exposes this flag for detection and validation, enabling automated accessibility checks and cleanup.

The following code sample shows how to determine whether a shape is marked as decorative.
```php
use aspose\slides\Presentation;
$presentation = new Presentation("sample.pptx");
try {
$shape = $presentation->getSlides()->get_Item(0)->getShapes()->get_Item(0);
echo "Is shape decorative: " . (java_values($shape->isDecorative()) ? "true" : "false") . PHP_EOL;
} finally {
$presentation->dispose();
}
```
## **FAQ**
**What should I put in the alternative text title and description?**
Use a short title to identify the subject and a description to explain the information the visual conveys in the context of the slide. For a chart, describe the relevant trend or comparison rather than only saying "chart."
**Should I use alternative text to locate shapes in a template?**
Prefer finding the shape by the name returned by [getName](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getname/) and checking that it is the expected shape. Alternative text may be edited or translated, which can break code that searches for an exact description; see [Identify and Find Shapes](https://docs.aspose.com/slides/php-java/shape-manipulations/).
**When should a shape be marked as decorative?**
Use the decorative flag for visuals that add no information, such as ornamental flourishes. Images and charts that communicate meaning need an appropriate description instead.
**Does adding alternative text make a presentation fully accessible?**
No. Alternative text addresses only part of accessibility. Also review reading order, color contrast, text readability, and other applicable requirements; setting these properties alone does not establish compliance.
# Manage Presentation Backgrounds in PHP
> Learn how to set dynamic backgrounds in PowerPoint and OpenDocument files using Aspose.Slides for PHP via Java, with code tips to boost your presentations.
Source: https://docs.aspose.com/slides/php-java/presentation-background/
Updated: 2026-08-13
## **Introduction**
Solid colors, gradients, and images are commonly used for slide backgrounds. You can set the background for a **normal slide** (a single slide) or a **master slide** (applies to multiple slides at once).

## **Set a Solid Color Background for a Normal Slide**
Aspose.Slides allows you to set a solid color as the background for a specific slide in a presentation—even if the presentation uses a master slide. The change applies only to the selected slide.
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
2. Set the slide’s [BackgroundType](https://reference.aspose.com/slides/php-java/aspose.slides/backgroundtype/) to `OwnBackground`.
3. Set the slide background [FillType](https://reference.aspose.com/slides/php-java/aspose.slides/filltype/) to `Solid`.
4. Use the [getSolidFillColor](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/#getSolidFillColor) method on [FillFormat](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/) to specify the solid background color.
5. Save the modified presentation.
The following PHP example shows how to set a blue solid color as the background for a normal slide:
```php
// Create an instance of the Presentation class.
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
// Set the background color of the slide to blue.
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLUE);
// Save the presentation to disk.
$presentation->save("SolidColorBackground.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Set a Solid Color Background for a Master Slide**
Aspose.Slides allows you to set a solid color as the background for the master slide in a presentation. The master slide acts as a template that controls formatting for all slides, so when you choose a solid color for the master slide’s background, it applies to every slide.
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
2. Set the master slide’s [BackgroundType](https://reference.aspose.com/slides/php-java/aspose.slides/backgroundtype/) (via `getMasters`) to `OwnBackground`.
3. Set the master slide background [FillType](https://reference.aspose.com/slides/php-java/aspose.slides/filltype/) to `Solid`.
4. Use the [getSolidFillColor](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/#getSolidFillColor) method to specify the solid background color.
5. Save the modified presentation.
The following PHP example shows how to set a solid color (green) as the background for a master slide:
```php
// Create an instance of the Presentation class.
$presentation = new Presentation();
try {
$masterSlide = $presentation->getMasters()->get_Item(0);
// Set the background color for the Master slide to Forest Green.
$masterSlide->getBackground()->setType(BackgroundType::OwnBackground);
$masterSlide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$masterSlide->getBackground()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->GREEN);
// Save the presentation to disk.
$presentation->save("MasterSlideBackground.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Set a Gradient Background for a Slide**
A gradient is a graphical effect created by a gradual change in color. When used as a slide background, gradients can make presentations look more artistic and professional. Aspose.Slides allows you to set a gradient color as the background for slides.
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
2. Set the slide’s [BackgroundType](https://reference.aspose.com/slides/php-java/aspose.slides/backgroundtype/) to `OwnBackground`.
3. Set the slide background [FillType](https://reference.aspose.com/slides/php-java/aspose.slides/filltype/) to `Gradient`.
4. Use the [getGradientFormat](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/#getGradientFormat) method on [FillFormat](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/) to configure your preferred gradient settings.
5. Save the modified presentation.
The following PHP example shows how to set a gradient color as the background for a slide:
```php
// Create an instance of the Presentation class.
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
// Apply a gradient effect to the background.
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$slide->getBackground()->getFillFormat()->setFillType(FillType::Gradient);
$slide->getBackground()->getFillFormat()->getGradientFormat()->setTileFlip(TileFlip::FlipBoth);
// Save the presentation to disk.
$presentation->save("GradientBackground.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Set an Image as a Slide Background**
In addition to solid and gradient fills, Aspose.Slides allows you to use images as slide backgrounds.
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
2. Set the slide’s [BackgroundType](https://reference.aspose.com/slides/php-java/aspose.slides/backgroundtype/) to `OwnBackground`.
3. Set the slide background [FillType](https://reference.aspose.com/slides/php-java/aspose.slides/filltype/) to `Picture`.
4. Load the image you want to use as the slide background.
5. Add the image to the presentation’s image collection.
6. Use the [getPictureFillFormat](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/#getPictureFillFormat) method on [FillFormat](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/) to assign the image as the background.
7. Save the modified presentation.
The following PHP example shows how to set an image as the background for a slide:
```php
// Create an instance of the Presentation class.
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
// Set background image properties.
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$slide->getBackground()->getFillFormat()->setFillType(FillType::Picture);
$slide->getBackground()->getFillFormat()->getPictureFillFormat()->setPictureFillMode(PictureFillMode::Stretch);
// Load the image.
$image = Images::fromFile("Tulips.jpg");
// Add the image to the presentation's image collection.
$ppImage = $presentation->getImages()->addImage($image);
$image->dispose();
$slide->getBackground()->getFillFormat()->getPictureFillFormat()->getPicture()->setImage($ppImage);
// Save the presentation to disk.
$presentation->save("ImageAsBackground.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The following code sample shows how to set the background fill type to a tiled picture and modify the tiling properties:
```php
$presentation = new Presentation();
try {
$firstSlide = $presentation->getSlides()->get_Item(0);
$background = $firstSlide->getBackground();
$background->setType(BackgroundType::OwnBackground);
$background->getFillFormat()->setFillType(FillType::Picture);
$newImage = Images::fromFile("image.png");
$ppImage = $presentation->getImages()->addImage($newImage);
$newImage->dispose();
// Set the image used for the background fill.
$backPictureFillFormat = $background->getFillFormat()->getPictureFillFormat();
$backPictureFillFormat->getPicture()->setImage($ppImage);
// Set the picture fill mode to Tile and adjust the tile properties.
$backPictureFillFormat->setPictureFillMode(PictureFillMode::Tile);
$backPictureFillFormat->setTileOffsetX(15);
$backPictureFillFormat->setTileOffsetY(15);
$backPictureFillFormat->setTileScaleX(46);
$backPictureFillFormat->setTileScaleY(87);
$backPictureFillFormat->setTileAlignment(RectangleAlignment::Center);
$backPictureFillFormat->setTileFlip(TileFlip::FlipY);
$presentation->save("TileBackground.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Read more: [**Tile Picture As Texture**](https://docs.aspose.com/slides/php-java/shape-formatting/#tile-picture-as-texture).
### **Change the Background Image Transparency**
You may want to adjust the transparency of a slide's background image to make the contents of the slide stand out. The following PHP code shows you how to change the transparency for a slide background image:
```php
$presentation = new Presentation("ImageAsBackground.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$transparencyValue = 30; // For example.
// Get the collection of picture transform operations.
$imageTransform = $slide->getBackground()->getFillFormat()->getPictureFillFormat()->getPicture()->getImageTransform();
// Find an existing fixed-percentage transparency effect.
$transparencyOperation = null;
foreach($imageTransform as $operation) {
if (java_instanceof($operation, new JavaClass("com.aspose.slides.AlphaModulateFixed"))) {
$transparencyOperation = $operation;
break;
}
}
// Set the new transparency value.
if (java_is_null($transparencyOperation)) {
$imageTransform->addAlphaModulateFixedEffect(100 - $transparencyValue);
} else {
$transparencyOperation->setAmount(100 - $transparencyValue);
}
$presentation->save("TransparentBackground.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Get the Slide Background Value**
Aspose.Slides provides the `BackgroundEffectiveData`class for retrieving a slide’s effective background values. This class exposes the effective [FillFormat](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/) and [EffectFormat](https://reference.aspose.com/slides/php-java/aspose.slides/effectformat/).
Using the [BaseSlide](https://reference.aspose.com/slides/php-java/aspose.slides/baseslide/) class’s `getBackground` method, you can obtain the effective background for a slide.
The following PHP example shows how to get a slide’s effective background value:
```php
// Create an instance of the Presentation class.
$presentation = new Presentation("Sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Retrieve the effective background, taking into account master, layout, and theme.
$effBackground = $slide->getBackground()->getEffective();
if ($effBackground->getFillFormat()->getFillType() == FillType::Solid)
echo "Fill color: " . $effBackground->getFillFormat()->getSolidFillColor() . "\n";
else
echo "Fill type: " . $effBackground->getFillFormat()->getFillType() . "\n";
} finally {
$presentation->dispose();
}
```
## **FAQ**
### Can I reset a custom background and restore the theme/layout background?
Yes. Remove the slide’s custom fill, and the background will be inherited again from the corresponding [layout](https://docs.aspose.com/slides/php-java/slide-layout/)/[master](https://docs.aspose.com/slides/php-java/slide-master/) slide (i.e., the [theme background](https://docs.aspose.com/slides/php-java/presentation-theme/)).
### What happens to the background if I change the presentation’s theme later?
If a slide has its own fill, it will remain unchanged. If the background is inherited from the [layout](https://docs.aspose.com/slides/php-java/slide-layout/)/[master](https://docs.aspose.com/slides/php-java/slide-master/), it will update to match the [new theme](https://docs.aspose.com/slides/php-java/presentation-theme/).
## Related articles
- [Format PowerPoint Shapes in PHP](https://docs.aspose.com/slides/php-java/shape-formatting/)
# Manage Presentation Comments in PHP
> Manage presentation comments with Aspose.Slides for PHP via Java: add, read, edit, reply to, and remove comments in PowerPoint presentations quickly and easily.
Source: https://docs.aspose.com/slides/php-java/presentation-comments/
Updated: 2026-11-08
## **Overview**
This article explains how to manage presentation comments with Aspose.Slides for PHP via Java. It introduces the main comment-related types and demonstrates how to add comments to slides, access existing comments, work with replies and modern comments, and remove comments from a presentation.
The examples cover common review and collaboration scenarios in PowerPoint, such as assigning comments to authors, reading comment text and metadata, building reply chains, and removing selected comments or all comments.
In PowerPoint, comments appear as annotations on slides. Selecting a comment displays its text and related discussion.
To request that comments be shown or hidden when a presentation opens without changing the comments themselves, see [Show or Hide Comments When Opening a Presentation](https://docs.aspose.com/slides/php-java/presentation-view-properties/).
## **Why Add Comments to Presentations?**
You can use comments to provide feedback and collaborate with colleagues when reviewing presentations.
Aspose.Slides for PHP via Java provides the following APIs for working with comments:
* The [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class, which provides access to the presentation's comment authors.
* The [CommentCollection](https://reference.aspose.com/slides/php-java/aspose.slides/commentcollection/) class, which represents the comments associated with an individual author.
* The [Comment](https://reference.aspose.com/slides/php-java/aspose.slides/comment/) class, which provides information about a comment, including its author, creation time, position, and text.
* The [CommentAuthor](https://reference.aspose.com/slides/php-java/aspose.slides/commentauthor/) class, which provides information about an author, including their name, initials, and associated comments.
## **Add Slide Comments**
The example creates two slides and registers a comment author with [addAuthor](https://reference.aspose.com/slides/php-java/aspose.slides/commentauthorcollection/addauthor/). It uses [addComment](https://reference.aspose.com/slides/php-java/aspose.slides/commentcollection/addcomment/) to place one comment on each slide, then retrieves the first slide's comments for that author with [getSlideComments](https://reference.aspose.com/slides/php-java/aspose.slides/slide/getslidecomments/). The console displays the first comment's text twice, demonstrating access through both the slide and the author, and the saved presentation contains both comments.
```php
use aspose\slides\Point2DFloat;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$firstSlide = $presentation->getSlides()->get_Item(0);
$secondSlide = $presentation->getSlides()->addEmptySlide($presentation->getLayoutSlides()->get_Item(0));
$author = $presentation->getCommentAuthors()->addAuthor("Jawad", "MF");
$position = new Point2DFloat(0.2, 0.2);
$createdTime = new Java("java.util.Date");
$author->getComments()->addComment("Hello Jawad, this is a slide comment", $firstSlide, $position, $createdTime);
$author->getComments()->addComment("Hello Jawad, this is the second slide comment", $secondSlide, $position, $createdTime);
$comments = $firstSlide->getSlideComments($author);
$arrayClass = new JavaClass("java.lang.reflect.Array");
$commentCount = java_values($arrayClass->getLength($comments));
if ($commentCount > 0) {
$firstComment = $comments[0];
echo java_values($firstComment->getText()) . PHP_EOL;
$authorComments = $firstComment->getAuthor()->getComments();
$commentText = $authorComments->get_Item(0)->getText();
echo java_values($commentText) . PHP_EOL;
}
$presentation->save("Comments_out.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Find or Create a Comment Author**
When an automated review processes the same presentation repeatedly, search the collection returned by [getCommentAuthors](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/getcommentauthors/) before adding an author. [findByNameAndInitials](https://reference.aspose.com/slides/php-java/aspose.slides/commentauthorcollection/findbynameandinitials/) matches both the name and initials and returns an array of matching authors, or an empty array if no matches exist. In contrast, [findByName](https://reference.aspose.com/slides/php-java/aspose.slides/commentauthorcollection/findbyname/) searches by name alone, regardless of initials. Calling [addAuthor](https://reference.aspose.com/slides/php-java/aspose.slides/commentauthorcollection/addauthor/) with a name and initials already present in the collection throws an exception.
The example requires a presentation file with at least one slide. On each of two passes, it reuses the first matching author, or creates one only when the result is empty. If there are multiple matches, it selects the first array element without merging or removing the other authors. It then calls [addComment](https://reference.aspose.com/slides/php-java/aspose.slides/commentcollection/addcomment/) for the selected author and saves the presentation. The second pass opens the first pass's output and repeats the operation.
```php
use aspose\slides\Point2DFloat;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$authorName = "Reviewer";
$authorInitials = "RV";
$inputFile = "input.pptx";
$position = new Point2DFloat(20, 20);
$arrayClass = new JavaClass("java.lang.reflect.Array");
for ($pass = 1; $pass <= 2; $pass++) {
$presentation = new Presentation($inputFile);
try {
$matches = $presentation->getCommentAuthors()->findByNameAndInitials($authorName, $authorInitials);
$matchCount = java_values($arrayClass->getLength($matches));
$author = $matchCount > 0 ? $matches[0] : $presentation->getCommentAuthors()->addAuthor($authorName, $authorInitials);
$createdTime = new Java("java.util.Date");
$author->getComments()->addComment("Please review this slide.", $presentation->getSlides()->get_Item(0), $position, $createdTime);
$outputFile = "review_pass_" . $pass . ".pptx";
$presentation->save($outputFile, SaveFormat::Pptx);
$inputFile = $outputFile;
} finally {
$presentation->dispose();
}
}
```
The second pass adds another comment without adding another author or removing existing comments. The final file, `review_pass_2.pptx`, contains both new comments alongside any original comments. Reusing an author does not deduplicate comments: to avoid repeatedly adding the same comment, implement separate duplicate detection before adding it.
## **Access Slide Comments**
The example opens an existing presentation and reads the collection returned by [getCommentAuthors](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/getcommentauthors/). For each author, it iterates through the collection returned by [getComments](https://reference.aspose.com/slides/php-java/aspose.slides/commentauthor/getcomments/) and prints the slide number, comment text, author name, and creation time. The input presentation must contain comments to produce console output.
```php
use aspose\slides\Presentation;
$presentation = new Presentation("Comments1.pptx");
try {
foreach ($presentation->getCommentAuthors() as $author) {
foreach ($author->getComments() as $comment) {
echo "Slide: " . java_values($comment->getSlide()->getSlideNumber()) . PHP_EOL;
echo "Comment: " . java_values($comment->getText()) . PHP_EOL;
echo "Author: " . java_values($comment->getAuthor()->getName()) . PHP_EOL;
echo "Posted at: " . java_values($comment->getCreatedTime()->toString()) . PHP_EOL;
echo PHP_EOL;
}
}
} finally {
$presentation->dispose();
}
```
## **Reply to Comments**
A parent comment is the original comment at the top of a reply hierarchy. The [Comment::getParentComment](https://reference.aspose.com/slides/php-java/aspose.slides/comment/getparentcomment/) and [Comment::setParentComment](https://reference.aspose.com/slides/php-java/aspose.slides/comment/setparentcomment/) methods let you get or set the parent of a comment.
The example creates comments from two authors and uses [setParentComment](https://reference.aspose.com/slides/php-java/aspose.slides/comment/setparentcomment/) to build replies, including a reply to another reply. Passing `null` to [getSlideComments](https://reference.aspose.com/slides/php-java/aspose.slides/slide/getslidecomments/) retrieves comments from all authors; the console indents each entry according to its depth in the reply hierarchy. The example saves the complete discussion, calls [remove](https://reference.aspose.com/slides/php-java/aspose.slides/comment/remove/) on the first root comment, and saves a second presentation with that comment and its replies removed.
```php
use aspose\slides\Point2DFloat;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$position = new Point2DFloat(10, 10);
$createdTime = new Java("java.util.Date");
$author1 = $presentation->getCommentAuthors()->addAuthor("Author_1", "A.A.");
$comment1 = $author1->getComments()->addComment("comment 1", $slide, $position, $createdTime);
$author2 = $presentation->getCommentAuthors()->addAuthor("Author_2", "B.B.");
$reply1 = $author2->getComments()->addComment("reply 1 for comment 1", $slide, $position, $createdTime);
$reply1->setParentComment($comment1);
$reply2 = $author2->getComments()->addComment("reply 2 for comment 1", $slide, $position, $createdTime);
$reply2->setParentComment($comment1);
$subReply = $author1->getComments()->addComment("subreply 3 for reply 2", $slide, $position, $createdTime);
$subReply->setParentComment($reply2);
$author2->getComments()->addComment("comment 2", $slide, $position, $createdTime);
$comment3 = $author2->getComments()->addComment("comment 3", $slide, $position, $createdTime);
$reply3 = $author1->getComments()->addComment("reply 4 for comment 3", $slide, $position, $createdTime);
$reply3->setParentComment($comment3);
$comments = $slide->getSlideComments(null);
$arrayClass = new JavaClass("java.lang.reflect.Array");
$commentCount = java_values($arrayClass->getLength($comments));
for ($i = 0; $i < $commentCount; $i++) {
$comment = $comments[$i];
while (!java_is_null($comment->getParentComment())) {
echo "\t";
$comment = $comment->getParentComment();
}
echo java_values($comments[$i]->getAuthor()->getName()) . ": " . java_values($comments[$i]->getText()) . PHP_EOL;
}
$presentation->save("parent_comment.pptx", SaveFormat::Pptx);
$comment1->remove();
$presentation->save("remove_comment.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
* When the [Comment::remove](https://reference.aspose.com/slides/php-java/aspose.slides/comment/remove/) method is used to delete a comment, all replies to that comment are also deleted.
* If [Comment::setParentComment](https://reference.aspose.com/slides/php-java/aspose.slides/comment/setparentcomment/) creates a circular reference, a [PptxEditException](https://reference.aspose.com/slides/php-java/aspose.slides/pptxeditexception/) is thrown.
## **Add Modern Comments**
Modern comments can be associated with the slide itself, with a specific shape, or with a text range inside an AutoShape. The [CommentCollection::addModernComment](https://reference.aspose.com/slides/php-java/aspose.slides/commentcollection/addmoderncomment/) method accepts a [Shape](https://reference.aspose.com/slides/php-java/aspose.slides/shape/) argument in addition to the slide and comment-marker coordinates.
When `null` is passed for the shape argument, the comment is a slide-level comment. Its marker is positioned by the supplied coordinates, but it is not associated with a particular shape, so [ModernComment::getShape](https://reference.aspose.com/slides/php-java/aspose.slides/moderncomment/getshape/) returns `null`. When a [Shape](https://reference.aspose.com/slides/php-java/aspose.slides/shape/) is supplied, the comment is anchored to that shape. The coordinates still define the position of the comment marker on the slide, while the shape association can be retrieved through [ModernComment::getShape](https://reference.aspose.com/slides/php-java/aspose.slides/moderncomment/getshape/).
### **Anchor a Modern Comment to a Shape**
The example calls [addModernComment](https://reference.aspose.com/slides/php-java/aspose.slides/commentcollection/addmoderncomment/) twice: once with a `null` shape for a slide-level comment and once with a rectangle as the anchor. Reading [getShape](https://reference.aspose.com/slides/php-java/aspose.slides/moderncomment/getshape/) prints `true` for the slide-level comment's null check and `Revenue title` for the anchored comment. Both comments are saved with the presentation.
```php
use aspose\slides\Point2DFloat;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$author = $presentation->getCommentAuthors()->addAuthor("Reviewer", "RV");
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 300, 80);
$shape->setName("Revenue title");
$shape->getTextFrame()->setText("Quarterly revenue");
$createdTime = new Java("java.util.Date");
$slideCommentPosition = new Point2DFloat(20, 20);
$shapeCommentPosition = new Point2DFloat(60, 60);
$slideComment = $author->getComments()->addModernComment("Review the overall slide layout.", $slide, null, $slideCommentPosition, $createdTime);
$shapeComment = $author->getComments()->addModernComment("Check this title.", $slide, $shape, $shapeCommentPosition, $createdTime);
echo (java_is_null($slideComment->getShape()) ? "true" : "false") . PHP_EOL;
echo java_values($shapeComment->getShape()->getName()) . PHP_EOL;
$presentation->save("modern_comments.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Anchor Comments to Different Shape Types**
Any slide object represented by the [Shape](https://reference.aspose.com/slides/php-java/aspose.slides/shape/) class can be used as a shape anchor. Common examples include [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/), [PictureFrame](https://reference.aspose.com/slides/php-java/aspose.slides/pictureframe/), [GroupShape](https://reference.aspose.com/slides/php-java/aspose.slides/groupshape/), [Connector](https://reference.aspose.com/slides/php-java/aspose.slides/connector/), and [GraphicalObject](https://reference.aspose.com/slides/php-java/aspose.slides/graphicalobject/) instances such as charts.
The example uses [addModernComment](https://reference.aspose.com/slides/php-java/aspose.slides/commentcollection/addmoderncomment/) to associate a comment with each of five shape types: an AutoShape, a picture frame, a group, a connector, and a chart. The picture uses embedded image data, so no external image is required. Each comment has its own marker position, and the saved presentation retains all five shape associations.
```php
use aspose\slides\ChartType;
use aspose\slides\Point2DFloat;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$author = $presentation->getCommentAuthors()->addAuthor("Reviewer", "RV");
$createdTime = new Java("java.util.Date");
$autoShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 20, 180, 60);
$autoShape->getTextFrame()->setText("AutoShape");
$autoShapeCommentPosition = new Point2DFloat(30, 30);
$author->getComments()->addModernComment("Comment on an AutoShape.", $slide, $autoShape, $autoShapeCommentPosition, $createdTime);
$imageBase64 = "iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAAFklEQVR4nGP8//8/AwMDEwMDAwMDAwAkBgMB/DXemwAAAABJRU5ErkJggg==";
$base64Class = new JavaClass("java.util.Base64");
$imageData = $base64Class->getDecoder()->decode($imageBase64);
$image = $presentation->getImages()->addImage($imageData);
$pictureFrame = $slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 220, 20, 120, 80, $image);
$pictureCommentPosition = new Point2DFloat(230, 30);
$author->getComments()->addModernComment("Comment on a picture.", $slide, $pictureFrame, $pictureCommentPosition, $createdTime);
$groupShape = $slide->getShapes()->addGroupShape();
$groupShape->getShapes()->addAutoShape(ShapeType::Rectangle, 0, 0, 80, 40);
$groupShape->getShapes()->addAutoShape(ShapeType::Ellipse, 100, 0, 80, 40);
$groupCommentPosition = new Point2DFloat(40, 150);
$author->getComments()->addModernComment("Comment on a group.", $slide, $groupShape, $groupCommentPosition, $createdTime);
$connector = $slide->getShapes()->addConnector(ShapeType::StraightConnector1, 220, 150, 140, 40);
$connectorCommentPosition = new Point2DFloat(240, 150);
$author->getComments()->addModernComment("Comment on a connector.", $slide, $connector, $connectorCommentPosition, $createdTime);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 400, 20, 250, 180);
$chartCommentPosition = new Point2DFloat(420, 40);
$author->getComments()->addModernComment("Comment on a graphical object.", $slide, $chart, $chartCommentPosition, $createdTime);
$presentation->save("modern_comment_shape_types.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Anchor a Comment to Text and Set Its Status**
For a modern comment associated with an [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/), [ModernComment::getTextSelectionStart](https://reference.aspose.com/slides/php-java/aspose.slides/moderncomment/gettextselectionstart/) and [ModernComment::setTextSelectionStart](https://reference.aspose.com/slides/php-java/aspose.slides/moderncomment/settextselectionstart/) access the starting position of the selected text in the shape's text frame. [ModernComment::getTextSelectionLength](https://reference.aspose.com/slides/php-java/aspose.slides/moderncomment/gettextselectionlength/) and [ModernComment::setTextSelectionLength](https://reference.aspose.com/slides/php-java/aspose.slides/moderncomment/settextselectionlength/) access the length of the selection. Together, these values associate the comment with a specific text range inside the AutoShape.
The [ModernComment::getStatus](https://reference.aspose.com/slides/php-java/aspose.slides/moderncomment/getstatus/) and [ModernComment::setStatus](https://reference.aspose.com/slides/php-java/aspose.slides/moderncomment/setstatus/) methods access a value from the [ModernCommentStatus](https://reference.aspose.com/slides/php-java/aspose.slides/moderncommentstatus/) constants:
- `NotDefined` — no specific modern-comment status is defined.
- `Active` — the comment is active.
- `Resolved` — the comment has been resolved.
- `Closed` — the comment is closed.
The example anchors a modern comment to the words "quarterly revenue" in a rectangle's text. It calculates the zero-based selection start from the text and passes it to [setTextSelectionStart](https://reference.aspose.com/slides/php-java/aspose.slides/moderncomment/settextselectionstart/) and uses [setTextSelectionLength](https://reference.aspose.com/slides/php-java/aspose.slides/moderncomment/settextselectionlength/) to set the number of selected characters. After calling [setStatus](https://reference.aspose.com/slides/php-java/aspose.slides/moderncomment/setstatus/) with `Resolved`, it saves and reopens the presentation. The four console checks should each print `true`, confirming that the shape anchor, text range, and status were preserved.
```php
use aspose\slides\ModernCommentStatus;
use aspose\slides\Point2DFloat;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$outputFile = "modern_comment_text_anchor.pptx";
$shapeText = "Review the quarterly revenue forecast.";
$selectedText = "quarterly revenue";
$expectedSelectionStart = strpos($shapeText, $selectedText);
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 400, 100);
$shape->setName("Forecast text");
$shape->getTextFrame()->setText($shapeText);
$author = $presentation->getCommentAuthors()->addAuthor("Reviewer", "RV");
$commentPosition = new Point2DFloat(60, 60);
$comment = $author->getComments()->addModernComment("Verify this forecast wording.", $slide, $shape, $commentPosition, new Java("java.util.Date"));
$comment->setTextSelectionStart($expectedSelectionStart);
$comment->setTextSelectionLength(strlen($selectedText));
$comment->setStatus(ModernCommentStatus::Resolved);
$presentation->save($outputFile, SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
$reopenedPresentation = new Presentation($outputFile);
try {
$reopenedSlide = $reopenedPresentation->getSlides()->get_Item(0);
$reopenedComments = $reopenedSlide->getSlideComments(null);
$modernCommentClass = new JavaClass("com.aspose.slides.ModernComment");
foreach ($reopenedComments as $reopenedComment) {
if (!java_instanceof($reopenedComment, $modernCommentClass)) {
continue;
}
$shape = $reopenedComment->getShape();
$shapeMatches = !java_is_null($shape) && java_values($shape->getName()) === "Forecast text";
$selectionStartMatches = java_values($reopenedComment->getTextSelectionStart()) === $expectedSelectionStart;
$selectionLengthMatches = java_values($reopenedComment->getTextSelectionLength()) === strlen($selectedText);
$statusMatches = java_values($reopenedComment->getStatus()) === ModernCommentStatus::Resolved;
echo "Shape anchor preserved: " . ($shapeMatches ? "true" : "false") . PHP_EOL;
echo "Text selection start preserved: " . ($selectionStartMatches ? "true" : "false") . PHP_EOL;
echo "Text selection length preserved: " . ($selectionLengthMatches ? "true" : "false") . PHP_EOL;
echo "Resolved status preserved: " . ($statusMatches ? "true" : "false") . PHP_EOL;
}
} finally {
$reopenedPresentation->dispose();
}
```
[](https://docs.aspose.com/slides/php-java/presentation-comments/visual-presentation-comments-94241d308643.svg)
*Schematic annotation of the example’s text range. A licensed .NET 26.11 save/reopen check retained the Forecast text anchor, start 11, length 17 and Resolved status. Marker coordinates are separate from the anchor; this figure does not depict a client comment pane.*
### **Inspect Existing Modern Comments**
The example requires an existing presentation containing modern comments and prints their text, status, and anchor details. To inspect it, check whether each comment is a [ModernComment](https://reference.aspose.com/slides/php-java/aspose.slides/moderncomment/), then examine [ModernComment::getShape](https://reference.aspose.com/slides/php-java/aspose.slides/moderncomment/getshape/), [ModernComment::getTextSelectionStart](https://reference.aspose.com/slides/php-java/aspose.slides/moderncomment/gettextselectionstart/), [ModernComment::getTextSelectionLength](https://reference.aspose.com/slides/php-java/aspose.slides/moderncomment/gettextselectionlength/), and [ModernComment::getStatus](https://reference.aspose.com/slides/php-java/aspose.slides/moderncomment/getstatus/). A `null` shape indicates a slide-level comment. For an [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/) anchor, the text-selection methods identify the associated range in the shape's text frame.
```php
use aspose\slides\Presentation;
$presentation = new Presentation("comments.pptx");
try {
$modernCommentClass = new JavaClass("com.aspose.slides.ModernComment");
$autoShapeClass = new JavaClass("com.aspose.slides.AutoShape");
foreach ($presentation->getSlides() as $slide) {
$comments = $slide->getSlideComments(null);
foreach ($comments as $comment) {
if (!java_instanceof($comment, $modernCommentClass)) {
continue;
}
echo "Slide: " . java_values($slide->getSlideNumber()) . PHP_EOL;
echo "Text: " . java_values($comment->getText()) . PHP_EOL;
echo "Status: " . java_values($comment->getStatus()) . PHP_EOL;
$shape = $comment->getShape();
if (java_is_null($shape)) {
echo "Anchor: slide level" . PHP_EOL;
} else {
echo "Anchor shape: " . java_values($shape->getName()) . PHP_EOL;
echo "Anchor type: " . java_values($shape->getClass()->getSimpleName()) . PHP_EOL;
if (java_instanceof($shape, $autoShapeClass)) {
echo "Text selection start: " . java_values($comment->getTextSelectionStart()) . PHP_EOL;
echo "Text selection length: " . java_values($comment->getTextSelectionLength()) . PHP_EOL;
}
}
echo PHP_EOL;
}
}
} finally {
$presentation->dispose();
}
```
## **Remove Comments**
Aspose.Slides for PHP via Java lets you remove all comments and their authors from a presentation or delete selected comments while keeping the rest. The following examples demonstrate both approaches and save the updated presentation.
### **Remove All Comments and Comment Authors**
The example opens an existing presentation and calls [CommentCollection::clear](https://reference.aspose.com/slides/php-java/aspose.slides/commentcollection/clear/) for each author, then calls [CommentAuthorCollection::clear](https://reference.aspose.com/slides/php-java/aspose.slides/commentauthorcollection/clear/) to remove the authors themselves. The saved presentation contains neither comments nor comment authors. Use a presentation containing comments to observe the removal.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("example.pptx");
try {
foreach ($presentation->getCommentAuthors() as $author) {
$author->getComments()->clear();
}
$presentation->getCommentAuthors()->clear();
$presentation->save("example_out.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Remove Specific Comments**
The example creates two comments on one slide and uses [getSlideComments](https://reference.aspose.com/slides/php-java/aspose.slides/slide/getslidecomments/) to find comments by each author. It collects comments whose text equals "comment 1" before calling [CommentCollection::remove](https://reference.aspose.com/slides/php-java/aspose.slides/commentcollection/remove/), avoiding changes to the collection during selection. The saved presentation retains only "comment 2".
```php
use aspose\slides\Point2DFloat;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$author = $presentation->getCommentAuthors()->addAuthor("Author", "A");
$createdTime = new Java("java.util.Date");
$firstCommentPosition = new Point2DFloat(0.2, 0.2);
$secondCommentPosition = new Point2DFloat(0.3, 0.2);
$author->getComments()->addComment("comment 1", $slide, $firstCommentPosition, $createdTime);
$author->getComments()->addComment("comment 2", $slide, $secondCommentPosition, $createdTime);
foreach ($presentation->getCommentAuthors() as $commentAuthor) {
$commentsToRemove = new Java("java.util.ArrayList");
$comments = $slide->getSlideComments($commentAuthor);
foreach ($comments as $comment) {
if ($comment->getText()->equals("comment 1")) {
$commentsToRemove->add($comment);
}
}
foreach ($commentsToRemove as $comment) {
$commentAuthor->getComments()->remove($comment);
}
}
$presentation->save("pres.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **FAQ**
**Does Aspose.Slides support a resolved status for modern comments?**
Yes. [ModernComment::getStatus](https://reference.aspose.com/slides/php-java/aspose.slides/moderncomment/getstatus/) and [ModernComment::setStatus](https://reference.aspose.com/slides/php-java/aspose.slides/moderncomment/setstatus/) access a [ModernCommentStatus](https://reference.aspose.com/slides/php-java/aspose.slides/moderncommentstatus/) value, including `Resolved`. The status is stored in the presentation and can be read again after the file is reopened.
**Are threaded discussions (reply chains) supported, and is there a nesting limit?**
Yes. Each comment can reference its [parent comment](https://reference.aspose.com/slides/php-java/aspose.slides/comment/getparentcomment/), enabling reply chains. The API does not define a specific nesting-depth limit.
**In what coordinate system is a comment marker's position defined on a slide?**
The marker position is defined by floating-point coordinates in the slide coordinate system, allowing you to place it precisely on the slide.
## Related articles
- [Comment](https://docs.aspose.com/slides/php-java/examples/elements/comment/)
# Manage Presentation Content in PHP
> Create, edit, and extract presentation content with Aspose.Slides for PHP via Java — get code examples for text, images, shapes, charts; PPT, PPTX and ODP.
Source: https://docs.aspose.com/slides/php-java/presentation-content/
Updated: 2025-11-30
---
lastmod: 2025-11-30T13:47:17+04:00
title: Manage Presentation Content in PHP
linktitle: Presentation Content
type: docs
weight: 30
url: /php-java/presentation-content/
keywords:
- content
- BLOB
- hyperlink
- media
- OLE
- text
- zoom
- chart
- equation
- shape
- ink
- SmartArt
- table
- PowerPoint
- OpenDocument
- presentation
- PHP
- Aspose.Slides
description: "Create, edit, and extract presentation content with Aspose.Slides for PHP via Java — get code examples for text, images, shapes, charts; PPT, PPTX and ODP."
---
## Related articles
- [OleObject](https://docs.aspose.com/slides/php-java/examples/elements/ole-object/)
- [Ink](https://docs.aspose.com/slides/php-java/examples/elements/ink/)
- [Hyperlink](https://docs.aspose.com/slides/php-java/examples/elements/hyperlink/)
# Design Professional Presentations in PHP
> Boost your slides with Aspose.Slides for PHP via Java — design, automate, and convert PowerPoint and OpenDocument presentations effortlessly. Learn more now!
Source: https://docs.aspose.com/slides/php-java/presentation-design/
Updated: 2025-11-30
---
lastmod: 2025-11-30T13:47:17+04:00
title: Design Professional Presentations in PHP
linktitle: Presentation Design
type: docs
weight: 40
url: /php-java/presentation-design/
keywords:
- PowerPoint design
- OpenDocument design
- presentation design
- slide design
- PPT design
- PPTX design
- ODP design
- PowerPoint
- OpenDocument
- presentation
- PHP
- Aspose.Slides
description: "Boost your slides with Aspose.Slides for PHP via Java — design, automate, and convert PowerPoint and OpenDocument presentations effortlessly. Learn more now!"
---
# Manage Presentation Headers and Footers in PHP
> Learn how to manage footer, date-time, slide-number, and header placeholders on slides, notes pages, and handouts with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/presentation-header-and-footer/
Updated: 2026-11-08
## **Overview**
PowerPoint uses different header and footer placeholders depending on the page type. Aspose.Slides for PHP via Java lets you control the text and visibility of these placeholders through header/footer manager classes.
The available placeholders depend on the scope:
| Scope | Header | Footer | Date/time | Slide/page number |
|---|---|---|---|---|
| Regular slide | No | Yes | Yes | Yes |
| Notes master | Yes | Yes | Yes | Yes |
| Notes slide | Yes | Yes | Yes | Yes |
| Handout master | Yes | Yes | Yes | Yes |
A regular presentation slide does not have a header placeholder. Headers are available on notes pages and handouts. For regular slides, use footer, date/time, and slide-number placeholders instead.
The scope of a change depends on the manager you use. The [SlideHeaderFooterManager](https://reference.aspose.com/slides/php-java/aspose.slides/slideheaderfootermanager/) class controls one regular slide. The [NotesSlideHeaderFooterManager](https://reference.aspose.com/slides/php-java/aspose.slides/notesslideheaderfootermanager/) class controls one notes slide. Master and layout managers can also propagate settings to dependent slides, while the [MasterHandoutSlideHeaderFooterManager](https://reference.aspose.com/slides/php-java/aspose.slides/masterhandoutslideheaderfootermanager/) class controls the handout master.
## **Update Header, Footer, and Date/Time Text Across a Presentation**
Use the [Presentation::getHeaderFooterManager](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/getheaderfootermanager/) method to access [PresentationHeaderFooterManager](https://reference.aspose.com/slides/php-java/aspose.slides/presentationheaderfootermanager/) and apply consistent text across a presentation without updating each page or master individually.
| Method | Affected objects |
|---|---|
| [setAllHeadersText](https://reference.aspose.com/slides/php-java/aspose.slides/presentationheaderfootermanager/setallheaderstext/) | Existing notes pages, notes master, and handout master |
| [setAllFootersText](https://reference.aspose.com/slides/php-java/aspose.slides/presentationheaderfootermanager/setallfooterstext/) | Regular slides, layouts, slide masters, existing notes pages, notes master, and handout master |
| [setAllDateTimesText](https://reference.aspose.com/slides/php-java/aspose.slides/presentationheaderfootermanager/setalldatetimestext/) | Regular slides, layouts, slide masters, existing notes pages, notes master, and handout master |
Headers apply only to notes pages and handouts; regular slides do not support header placeholders. Handout settings are updated through the handout master.
Setting text does not make a placeholder visible. First use [setAllHeadersVisibility](https://reference.aspose.com/slides/php-java/aspose.slides/presentationheaderfootermanager/setallheadersvisibility/), [setAllFootersVisibility](https://reference.aspose.com/slides/php-java/aspose.slides/presentationheaderfootermanager/setallfootersvisibility/), and [setAllDateTimesVisibility](https://reference.aspose.com/slides/php-java/aspose.slides/presentationheaderfootermanager/setalldatetimesvisibility/) to enable the corresponding placeholders, then set their text. These visibility methods have the same scope as the corresponding text methods.
The following example assumes that a presentation contains regular slides, notes pages, a notes master, and a handout master. It applies corporate text and a fixed date label, then saves the result.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("presentation.pptx");
try {
$manager = $presentation->getHeaderFooterManager();
$manager->setAllHeadersVisibility(true);
$manager->setAllFootersVisibility(true);
$manager->setAllDateTimesVisibility(true);
$manager->setAllHeadersText("Contoso");
$manager->setAllFootersText("Internal use only");
$manager->setAllDateTimesText("October 2026");
$presentation->save("updated.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The text methods skip missing placeholders. Enabling visibility first creates the required placeholders on existing pages and masters. Neither the text methods nor the visibility methods create missing notes pages, notes masters, or handout masters. The date/time text is a fixed label, not an automatically updating date/time field.
For narrower changes, see the examples for [regular slides](https://docs.aspose.com/slides/php-java/presentation-header-and-footer/#set-footer-datetime-and-slide-numbers-on-regular-slides), the [notes master](https://docs.aspose.com/slides/php-java/presentation-header-and-footer/#set-headers-and-footers-on-the-notes-master), an [individual notes page](https://docs.aspose.com/slides/php-java/presentation-header-and-footer/#set-headers-and-footers-on-an-individual-notes-slide), and the [handout master](https://docs.aspose.com/slides/php-java/presentation-header-and-footer/#set-headers-and-footers-on-the-handout-master). See [Presentation Notes](https://docs.aspose.com/slides/php-java/presentation-notes/) for removing notes and managing notes masters.
## **Set Footer, Date/Time, and Slide Numbers on Regular Slides**
For regular slides, the basic workflow is to access each slide's header/footer manager, set the footer and date/time text, enable the required placeholders, and save the presentation. Slide numbers are generated by the presentation, so you only need to control their visibility.
Use [setFooterText](https://reference.aspose.com/slides/java/com.aspose.slides/baseslideheaderfootermanager/#setFooterText-java.lang.String-) and [setDateTimeText](https://reference.aspose.com/slides/java/com.aspose.slides/baseslideheaderfootermanager/#setDateTimeText-java.lang.String-) to set text, and use [setFooterVisibility](https://reference.aspose.com/slides/java/com.aspose.slides/baseslideheaderfootermanager/#setFooterVisibility-boolean-), [setDateTimeVisibility](https://reference.aspose.com/slides/java/com.aspose.slides/baseslideheaderfootermanager/#setDateTimeVisibility-boolean-), and [setSlideNumberVisibility](https://reference.aspose.com/slides/java/com.aspose.slides/baseslideheaderfootermanager/#setSlideNumberVisibility-boolean-) to show the corresponding placeholders.
The following end-to-end example applies the same footer, date/time text, and slide-number visibility to all regular slides:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("presentation.pptx");
try {
foreach ($presentation->getSlides() as $slide) {
$headerFooterManager = $slide->getHeaderFooterManager();
$headerFooterManager->setFooterText("Company Confidential");
$headerFooterManager->setFooterVisibility(true);
$headerFooterManager->setDateTimeText("Date and time text");
$headerFooterManager->setDateTimeVisibility(true);
$headerFooterManager->setSlideNumberVisibility(true);
}
$presentation->save("presentation_with_slide_footers.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
If you need to update only one slide, access that slide directly through the [getSlides](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/getslides/) method instead of iterating through the entire collection.
## **Set Headers and Footers on the Notes Master**
The notes master defines common formatting and placeholder behavior for notes pages. Use the [MasterNotesSlideHeaderFooterManager](https://reference.aspose.com/slides/php-java/aspose.slides/masternotesslideheaderfootermanager/) class when you want to change only the notes master itself.
The following example sets header, footer, and date/time text on the notes master and makes all supported placeholders visible on that master:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("presentation.pptx");
try {
$masterNotesSlide = $presentation->getMasterNotesSlideManager()->getMasterNotesSlide();
if (!java_is_null($masterNotesSlide)) {
$headerFooterManager = $masterNotesSlide->getHeaderFooterManager();
$headerFooterManager->setHeaderText("Notes header");
$headerFooterManager->setHeaderVisibility(true);
$headerFooterManager->setFooterText("Notes footer");
$headerFooterManager->setFooterVisibility(true);
$headerFooterManager->setDateTimeText("Date and time text");
$headerFooterManager->setDateTimeVisibility(true);
$headerFooterManager->setSlideNumberVisibility(true);
}
$presentation->save("presentation_with_notes_master_footers.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The [getMasterNotesSlide](https://reference.aspose.com/slides/java/com.aspose.slides/imasternotesslidemanager/#getMasterNotesSlide--) method returns `null` when the presentation does not contain a notes master. To clean up a template without notes pages, see [Remove an Unused Notes Master](https://docs.aspose.com/slides/php-java/presentation-notes/#remove-an-unused-notes-master).
## **Apply Notes Master Settings to Child Notes Slides**
A notes master can apply header and footer settings to itself and to all dependent notes slides. Use the dedicated propagation methods on [MasterNotesSlideHeaderFooterManager](https://reference.aspose.com/slides/php-java/aspose.slides/masternotesslideheaderfootermanager/) when the same settings should be applied across the notes hierarchy.
For example, [setHeaderAndChildHeadersText](https://reference.aspose.com/slides/php-java/aspose.slides/masternotesslideheaderfootermanager/setheaderandchildheaderstext/) and [setHeaderAndChildHeadersVisibility](https://reference.aspose.com/slides/php-java/aspose.slides/masternotesslideheaderfootermanager/setheaderandchildheadersvisibility/) update the notes master header and all child headers. Equivalent methods are available for footers, date/time, and slide numbers.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("presentation.pptx");
try {
$masterNotesSlide = $presentation->getMasterNotesSlideManager()->getMasterNotesSlide();
if (!java_is_null($masterNotesSlide)) {
$headerFooterManager = $masterNotesSlide->getHeaderFooterManager();
$headerFooterManager->setHeaderAndChildHeadersText("Notes header");
$headerFooterManager->setHeaderAndChildHeadersVisibility(true);
$headerFooterManager->setFooterAndChildFootersText("Notes footer");
$headerFooterManager->setFooterAndChildFootersVisibility(true);
$headerFooterManager->setDateTimeAndChildDateTimesText("Date and time text");
$headerFooterManager->setDateTimeAndChildDateTimesVisibility(true);
$headerFooterManager->setSlideNumberAndChildSlideNumbersVisibility(true);
}
$presentation->save("presentation_with_child_notes_footers.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The propagation methods used above are [setFooterAndChildFootersText](https://reference.aspose.com/slides/php-java/aspose.slides/masternotesslideheaderfootermanager/setfooterandchildfooterstext/), [setFooterAndChildFootersVisibility](https://reference.aspose.com/slides/php-java/aspose.slides/masternotesslideheaderfootermanager/setfooterandchildfootersvisibility/), [setDateTimeAndChildDateTimesText](https://reference.aspose.com/slides/php-java/aspose.slides/masternotesslideheaderfootermanager/setdatetimeandchilddatetimestext/), [setDateTimeAndChildDateTimesVisibility](https://reference.aspose.com/slides/php-java/aspose.slides/masternotesslideheaderfootermanager/setdatetimeandchilddatetimesvisibility/), and [setSlideNumberAndChildSlideNumbersVisibility](https://reference.aspose.com/slides/php-java/aspose.slides/masternotesslideheaderfootermanager/setslidenumberandchildslidenumbersvisibility/).
## **Set Headers and Footers on an Individual Notes Slide**
A notes slide belongs to a specific regular slide. Use its [NotesSlideHeaderFooterManager](https://reference.aspose.com/slides/php-java/aspose.slides/notesslideheaderfootermanager/) class when you want to customize only that notes page.
The [addNotesSlide](https://reference.aspose.com/slides/php-java/aspose.slides/notesslidemanager/addnotesslide/) method returns the notes slide for the current slide and creates one if it does not already exist. The following example configures the notes page associated with the first presentation slide:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("presentation.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$notesSlide = $slide->getNotesSlideManager()->addNotesSlide();
$headerFooterManager = $notesSlide->getHeaderFooterManager();
$headerFooterManager->setHeaderText("Header for the first notes page");
$headerFooterManager->setHeaderVisibility(true);
$headerFooterManager->setFooterText("Footer for the first notes page");
$headerFooterManager->setFooterVisibility(true);
$headerFooterManager->setDateTimeText("Date and time text");
$headerFooterManager->setDateTimeVisibility(true);
$headerFooterManager->setSlideNumberVisibility(true);
$presentation->save("presentation_with_custom_notes_footers.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
If you first propagate settings from the notes master and then change an individual notes slide, the later per-slide settings let you customize that notes page independently.
## **Set Headers and Footers on the Handout Master**
Handout pages use the handout master for their header, footer, date/time, and page-number placeholders. Unlike notes pages, handout settings are managed through the handout master rather than through individual handout slides.
Use the [getMasterHandoutSlide](https://reference.aspose.com/slides/java/com.aspose.slides/imasterhandoutslidemanager/#getMasterHandoutSlide--) method to access the handout master. If it is not present, call [setDefaultMasterHandoutSlide](https://reference.aspose.com/slides/java/com.aspose.slides/imasterhandoutslidemanager/#setDefaultMasterHandoutSlide--) to create the default handout master.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("presentation.pptx");
try {
$masterHandoutSlide = $presentation->getMasterHandoutSlideManager()->getMasterHandoutSlide();
if (java_is_null($masterHandoutSlide)) {
$masterHandoutSlide = $presentation->getMasterHandoutSlideManager()->setDefaultMasterHandoutSlide();
}
if (!java_is_null($masterHandoutSlide)) {
$headerFooterManager = $masterHandoutSlide->getHeaderFooterManager();
$headerFooterManager->setHeaderText("Handout header");
$headerFooterManager->setHeaderVisibility(true);
$headerFooterManager->setFooterText("Handout footer");
$headerFooterManager->setFooterVisibility(true);
$headerFooterManager->setDateTimeText("Date and time text");
$headerFooterManager->setDateTimeVisibility(true);
$headerFooterManager->setSlideNumberVisibility(true);
}
$presentation->save("presentation_with_handout_footers.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
To remove the entire handout master, including its formatting and placeholders, see [Remove a Handout Master](https://docs.aspose.com/slides/php-java/presentation-notes/#remove-a-handout-master). If you only need to hide a header or footer, change its visibility instead to preserve the master's other formatting.
## **Understand Scope and Inheritance**
Choose the header/footer manager that matches the scope you want to change:
- [PresentationHeaderFooterManager](https://reference.aspose.com/slides/php-java/aspose.slides/presentationheaderfootermanager/) updates supported placeholders throughout the presentation, as shown in the [presentation-wide example](https://docs.aspose.com/slides/php-java/presentation-header-and-footer/#update-header-footer-and-datetime-text-across-a-presentation).
- [SlideHeaderFooterManager](https://reference.aspose.com/slides/php-java/aspose.slides/slideheaderfootermanager/) changes footer, date/time, and slide-number settings for one regular slide.
- [LayoutSlideHeaderFooterManager](https://reference.aspose.com/slides/php-java/aspose.slides/layoutslideheaderfootermanager/) controls a layout slide and can propagate supported settings to dependent slides.
- [MasterSlideHeaderFooterManager](https://reference.aspose.com/slides/php-java/aspose.slides/masterslideheaderfootermanager/) controls a regular slide master and can propagate supported settings to dependent slides.
- [MasterNotesSlideHeaderFooterManager](https://reference.aspose.com/slides/php-java/aspose.slides/masternotesslideheaderfootermanager/) controls the notes master and can propagate settings to all dependent notes slides.
- [NotesSlideHeaderFooterManager](https://reference.aspose.com/slides/php-java/aspose.slides/notesslideheaderfootermanager/) changes one notes slide and supports a header placeholder in addition to footer, date/time, and slide number.
- [MasterHandoutSlideHeaderFooterManager](https://reference.aspose.com/slides/php-java/aspose.slides/masterhandoutslideheaderfootermanager/) changes the handout master and supports all four placeholder types.
Use propagation from a master or layout when the same setting should apply throughout its hierarchy. Use an individual slide or notes-slide manager when you need a local setting for one page.
[](https://docs.aspose.com/slides/php-java/presentation-header-and-footer/visual-presentation-header-and-footer-542f03b4f600.svg)
*Choose a manager for the presentation, a regular master/layout, one regular slide, a notes master/slide or a handout master. Regular slides have no header placeholder. Propagation methods apply supported settings to dependents; individual managers target local settings.*
## **FAQ**
**Can I add a header to a regular slide?**
No. PowerPoint does not define a header placeholder for regular slides. On regular slides, use the footer, date/time, and slide-number placeholders. Header placeholders are available on notes pages and handouts.
**What if a footer, date/time, or slide-number placeholder is not visible?**
Use the corresponding header/footer manager to check its visibility and enable it when needed. For example, [isFooterVisible](https://reference.aspose.com/slides/java/com.aspose.slides/baseslideheaderfootermanager/#isFooterVisible--) reports whether a footer placeholder is present, and [setFooterVisibility](https://reference.aspose.com/slides/java/com.aspose.slides/baseslideheaderfootermanager/#setFooterVisibility-boolean-) changes its visibility.
**How do I start slide numbering from a value other than 1?**
Call the presentation's [setFirstSlideNumber](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/setfirstslidenumber/) method. The slide-number placeholders then use the updated numbering sequence.
**What happens to headers and footers when exporting to PDF, images, or HTML?**
Visible header and footer elements are rendered with the rest of the presentation content in the output format. Their appearance depends on the page type being exported and the corresponding placeholder visibility settings.
## Related articles
- [HeaderFooter](https://docs.aspose.com/slides/php-java/examples/elements/header-footer/)
- [Apply or Change Slide Layouts in PHP](https://docs.aspose.com/slides/php-java/slide-layout/)
- [Manage Presentation Placeholders in PHP](https://docs.aspose.com/slides/php-java/manage-placeholder/)
# Automate Presentation Localization in PHP
> Set proofing languages for PowerPoint and OpenDocument presentation text in PHP with Aspose.Slides, including defaults and multilingual paragraphs.
Source: https://docs.aspose.com/slides/php-java/presentation-localization/
Updated: 2026-08-31
## **Overview**
Aspose.Slides for PHP via Java lets you configure proofing metadata for individual text portions. Use [BasePortionFormat::setLanguageId](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setLanguageId) to identify the proofing language, [BasePortionFormat::setSpellCheck](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setSpellCheck) to allow or suppress spelling checks, and [BasePortionFormat::setProofDisabled](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setProofDisabled) to control the broader no-proof state. Because these settings are applied at the portion level, one paragraph can contain multiple languages and different proofing rules.
This article explains how to assign a language to specific text, set the default language for new text with [LoadOptions::setDefaultTextLanguage](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/#setDefaultTextLanguage), build multilingual paragraphs, choose between `SpellCheck` and `ProofDisabled`, and preserve the intended settings when using [Presentation::joinPortionsWithSameFormatting](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#joinPortionsWithSameFormatting). These properties store metadata for presentation applications; they do not translate text, perform dictionary-based spell checking, or return misspelled words.
## **Set the Proofing Language for Text**
Create or load a [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/), access the required text portion through [Portion::getPortionFormat](https://reference.aspose.com/slides/php-java/aspose.slides/portion/#getPortionFormat), and assign its language identifier. The following example creates a shape, sets British English as the proofing language, and saves the result with [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#save):
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 320, 80);
$shape->getTextFrame()->setText("Set the proofing language for this text.");
$portion = $shape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
$portion->getPortionFormat()->setLanguageId("en-GB");
$presentation->save("proofing_language.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Set the Default Language for New Text**
Use [LoadOptions::setDefaultTextLanguage](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/#setDefaultTextLanguage) to specify the proofing language that Aspose.Slides assigns to newly created text. This setting is useful when most or all new text in a presentation uses the same language. It does not change the language metadata of text that already has an explicit language.
The following example creates a presentation whose new text uses German proofing rules:
```php
use aspose\slides\LoadOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$loadOptions = new LoadOptions();
$loadOptions->setDefaultTextLanguage("de-DE");
$presentation = new Presentation($loadOptions);
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 320, 80);
$shape->getTextFrame()->setText("Willkommen zur Präsentation");
$presentation->save("default_text_language.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Use Multiple Languages in One Paragraph**
A [Paragraph](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/) contains a collection of text portions. Create a separate [Portion](https://reference.aspose.com/slides/php-java/aspose.slides/portion/) for each language and set its `LanguageId` independently.
This example creates one paragraph with English and French portions:
```php
use aspose\slides\Portion;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 420, 80);
$paragraph = $shape->getTextFrame()->getParagraphs()->get_Item(0);
$paragraph->getPortions()->clear();
$englishPortion = new Portion("Welcome");
$englishPortion->getPortionFormat()->setLanguageId("en-US");
$paragraph->getPortions()->add($englishPortion);
$frenchPortion = new Portion(" — Bienvenue");
$frenchPortion->getPortionFormat()->setLanguageId("fr-FR");
$paragraph->getPortions()->add($frenchPortion);
$presentation->save("multilingual_text.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Enable or Suppress Spell Checking for Individual Portions**
[PortionFormat](https://reference.aspose.com/slides/php-java/aspose.slides/portionformat/) inherits the common text properties defined by [BasePortionFormat](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/). Access a portion's format through [Portion::getPortionFormat](https://reference.aspose.com/slides/php-java/aspose.slides/portion/#getPortionFormat) and use [BasePortionFormat::setSpellCheck](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setSpellCheck) to control whether a presentation application may check spelling for that portion. The default value is `false`: `true` allows spell checking, while `false` suppresses it.
The setting applies to individual text portions. Different portions in the same paragraph can therefore use different values. [BasePortionFormat::setLanguageId](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setLanguageId) and `setSpellCheck` serve complementary purposes: `setLanguageId` identifies the proofing language, while `setSpellCheck` determines whether spelling checks are allowed for the portion.
[BasePortionFormat::setProofDisabled](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setProofDisabled) also controls proofing, but it represents the broader "do not proof" state as a [NullableBool](https://reference.aspose.com/slides/php-java/aspose.slides/nullablebool/). Use `setSpellCheck` when you need a direct Boolean switch specifically for spelling checks. Use `setProofDisabled` when you need to preserve or explicitly control the presentation's no-proof metadata, including its `NotDefined` state. If you set both properties, keep their values consistent; do not combine `setSpellCheck(true)` with `setProofDisabled(NullableBool::True)`.
These properties configure proofing metadata used by PowerPoint and other presentation applications. Aspose.Slides does not use them to run dictionary-based spell checking or return a list of misspelled words.
The following complete example creates an input presentation, loads it, assigns different spell-check settings and proofing languages to two portions in the same paragraph, saves the result, reopens it, and verifies the stored values:
```php
use aspose\slides\Portion;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$inputFile = "spell_check_input.pptx";
$outputFile = "spell_check_settings.pptx";
$sourcePresentation = new Presentation();
try {
$sourceSlide = $sourcePresentation->getSlides()->get_Item(0);
$sourceShape = $sourceSlide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 420, 80);
$sourceParagraph = $sourceShape->getTextFrame()->getParagraphs()->get_Item(0);
$sourceParagraph->getPortions()->clear();
$sourceEnglishPortion = new Portion("Check this text. ");
$sourceEnglishPortion->getPortionFormat()->setLanguageId("en-US");
$sourceParagraph->getPortions()->add($sourceEnglishPortion);
$sourceFrenchPortion = new Portion("Ignorer ce code : ZX-81.");
$sourceFrenchPortion->getPortionFormat()->setLanguageId("fr-FR");
$sourceParagraph->getPortions()->add($sourceFrenchPortion);
$sourcePresentation->save($inputFile, SaveFormat::Pptx);
} finally {
$sourcePresentation->dispose();
}
$presentation = new Presentation($inputFile);
try {
$shape = $presentation->getSlides()->get_Item(0)->getShapes()->get_Item(0);
$portions = $shape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions();
$checkedPortion = $portions->get_Item(0);
$checkedPortion->getPortionFormat()->setLanguageId("en-US");
$checkedPortion->getPortionFormat()->setSpellCheck(true);
$suppressedPortion = $portions->get_Item(1);
$suppressedPortion->getPortionFormat()->setLanguageId("fr-FR");
$suppressedPortion->getPortionFormat()->setSpellCheck(false);
$presentation->save($outputFile, SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
$reopenedPresentation = new Presentation($outputFile);
try {
$reopenedShape = $reopenedPresentation->getSlides()->get_Item(0)->getShapes()->get_Item(0);
$storedPortions = $reopenedShape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions();
$storedPortionCount = java_values($storedPortions->getCount());
$firstStoredFormat = $storedPortions->get_Item(0)->getPortionFormat();
$secondStoredFormat = $storedPortions->get_Item(1)->getPortionFormat();
$firstPortionStored = $storedPortionCount === 2 &&
java_values($firstStoredFormat->getLanguageId()) === "en-US" &&
java_values($firstStoredFormat->getSpellCheck());
$secondPortionStored = $storedPortionCount === 2 &&
java_values($secondStoredFormat->getLanguageId()) === "fr-FR" &&
!java_values($secondStoredFormat->getSpellCheck());
if ($firstPortionStored && $secondPortionStored) {
echo "The proofing settings were stored correctly.";
} else {
echo "The proofing settings could not be verified.";
}
} finally {
$reopenedPresentation->dispose();
}
```
[Presentation::joinPortionsWithSameFormatting](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#joinPortionsWithSameFormatting) combines adjacent portions that have the same formatting. A difference in `SpellCheck` alone does not keep such portions separate; after they are joined, the resulting portion retains the `SpellCheck` value of the first portion. If portions need different spell-check settings, call `joinPortionsWithSameFormatting` before assigning those settings, or inspect the resulting portion boundaries and reapply the settings afterward. Portions with different `LanguageId` values remain separate because their proofing-language formatting differs.
## **FAQ**
**Does a language ID translate the text?**
No. [BasePortionFormat::setLanguageId](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setLanguageId) stores proofing metadata for spelling and grammar; it does not alter the text content. Translate the text separately, and then set the appropriate language identifier for each translated portion.
**Does the proofing language control fonts, hyphenation, or line wrapping?**
No. The language identifier is for proofing. Text rendering and layout primarily depend on the available [fonts](https://docs.aspose.com/slides/php-java/powerpoint-fonts/), the writing system, and the text-frame settings. For reliable rendering, provide the required fonts, configure [font substitution](https://docs.aspose.com/slides/php-java/font-substitution/), or [embed fonts](https://docs.aspose.com/slides/php-java/embedded-font/) in the presentation.
**Can one paragraph use several proofing languages?**
Yes. Assign each language to a separate portion, as shown in the multilingual paragraph example.
**Should I use `setDefaultTextLanguage` or `setLanguageId`?**
Use [LoadOptions::setDefaultTextLanguage](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/#setDefaultTextLanguage) when you want a default for newly created text. Use [BasePortionFormat::setLanguageId](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setLanguageId) when a specific portion needs an explicit proofing language or when a paragraph contains multiple languages.
# Manage Presentation Notes in PHP
> Remove slide notes and customize master notes text styles in PowerPoint and OpenDocument presentations with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/presentation-notes/
Updated: 2026-10-28
## **Overview**
Aspose.Slides for PHP via Java lets you remove notes from individual slides or an entire presentation, customize the text style defined in the master notes slide, and remove notes and handout masters. This article shows how to perform these operations and save the updated presentation.
To read or change notes page dimensions, switch orientation, and check export behavior, see [Notes Page Size](https://docs.aspose.com/slides/php-java/notes-size/).
## **Remove Notes from a Slide**
To remove notes from a specific slide, call its [getNotesSlideManager](https://reference.aspose.com/slides/php-java/aspose.slides/slide/getnotesslidemanager/) method and call [removeNotesSlide](https://reference.aspose.com/slides/php-java/aspose.slides/notesslidemanager/removenotesslide/). The example loads a presentation containing at least one slide and removes the notes from the first slide, accessed at index zero. Notes on other slides remain unchanged, and the updated presentation is saved in PPTX format.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("presentation.pptx");
try {
$notesManager = $presentation->getSlides()->get_Item(0)->getNotesSlideManager();
$notesManager->removeNotesSlide();
$presentation->save("presentation_without_first_slide_notes.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Remove Notes from All Slides**
To remove all slide notes, iterate through the collection returned by the presentation's [getSlides](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/getslides/) method and call [removeNotesSlide](https://reference.aspose.com/slides/php-java/aspose.slides/notesslidemanager/removenotesslide/) for each slide. This example processes every slide in an existing presentation and saves a PPTX copy without slide notes.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("presentation.pptx");
try {
for ($i = 0; $i < java_values($presentation->getSlides()->size()); $i++) {
$presentation->getSlides()->get_Item($i)->getNotesSlideManager()->removeNotesSlide();
}
$presentation->save("presentation_without_notes.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Remove Notes and Handout Masters**
Notes and handout masters define shared formatting and placeholders for their respective page types. Removing a master is a separate operation from removing an individual slide's notes with [removeNotesSlide](https://reference.aspose.com/slides/php-java/aspose.slides/notesslidemanager/removenotesslide/).
### **Remove an Unused Notes Master**
When cleaning up a template that has no notes pages, you can remove its unused notes master. Access [getMasterNotesSlideManager](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/getmasternotesslidemanager/), check [getMasterNotesSlide](https://reference.aspose.com/slides/java/com.aspose.slides/imasternotesslidemanager/#getMasterNotesSlide--), and call [removeMasterNotesSlide](https://reference.aspose.com/slides/java/com.aspose.slides/imasternotesslidemanager/#removeMasterNotesSlide--).
The following example requires a presentation to contain no notes pages. It removes the notes master if one exists, including its formatting and header/footer placeholders, and saves the template.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("template_without_notes.pptx");
try {
$manager = $presentation->getMasterNotesSlideManager();
if (!java_is_null($manager->getMasterNotesSlide())) {
$manager->removeMasterNotesSlide();
}
$presentation->save("template_without_notes_master.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
After removal, [getMasterNotesSlide](https://reference.aspose.com/slides/java/com.aspose.slides/imasternotesslidemanager/#getMasterNotesSlide--) returns `null`. If the master is already absent, the example skips removal and still saves the presentation.
### **Remove a Handout Master**
To remove a handout master, access [getMasterHandoutSlideManager](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/getmasterhandoutslidemanager/), check [getMasterHandoutSlide](https://reference.aspose.com/slides/java/com.aspose.slides/imasterhandoutslidemanager/#getMasterHandoutSlide--), and call [removeMasterHandoutSlide](https://reference.aspose.com/slides/java/com.aspose.slides/imasterhandoutslidemanager/#removeMasterHandoutSlide--).
For this example, use a presentation containing slide notes and customized notes and handout masters. Give the handout master a visible banner and header/footer text so that the effect of removal is easy to compare in handout output.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("presentation_with_custom_masters.pptx");
try {
$manager = $presentation->getMasterHandoutSlideManager();
if (!java_is_null($manager->getMasterHandoutSlide())) {
$manager->removeMasterHandoutSlide();
}
$presentation->save("presentation_without_handout_master.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
After removal, [getMasterHandoutSlide](https://reference.aspose.com/slides/java/com.aspose.slides/imasterhandoutslidemanager/#getMasterHandoutSlide--) returns `null`. Existing slide notes and the notes master remain unchanged. If the handout master is already absent, the example simply saves the presentation.
In handout output, the removed master's banner, formatting, and header, footer, date/time, and page-number placeholders no longer appear. The presentation slides still appear in the handout layout, including any footer or date text on the slides themselves. Slide numbers added by the handout export settings are separate from the master's page-number placeholder.
If you only want to hide handout headers or footers, change the corresponding placeholder visibility through the [handout master's header/footer manager](https://docs.aspose.com/slides/php-java/presentation-header-and-footer/#set-headers-and-footers-on-the-handout-master) instead. This keeps the master and its other formatting, such as a custom banner.
## **Add a Notes Style**
The [getNotesStyle](https://reference.aspose.com/slides/php-java/aspose.slides/masternotesslide/getnotesstyle/) method of [MasterNotesSlide](https://reference.aspose.com/slides/php-java/aspose.slides/masternotesslide/) returns the master notes text style. The example accesses the existing notes master through [getMasterNotesSlide](https://reference.aspose.com/slides/java/com.aspose.slides/imasternotesslidemanager/#getMasterNotesSlide--) and uses [getLevel](https://reference.aspose.com/slides/php-java/aspose.slides/textstyle/getlevel/) with index zero to select the first paragraph level. It sets the bullet type to [BulletType::Symbol](https://reference.aspose.com/slides/php-java/aspose.slides/bullettype/#Symbol) and saves the presentation in PPTX format. The input must contain a master notes slide with a defined first paragraph level for the style change to take effect; otherwise, the presentation is saved without changing the notes style.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\BulletType;
$presentation = new Presentation("presentation.pptx");
try {
$notesMaster = $presentation->getMasterNotesSlideManager()->getMasterNotesSlide();
if (!java_is_null($notesMaster)) {
$notesStyle = $notesMaster->getNotesStyle();
$paragraphFormat = $notesStyle->getLevel(0);
if (!java_is_null($paragraphFormat)) {
$paragraphFormat->getBullet()->setType(BulletType::Symbol);
}
}
$presentation->save("presentation_with_notes_style.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **FAQ**
**Which API provides access to the notes of a specific slide?**
Use the slide's [getNotesSlideManager](https://reference.aspose.com/slides/php-java/aspose.slides/slide/getnotesslidemanager/) method. The manager's [getNotesSlide](https://reference.aspose.com/slides/php-java/aspose.slides/notesslidemanager/getnotesslide/) method returns the notes slide, or `null` if the slide has no notes.
**Does working with notes require Microsoft PowerPoint to be installed?**
No. Aspose.Slides works with notes in PowerPoint and OpenDocument presentations without requiring Microsoft PowerPoint to be installed.
# Manage Presentation Properties in PHP
> Master presentation properties in Aspose.Slides for PHP via Java and streamline search, branding and workflow in your PowerPoint and OpenDocument files.
Source: https://docs.aspose.com/slides/php-java/presentation-properties/
Updated: 2026-11-02
## **Introduction**
Aspose.Slides for PHP via Java supports **built-in** and **custom** document properties. Use these properties to read and update presentation metadata, such as the author, title, and user-defined values.
Aspose.Slides allows you to work with presentation document properties through the [DocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/) class. An instance of this class is returned by [Presentation::getDocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/getdocumentproperties/). The following examples show how to read, modify, and manage these properties. They assume that PHP/Java Bridge and the Aspose.Slides PHP wrapper are initialized.
Aspose.Slides manages the application and producer metadata when saving presentations; these fields identify the software that created the output.
## **Manage Presentation Properties**
Document properties store descriptive information alongside presentation content. They fall into two categories:
- **Built-in properties** contain standard metadata, such as the title, author, and document statistics.
- **Custom properties** store user-defined name/value pairs.
Aspose.Slides for PHP via Java provides access to both categories. In PowerPoint, select **File → Info → Properties → Advanced Properties** to inspect document metadata. The dialog groups information into tabs such as **Summary**, **Statistics**, **Contents**, and **Custom**. Use the **Custom** tab to manage user-defined properties.
## **Read Public Properties from an Encrypted Presentation**
An opening password normally protects both presentation content and document properties. When a presentation is encrypted after calling [ProtectionManager::setEncryptDocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/protectionmanager/setencryptdocumentproperties/) with `false`, its document properties remain public. An application can then call [LoadOptions::setOnlyLoadDocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/setonlyloaddocumentproperties/) with `true` and read the public metadata without supplying the opening password.
[LoadOptions::setOnlyLoadDocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/setonlyloaddocumentproperties/) controls what Aspose.Slides loads; it does not decrypt anything. If the properties were included in encryption, loading them without the password fails. If the presentation is not encrypted, the option is ignored and the complete presentation is loaded.
The example requires an encrypted presentation whose document properties were left public. It verifies the loading mode through [ProtectionManager::isOnlyDocumentPropertiesLoaded](https://reference.aspose.com/slides/php-java/aspose.slides/protectionmanager/isonlydocumentpropertiesloaded/) and then reads built-in properties through [Presentation::getDocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/getdocumentproperties/):
```php
use aspose\slides\LoadOptions;
use aspose\slides\Presentation;
$loadOptions = new LoadOptions();
$loadOptions->setOnlyLoadDocumentProperties(true);
$presentation = new Presentation("public-properties-encrypted.pptx", $loadOptions);
try {
if (java_values($presentation->getProtectionManager()->isOnlyDocumentPropertiesLoaded())) {
$documentProperties = $presentation->getDocumentProperties();
echo("Author: " . $documentProperties->getAuthor() . "\n");
echo("Title: " . $documentProperties->getTitle() . "\n");
echo("Keywords: " . $documentProperties->getKeywords() . "\n");
} else {
echo("The presentation was not loaded in document-properties-only mode." . "\n");
}
} finally {
$presentation->dispose();
}
```
In this mode, slide content is not loaded. Slides, masters, layouts, shapes, media, and other presentation objects are unavailable. Applications should always check [ProtectionManager::isOnlyDocumentPropertiesLoaded](https://reference.aspose.com/slides/php-java/aspose.slides/protectionmanager/isonlydocumentpropertiesloaded/) before performing an operation that requires the complete presentation object model.
Public metadata may expose author names, titles, subjects, keywords, company information, comments, and custom values. Encrypt sensitive properties together with the presentation. Leave them public only when indexing, classification, search, or document-management systems have a specific requirement to access them without a password.
## **Update Properties of an Encrypted Presentation**
For an encrypted PPTX file, a presentation loaded after calling [LoadOptions::setOnlyLoadDocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/setonlyloaddocumentproperties/) with `true` is intended for reading public metadata. Aspose.Slides cannot save changed properties from that metadata-only object because the public properties must remain consistent with the corresponding data inside the encrypted presentation. Updating them therefore requires the correct opening password and a complete load.
The example requires an encrypted PPTX presentation with public document properties and a known opening password. It opens the complete presentation with [LoadOptions::setPassword](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/setpassword/), updates public built-in properties, and saves the result. It then uses [PresentationInfo::isEncrypted](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/isencrypted/) to verify that encryption is preserved and reopens the public metadata without a password to verify the new values:
```php
use aspose\slides\LoadOptions;
use aspose\slides\Presentation;
use aspose\slides\PresentationFactory;
use aspose\slides\SaveFormat;
$inputPath = "public-properties-encrypted.pptx";
$outputPath = "updated-public-properties-encrypted.pptx";
$loadOptions = new LoadOptions();
$loadOptions->setPassword("open_password");
$presentation = new Presentation($inputPath, $loadOptions);
try {
$documentProperties = $presentation->getDocumentProperties();
$documentProperties->setTitle("Updated Product Roadmap");
$documentProperties->setKeywords("roadmap, planning, indexed");
$presentation->save($outputPath, SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
$presentationInfo = PresentationFactory::getInstance()->getPresentationInfo($outputPath);
echo("The presentation is encrypted: " . (java_values($presentationInfo->isEncrypted()) ? "true" : "false") . "\n");
$metadataLoadOptions = new LoadOptions();
$metadataLoadOptions->setOnlyLoadDocumentProperties(true);
$metadataPresentation = new Presentation($outputPath, $metadataLoadOptions);
try {
if (java_values($metadataPresentation->getProtectionManager()->isOnlyDocumentPropertiesLoaded())) {
echo("Title: " . $metadataPresentation->getDocumentProperties()->getTitle() . "\n");
echo("Keywords: " . $metadataPresentation->getDocumentProperties()->getKeywords() . "\n");
} else {
echo("The presentation was not loaded in document-properties-only mode." . "\n");
}
} finally {
$metadataPresentation->dispose();
}
```
If an application is not allowed to decrypt or load the presentation content, it must treat public properties of an encrypted PPTX file as read-only.
## **Access Built-in Properties**
The [DocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/) class exposes built-in metadata through getter methods, including [getAuthor](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/getauthor/), [getTitle](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/gettitle/), and [getCreatedTime](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/getcreatedtime/). This example opens an existing presentation and prints its stored metadata to the console. Values depend on the input presentation; some fields may be empty.
```php
use aspose\slides\Presentation;
$presentation = new Presentation("AccessBuiltInProperties.pptx");
try {
$documentProperties = $presentation->getDocumentProperties();
echo("Category: " . $documentProperties->getCategory() . "\n");
echo("Content status: " . $documentProperties->getContentStatus() . "\n");
echo("Creation date: " . $documentProperties->getCreatedTime() . "\n");
echo("Author: " . $documentProperties->getAuthor() . "\n");
echo("Comments: " . $documentProperties->getComments() . "\n");
echo("Keywords: " . $documentProperties->getKeywords() . "\n");
echo("Last modified by: " . $documentProperties->getLastSavedBy() . "\n");
echo("Manager: " . $documentProperties->getManager() . "\n");
echo("Modified date: " . $documentProperties->getLastSavedTime() . "\n");
echo("Presentation format: " . $documentProperties->getPresentationFormat() . "\n");
echo("Last print date: " . $documentProperties->getLastPrinted() . "\n");
echo("Is shared between producers: " . (java_values($documentProperties->getSharedDoc()) ? "true" : "false") . "\n");
echo("Subject: " . $documentProperties->getSubject() . "\n");
echo("Title: " . $documentProperties->getTitle() . "\n");
} finally {
$presentation->dispose();
}
```
## **Modify Built-in Properties**
To update built-in metadata, use the setter methods on the object returned by [Presentation::getDocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/getdocumentproperties/). This example opens an existing presentation, calls [setAuthor](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/setauthor/), [setTitle](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/settitle/), [setSubject](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/setsubject/), [setComments](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/setcomments/), and [setManager](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/setmanager/), then saves the updated presentation with [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/save/). The saved PPTX contains the new metadata.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("ModifyBuiltInProperties.pptx");
try {
$documentProperties = $presentation->getDocumentProperties();
$documentProperties->setAuthor("Aspose.Slides for PHP via Java");
$documentProperties->setTitle("Manage PowerPoint Presentation Properties");
$documentProperties->setSubject("Modify Built-in Properties");
$documentProperties->setComments("Aspose description");
$documentProperties->setManager("Aspose manager");
$presentation->save("DocumentProperties_output.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Manage the Hyperlink Base**
[DocumentProperties::getHyperlinkBase](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/gethyperlinkbase/) returns the document-level base for relative hyperlinks. Use [DocumentProperties::setHyperlinkBase](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/sethyperlinkbase/) to change or clear it. This is useful when moving a presentation and its linked files to another location. It is separate from an individual hyperlink's [Hyperlink::getExternalUrl](https://reference.aspose.com/slides/php-java/aspose.slides/hyperlink/getexternalurl/): changing the base does not rewrite the stored link addresses or change absolute destinations.
The example requires a presentation containing both a relative link, such as `target.html`, and an absolute link, such as `https://example.org/absolute.html`. It reads the existing base, assigns a new base address, and saves and reopens the presentation to check the value. It then clears the base with an empty string and verifies the empty value in a separate saved file. Replace the example base address with the location of your linked files.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("hyperlinks.pptx");
try {
echo("Original base: " . $presentation->getDocumentProperties()->getHyperlinkBase() . "\n");
$newBase = "https://example.com/new/";
$presentation->getDocumentProperties()->setHyperlinkBase($newBase);
$presentation->save("hyperlinks-updated.pptx", SaveFormat::Pptx);
$updatedPresentation = new Presentation("hyperlinks-updated.pptx");
try {
echo("Base preserved: " . ((string) $updatedPresentation->getDocumentProperties()->getHyperlinkBase() === $newBase ? "true" : "false") . "\n");
$updatedPresentation->getDocumentProperties()->setHyperlinkBase("");
$updatedPresentation->save("hyperlinks-cleared.pptx", SaveFormat::Pptx);
$clearedPresentation = new Presentation("hyperlinks-cleared.pptx");
try {
echo("Base cleared: " . ((string) $clearedPresentation->getDocumentProperties()->getHyperlinkBase() === "" ? "true" : "false") . "\n");
} finally {
$clearedPresentation->dispose();
}
} finally {
$updatedPresentation->dispose();
}
} finally {
$presentation->dispose();
}
```
The two verification messages should print `true`. Clearing the base leaves the individual hyperlink addresses intact.
A relative link to `target.pptx` opened `old/target.pptx` when the base pointed to the `old` folder. After changing the base to the `new` folder, saving, and reopening the presentation, the same link opened `new/target.pptx`. An absolute link continued to open the same file. Test your relative links in PowerPoint before and after moving the presentation or changing its base.
## **Add Custom Presentation Properties**
Custom properties store metadata that has no corresponding built-in field. The [DocumentProperties::set_Item](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/set_item/) method lets you assign a value by property name. This example creates a presentation, adds two text values and an integer version value, and saves the presentation with [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/save/). Assigning a value to an existing name replaces that property’s value.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$documentProperties = $presentation->getDocumentProperties();
$documentProperties->set_Item("Reviewed by", "John Smith");
$documentProperties->set_Item("Confidentiality level", "Internal");
$documentProperties->set_Item("Document version", 2);
$presentation->save("CustomDocumentProperties_output.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Access and Modify Custom Properties**
This example opens a presentation containing custom properties and uses [getCountOfCustomProperties](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/getcountofcustomproperties/) to iterate over them. [getCustomPropertyName](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/getcustompropertyname/) accepts a zero-based index and returns the name used by [DocumentProperties::set_Item](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/set_item/). The example prints each original name and value, replaces every value with a numbered string regardless of its original type, and saves the changes. If there are no custom properties, the loop makes no changes.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("AccessAndModifyProperties.pptx");
try {
$documentProperties = $presentation->getDocumentProperties();
for ($i = 0; $i < java_values($documentProperties->getCountOfCustomProperties()); $i++) {
$propertyName = $documentProperties->getCustomPropertyName($i);
$propertyValue = $documentProperties->get_Item($propertyName);
echo("Custom property name: " . $propertyName . "\n");
echo("Custom property value: " . $propertyValue . "\n");
$documentProperties->set_Item($propertyName, "New Value " . ($i + 1));
}
$presentation->save("CustomProperties_output.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Live Example**
Try the [**View & Edit PowerPoint Metadata**](https://products.aspose.app/slides/metadata) online app to see how to work with document properties using the Aspose.Slides API:
[](https://products.aspose.app/slides/metadata)
## **FAQ**
**How can I remove a built-in property from a presentation?**
Built-in properties are an integral part of the presentation and cannot be removed entirely. However, you can either change their values or set them to empty if allowed by the specific property.
**What happens if I add a custom property that already exists?**
If you add a custom property that already exists, its existing value will be overwritten with the new one. You do not need to remove or check the property beforehand, as Aspose.Slides automatically updates the property's value.
**Can I access presentation properties without fully loading the presentation?**
Yes. Use [PresentationFactory::getPresentationInfo](https://reference.aspose.com/slides/php-java/aspose.slides/presentationfactory/getpresentationinfo/) and then [PresentationInfo::readDocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/readdocumentproperties/) to read stored document metadata without creating a [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) instance. See [Build a Lightweight Presentation Inventory](https://docs.aspose.com/slides/php-java/examine-presentation/) for a complete reporting example and format-specific limitations.
**Can I read public properties of an encrypted presentation without its opening password?**
Yes. The presentation must have been encrypted after calling [ProtectionManager::setEncryptDocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/protectionmanager/setencryptdocumentproperties/) with `false`, and it must be loaded after calling [LoadOptions::setOnlyLoadDocumentProperties](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/setonlyloaddocumentproperties/) with `true`.
**Can I update an encrypted PPTX file in document-properties-only mode?**
No. Public and encrypted property data must remain consistent, so updating an encrypted PPTX file requires loading the complete presentation with the correct opening password.
# Secure Presentations in PHP
> Protect PowerPoint PPT, PPTX and ODP presentations in PHP with Aspose.Slides—set passwords, apply encryption, enforce read-only, and remove protection.
Source: https://docs.aspose.com/slides/php-java/presentation-security/
Updated: 2025-11-30
---
lastmod: 2025-11-30T13:47:17+04:00
title: Secure Presentations in PHP
linktitle: Presentation Security
type: docs
weight: 60
url: /php-java/presentation-security/
keywords:
- presentation security
- digital signature
- password protection
- read only
- watermark
- PowerPoint
- OpenDocument
- presentation
- PHP
- Aspose.Slides
description: "Protect PowerPoint PPT, PPTX and ODP presentations in PHP with Aspose.Slides—set passwords, apply encryption, enforce read-only, and remove protection."
---
## Related articles
- [Secure Presentations with Passwords in PHP](https://docs.aspose.com/slides/php-java/password-protected-presentation/)
# Manage Presentation Slides in PHP
> Learn how to create, access, and manage slides in PPT, PPTX, and ODP presentations using Aspose.Slides for PHP. Easy-to-follow guide with code examples.
Source: https://docs.aspose.com/slides/php-java/presentation-slide/
Updated: 2025-11-30
---
lastmod: 2025-11-30T13:47:17+04:00
title: Manage Presentation Slides in PHP
linktitle: Presentation Slide
type: docs
weight: 20
url: /php-java/presentation-slide/
keywords:
- add slide
- access slide
- remove slide
- clone slide
- copy slide
- convert slide
- compare slides
- slide layout
- slide master
- slide size
- slide transition
- slide section
- PowerPoint
- OpenDocument
- presentation
- PHP
- Aspose.Slides
description: "Learn how to create, access, and manage slides in PPT, PPTX, and ODP presentations using Aspose.Slides for PHP. Easy-to-follow guide with code examples."
---
# Manage Presentation Themes in PHP
> Master presentation themes in Aspose.Slides for PHP via Java to create, customize and convert PowerPoint files with consistent branding.
Source: https://docs.aspose.com/slides/php-java/presentation-theme/
Updated: 2026-10-27
## **Introduction**
A presentation theme defines a coordinated set of colors, fonts, background styles, fills, lines, and effects. Theme-aware objects refer to these shared definitions instead of storing every visual property as a fixed value, so a theme change can update many objects at once.
In Aspose.Slides, the presentation-level theme is available through [Presentation::getMasterTheme](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/). A presentation can also contain theme overrides at lower levels. A master can override the presentation theme through [MasterThemeManager::getOverrideTheme](https://reference.aspose.com/slides/php-java/aspose.slides/masterthememanager/), while a layout or an individual slide can override its inherited theme through [BaseOverrideThemeManager::getOverrideTheme](https://reference.aspose.com/slides/php-java/aspose.slides/baseoverridethememanager/). In practice, the effective theme for a slide is resolved through this inheritance chain: presentation theme, master override, layout override, and slide override.

The sections below show the most common theme workflows: inspect a theme, change colors and fonts, copy or apply a theme, update background and effect styles, and read effective values after inheritance and overrides have been resolved.
## **Inspect a Theme**
The [MasterTheme](https://reference.aspose.com/slides/php-java/aspose.slides/mastertheme/) object exposes the theme's color scheme, font scheme, and format scheme through [MasterTheme::getColorScheme](https://reference.aspose.com/slides/php-java/aspose.slides/mastertheme/), [MasterTheme::getFontScheme](https://reference.aspose.com/slides/php-java/aspose.slides/mastertheme/), and [MasterTheme::getFormatScheme](https://reference.aspose.com/slides/php-java/aspose.slides/mastertheme/). Inspecting these collections before changing them is especially useful when a presentation comes from an external source because the number and content of style entries can vary.
The following example reads the main theme properties and reports how many background, fill, line, and effect styles are stored in the theme:
```php
use aspose\slides\Presentation;
$presentation = new Presentation("input.pptx");
try {
$theme = $presentation->getMasterTheme();
echo "Theme name: " . $theme->getName() . PHP_EOL;
echo "Accent 1: " . $theme->getColorScheme()->getAccent1()->getColor() . PHP_EOL;
echo "Major Latin font: " . $theme->getFontScheme()->getMajor()->getLatinFont()->getFontName() . PHP_EOL;
echo "Minor Latin font: " . $theme->getFontScheme()->getMinor()->getLatinFont()->getFontName() . PHP_EOL;
echo "Background fill styles: " . java_values($theme->getFormatScheme()->getBackgroundFillStyles()->size()) . PHP_EOL;
echo "Fill styles: " . java_values($theme->getFormatScheme()->getFillStyles()->size()) . PHP_EOL;
echo "Line styles: " . java_values($theme->getFormatScheme()->getLineStyles()->size()) . PHP_EOL;
echo "Effect styles: " . java_values($theme->getFormatScheme()->getEffectStyles()->size()) . PHP_EOL;
} finally {
$presentation->dispose();
}
```
If a file uses multiple masters, do not assume that every slide has the same effective theme. Inspect the master associated with the slide, and use the effective-theme workflow shown later in this article when layout or slide overrides may be present.
## **Change Theme Colors**
Theme-aware fills, lines, and text can refer to a logical color from the [SchemeColor](https://reference.aspose.com/slides/php-java/aspose.slides/schemecolor/) enumeration. When you change the corresponding entry in the [ColorScheme](https://reference.aspose.com/slides/php-java/aspose.slides/colorscheme/), all objects that still reference that theme color are resolved against the new value. Objects that use a direct RGB color are not changed by a theme-color update.
The following end-to-end example creates a shape that uses `Accent4`, changes the theme's `Accent4` color to red, saves the presentation, reopens it, and prints the effective fill color:
```php
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SchemeColor;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 10, 10, 100, 100);
$shape->getFillFormat()->setFillType(FillType::Solid);
$shape->getFillFormat()->getSolidFillColor()->setSchemeColor(SchemeColor::Accent4);
$presentation->getMasterTheme()->getColorScheme()->getAccent4()->setColor(java("java.awt.Color")->RED);
$presentation->save("theme-color.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
$savedPresentation = new Presentation("theme-color.pptx");
try {
$savedSlide = $savedPresentation->getSlides()->get_Item(0);
$savedShape = $savedSlide->getShapes()->get_Item(0);
$effectiveColor = $savedShape->getFillFormat()->getEffective()->getSolidFillColor();
echo sprintf("Effective fill color: A=%d, R=%d, G=%d, B=%d", java_values($effectiveColor->getAlpha()), java_values($effectiveColor->getRed()), java_values($effectiveColor->getGreen()), java_values($effectiveColor->getBlue())) . PHP_EOL;
} finally {
$savedPresentation->dispose();
}
```
Because the rectangle remains linked to `Accent4`, its visible color becomes red after the theme is changed. If you replace the scheme color with a direct color on the shape, later changes to `Accent4` will no longer affect that fill.
### **Use Colors from the Additional Palette**
PowerPoint derives lighter and darker variants from a theme color by applying color transformations. Aspose.Slides exposes these transformations through the [ColorTransformOperation](https://reference.aspose.com/slides/php-java/aspose.slides/colortransformoperation/) enumeration.

**1** - Main theme colors.
**2** - Lighter and darker variants produced from the main theme colors.
The following example creates six rectangles based on `Accent4`, applies luminance transformations to five of them, and saves the result:
```php
use aspose\slides\ColorTransformOperation;
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SchemeColor;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape1 = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 10, 10, 50, 50);
$shape1->getFillFormat()->setFillType(FillType::Solid);
$shape1->getFillFormat()->getSolidFillColor()->setSchemeColor(SchemeColor::Accent4);
$shape2 = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 10, 70, 50, 50);
$shape2->getFillFormat()->setFillType(FillType::Solid);
$shape2->getFillFormat()->getSolidFillColor()->setSchemeColor(SchemeColor::Accent4);
$shape2->getFillFormat()->getSolidFillColor()->getColorTransform()->add(ColorTransformOperation::MultiplyLuminance, 0.2);
$shape2->getFillFormat()->getSolidFillColor()->getColorTransform()->add(ColorTransformOperation::AddLuminance, 0.8);
$shape3 = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 10, 130, 50, 50);
$shape3->getFillFormat()->setFillType(FillType::Solid);
$shape3->getFillFormat()->getSolidFillColor()->setSchemeColor(SchemeColor::Accent4);
$shape3->getFillFormat()->getSolidFillColor()->getColorTransform()->add(ColorTransformOperation::MultiplyLuminance, 0.4);
$shape3->getFillFormat()->getSolidFillColor()->getColorTransform()->add(ColorTransformOperation::AddLuminance, 0.6);
$shape4 = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 10, 190, 50, 50);
$shape4->getFillFormat()->setFillType(FillType::Solid);
$shape4->getFillFormat()->getSolidFillColor()->setSchemeColor(SchemeColor::Accent4);
$shape4->getFillFormat()->getSolidFillColor()->getColorTransform()->add(ColorTransformOperation::MultiplyLuminance, 0.6);
$shape4->getFillFormat()->getSolidFillColor()->getColorTransform()->add(ColorTransformOperation::AddLuminance, 0.4);
$shape5 = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 10, 250, 50, 50);
$shape5->getFillFormat()->setFillType(FillType::Solid);
$shape5->getFillFormat()->getSolidFillColor()->setSchemeColor(SchemeColor::Accent4);
$shape5->getFillFormat()->getSolidFillColor()->getColorTransform()->add(ColorTransformOperation::MultiplyLuminance, 0.75);
$shape6 = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 10, 310, 50, 50);
$shape6->getFillFormat()->setFillType(FillType::Solid);
$shape6->getFillFormat()->getSolidFillColor()->setSchemeColor(SchemeColor::Accent4);
$shape6->getFillFormat()->getSolidFillColor()->getColorTransform()->add(ColorTransformOperation::MultiplyLuminance, 0.5);
$presentation->save("theme-color-palette.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
These variants remain based on the theme color. If `Accent4` changes later, the transformed colors are recalculated from the new `Accent4` value.
### **Map `SchemeColor` Values to `ColorScheme` Slots**
The [SchemeColor](https://reference.aspose.com/slides/php-java/aspose.slides/schemecolor/) enumeration uses `Text1`, `Background1`, `Text2`, and `Background2`, while the [ColorScheme](https://reference.aspose.com/slides/php-java/aspose.slides/colorscheme/) exposes the same theme slots as `Dark1`, `Light1`, `Dark2`, and `Light2`. The mapping is fixed:
* `Text1` = `Dark1`
* `Background1` = `Light1`
* `Text2` = `Dark2`
* `Background2` = `Light2`
These are alternate names for the same theme slots; they are not values that are dynamically converted from one form to another.
## **Change Theme Fonts**
A theme font scheme contains a major font set for headings and a minor font set for body text. The [FontScheme::getMajor](https://reference.aspose.com/slides/php-java/aspose.slides/fontscheme/) and [FontScheme::getMinor](https://reference.aspose.com/slides/php-java/aspose.slides/fontscheme/) methods expose those sets.
PowerPoint-compatible theme font identifiers can be used in text formatting:
* `+mn-lt` - Body Font Latin (Minor Latin Font)
* `+mj-lt` - Heading Font Latin (Major Latin Font)
* `+mn-ea` - Body Font East Asian (Minor East Asian Font)
* `+mj-ea` - Heading Font East Asian (Major East Asian Font)
* `+mn-cs` - Body Font Complex Script (Minor Complex Script Font)
* `+mj-cs` - Heading Font Complex Script (Major Complex Script Font)
The following example creates one heading that uses the major Latin theme font and one body line that uses the minor Latin theme font. It then changes the theme fonts and saves the result:
```php
use aspose\slides\FontData;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$heading = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 40, 40, 500, 60);
$heading->getTextFrame()->setText("Theme heading");
$heading->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0)->getPortionFormat()->setLatinFont(new FontData("+mj-lt"));
$body = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 40, 120, 500, 60);
$body->getTextFrame()->setText("Theme body text");
$body->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0)->getPortionFormat()->setLatinFont(new FontData("+mn-lt"));
$presentation->getMasterTheme()->getFontScheme()->getMajor()->setLatinFont(new FontData("Aptos Display"));
$presentation->getMasterTheme()->getFontScheme()->getMinor()->setLatinFont(new FontData("Arial"));
$presentation->save("theme-fonts.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The heading follows the major font and the body text follows the minor font. Text that has an explicit font name instead of a theme identifier will not automatically switch when the theme font scheme changes.
The major and minor font collections can also contain font mappings for individual writing systems, such as Cyrillic, Arabic, Japanese, Georgian, and Thaana. To inspect, add, replace, or remove these mappings, see [Script-Specific Theme Fonts](https://docs.aspose.com/slides/php-java/script-specific-font-mappings/).
For more information about presentation fonts, see [PowerPoint Fonts](https://docs.aspose.com/slides/php-java/powerpoint-fonts/).
### **Resolve Theme Font References**
When inspecting text, [FontData::getFontName](https://reference.aspose.com/slides/php-java/aspose.slides/fontdata/) can return a theme reference such as `+mn-lt` instead of a font family name. Call [FontData::getFontName](https://reference.aspose.com/slides/php-java/aspose.slides/fontdata/) with the appropriate effective theme data to resolve that reference. The `+mj` and `+mn` prefixes select the major and minor font sets; the `-lt`, `-ea`, and `-cs` suffixes select their Latin, East Asian, and Complex Script fonts, respectively.
Obtain the effective theme through [Slide::createThemeEffective](https://reference.aspose.com/slides/php-java/aspose.slides/slide/) on the object whose theme applies to the inspected text. For ordinary text on a slide, call this method on the slide so the context includes that slide's inherited theme and local overrides. When inspecting a layout or master itself, use its own effective theme. Do not assume that the first master's theme applies to every slide.
The following example creates a text portion that explicitly references the minor Latin font. It initializes a slide font scheme through [OverrideTheme::initFontSchemeFromInherited](https://reference.aspose.com/slides/php-java/aspose.slides/overridetheme/) and sets the major and minor Latin families to `Arial` and `Calibri`, making the result reproducible without an input file.
```php
use aspose\slides\FontData;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$theme = $slide->getThemeManager()->getOverrideTheme();
$theme->initFontSchemeFromInherited();
$theme->getFontScheme()->getMajor()->setLatinFont(new FontData("Arial"));
$theme->getFontScheme()->getMinor()->setLatinFont(new FontData("Calibri"));
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 20, 400, 60);
$shape->getTextFrame()->setText("Text using the minor theme font");
$portion = $shape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
$portion->getPortionFormat()->setLatinFont(new FontData("+mn-lt"));
$font = $portion->getPortionFormat()->getLatinFont();
$effectiveTheme = $slide->createThemeEffective();
echo $font->getFontName() . " -> " . $font->getFontName($effectiveTheme) . PHP_EOL;
$explicitFont = new FontData("Verdana");
echo $explicitFont->getFontName() . " -> " . $explicitFont->getFontName($effectiveTheme) . PHP_EOL;
} finally {
$presentation->dispose();
}
```
The output is `+mn-lt -> Calibri` followed by `Verdana -> Verdana`. The stored reference remains unchanged, while an explicit family name is returned as-is. If the portion used `+mj-lt`, it would resolve to `Arial` in this theme.
Resolving a theme reference identifies the font family specified by the theme. It does not check font availability or determine the font file ultimately used after substitution or glyph fallback during rendering. See [Font Selection Sequence](https://docs.aspose.com/slides/php-java/font-selection-sequence/) and [Font Substitution](https://docs.aspose.com/slides/php-java/font-substitution/) for those separate steps.
## **Copy or Apply a Theme**
The workflows below solve different theme-related problems.
### **Apply an External Theme to a Master's Dependent Slides**
Use [MasterSlide::applyExternalThemeToDependingSlides](https://reference.aspose.com/slides/php-java/aspose.slides/masterslide/) when you have a PowerPoint theme file (`.thmx`) and want to restyle every slide that depends on a particular master. Select the master from the [Presentation::getMasters](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) collection, which is represented by [MasterSlideCollection](https://reference.aspose.com/slides/php-java/aspose.slides/masterslidecollection/), and pass the theme file path to the method.
The method performs the following operations:
1. Creates a new master slide based on the selected master.
1. Applies the external theme to the new master.
1. Assigns the new master to all slides that previously depended on the selected master.
1. Returns the newly created [MasterSlide](https://reference.aspose.com/slides/php-java/aspose.slides/masterslide/).
The following example applies an external theme to the slides that depend on the first master and saves the presentation:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("presentation.pptx");
try {
$selectedMaster = $presentation->getMasters()->get_Item(0);
$themedMaster = $selectedMaster->applyExternalThemeToDependingSlides("corporate-theme.thmx");
echo "Created master: " . java_values($themedMaster->getName()) . PHP_EOL;
$presentation->save("presentation-with-external-theme.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
An invalid, corrupted, or unsupported theme can cause [PptxReadException](https://reference.aspose.com/slides/php-java/aspose.slides/pptxreadexception/). Validate paths supplied by users, handle file-system access failures, and save the presentation only after the theme has been applied successfully.
Only the slides that depended on the selected master are reassigned. Slides associated with other masters retain their existing masters and themes. Theme-aware colors, fonts, fills, lines, backgrounds, and effects are resolved against the external theme. Directly assigned colors, fonts, fills, and other explicit formatting may remain unchanged. Layout-level and slide-level overrides can also take precedence over values inherited from the new master.
The theme can reference fonts that are not available in the runtime environment. For consistent rendering and export, install the required fonts, provide them through [custom font sources](https://docs.aspose.com/slides/php-java/custom-font/), or configure [font substitution](https://docs.aspose.com/slides/php-java/font-substitution/).
This is a direct master-level workflow: the method accepts a file path to a `.thmx` file and does not require manually creating slide-level or layout-level theme overrides.
### **Apply Different External Themes in a Multi-Master Presentation**
When the relevant master is not known in advance, obtain it from a representative slide through [Slide::getLayoutSlide](https://reference.aspose.com/slides/php-java/aspose.slides/slide/) and [LayoutSlide::getMasterSlide](https://reference.aspose.com/slides/php-java/aspose.slides/layoutslide/). Store the original master references before applying any themes because each call creates another master in the presentation.
The following example uses slides from two sections to locate their masters and applies a different external theme to each group:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("multi-master-presentation.pptx");
try {
if (java_values($presentation->getSlides()->size()) < 5) {
echo "The presentation does not contain the expected representative slides." . PHP_EOL;
} else {
$firstGroupMaster = $presentation->getSlides()->get_Item(0)->getLayoutSlide()->getMasterSlide();
$secondGroupMaster = $presentation->getSlides()->get_Item(4)->getLayoutSlide()->getMasterSlide();
if (java_values($firstGroupMaster->getSlideId()) === java_values($secondGroupMaster->getSlideId())) {
echo "The representative slides use the same master." . PHP_EOL;
} else {
$firstThemedMaster = $firstGroupMaster->applyExternalThemeToDependingSlides("blue-theme.thmx");
$secondThemedMaster = $secondGroupMaster->applyExternalThemeToDependingSlides("green-theme.thmx");
echo "First themed master: " . java_values($firstThemedMaster->getName()) . PHP_EOL;
echo "Second themed master: " . java_values($secondThemedMaster->getName()) . PHP_EOL;
$presentation->save("multi-master-with-external-themes.pptx", SaveFormat::Pptx);
}
}
} finally {
$presentation->dispose();
}
```
The first call affects only slides that depended on `$firstGroupMaster`, and the second call affects only slides that depended on `$secondGroupMaster`. Slides belonging to any other master are not restyled.
### **Preserve a Source Theme When Moving Slides**
If you want to move a slide to another presentation and preserve its original design, clone the source master into the target presentation with [MasterSlideCollection::addClone](https://reference.aspose.com/slides/php-java/aspose.slides/masterslidecollection/), then clone the slide with [SlideCollection::addClone](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/) and the cloned master. This carries the master, its layouts, and the associated theme together.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$source = new Presentation("source-theme.pptx");
try {
$target = new Presentation("target.pptx");
try {
$sourceSlide = $source->getSlides()->get_Item(0);
$sourceMaster = $sourceSlide->getLayoutSlide()->getMasterSlide();
$clonedMaster = $target->getMasters()->addClone($sourceMaster);
$target->getSlides()->addClone($sourceSlide, $clonedMaster, true);
$target->save("theme-preserved.pptx", SaveFormat::Pptx);
} finally {
$target->dispose();
}
} finally {
$source->dispose();
}
```
This is the preferred workflow when the source slide must look the same in the destination. Simply cloning content onto an unrelated destination master can change theme-driven colors, fonts, backgrounds, and effects.
### **Apply Theme Values to an Existing Slide**
If the target slide must stay on its current master and layout, initialize a slide-level override from the source theme. The [OverrideTheme::initColorSchemeFrom](https://reference.aspose.com/slides/php-java/aspose.slides/overridetheme/), [OverrideTheme::initFontSchemeFrom](https://reference.aspose.com/slides/php-java/aspose.slides/overridetheme/), and [OverrideTheme::initFormatSchemeFrom](https://reference.aspose.com/slides/php-java/aspose.slides/overridetheme/) methods copy the three main theme components into the override.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$source = new Presentation("source-theme.pptx");
try {
$target = new Presentation("target.pptx");
try {
$targetSlide = $target->getSlides()->get_Item(0);
$overrideTheme = $targetSlide->getThemeManager()->getOverrideTheme();
$overrideTheme->initColorSchemeFrom($source->getMasterTheme()->getColorScheme());
$overrideTheme->initFontSchemeFrom($source->getMasterTheme()->getFontScheme());
$overrideTheme->initFormatSchemeFrom($source->getMasterTheme()->getFormatScheme());
$target->save("theme-applied-to-slide.pptx", SaveFormat::Pptx);
} finally {
$target->dispose();
}
} finally {
$source->dispose();
}
```
This changes the theme used by that slide without changing the theme inherited by other slides. To remove the local override and return to inherited values, call [OverrideTheme::clear](https://reference.aspose.com/slides/php-java/aspose.slides/overridetheme/).
### **Apply a Theme Override to a Layout**
A layout-level override applies to slides that use that layout, unless a particular slide has its own override. The same initialization methods can be used through the [LayoutSlideThemeManager](https://reference.aspose.com/slides/php-java/aspose.slides/layoutslidethememanager/):
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$source = new Presentation("source-theme.pptx");
try {
$target = new Presentation("target.pptx");
try {
$targetSlide = $target->getSlides()->get_Item(0);
$overrideTheme = $targetSlide->getLayoutSlide()->getThemeManager()->getOverrideTheme();
$overrideTheme->initColorSchemeFrom($source->getMasterTheme()->getColorScheme());
$overrideTheme->initFontSchemeFrom($source->getMasterTheme()->getFontScheme());
$overrideTheme->initFormatSchemeFrom($source->getMasterTheme()->getFormatScheme());
$target->save("theme-applied-to-layout.pptx", SaveFormat::Pptx);
} finally {
$target->dispose();
}
} finally {
$source->dispose();
}
```
Use a master or presentation-level theme when many layouts and slides should share the same base design, a layout override when one layout family needs different styling, and a slide override only for true exceptions. Excessive slide-level overrides make later global theme changes harder to predict.
## **Update Theme Background Styles**
The theme's background fills are stored in [FormatScheme::getBackgroundFillStyles](https://reference.aspose.com/slides/php-java/aspose.slides/formatscheme/). PowerPoint can present more background choices in its UI than the number of fill definitions physically stored in this collection because the UI can combine theme fills with theme colors and other style references.

Before using a background style, inspect the stored collection and the current [Background::getStyleIndex](https://reference.aspose.com/slides/php-java/aspose.slides/background/). A style index of `0` means no themed fill; positive values are theme background-style references. This is different from indexing the PHP collection directly, where `get_Item(0)` means the first stored item. Do not assume that every presentation contains the same number of background fill styles.
The following example reports the available background fill count, assigns a themed background reference to the first master, and saves the presentation:
```php
use aspose\slides\BackgroundType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("input.pptx");
try {
$backgroundStyleCount = java_values($presentation->getMasterTheme()->getFormatScheme()->getBackgroundFillStyles()->size());
echo "Background fill styles: " . $backgroundStyleCount . PHP_EOL;
if ($backgroundStyleCount === 0) {
throw new RuntimeException("The presentation theme does not contain background fill styles.");
}
$masterSlide = $presentation->getMasters()->get_Item(0);
$masterSlide->getBackground()->setType(BackgroundType::Themed);
$masterSlide->getBackground()->setStyleIndex(1);
$presentation->save("theme-background.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The visible result depends on the theme entry referenced by the master and on any background overrides at the layout or slide level. If a slide uses its own background, changing only the master background may not change that slide. Use [Background::getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/background/) when you need to know the final background after inheritance has been applied.
Do not treat the style index as a zero-based collection index. Also avoid hard-coding a style number from one file and assuming it has the same appearance in another file; theme style definitions are presentation-specific.
For direct background formatting and background inheritance, see [Presentation Background](https://docs.aspose.com/slides/php-java/presentation-background/).
## **Update Theme Effects**
A theme format scheme contains separate fill, line, and effect style collections exposed through [FormatScheme::getFillStyles](https://reference.aspose.com/slides/php-java/aspose.slides/formatscheme/), [FormatScheme::getLineStyles](https://reference.aspose.com/slides/php-java/aspose.slides/formatscheme/), and [FormatScheme::getEffectStyles](https://reference.aspose.com/slides/php-java/aspose.slides/formatscheme/). Typical Office themes often contain three principal style entries that correspond visually to subtle, moderate, and intense formatting, but code should inspect each collection instead of assuming a fixed count.

When you access these collections in PHP, the collection index is zero-based: `get_Item(0)` is the first stored style and `get_Item(2)` is the third. A shape's style-reference indexes are a separate concept, exposed through [ShapeStyle](https://reference.aspose.com/slides/php-java/aspose.slides/shapestyle/). Modifying a theme style affects shapes that reference that theme style; shapes with direct formatting may remain unchanged.
The following example checks that the required style entries exist, changes the first line style, changes the third fill style, enables an outer shadow in the third effect style, and saves the result:
```php
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("Subtle_Moderate_Intense.pptx");
try {
$formatScheme = $presentation->getMasterTheme()->getFormatScheme();
if (java_values($formatScheme->getLineStyles()->size()) < 1 || java_values($formatScheme->getFillStyles()->size()) < 3 || java_values($formatScheme->getEffectStyles()->size()) < 3) {
throw new RuntimeException("The theme does not contain the style entries required by this example.");
}
$formatScheme->getLineStyles()->get_Item(0)->getFillFormat()->setFillType(FillType::Solid);
$formatScheme->getLineStyles()->get_Item(0)->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->RED);
$formatScheme->getFillStyles()->get_Item(2)->setFillType(FillType::Solid);
$formatScheme->getFillStyles()->get_Item(2)->getSolidFillColor()->setColor(new Java("java.awt.Color", 34, 139, 34));
$effectFormat = $formatScheme->getEffectStyles()->get_Item(2)->getEffectFormat();
$effectFormat->enableOuterShadowEffect();
$effectFormat->getOuterShadowEffect()->setDistance(10.0);
$presentation->save("theme-effects.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
For shapes that reference these slots, the first theme line style becomes red, the third theme fill style becomes solid forest green, and the third effect style gains an outer shadow with a distance of 10 points. The exact visual result still depends on which style slots each shape references and whether direct formatting overrides the theme.

## **Determine Whether an Effective Solid Fill Uses a Theme Color**
A fill can be stored directly on an object or inherited from a paragraph, layout, master, theme style, or another formatting level. Call [FillFormat::getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/) to resolve that hierarchy into immutable effective fill data. First check its `getFillType` result. Only when it is `FillType::Solid` should you read the solid-fill properties.
For a solid fill, `getSolidFillColor` returns the final rendered RGB value after inheritance, theme lookup, and color transformations are applied. The `getSolidFillSchemeColor` method returns the corresponding logical [SchemeColor](https://reference.aspose.com/slides/php-java/aspose.slides/schemecolor/) slot, such as `Text1` or `Accent6`. A value of `SchemeColor::NotDefined` means that the effective solid fill is not based on a scheme color. In a workflow where fills are either theme colors or direct RGB colors, this value identifies a direct RGB fill.
Do not use the local [ColorFormat::getSchemeColor](https://reference.aspose.com/slides/php-java/aspose.slides/colorformat/) value alone to classify a fill. For example, a text portion can have no locally defined scheme color, so its local value is `NotDefined`, while its effective fill inherits a theme color and resolves to `Text1` or `Accent6`. Conversely, `getSolidFillSchemeColor` tells you which logical theme slot produced the effective color, but it does not tell you whether that slot came from the object, paragraph, layout, master, or another level of the formatting hierarchy.
The following example loads a presentation, audits both shape fills and text-portion fills, prints each final RGB value and associated scheme color, and flags solid fills that will not track theme color changes:
```php
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SchemeColor;
$auditFill = function (string $objectName, $localFill): void {
$effectiveFill = $localFill->getEffective();
if (java_values($effectiveFill->getFillType()) != FillType::Solid) {
echo $objectName . ": fill type = " . java_values($effectiveFill->getFillType()) . "; not a solid fill." . PHP_EOL;
return;
}
$rgb = $effectiveFill->getSolidFillColor();
$effectiveSchemeColor = java_values($effectiveFill->getSolidFillSchemeColor());
$localSchemeColor = java_values($localFill->getSolidFillColor()->getSchemeColor());
echo sprintf("%s: RGB = #%02X%02X%02X", $objectName, java_values($rgb->getRed()), java_values($rgb->getGreen()), java_values($rgb->getBlue())) . PHP_EOL;
echo $objectName . ": local scheme = " . $localSchemeColor . ", effective scheme = " . $effectiveSchemeColor . PHP_EOL;
if ($effectiveSchemeColor == SchemeColor::NotDefined) {
echo $objectName . ": direct RGB or another non-scheme fill; audit as theme-independent." . PHP_EOL;
} else {
echo $objectName . ": theme-dependent through " . $effectiveSchemeColor . "." . PHP_EOL;
}
};
$autoShapeClass = new JavaClass("com.aspose.slides.AutoShape");
$presentation = new Presentation("input.pptx");
try {
$slideCount = java_values($presentation->getSlides()->size());
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$shapeCount = java_values($slide->getShapes()->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $slide->getShapes()->get_Item($shapeIndex);
$shapeName = "Slide " . ($slideIndex + 1) . ", shape " . ($shapeIndex + 1);
$auditFill($shapeName, $shape->getFillFormat());
if (java_instanceof($shape, $autoShapeClass)) {
$paragraphCount = java_values($shape->getTextFrame()->getParagraphs()->getCount());
for ($paragraphIndex = 0; $paragraphIndex < $paragraphCount; $paragraphIndex++) {
$paragraph = $shape->getTextFrame()->getParagraphs()->get_Item($paragraphIndex);
$portionCount = java_values($paragraph->getPortions()->getCount());
for ($portionIndex = 0; $portionIndex < $portionCount; $portionIndex++) {
$portion = $paragraph->getPortions()->get_Item($portionIndex);
$portionName = $shapeName . ", paragraph " . ($paragraphIndex + 1) . ", portion " . ($portionIndex + 1);
$auditFill($portionName, $portion->getPortionFormat()->getFillFormat());
}
}
}
}
}
} finally {
$presentation->dispose();
}
```
The `NotDefined` branch provides an audit list of solid fills that will not respond to changes in theme color slots. Review those objects when a presentation must follow a new brand palette. The reported RGB value still shows the current appearance, while the scheme value explains whether that appearance is connected to the theme.
Effective-format objects are snapshots. After changing the presentation theme, a theme override, or any inherited formatting, call `getEffective` again and read new effective fill data before comparing or reporting colors.
## **Read Effective Theme Values**
Raw theme objects tell you what is defined at a particular level. Effective values tell you what a slide or shape actually uses after inheritance and local overrides are resolved. For a slide, call [BaseOverrideThemeManager::createThemeEffective](https://reference.aspose.com/slides/php-java/aspose.slides/baseoverridethememanager/). For a background, use [Background::getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/background/), and for a fill, use [FillFormat::getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/).
The following example reads the effective theme, background, and first shape fill from a slide:
```php
use aspose\slides\FillType;
use aspose\slides\Presentation;
$presentation = new Presentation("input.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$effectiveTheme = $slide->getThemeManager()->createThemeEffective();
$effectiveBackground = $slide->getBackground()->getEffective();
echo "Effective major Latin font: " . $effectiveTheme->getFontScheme()->getMajor()->getLatinFont()->getFontName() . PHP_EOL;
echo "Effective minor Latin font: " . $effectiveTheme->getFontScheme()->getMinor()->getLatinFont()->getFontName() . PHP_EOL;
echo "Effective background fill type: " . java_values($effectiveBackground->getFillFormat()->getFillType()) . PHP_EOL;
if (java_values($slide->getShapes()->size()) > 0) {
$effectiveFill = $slide->getShapes()->get_Item(0)->getFillFormat()->getEffective();
echo "First shape effective fill type: " . java_values($effectiveFill->getFillType()) . PHP_EOL;
if (java_values($effectiveFill->getFillType()) == FillType::Solid) {
$effectiveColor = $effectiveFill->getSolidFillColor();
echo sprintf("First shape effective fill color: A=%d, R=%d, G=%d, B=%d", java_values($effectiveColor->getAlpha()), java_values($effectiveColor->getRed()), java_values($effectiveColor->getGreen()), java_values($effectiveColor->getBlue())) . PHP_EOL;
}
}
} finally {
$presentation->dispose();
}
```
Use effective data for rendering diagnostics, validation, and comparisons. If you inspect only [Presentation::getMasterTheme](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/), you can miss a master, layout, slide, or shape override that changes the final appearance.
## **FAQ**
**Does applying an external theme affect every slide in the presentation?**
No. [MasterSlide::applyExternalThemeToDependingSlides](https://reference.aspose.com/slides/php-java/aspose.slides/masterslide/) reassigns only the slides that depend on the selected master. Slides that use other masters retain their existing themes.
**Can I apply a theme to a single slide without changing the master?**
Yes. Use the slide's [SlideThemeManager](https://reference.aspose.com/slides/php-java/aspose.slides/slidethememanager/) and initialize its override theme. The change remains local to that slide; other slides continue to inherit their existing themes.
**What is the safest way to carry a theme from one presentation to another?**
When moving a slide and preserving its source appearance, clone the source master into the destination and clone the slide with that master using [MasterSlideCollection::addClone](https://reference.aspose.com/slides/php-java/aspose.slides/masterslidecollection/) and [SlideCollection::addClone](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/). This keeps the master, layouts, and theme together.
**How can I see the effective values after inheritance and overrides?**
Use [BaseOverrideThemeManager::createThemeEffective](https://reference.aspose.com/slides/php-java/aspose.slides/baseoverridethememanager/) for a slide or layout theme and the corresponding effective-data methods for format objects such as [Background::getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/background/) and [FillFormat::getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/). These APIs return the resolved values after inheritance and overrides are applied.
# Manage VBA Projects in Presentations Using PHP
> Discover how to generate and manipulate PowerPoint and OpenDocument presentations via VBA with Aspose.Slides for PHP via Java to streamline your workflow.
Source: https://docs.aspose.com/slides/php-java/presentation-via-vba/
Updated: 2026-08-13
## **Introduction**
The Aspose.Slides API contains classes for working with macros and VBA code.
When you convert a presentation containing macros to a different file format (PDF, HTML, etc.), Aspose.Slides ignores all macros (macros are not carried into the resulting file).
When you add macros to a presentation or resave a presentation containing macros, Aspose.Slides simply writes the bytes for the macros.
Aspose.Slides **never** runs the macros in a presentation.
## **Add VBA Macros**
Aspose.Slides provides the [VbaProject](https://reference.aspose.com/slides/php-java/aspose.slides/vbaproject/) class to allow you to create VBA projects (and project references) and edit existing modules. You can use the `VbaProject` class to manage VBA embedded in a presentation.
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation) class.
1. Use the [VbaProject](https://reference.aspose.com/slides/php-java/aspose.slides/vbaproject/#VbaProject) constructor to add a new VBA project.
1. Add a module to the VbaProject.
1. Set the module source code.
1. Add references to .
1. Add references to **Microsoft Office**.
1. Associate the references with the VBA project.
1. Save the presentation.
This PHP code shows you how to add a VBA macro from scratch to a presentation:
```php
# Creates an instance of the presentation class
$pres = new Presentation();
try {
# Creates a new VBA Project
$pres->setVbaProject(new VbaProject());
# Adds an empty module to the VBA project
$module = $pres->getVbaProject()->getModules()->addEmptyModule("Module");
# Sets the module source code
$module->setSourceCode("Sub Test(oShape As Shape)MsgBox Test End Sub");
# Creates a reference to
$stdoleReference = new VbaReferenceOleTypeLib("stdole", "*\\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\\Windows\\system32\\stdole2.tlb#OLE Automation");
# Creates a reference to Office
$officeReference = new VbaReferenceOleTypeLib("Office", "*\\G{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}#2.0#0#C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE14\\MSO.DLL#Microsoft Office 14.0 Object Library");
# Adds references to the VBA project
$pres->getVbaProject()->getReferences()->add($stdoleReference);
$pres->getVbaProject()->getReferences()->add($officeReference);
# Saves the Presentation
$pres->save("test.pptm", SaveFormat::Pptm);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
You may want to check out **Aspose** [Macro Remover](https://products.aspose.app/slides/remove-macros), which a free web app used to remove macros from PowerPoint, Excel, and Word documents.
## **Remove VBA Macros**
Using the [VbaProject](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getVbaProject) property under the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation) class, you can remove a VBA macro.
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation) class and load the presentation containing the macro.
1. Access the Macro module and remove it.
1. Save the modified presentation.
This PHP code shows you how to remove a VBA macro:
```php
# Loads the presentation containing the macro
$pres = new Presentation("VBA.pptm");
try {
# Accesses the Vba module and removes it
$pres->getVbaProject()->getModules()->remove($pres->getVbaProject()->getModules()->get_Item(0));
# Saves the Presentation
$pres->save("test.pptm", SaveFormat::Pptm);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Extract VBA Macros**
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation) class and load the presentation containing the macro.
2. Check if the presentation contains a VBA Project.
3. Loop through all the modules contained in the VBA Project to view the macros.
This PHP code shows you how to extract VBA macros from a presentation containing macros:
```php
# Loads the presentation containing the macro
$pres = new Presentation("VBA.pptm");
try {
# Checks whether the Presentation contains a VBA Project
if (!java_is_null($pres->getVbaProject())) {
foreach($pres->getVbaProject()->getModules() as $module) {
echo($module->getName());
echo($module->getSourceCode());
}
}
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Check Whether a VBA Project Is Password-Protected**
Using the [VbaProject::isPasswordProtected](https://reference.aspose.com/slides/php-java/aspose.slides/vbaproject/#isPasswordProtected) method, you can determine whether a project’s properties are password-protected.
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class and load a presentation that contains a macro.
2. Check whether the presentation contains a [VBA project](https://reference.aspose.com/slides/php-java/aspose.slides/vbaproject/).
3. Check whether the VBA project is password-protected to view its properties.
```php
$presentation = new Presentation("VBA.pptm");
try {
if ($presentation->getVbaProject() != null) { // Check whether the presentation contains a VBA project.
if ($presentation->getVbaProject()->isPasswordProtected()) {
printf("The VBA Project '%s' is protected by password to view project properties.",
$presentation->getVbaProject()->getName());
}
}
} finally {
$presentation->dispose();
}
```
## **FAQ**
### What happens to macros if I save the presentation as PPTX?
Macros will be removed because PPTX does not support VBA. To keep macros, choose PPTM, PPSM, or POTM.
### Can Aspose.Slides run macros inside a presentation to, for example, refresh data?
No. The library never executes VBA code; execution is only possible inside PowerPoint with the appropriate security settings.
### Is working with ActiveX controls linked to VBA code supported?
Yes, you can access existing [ActiveX controls](https://docs.aspose.com/slides/php-java/activex/), modify their properties, and remove them. This is useful when macros interact with ActiveX.
## Related articles
- [VbaMacro](https://docs.aspose.com/slides/php-java/examples/elements/vba-macro/)
# Retrieve and Update Presentation View Properties in PHP
> Use Aspose.Slides for PHP via Java to configure the normal view layout, slide and notes zoom, grid spacing, and comment visibility in PowerPoint presentations.
Source: https://docs.aspose.com/slides/php-java/presentation-view-properties/
Updated: 2026-11-16
## **Introduction**
In PowerPoint's normal view, the slide appears between a side pane for thumbnails or an outline and a notes pane below. Aspose.Slides for PHP via Java exposes the presentation's saved editing preferences through [Presentation::getViewProperties](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/getviewproperties/). These include the pane layout, zoom levels, grid spacing, and comment visibility.
## **About NormalViewProperties**
Use [getNormalViewProperties](https://reference.aspose.com/slides/php-java/aspose.slides/viewproperties/getnormalviewproperties/) to access the [NormalViewProperties](https://reference.aspose.com/slides/php-java/aspose.slides/normalviewproperties/) class. [setShowOutlineIcons](https://reference.aspose.com/slides/php-java/aspose.slides/normalviewproperties/setshowoutlineicons/) controls whether icons appear beside slide titles in the outline. [setSnapVerticalSplitter](https://reference.aspose.com/slides/php-java/aspose.slides/normalviewproperties/setsnapverticalsplitter/) lets the side pane snap to its minimized state when the user narrows it. [setPreferSingleView](https://reference.aspose.com/slides/php-java/aspose.slides/normalviewproperties/setprefersingleview/) indicates a preference for displaying one pane in the full window.
[setVerticalBarState](https://reference.aspose.com/slides/php-java/aspose.slides/normalviewproperties/setverticalbarstate/) controls the divider between the side pane and the slide. [setHorizontalBarState](https://reference.aspose.com/slides/php-java/aspose.slides/normalviewproperties/sethorizontalbarstate/) controls the divider above the notes pane. Both accept a [SplitterBarStateType](https://reference.aspose.com/slides/php-java/aspose.slides/splitterbarstatetype/) value of `Minimized`, `Maximized`, or `Restored`.
## **About Restoring NormalViewProperties**
When a divider is restored, [getRestoredLeft](https://reference.aspose.com/slides/php-java/aspose.slides/normalviewproperties/getrestoredleft/) supplies the saved size of the side pane and [getRestoredTop](https://reference.aspose.com/slides/php-java/aspose.slides/normalviewproperties/getrestoredtop/) supplies the saved size of the upper slide area. Both expose [NormalViewRestoredProperties](https://reference.aspose.com/slides/php-java/aspose.slides/normalviewrestoredproperties/). Its [setDimensionSize](https://reference.aspose.com/slides/php-java/aspose.slides/normalviewrestoredproperties/setdimensionsize/) method accepts a percentage from 0 to 100, and [setAutoAdjust](https://reference.aspose.com/slides/php-java/aspose.slides/normalviewrestoredproperties/setautoadjust/) controls whether the editor adjusts the size when the window is resized.
This example updates an existing presentation. It restores the horizontal divider, sets the size returned by [getRestoredTop](https://reference.aspose.com/slides/php-java/aspose.slides/normalviewproperties/getrestoredtop/) to 80% with automatic adjustment enabled, and maximizes the vertical divider. It also calls [setShowOutlineIcons](https://reference.aspose.com/slides/php-java/aspose.slides/normalviewproperties/setshowoutlineicons/) to display icons in outline view.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SplitterBarStateType;
$presentation = new Presentation("demo.pptx");
try {
$normalView = $presentation->getViewProperties()->getNormalViewProperties();
$normalView->setHorizontalBarState(SplitterBarStateType::Restored);
$normalView->setVerticalBarState(SplitterBarStateType::Maximized);
$normalView->getRestoredTop()->setAutoAdjust(true);
$normalView->getRestoredTop()->setDimensionSize(80);
$normalView->setShowOutlineIcons(true);
$presentation->save("presentation_normal_view_state.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Set the Default Zoom Value**
[getSlideViewProperties](https://reference.aspose.com/slides/php-java/aspose.slides/viewproperties/getslideviewproperties/) and [getNotesViewProperties](https://reference.aspose.com/slides/php-java/aspose.slides/viewproperties/getnotesviewproperties/) store independent zoom settings for the editor. These settings do not affect slide dimensions, slide-show playback, or image export resolution.
This example opens an existing presentation and calls [setVariableScale](https://reference.aspose.com/slides/php-java/aspose.slides/commonslideviewproperties/setvariablescale/) to fit the slide to the editing window. For the notes page, it disables automatic scaling and calls [setScale](https://reference.aspose.com/slides/php-java/aspose.slides/commonslideviewproperties/setscale/) to set a fixed 80% zoom.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("demo.pptx");
try {
$viewProperties = $presentation->getViewProperties();
$viewProperties->getSlideViewProperties()->setVariableScale(true);
$viewProperties->getNotesViewProperties()->setVariableScale(false);
$viewProperties->getNotesViewProperties()->setScale(80);
$presentation->save("zoom.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Set the Grid Spacing**
The `setGridSpacing` method of [ViewProperties](https://reference.aspose.com/slides/php-java/aspose.slides/viewproperties/) sets the distance between editing grid lines throughout the presentation. It takes a positive value in points, with 72 points per inch. This example prints the current spacing in an existing presentation and saves a quarter-inch grid by setting the interval to 18 points.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("demo.pptx");
try {
$viewProperties = $presentation->getViewProperties();
echo "Current grid spacing: " . java_values($viewProperties->getGridSpacing()) . " points" . PHP_EOL;
$viewProperties->setGridSpacing(18.0);
$presentation->save("grid-spacing.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The grid repeats at a fixed interval. [Drawing guides](https://docs.aspose.com/slides/php-java/drawing-guides/) mark individual horizontal or vertical positions. Both are editing aids and appear only in editors that display them. Slide shows and exports to PDF, images, or SVG omit them.
## **Show or Hide Comments When Opening a Presentation**
[setShowComments](https://reference.aspose.com/slides/php-java/aspose.slides/viewproperties/setshowcomments/) stores a preference that compatible editors use when opening the presentation. For an existing presentation with comments, this example prints the current setting and saves a copy with comments hidden. It also calls [setLastView](https://reference.aspose.com/slides/php-java/aspose.slides/viewproperties/setlastview/) with [ViewType::SlideView](https://reference.aspose.com/slides/php-java/aspose.slides/viewtype/#SlideView) so the copy opens in slide view.
```php
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ViewType;
$presentation = new Presentation("comments.pptx");
try {
$viewProperties = $presentation->getViewProperties();
echo "Current comment visibility: " . java_values($viewProperties->getShowComments()) . PHP_EOL;
$viewProperties->setShowComments(NullableBool::False);
$viewProperties->setLastView(ViewType::SlideView);
$presentation->save("comments-hidden.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Hiding comments preserves their text, authors, positions, replies, and statuses. To change the comments themselves, see [Presentation Comments](https://docs.aspose.com/slides/php-java/presentation-comments/). Export settings control whether comments appear in PDF, HTML, images, notes, or handouts.
## **FAQ**
**Why is the grid hidden when I reopen the presentation?**
The presentation stores the grid interval. To see the grid, enable grid visibility in the editor.
**Does clearing drawing guides change the grid spacing?**
No. Adding, moving, or clearing a guide leaves the grid interval unchanged.
**Can different sections of a presentation have different view settings?**
No. [Presentation::getViewProperties](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/getviewproperties/) applies to the entire presentation.
**Can I save different view settings for different users?**
The file stores one set of view properties for everyone. An editor may also apply a user's local preferences.
**Can I save view settings in a template?**
Yes. Presentations created from the template inherit its saved view settings.
# Create a Presentation Viewer in PHP
> Create a custom presentation viewer using Aspose.Slides for PHP via Java. Easily display PowerPoint and OpenDocument files without Microsoft PowerPoint.
Source: https://docs.aspose.com/slides/php-java/presentation-viewer/
Updated: 2026-08-05
## **Introduction**
Aspose.Slides for PHP via Java is used to create presentation files with slides. These slides can be viewed by opening presentations in Microsoft PowerPoint, for example. However, sometimes developers may need to view slides as images in their preferred image viewer or create their own presentation viewer. In such cases, Aspose.Slides allows you to export an individual slide as an image. This article describes how to do it.
## **Generate an SVG Image from a Slide**
To generate an SVG image from a presentation slide with Aspose.Slides, please follow the steps below:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
1. Get the slide reference by its index.
1. Open a file stream.
1. Save the slide as an SVG image to the file stream.
```php
$slideIndex = 0;
$presentation = new Presentation("sample.pptx");
$slide = $presentation->getSlides()->get_Item($slideIndex);
$svgStream = new Java("java.io.FileOutputStream", "output.svg");
$slide->writeAsSvg($svgStream);
$svgStream->close();
$presentation->dispose();
```
## **Generate an SVG with a Custom Shape ID**
Aspose.Slides can be used to generate an [SVG](https://docs.fileformat.com/page-description-language/svg/) from a slide with a custom shape ID. To do this, use the `setId` method from [SvgShape](https://reference.aspose.com/slides/php-java/aspose.slides/svgshape/). `CustomSvgShapeFormattingController` can be used to set the shape ID.
```php
$slideIndex = 0;
$presentation = new Presentation("sample.pptx");
$slide = $presentation->getSlides()->get_Item($slideIndex);
$shapeFormattingController = java_closure(new CustomSvgShapeFormattingController(0), null, java("com.aspose.slides.ISvgShapeFormattingController"));
$svgOptions = new SVGOptions();
$svgOptions->setShapeFormattingController($shapeFormattingController);
$svgStream = new Java("java.io.FileOutputStream", "output.svg");
$slide->writeAsSvg($svgStream, $svgOptions);
$svgStream->close();
$presentation->dispose();
```
```php
class CustomSvgShapeFormattingController {
private $m_shapeIndex;
public function __construct($shapeStartIndex) {
$this->m_shapeIndex = $shapeStartIndex;
}
public function formatShape($svgShape, $shape) {
$svgShape->setId(sprintf("shape-%d", $this->m_shapeIndex++));
}
}
```
## **Create a Slide Thumbnail Image**
Aspose.Slides helps you generate thumbnail images of slides. To generate a thumbnail of a slide using Aspose.Slides, please follow the steps below:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
1. Get the slide reference by its index.
1. Get the thumbnail image of the referenced slide at a defined scale.
1. Save the thumbnail image in any desired image format.
```php
$slideIndex = 0;
$scaleX = 1.0;
$scaleY = $scaleX;
$presentation = new Presentation("sample.pptx");
$slide = $presentation->getSlides()->get_Item($slideIndex);
$image = $slide->getImage($scaleX, $scaleY);
$image->save("output.jpg", ImageFormat::Jpeg);
$image->dispose();
$presentation->dispose();
```
## **Create a Slide Thumbnail with User Defined Dimensions**
To create a slide thumbnail image with user defined dimensions, please follow the steps below:
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
1. Get the slide reference by its index.
1. Get the thumbnail image of the referenced slide with the defined dimensions.
1. Save the thumbnail image in any desired image format.
```php
$slideIndex = 0;
$slideSize = new Java("java.awt.Dimension", 1200, 800);
$presentation = new Presentation("sample.pptx");
$slide = $presentation->getSlides()->get_Item($slideIndex);
$image = $slide->getImage($slideSize);
$image->save("output.jpg", ImageFormat::Jpeg);
$image->dispose();
$presentation->dispose();
```
## **Create a Slide Thumbnail with Speaker Notes**
To generate the thumbnail of a slide with speaker notes using Aspose.Slides, please follow the steps below:
1. Create an instance of the [RenderingOptions](https://reference.aspose.com/slides/php-java/aspose.slides/renderingoptions/) class.
1. Use the `RenderingOptions.setSlidesLayoutOptions` method to set the position of speaker notes.
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
1. Get the slide reference by its index.
1. Get the thumbnail image of the referenced slide with the rendering options.
1. Save the thumbnail image in any desired image format.
```php
$slideIndex = 0;
$layoutingOptions = new NotesCommentsLayoutingOptions();
$layoutingOptions->setNotesPosition(NotesPositions::BottomTruncated);
$renderingOptions = new RenderingOptions();
$renderingOptions->setSlidesLayoutOptions($layoutingOptions);
$presentation = new Presentation("sample.pptx");
$slide = $presentation->getSlides()->get_Item($slideIndex);
$image = $slide->getImage($renderingOptions);
$image->save("output.png", ImageFormat::Png);
$image->dispose();
$presentation->dispose();
```
## **Live Example**
You can try [**Aspose.Slides Viewer**](https://products.aspose.app/slides/viewer/) free app to see what you can implement with Aspose.Slides API:

## **FAQ**
### Can I embed a presentation viewer in a web application?
Yes. You can use Aspose.Slides on the server side to render slides as images or HTML and display them in the browser. Navigation and zoom features can be implemented with JavaScript for an interactive experience.
### What is the best way to display slides inside a custom viewer?
The recommended approach is to render each slide as an image (e.g., PNG or SVG) or convert it to HTML using Aspose.Slides, then display the output inside a picture box (for desktop) or HTML container (for web).
### How do I handle large presentations with many slides?
For large decks, consider lazy-loading or on-demand rendering of slides. This means generating a slide's content only when the user navigates to it, reducing memory and load time.
## Related articles
- [Create Thumbnails of Presentation Shapes in PHP](https://docs.aspose.com/slides/php-java/create-shape-thumbnails/)
# Handle Presentation Warnings in PHP
> Learn how to collect, classify, and act on warnings while loading, rendering, converting, and saving presentations with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/presentation-warnings/
Updated: 2026-09-03
## **Overview**
Aspose.Slides can report recoverable problems while it loads, renders, converts, or saves a presentation. Examples include damaged source records, content that cannot be preserved, font substitution, and limitations of a target format. A warning callback lets an application record these conditions and decide whether the current operation may continue.
Create a PHP class with a public `warning` method and expose it through PHP Java Bridge as the Java [IWarningCallback](https://reference.aspose.com/slides/java/com.aspose.slides/iwarningcallback/) interface using `java_closure`. Examine the [getWarningType](https://reference.aspose.com/slides/java/com.aspose.slides/iwarninginfo/#getWarningType--) and [getDescription](https://reference.aspose.com/slides/java/com.aspose.slides/iwarninginfo/#getDescription--) values supplied through [IWarningInfo](https://reference.aspose.com/slides/java/com.aspose.slides/iwarninginfo/). Return [ReturnAction::Continue](https://reference.aspose.com/slides/php-java/aspose.slides/returnaction/#Continue) to accept the warning or [ReturnAction::Abort](https://reference.aspose.com/slides/php-java/aspose.slides/returnaction/#Abort) to stop the operation.
Use [LoadOptions::setWarningCallback](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/#setWarningCallback) for warnings raised while opening a presentation. Rendering and export option classes inherit [SaveOptions::setWarningCallback](https://reference.aspose.com/slides/php-java/aspose.slides/saveoptions/#setWarningCallback), which receives warnings from slide rendering, conversion, and saving. Because the warning itself does not identify the application operation, associate each callback instance with an operation stage when you build a combined report.
## **Warnings and Exceptions**
Java exceptions are exposed to PHP through PHP Java Bridge; catch them at the operation boundary, as shown in the example below. The Java interface links in this article describe the callback contract used by the bridge.
A warning describes a condition from which Aspose.Slides can recover if the callback returns `ReturnAction::Continue`. An exception means the requested operation cannot complete normally; exceptions are not converted into warnings and cannot be handled by a warning policy.
Returning `ReturnAction::Abort` asks the warning dispatcher to terminate the current operation by raising an exception. The public exception depends on the operation and presentation format. For example, loading can surface a [PptxReadException](https://reference.aspose.com/slides/php-java/aspose.slides/pptxreadexception/) or [PptReadException](https://reference.aspose.com/slides/php-java/aspose.slides/pptreadexception/), while saving or exporting can surface a [PptxException](https://reference.aspose.com/slides/php-java/aspose.slides/pptxexception/). Handle the exception at the boundary of the operation and use the warning report to determine whether the application policy caused the termination instead of relying on one exception subtype or message. The callback records the warning before returning `ReturnAction::Abort`, ensuring that the reason remains available to the application.
## **Warning Categories**
The [WarningType](https://reference.aspose.com/slides/php-java/aspose.slides/warningtype/) class provides integer constants for the following categories:
| Warning type | Meaning | Typical policy |
| --- | --- | --- |
| [SourceFileCorruption](https://reference.aspose.com/slides/php-java/aspose.slides/warningtype/#SourceFileCorruption) | The source presentation contains corruption that can make a document saved in its original format unusable. | Abort. |
| [DataLoss](https://reference.aspose.com/slides/php-java/aspose.slides/warningtype/#DataLoss) | Text, charts, images, or other data may be absent after loading or saving. | Abort. |
| [MajorFormattingLoss](https://reference.aspose.com/slides/php-java/aspose.slides/warningtype/#MajorFormattingLoss) | The presentation may lose important formatting. | Abort in strict validation mode; otherwise record and continue. |
| [MinorFormattingLoss](https://reference.aspose.com/slides/php-java/aspose.slides/warningtype/#MinorFormattingLoss) | A limited formatting difference may occur. | Record for diagnostics and continue. |
| [CompatibilityIssue](https://reference.aspose.com/slides/php-java/aspose.slides/warningtype/#CompatibilityIssue) | The result may not open or behave correctly in some applications or older versions. | Log and continue unless compatibility is mandatory. |
| [UnexpectedContent](https://reference.aspose.com/slides/php-java/aspose.slides/warningtype/#UnexpectedContent) | The source contains unsupported or unrecognized content whose effect may not yet be known. | Record and continue, or treat as an error in a strict policy. |
The category should drive the policy decision. Store the value returned by [getDescription](https://reference.aspose.com/slides/java/com.aspose.slides/iwarninginfo/#getDescription--) for diagnostics, but do not depend on its wording for application logic because message text can vary between warning scenarios and product versions.
## **Collect and Classify Warnings**
The following example uses one application-level report for the complete processing pipeline. A separate callback instance labels warnings from loading, rendering, PDF conversion, and PPTX saving. The policy aborts on source corruption or data loss, optionally aborts on major formatting loss, and continues for other warnings. The callback converts warning values to native PHP values with `java_values` before recording and comparing them.
```php
use aspose\slides\ImageFormat;
use aspose\slides\LoadOptions;
use aspose\slides\PdfOptions;
use aspose\slides\PptxOptions;
use aspose\slides\Presentation;
use aspose\slides\RenderingOptions;
use aspose\slides\ReturnAction;
use aspose\slides\SaveFormat;
use aspose\slides\WarningType;
class WarningReport {
private $entries = [];
public function getEntries() {
return $this->entries;
}
public function add($stage, $type, $description) {
$this->entries[] = [
"stage" => $stage,
"type" => $type,
"description" => $description
];
}
}
class WarningPolicy {
private $abortOnMajorFormattingLoss;
public function __construct($abortOnMajorFormattingLoss) {
$this->abortOnMajorFormattingLoss = $abortOnMajorFormattingLoss;
}
public function getAction($warningType) {
if ($warningType === WarningType::SourceFileCorruption || $warningType === WarningType::DataLoss) {
return ReturnAction::Abort;
}
if ($warningType === WarningType::MajorFormattingLoss && $this->abortOnMajorFormattingLoss) {
return ReturnAction::Abort;
}
return ReturnAction::Continue;
}
}
class ReportingWarningCallback {
private $stage;
private $report;
private $policy;
public function __construct($stage, WarningReport $report, WarningPolicy $policy) {
$this->stage = $stage;
$this->report = $report;
$this->policy = $policy;
}
public function warning($warning) {
$type = (int) java_values($warning->getWarningType());
$description = (string) java_values($warning->getDescription());
$this->report->add($this->stage, $type, $description);
return $this->policy->getAction($type);
}
}
function createWarningCallback($stage, WarningReport $report, WarningPolicy $policy) {
$handler = new ReportingWarningCallback($stage, $report, $policy);
$warningInterface = java("com.aspose.slides.IWarningCallback");
return java_closure($handler, null, $warningInterface);
}
function processPresentation($inputPath, WarningReport $report, WarningPolicy $policy) {
try {
$loadOptions = new LoadOptions();
$callback = createWarningCallback("Loading", $report, $policy);
$loadOptions->setWarningCallback($callback);
$presentation = new Presentation($inputPath, $loadOptions);
try {
if (!renderFirstSlide($presentation, $report, $policy)) {
return false;
}
if (!convertToPdf($presentation, $report, $policy)) {
return false;
}
return saveValidatedCopy($presentation, $report, $policy);
} finally {
$presentation->dispose();
}
} catch (Throwable $exception) {
echo "Loading stopped: " . $exception->getMessage() . PHP_EOL;
return false;
}
}
function renderFirstSlide($presentation, WarningReport $report, WarningPolicy $policy) {
if ((int) java_values($presentation->getSlides()->size()) === 0) {
echo "Rendering stopped: the presentation has no slides." . PHP_EOL;
return false;
}
try {
$options = new RenderingOptions();
$callback = createWarningCallback("Rendering", $report, $policy);
$options->setWarningCallback($callback);
$image = $presentation->getSlides()->get_Item(0)->getImage($options);
try {
$image->save("slide-1.png", ImageFormat::Png);
return true;
} finally {
$image->dispose();
}
} catch (Throwable $exception) {
echo "Rendering stopped: " . $exception->getMessage() . PHP_EOL;
return false;
}
}
function convertToPdf($presentation, WarningReport $report, WarningPolicy $policy) {
try {
$options = new PdfOptions();
$callback = createWarningCallback("Conversion", $report, $policy);
$options->setWarningCallback($callback);
$presentation->save("converted.pdf", SaveFormat::Pdf, $options);
return true;
} catch (Throwable $exception) {
echo "Conversion stopped: " . $exception->getMessage() . PHP_EOL;
return false;
}
}
function saveValidatedCopy($presentation, WarningReport $report, WarningPolicy $policy) {
try {
$options = new PptxOptions();
$callback = createWarningCallback("Saving", $report, $policy);
$options->setWarningCallback($callback);
$presentation->save("validated-output.pptx", SaveFormat::Pptx, $options);
return true;
} catch (Throwable $exception) {
echo "Saving stopped: " . $exception->getMessage() . PHP_EOL;
return false;
}
}
function warningTypeName($warningType) {
switch ($warningType) {
case WarningType::SourceFileCorruption:
return "SourceFileCorruption";
case WarningType::DataLoss:
return "DataLoss";
case WarningType::MajorFormattingLoss:
return "MajorFormattingLoss";
case WarningType::MinorFormattingLoss:
return "MinorFormattingLoss";
case WarningType::CompatibilityIssue:
return "CompatibilityIssue";
case WarningType::UnexpectedContent:
return "UnexpectedContent";
default:
return "Unknown (" . $warningType . ")";
}
}
$report = new WarningReport();
$policy = new WarningPolicy(true);
$completed = processPresentation("input.pptx", $report, $policy);
echo ($completed ? "Processing completed." : "Processing stopped.") . PHP_EOL;
foreach ($report->getEntries() as $entry) {
$typeName = warningTypeName($entry["type"]);
echo "[" . $entry["stage"] . "] " . $typeName . ": " . $entry["description"] . PHP_EOL;
}
```
Pass `false` for `abortOnMajorFormattingLoss` when constructing `WarningPolicy` if major formatting differences are acceptable. Compatibility issues, minor formatting loss, and unexpected content are still retained in the report even when the operation continues. Extend `WarningPolicy::getAction` if the application must reject any of those categories.
## **Common Warning Scenarios**
Warnings can appear at different stages of a workflow:
- **Digital signatures:** A signed presentation can produce a warning during loading that its signature will be lost during processing. Aspose.Slides reports this `DataLoss` condition through [IPresentationSignedWarningInfo](https://reference.aspose.com/slides/java/com.aspose.slides/ipresentationsignedwarninginfo/). A load-stage callback lets the application reject the file or explicitly accept the reported loss.
- **Font substitution:** An unavailable font can be replaced while a slide is rendered or exported. Font substitution warnings are reported as `DataLoss`, so the strict policy above aborts even if the application would consider a particular replacement visually acceptable. To observe this behavior, use an input presentation containing text in a font unavailable to the runtime. The warning description identifies the substitution; configure the required fonts or [font substitution rules](https://docs.aspose.com/slides/php-java/font-substitution/) before retrying.
- **Unsupported or unexpected content:** A loader can encounter presentation records or features it does not recognize. Such warnings may use `UnexpectedContent`, or a more severe category when data or formatting is known to be affected.
- **Format compatibility:** Saving to another presentation format can omit features or produce a result that behaves differently in some applications. For example, saving a presentation with more than eight horizontal or eight vertical drawing guides to legacy PPT reports a `CompatibilityIssue`. The save-stage callback can record the loss and continue, or reject it if preserving all guides is required.
- **Loading behavior:** Loading options and legacy behaviors can also produce warnings. For example, [IObsoletePresLockingBehaviorWarningInfo](https://reference.aspose.com/slides/java/com.aspose.slides/iobsoletepreslockingbehaviorwarninginfo/) identifies use of an obsolete presentation-locking behavior as a `CompatibilityIssue`.
Warnings depend on the source document, target format, operation, and Aspose.Slides version. Do not assume that every file produces a warning or that a scenario always maps to only one category.
## **Safely Handle Aborted Operations**
When a callback returns `ReturnAction::Abort`, do not use an object that failed to load and do not assume that a rendering or save output is complete. The operation can terminate after creating an output file but before finishing it.
Save validated results to a separate path such as `validated-output.pptx`. Replace an existing presentation only after the operation finishes successfully, the warning report satisfies the application policy, and the output can be opened and checked. This avoids overwriting a valid source file with a partial or rejected result.
An empty warning report is not a guarantee that every source feature has been preserved. Apply any additional content and visual checks required by the application. See also [Open Presentations](https://docs.aspose.com/slides/php-java/open-presentation/) and [Save Presentations](https://docs.aspose.com/slides/php-java/save-presentation/).
## **FAQ**
**Can a warning callback handle every Aspose.Slides error?**
No. It handles recoverable conditions reported as warnings. Exceptions that occur independently of the callback must be handled by the application around the loading, rendering, conversion, or saving call.
**Does returning `ReturnAction::Continue` guarantee identical output?**
No. It only permits processing to continue. The reported condition can still cause data, formatting, or compatibility differences, so review the collected warning types and descriptions.
**How can an application identify the operation that produced a warning?**
Create a callback instance for each operation and store an application-defined stage together with the values returned by [getWarningType](https://reference.aspose.com/slides/java/com.aspose.slides/iwarninginfo/#getWarningType--) and [getDescription](https://reference.aspose.com/slides/java/com.aspose.slides/iwarninginfo/#getDescription--), as shown in the example.
# PresentationML (PPTX, XML)
>
Source: https://docs.aspose.com/slides/php-java/presentationml-pptx-xml/
Updated: 2026-08-13
PresentationML is a name for a family of XML-based formats for presentation documents. Office OpenXML (OOXML) is the XML-based format introduced in Microsoft Office 2007 applications. Office OpenXML is a container format for several specialized XML-based markup languages. PresentationML is the markup language used by Microsoft Office PowerPoint 2007 to store documents.
## **PresentationML in Aspose.Slides for PHP via Java**
OOXML PresentationML documents come as PPTX files, zipped XML packages that follow the [OOXML ECMA-376](https://www.ecma-international.org/publications-and-standards/standards/ecma-376/) specification. Aspose.Slides for PHP via Java extensively supports creating, reading, manipulating and writing PresentationML documents. In addition, Aspose.Slides for PHP via Java is capable of exporting PresentationML documents to a widely used document format like PDF. This is possible because Aspose.Slides for PHP via Java was designed with the aim to comprehensively handle presentation documents and PresentationML basically holds the internal presentation of documents as a zipped XML package.
**A PPTX document generated by Aspose.Slides for PHP via Java and opened in Microsoft PowerPoint**

**Viewing the same PPTX document generated by Aspose.Slides for PHP via Java in a ZIP**

## **PresentationML is Open, Why Use Aspose.Slides for PHP via Java?**
Since PresentationML is XML based, it is quite possible to build applications to process and generat PresentationML documents using XML classes without relying on a third party class library such as Aspose.Slides for PHP via Java. However, there are several advantages of using Aspose.Slides for PHP via Java over XML classes when working with PresentationML documents.
The OOXML specification is several thousand pages long so to properly handle the PresentationML documents, you have to spend a lot of time and effort to understand the format. On the other hand, with Aspose.Slides for PHP via Java, you just use classes and their methods and properties to performing operations which seem complex if performed via XML classes.
Some of the features that Aspose.Slides offer are not even available when you work with PresentationML documents through XML classes:
- Export PPT documents to PDF format.
- Render a slide to any image format supported by the Java Framework.
- Automatically copy masters from a source presentations using the cloning feature.
- Apply protection to shapes.
Below is an example of a PresentationML document with a single slide containing a text box with the text “Hello World”. To read the text using XML classes, you have to write a program that can parse this simple text from the following fragment. Aspose.Slides does that for you.
**XML**
``` xml
Hello World
```php
```
## Related articles
- [Microsoft PowerPoint (PPT)](https://docs.aspose.com/slides/php-java/microsoft-powerpoint-ppt/)
# Product Overview
> Aspose.Slides for PHP via Java lets you create, edit and convert PowerPoint (PPT, PPTX) and OpenDocument (ODP) presentations without Microsoft Office.
Source: https://docs.aspose.com/slides/php-java/product-overview/
Updated: 2026-08-02

## **Welcome to Aspose.Slides for PHP via Java!**
Aspose.Slides is a Microsoft PowerPoint® management API that allows applications to read, write, create, and modify PowerPoint presentations without using Microsoft PowerPoint®. The library supports working with presentations, slides, shapes, tables, text, animations, audio, video, and other presentation elements.
With Aspose.Slides, developers can open presentations from different sources, save them in various PowerPoint formats, export presentations to formats such as PDF, TIFF, XPS, SWF, HTML, and SVG, and save slides as images. The API also provides features for managing document properties, applying protection, previewing slides, editing slide content, working with slide notes, and handling advanced presentation elements such as embedded OLE objects.
### **Why You Should Use Aspose.Slides for PHP via Java**
- Aspose.Slides for PHP via Java is the first and only component that provides the functionalities required to manage PowerPoint® documents.
- Aspose.Slides for PHP via Java offers a lot of key features such as managing texts, shapes, tables & animations, adding audio and video to slides, previewing slides, exporting slides to SVG, PDF, and other formats, and many more capabilities.
- Aspose.Slides for PHP via Java not only lets you open PowerPoint files from different sources but also allows you to save your presentations in a variety of ways. For example, you can save your presentations in PPT; you can also save your slides as images.
- Aspose.Slides for PHP via Java gives you almost all the features you may or may not find in Microsoft PowerPoint. Given the versatility of Aspose.Slides for PHP via Java, besides tables and different kinds of shapes, you get to use it to add different kinds of frames—text, audio, and video frames—to your slides.
## **Aspose.Slides Features**
Aspose.Slides for PHP via Java features can be divided into these groups:
- Presentation Features.
- Slides Features.
- Graphics and Multimedia Features.
- Table Features.
- Text & Paragraph Features
- Advanced Features
### **Presentation Features**
- Opening Microsoft PowerPoint presentations from different sources.
- Saving presentations in different Microsoft PowerPoint formats.
- Creating presentations from scratch.
- Converting presentations to PDF documents without using any other component
- Reading or modifying a presentation's document properties
- Applying protection on presentation
- Exporting presentation to PDF
- Exporting presentation to TIFF
- Exporting presentation to XPS
- Exporting presentation to SWF
- Exporting presentation to PDF Note / Tiff Notes
- Exporting presentation to HTML
### **Slide Features**
- Creating new slides from scratch and adding them to presentations.
- Accessing any slide through its position in a presentation.
- Copying or cloning slides to the same or another presentation.
- Editing and deleting slides.
- Copying masters with slides automatically.
- Previewing slides.
- Getting or setting a slide's name.
- Saving slides as images.
- Exporting slides to SVG format.
- Working with many masters in presentations.
- Filling slides background with any supported style.
- Adding new or managing slide notes.
- Setting new slide masters and styles dynamically.
- Adding or modifying slide show transition.
- Adding Morph Transitions
### **Graphics & Multimedia Features**
- Creating or managing shapes such as lines, rectangles, ellipses, and polylines.
- Managing line styles in shapes.
- Getting a shape's alternative text.
- Rotating flip shapes.
- Filling shapes in different styles—for example, solid, gradient, pattern, texture, and picture.
- Using any of 48 pre-defined patterns and 24 textures.
- Assigning links to shapes.
- Reading, modifying, and adding new animation effects to slides and shapes.
- Adding new pictures to presentations and managing existing ones.
- Adding new picture bullets to presentations and managing existing ones.
- Adding new audio frames to presentations and managing existing ones.
- Adding new video frames to presentations and managing existing ones.
### **Table Features**
- Creating tables from scratch and adding them to slides.
- Resizing and moving tables.
- Accessing any cell in a table.
- Changing the format and borders of any cell.
- Resizing columns and rows.
- Adding and deleting columns and rows.
- Setting border width and color for the whole table.
### **Text & Paragraph Features**
- Getting and setting texts in text placeholders and text frames.
- Getting a placeholder's type.
- Changing the text formatting in a text frame.
- Adding new fonts or managing the fonts already used in a presentation.
- Changing texts and Text Formatting.
- Creating or managing links to the text.
- Supporting tabs and effective tabs.
- Adding new text frames to almost any type of shape.
- Accessing and modifying margins and text wrap settings of text frames.
- Accessing and modifying paragraph indentation.
### **Advanced Features**
- Accessing OLE objects embedded in presentations.
- Locking presentations.
## **Technical support**
Aspose provides unlimited free technical support for all its products. The support is available to all users (including users with evaluation packages). If you need help with Aspose.Slides for PHP via Java, consider the following:
- The main avenue for support is the [Aspose Forums](https://forum.aspose.com/). Post your question in the [Aspose.Slides forum](https://forum.aspose.com/c/slides/11)—and it will be answered within a few hours. Aspose.Slides support team directly answers questions posted on the forum.
- Please note that Aspose does not provide technical support over the phone. Phone support is only available for sales and purchase questions.
- When expecting a reply in the forums, please be patient and make evaluations for time zone differences.
If you have an issue with Aspose.Slides for PHP via Java, follow these guidelines to resolve it in the most efficient manner:
- Check and confirm that you are using the latest Aspose.Slides for PHP via Java version first before reporting the issue. Perhaps, the issue you experienced was already resolved in an update.
See [Aspose.Slides download](https://downloads.aspose.com/slides/php-java) to get information on the latest product version.
- Before reporting an issue, you may want to go through our forums, this documentation, and the API Reference. Perhaps, the answer to your question was provided already.
- When reporting an issue, please include the original document and (if possible) a fragment of your code pertaining to the problem. If you need to attach multiple files, put them in a ZIP package.
You can safely attach your documents in Aspose.Forums because only you and Aspose developers have access to the attached files.
- Create and use one thread for a specific issue. If you experience another issue, you have to create another thread to report it.
This table lists important Aspose.Slides for PHP via Java technical resources.
|**Resource**|**Description**|
| :- | :- |
|[Aspose.Slides for PHP via Java home page](https://products.aspose.com/slides/php-java/)|Product home page.|
|[Aspose.Slide blog](https://blog.aspose.com/category/slides/)|Check this page regularly for information on new releases and useful tips on Aspose.Slides.|
|[Aspose.Slides for PHP via Java download](https://packagist.org/packages/aspose/slides)|Download the latest version of Aspose.Slides here. We often release new versions.|
|[Aspose.Slides support forum](https://forum.aspose.com/c/slides/11)|Post your questions and issues here for a speedy resolution.|
|[Aspose.Slides for PHP via Java product documentation](https://docs.aspose.com/slides/php-java/)|Full online documentation that contains this document and the Aspose.Slides API Reference.|
## **FAQ**
### Does it support PDF conformance levels for archiving and accessibility (PDF/A and PDF/UA)?
Yes. You can save to PDF with PDF/A-2a/2b/2u, PDF/A-3a/3b, as well as PDF/UA by configuring [PDF export options](https://reference.aspose.com/slides/php-java/aspose.slides/pdfoptions/).
### Is there a font substitution mechanism and support for custom fonts to ensure correct rendering?
Yes. The library lets you [load custom fonts](https://docs.aspose.com/slides/php-java/custom-font/) and [define fallback rules](https://docs.aspose.com/slides/php-java/fallback-font/) so missing glyphs are substituted reliably during conversion and rendering.
### Can I detect whether a file is password-protected without fully opening it?
Yes. You can [inspect a presentation](https://docs.aspose.com/slides/php-java/examine-presentation/) to determine if it requires a password before loading the full document.
### Is Microsoft PowerPoint required for processing and conversions?
No. Aspose.Slides is a standalone engine; PowerPoint is not needed on the server or workstation.
### Is it safe to process presentations from multiple threads?
Yes, you can process different documents in parallel in separate threads; just avoid using the same presentation instance concurrently [across threads](https://docs.aspose.com/slides/php-java/multithreading/).
### Are macros preserved and can I manage VBA in PPTM/PPSM files?
Yes. Presentations with macros [are supported](https://docs.aspose.com/slides/php-java/presentation-via-vba/), and you can [inspect and manage VBA projects](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/getvbaproject/) in those files.
### Can I convert PDF or HTML back into PowerPoint slides?
Yes. You can [import PDF pages or HTML content](https://docs.aspose.com/slides/php-java/import-presentation/) to create or populate slides in a presentation.
### Is XPS export supported, and can I control the quality and content of the XPS output?
Yes. [Export to XPS](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-xps/) is available, and [save options](https://reference.aspose.com/slides/php-java/aspose.slides/xpsoptions/) allow you to tune output quality and included content.
### Can I convert slides to images and control the output quality?
Yes. Slides can be [rendered to PNG, JPEG, GIF, BMP, TIFF](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-png/) and other formats with fine-grained control over size and quality.
### Are mathematical formulas supported (MathML/MathText) and can they be exported?
Yes. You can [create and edit mathematical text](https://docs.aspose.com/slides/php-java/powerpoint-math-equations/) and [export equations](https://docs.aspose.com/slides/php-java/exporting-math-equations/), including to MathML.
### How does the library handle encryption and passwords (open, set, remove)?
[It supports](https://docs.aspose.com/slides/php-java/password-protected-presentation/) opening encrypted presentations, setting or removing passwords for opening and modifying, and checking a file’s protection status.
## Related articles
- [Product Support](https://docs.aspose.com/slides/php-java/product-support/)
- [Technical Support](https://docs.aspose.com/slides/php-java/technical-support/)
- [Aspose.Slides for PHP via Java](https://docs.aspose.com/slides/php-java/)
# Product Support
> Get free, fast Aspose.Slides for PHP product support: forums, docs, updates, code help to fix issues across PowerPoint and OpenDocument workflows.
Source: https://docs.aspose.com/slides/php-java/product-support/
Updated: 2026-08-13
## **Technical support**
Aspose provides unlimited free technical support for all its products. The support is available to all users (including users with evaluation packages).
When you need help with Aspose.Slides for PHP via Java, consider the following:
- The main avenue for support is the [Aspose.Forums](https://forum.aspose.com/c/slides/11). Post your question in the Aspose.Slides forum—and it will be answered within a few hours. Aspose.Slides support team directly answers questions posted on the forum.
- Please note that Aspose does not provide technical support over the phone. Phone support is only available for sales and purchase questions.
- When expecting a reply in the forums, please be patient and make evaluations for time zone differences.
When you experience an issue with Aspose.Slides for PHP via Java, follow these guidelines to resolve it in the most efficient manner:
- Check and confirm that you are using the latest Aspose.Slides for PHP via Java version before reporting the issue. Perhaps, the issue you experienced was already resolved in an update.
See [Aspose.Slides download](https://downloads.aspose.com/slides/php-java) to get information on the latest version.
- Before reporting an issue, you may want to go through our forums, this documentation, and the API Reference. Perhaps, the answer to your question was provided already.
- When reporting an issue, please include the original document and (if possible) a fragment of your code pertaining to the problem. If you need to attach multiple files, put them in a ZIP package. You can safely attach your documents in Aspose.Forums because **only** you and Aspose developers have access to the attached files.
- Create and use one thread for a specific issue. If you experience another issue, you have to create another thread to report it.
## **Resources**
This table list useful Aspose.Slides for PHP via Java technical resources.
|**Resource**|**Description**|
| :- | :- |
|[Aspose.Slides for PHP via Java home page](https://products.aspose.com/slides/php-java/)|Product home page.|
|[Aspose.Slides blog](https://blog.aspose.com/category/slides/)|Check this section regularly for information on new releases and useful tips on Aspose.Slides.|
|[Aspose.Slides for PHP via Java download](https://packagist.org/packages/aspose/slides)|Download the latest version of Aspose.Slides from this page. We often release new versions.|
|[Aspose.Slides support forum](https://forum.aspose.com/c/slides/11)|Post your questions and issues here for a speedy resolution.|
|[Aspose.Slides for PHP via Java product documentation](https://docs.aspose.com/slides/php-java/)|Full online documentation that contains this document and the Aspose.Slides API Reference.|
## Related articles
- [Technical Support](https://docs.aspose.com/slides/php-java/technical-support/)
- [Resources](https://docs.aspose.com/slides/php-java/resources/)
- [Product Overview](https://docs.aspose.com/slides/php-java/product-overview/)
# Save Presentations in Read-Only Mode Using PHP
> Load and save PowerPoint files (PPT, PPTX) in read-only mode with Aspose.Slides for PHP, offering precise slide previews without altering your presentations.
Source: https://docs.aspose.com/slides/php-java/read-only-presentation/
Updated: 2026-08-13
## **Introduction**
In PowerPoint 2019, Microsoft introduced the **Always Open Read-Only** setting as one of the options users can use to protect their presentations. You may want to use this Read-Only setting to protect a presentation when
- You want to prevent accidental edits and keep the content of your presentation safe.
- You want to alert people that the presentation you provided is the final version.
After you select the **Always Open Read-Only** option for a presentation, when users open the presentation, they see the **Read-Only** recommendation and may see a message in this form: *To prevent accidental changes, the author has set this file to open as read-only.*
The Read-Only recommendation is a simple yet effective deterrent that discourages editing because users have to perform a task to remove it before they are allowed to edit a presentation. If you do not want users to make changes to a presentation and want to tell them about this in a polite way, then the Read-Only recommendation may a good option for you.
> If a presentation with the **Read-Only** protection gets opened in an older Microsoft PowerPoint application—which does not support the recently introduced function—the **Read-Only** recommendation gets ignored (the presentation is opened normally).
## **Apply Read-Only Mode**
Aspose.Slides for PHP via Java allows you to set a presentation to **Read-Only**, which means users (after they open the presentation) see the **Read-Only** recommendation. This sample code shows you how to set a presentation to **Read-Only** using Aspose.Slides:
```php
$pres = new Presentation();
try {
$pres->getProtectionManager()->setReadOnlyRecommended(true);
$pres->save("ReadOnlyPresentation.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
**Note**: The **Read-Only** recommendation is simply meant to discourage editing or stop users from making accidental changes to a PowerPoint presentation. If a motivated person—who knows what they are doing—decides to edit your presentation, they can easily remove the Read-Only setting. If you seriously need to prevent unauthorized editing, you are better off using [more stringent protections that involve encryptions and passwords](https://docs.aspose.com/slides/php-java/password-protected-presentation/).
## **FAQ**
### How is 'Read-Only recommended' different from full password protection?
'Read-Only recommended' only displays a suggestion to open the file in read-only mode and is easy to bypass. [Password protection](https://docs.aspose.com/slides/php-java/password-protected-presentation/) actually restricts opening or editing and is appropriate when you need real security controls.
### Can 'Read-Only recommended' be combined with watermarks to further discourage edits?
Yes. The recommendation can be paired with [watermarks](https://docs.aspose.com/slides/php-java/watermark/) as a visual deterrent; they are separate mechanisms and work well together.
### Can a macro or external tool still modify the file when the recommendation is enabled?
Yes. The recommendation does not block programmatic changes. To prevent automated edits, use [passwords and encryption](https://docs.aspose.com/slides/php-java/password-protected-presentation/).
### How does 'Read-Only recommended' relate to the methods 'isEncrypted' and 'isWriteProtected'?
They are different signals. 'Read-Only recommended' is a soft, optional prompt; [isWriteProtected](https://reference.aspose.com/slides/php-java/aspose.slides/protectionmanager/iswriteprotected/) and [isEncrypted](https://reference.aspose.com/slides/php-java/aspose.slides/protectionmanager/isencrypted/) indicate actual write or read restrictions that depend on passwords or encryption.
# Add Rectangles to Presentations in PHP
> Boost your PowerPoint presentations by adding rectangles with Aspose.Slides for PHP via Java — easily design and modify shapes programmatically.
Source: https://docs.aspose.com/slides/php-java/rectangle/
Updated: 2026-08-02
## **Overview**
This article shows how to add rectangle shapes to PowerPoint slides by using Aspose.Slides. It covers creating a simple rectangle, creating a formatted rectangle, and saving the updated presentation as a PPTX file.
You will also see how to apply basic rectangle formatting, such as a solid fill color, line color, and line width. In addition, the article’s FAQ points to related rectangle tasks, including rounded corners, picture fills, visual effects, hyperlinks, shape locks, export options, and effective properties.
## **Add a Rectangle to a Slide**
To add a simple rectangle to a selected slide of the presentation, please follow the steps below:
- Create an instance of [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation) class.
- Obtain the reference of a slide by using its Index.
- Add an [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/) of Rectangle type using [addAutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/#addAutoShape) method exposed by [ShapeCollection](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/) object.
- Write the modified presentation as a PPTX file.
In the example given below, we have added a simple rectangle to the first slide of the presentation.
```php
# Instantiate Prseetation class that represents the PPTX
$pres = new Presentation();
try {
# Get the first slide
$sld = $pres->getSlides()->get_Item(0);
# Add AutoShape of ellipse type
$shp = $sld->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 150, 150, 50);
# Write the PPTX file to disk
$pres->save("RecShp1.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Add a Formatted Rectangle to a Slide**
To add a formatted rectangle to a slide, please follow the steps below:
- Create an instance of [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation) class.
- Obtain the reference of a slide by using its Index.
- Add an [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/) of Rectangle type using [addAutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/#addAutoShape) method exposed by [ShapeCollection](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/) object.
- Set the [Fill Type](https://reference.aspose.com/slides/php-java/aspose.slides/FillType) of the Rectangle to Solid.
- Set the Color of the Rectangle using [ColorFormat::setColor](https://reference.aspose.com/slides/php-java/aspose.slides/colorformat/#setColor) method as exposed by [FillFormat](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/) object associated with the [Shape](https://reference.aspose.com/slides/php-java/aspose.slides/shape/) object.
- Set the Color of the lines of the Rectangle.
- Set the Width of the lines of the Rectangle.
- Write the modified presentation as PPTX file.
The above steps are implemented in the example given below.
```php
# Instantiate Prseetation class that represents the PPTX
$pres = new Presentation();
try {
# Get the first slide
$sld = $pres->getSlides()->get_Item(0);
# Add AutoShape of ellipse type
$shp = $sld->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 150, 150, 50);
# Apply some formatting to ellipse shape
$shp->getFillFormat()->setFillType(FillType::Solid);
$shp->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->GRAY);
# Apply some formatting to the line of Ellipse
$shp->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$shp->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$shp->getLineFormat()->setWidth(5);
# Write the PPTX file to disk
$pres->save("RecShp2.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **FAQ**
### How do I add a rectangle with rounded corners?
Use the rounded-corner [shape type](https://reference.aspose.com/slides/php-java/aspose.slides/shapetype/) and adjust the corner radius in the shape’s properties; rounding can also be applied per corner via geometry adjustments.
### How do I fill a rectangle with an image (texture)?
Select the picture [fill type](https://reference.aspose.com/slides/php-java/aspose.slides/filltype/), provide the image source, and configure [stretching/tiling modes](https://reference.aspose.com/slides/php-java/aspose.slides/picturefillmode/).
### Can a rectangle have shadow and glow?
Yes. [Outer/inner shadow, glow, and soft edges](https://docs.aspose.com/slides/php-java/shape-effect/) are available with adjustable parameters.
### Can I turn a rectangle into a button with a hyperlink?
Yes. [Assign a hyperlink](https://docs.aspose.com/slides/php-java/manage-hyperlinks/) to the shape click (jump to a slide, file, web address, or e-mail).
### How can I protect a rectangle from moving and changes?
Use shape locks: you can forbid moving, resizing, selection, or text editing to preserve the layout.
### Can I convert a rectangle to a raster image or SVG?
Yes. You can [render the shape](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#getImage) to an image with a specified size/scale or [export it as SVG](https://reference.aspose.com/slides/php-java/aspose.slides/shape/writeassvg/) for vector use.
### How do I quickly get the actual (effective) properties of a rectangle considering theme and inheritance?
[Use the shape’s effective properties](https://docs.aspose.com/slides/php-java/shape-effective-properties/): the API returns computed values that account for theme styles, layout, and local settings, simplifying formatting analysis.
## Related articles
- [Add Ellipses to Presentations in PHP](https://docs.aspose.com/slides/php-java/ellipse/)
# Remove Slides from Presentations in PHP
> Effortlessly remove slides from PowerPoint and OpenDocument presentations with Aspose.Slides for PHP via Java. Get clear code examples and boost your workflow.
Source: https://docs.aspose.com/slides/php-java/remove-slide-from-presentation/
Updated: 2026-08-02
## **Introduction**
If a slide (or its contents) becomes redundant, you can delete it. Aspose.Slides provides the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class that encapsulates [SlideCollection](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/), which is a repository for all slides in a presentation. Using pointers (reference or index) for a known [Slide](https://reference.aspose.com/slides/php-java/aspose.slides/slide/) object, you can specify the slide you want to remove.
## **Remove a Slide by Reference**
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
1. Get a reference of the slide you want to remove through its ID or Index.
1. Remove the referenced slide from the presentation.
1. Save the modified presentation.
This PHP code shows you how to remove a slide through its reference:
```php
# Instantiate a Presentation object that represents a presentation file
$pres = new Presentation("demo.pptx");
try {
# Accesses a slide through its index in the slides collection
$slide = $pres->getSlides()->get_Item(0);
# Removes a slide through its reference
$pres->getSlides()->remove($slide);
# Saves the modified presentation
$pres->save("modified.pptx", SaveFormat::Pptx);
} finally {
$pres->dispose();
}
```
## **Remove a Slide by Index**
1. Create an instance of the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class.
1. Remove the slide from the presentation through its index position.
1. Save the modified presentation.
This PHP code shows you how to remove a slide through its index:
```php
# Instantiates a Presentation object that represents a presentation file
$pres = new Presentation("demo.pptx");
try {
# Removes a slide through its slide index
$pres->getSlides()->removeAt(0);
# Saves the modified presentation
$pres->save("modified.pptx", SaveFormat::Pptx);
} finally {
$pres->dispose();
}
```
## **Remove Unused Layout Slides**
Aspose.Slides provides the [removeUnusedLayoutSlides](https://reference.aspose.com/slides/php-java/aspose.slides/compress/#removeUnusedLayoutSlides-com.aspose.slides.Presentation-) method (from the [Compress](https://reference.aspose.com/slides/php-java/aspose.slides/compress/) class) to allow you to delete unwanted and unused layout slides. This PHP code shows you how to remove a layout slide from a PowerPoint presentation:
```php
$pres = new Presentation("pres.pptx");
try {
Compress->removeUnusedLayoutSlides($pres);
$pres->save("pres-out.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Remove Unused Master Slides**
Aspose.Slides provides the [removeUnusedMasterSlides](https://reference.aspose.com/slides/php-java/aspose.slides/compress/#removeUnusedMasterSlides-com.aspose.slides.Presentation-) method (from the [Compress](https://reference.aspose.com/slides/php-java/aspose.slides/compress/) class) to allow you to delete unwanted and unused master slides. This PHP code shows you how to remove a master slide from a PowerPoint presentation:
```php
$pres = new Presentation("pres.pptx");
try {
Compress->removeUnusedMasterSlides($pres);
$pres->save("pres-out.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **FAQ**
### What happens to slide indexes after I delete a slide?
After deletion, the [collection](https://reference.aspose.com/slides/php-java/aspose.slides/slidecollection/) reindexes: every subsequent slide shifts left by one position, so previous index numbers become outdated. If you need a stable reference, use each slide’s persistent ID rather than its index.
### Is a slide’s ID different from its index, and does it change when neighboring slides are deleted?
Yes. The index is the slide’s position and will change when slides are added or removed. The slide ID is a persistent identifier and does not change when other slides are deleted.
### How does deleting a slide affect slide sections?
If the slide belonged to a section, that section will simply contain one fewer slide. The section structure remains; if a section becomes empty, you can [remove or reorganize sections](https://docs.aspose.com/slides/php-java/slide-section/) as needed.
### What happens to notes and comments attached to a slide when it’s deleted?
[Notes](https://docs.aspose.com/slides/php-java/presentation-notes/) and [comments](https://docs.aspose.com/slides/php-java/presentation-comments/) are tied to that specific slide and are removed along with it. Content on other slides is unaffected.
### How is deleting slides different from cleaning up unused layouts/masters?
Deleting removes specific normal slides from the deck. Cleaning up unused layouts/masters removes layout or master slides that nothing references, reducing file size without changing remaining slide content. These actions are complementary: typically delete first, then clean up.
# Render Presentation Slides as SVG Images in PHP
> Export PowerPoint slides as SVG images in PHP and control fonts, text, images, IDs, and events with Aspose.Slides.
Source: https://docs.aspose.com/slides/php-java/render-a-slide-as-an-svg-image/
Updated: 2026-11-11
## **Overview**
SVG is a scalable XML-based image format that works well for web publishing, slide viewers, accessibility workflows, and automated post-processing. Aspose.Slides exports each slide to a separate SVG file and lets you control how text, fonts, pictures, and SVG elements are written.
Use [SVGOptions](https://reference.aspose.com/slides/php-java/aspose.slides/svgoptions/) when the exported SVG must be compact, predictable across browsers, or ready for interactive use.
## **Export a Slide as SVG**
Create a [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/), select a slide, and write it to a stream with [Slide.writeAsSvg](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#writeAsSvg). The following example exports every slide in a presentation as a separate SVG file.
```php
$presentation = new Presentation("presentation.pptx");
try {
$slideCount = java_values($presentation->getSlides()->size());
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$slideNumber = java_values($slide->getSlideNumber());
$outputFileName = sprintf("slide-%d.svg", $slideNumber);
$svgStream = new Java("java.io.FileOutputStream", $outputFileName);
$slide->writeAsSvg($svgStream);
$svgStream->close();
}
} finally {
$presentation->dispose();
}
```
The filename uses [Slide.getSlideNumber](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#getSlideNumber) rather than the loop index. You can also export an individual shape with [Shape.writeAsSvg](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#writeAsSvg) when a slide viewer or web page needs only that shape.
## **Configure SVG Output**
[SVGOptions](https://reference.aspose.com/slides/php-java/aspose.slides/svgoptions/) controls SVG rendering. For text frames, [SVGOptions.setUseFrameSize](https://reference.aspose.com/slides/php-java/aspose.slides/svgoptions/#setUseFrameSize) includes the text frame in the rendering area, and [SVGOptions.setUseFrameRotation](https://reference.aspose.com/slides/php-java/aspose.slides/svgoptions/#setUseFrameRotation) determines whether the frame rotation is applied. Set [SVGOptions.setDisableFontLigatures](https://reference.aspose.com/slides/php-java/aspose.slides/svgoptions/#setDisableFontLigatures) to `true` when text must be rendered without ligatures.
```php
$presentation = new Presentation("presentation.pptx");
$svgStream = null;
try {
$svgOptions = new SVGOptions();
$svgOptions->setDisableFontLigatures(true);
$svgOptions->setUseFrameSize(true);
$svgOptions->setUseFrameRotation(false);
$slide = $presentation->getSlides()->get_Item(0);
$svgStream = new Java("java.io.FileOutputStream", "slide-with-custom-options.svg");
$slide->writeAsSvg($svgStream, $svgOptions);
} finally {
$svgStream->close();
$presentation->dispose();
}
```
## **Control Line-End Cropping at Arrowheads**
SVG 1.1 has no marker inset setting to specify where a line should stop beneath an arrowhead. By default, Aspose.Slides shortens the exported line so its stroke does not protrude through the marker. Call [SVGOptions::setDisableLineEndCropping](https://reference.aspose.com/slides/php-java/aspose.slides/svgoptions/setdisablelineendcropping/) with `true` to draw the stroke all the way to the line's original endpoint. This setting affects only the SVG output. The line keeps its position and length on the slide.
The example draws triangle and diamond arrowheads on lines 2 and 10 points wide. It exports the same slide twice, changing only the cropping option.
```php
use aspose\slides\FillType;
use aspose\slides\LineArrowheadStyle;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
use aspose\slides\SVGOptions;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$y = 40;
foreach ([LineArrowheadStyle::Triangle, LineArrowheadStyle::Diamond] as $style) {
foreach ([2, 10] as $width) {
$line = $slide->getShapes()->addAutoShape(ShapeType::Line, 40, $y, 200, 0);
$format = $line->getLineFormat();
$format->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 0, 0, 139);
$format->getFillFormat()->getSolidFillColor()->setColor($color);
$format->setWidth($width);
$format->setEndArrowheadStyle($style);
$y += 50;
}
}
$options = new SVGOptions();
$options->setDisableLineEndCropping(false);
$cropped = new Java("java.io.FileOutputStream", "cropped.svg");
try {
$slide->writeAsSvg($cropped, $options);
} finally {
$cropped->close();
}
$options->setDisableLineEndCropping(true);
$uncropped = new Java("java.io.FileOutputStream", "uncropped.svg");
try {
$slide->writeAsSvg($uncropped, $options);
} finally {
$uncropped->close();
}
} finally {
$presentation->dispose();
}
```
The comparison shows the triangular arrowhead on the 10-point line. With cropping enabled, the tip is sharp. With cropping disabled, the stroke protrudes through the sloping sides of the marker and leaves a flat end.

In the other lines from the example, the protruding stroke is less visible on the 2-point triangle. The filled diamond covers the end of the stroke at both widths.
## **Control Text and Fonts**
When exporting slides to SVG, you can control whether text remains as text or is converted to vector graphics, and how external fonts are included or referenced. The following options help you balance visual consistency, text selection, and font dependencies in the exported SVG.
### **Vectorize All Text**
Set [SVGOptions.setVectorizeText](https://reference.aspose.com/slides/php-java/aspose.slides/svgoptions/#setVectorizeText) to `true` to write all slide text as vector graphics. This eliminates font dependencies and makes the visual result more consistent across browsers, but the text is no longer selectable or searchable as SVG text.
```php
$presentation = new Presentation("presentation.pptx");
$svgStream = null;
try {
$svgOptions = new SVGOptions();
$svgOptions->setVectorizeText(true);
$slide = $presentation->getSlides()->get_Item(0);
$svgStream = new Java("java.io.FileOutputStream", "slide-with-vectorized-text.svg");
$slide->writeAsSvg($svgStream, $svgOptions);
} finally {
$svgStream->close();
$presentation->dispose();
}
```
### **Choose How External Fonts Are Handled**
[SVGOptions.setExternalFontsHandling](https://reference.aspose.com/slides/php-java/aspose.slides/svgoptions/#setExternalFontsHandling) uses a [SvgExternalFontsHandling](https://reference.aspose.com/slides/php-java/aspose.slides/svgexternalfontshandling/) value for fonts that are loaded externally. Choose `AddLinksToFontFiles` to reference separate font files, `Embed` to include font data in the SVG, or `Vectorize` to render only text that uses external fonts as graphics. Verify font licensing before embedding fonts.
```php
$presentation = new Presentation("presentation.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$linkedFontsOptions = new SVGOptions();
$linkedFontsOptions->setExternalFontsHandling(SvgExternalFontsHandling::AddLinksToFontFiles);
$linkedFontsStream = new Java("java.io.FileOutputStream", "slide-with-font-links.svg");
try {
$slide->writeAsSvg($linkedFontsStream, $linkedFontsOptions);
} finally {
$linkedFontsStream->close();
}
$embeddedFontsOptions = new SVGOptions();
$embeddedFontsOptions->setExternalFontsHandling(SvgExternalFontsHandling::Embed);
$embeddedFontsStream = new Java("java.io.FileOutputStream", "slide-with-embedded-fonts.svg");
try {
$slide->writeAsSvg($embeddedFontsStream, $embeddedFontsOptions);
} finally {
$embeddedFontsStream->close();
}
$vectorizedExternalFontsOptions = new SVGOptions();
$vectorizedExternalFontsOptions->setExternalFontsHandling(SvgExternalFontsHandling::Vectorize);
$vectorizedExternalFontsStream = new Java("java.io.FileOutputStream", "slide-with-vectorized-external-fonts.svg");
try {
$slide->writeAsSvg($vectorizedExternalFontsStream, $vectorizedExternalFontsOptions);
} finally {
$vectorizedExternalFontsStream->close();
}
} finally {
$presentation->dispose();
}
```
## **Reduce Embedded Image Size**
Use [SVGOptions.setPicturesCompression](https://reference.aspose.com/slides/php-java/aspose.slides/svgoptions/#setPicturesCompression) to reduce the resolution of embedded pictures, [SVGOptions.setDeletePicturesCroppedAreas](https://reference.aspose.com/slides/php-java/aspose.slides/svgoptions/#setDeletePicturesCroppedAreas) to omit cropped source areas, and [SVGOptions.setJpegQuality](https://reference.aspose.com/slides/php-java/aspose.slides/svgoptions/#setJpegQuality) to control JPEG encoding quality. These settings reduce file size at the cost of image fidelity or retained image data.
```php
$presentation = new Presentation("presentation.pptx");
$svgStream = null;
try {
$svgOptions = new SVGOptions();
$svgOptions->setPicturesCompression(PicturesCompression::Dpi150);
$svgOptions->setDeletePicturesCroppedAreas(true);
$svgOptions->setJpegQuality(80);
$slide = $presentation->getSlides()->get_Item(0);
$svgStream = new Java("java.io.FileOutputStream", "compressed-slide.svg");
$slide->writeAsSvg($svgStream, $svgOptions);
} finally {
$svgStream->close();
$presentation->dispose();
}
```
## **Control Metafile Rasterization Resolution**
[SVGOptions.setMetafileRasterizationDpi](https://reference.aspose.com/slides/php-java/aspose.slides/svgoptions/setmetafilerasterizationdpi/) sets the lower resolution limit for rasterizing metafiles during SVG export. Use it to balance detail and file size when an EMF or WMF image is rasterized. It does not define a global DPI for the SVG or force every object on the slide to become a raster image.
Download [metafile-rasterization.pptx](https://docs.aspose.com/slides/php-java/render-a-slide-as-an-svg-image/metafile-rasterization.pptx), which contains an EMF image with closely spaced diagonal lines. The following example exports its first slide at three rasterization resolutions through [Slide.writeAsSvg](https://reference.aspose.com/slides/php-java/aspose.slides/slide/writeassvg/). All other export settings remain identical so that the results can be compared.
```php
$presentation = new Presentation("metafile-rasterization.pptx");
try {
foreach ([72, 150, 300] as $dpi) {
$svgOptions = new SVGOptions();
$svgOptions->setMetafileRasterizationDpi($dpi);
$svgOptions->setPicturesCompression(PicturesCompression::Dpi330);
$svgOptions->setJpegQuality(90);
$outputFileName = sprintf("slide-%d.svg", $dpi);
$svgStream = new Java("java.io.FileOutputStream", $outputFileName);
try {
$presentation->getSlides()->get_Item(0)->writeAsSvg($svgStream, $svgOptions);
} finally {
$svgStream->close();
}
}
} finally {
$presentation->dispose();
}
```
In the output, the EMF became one embedded PNG in each SVG. The following measurements are for the supplied presentation; they are not a general formula for converting DPI to pixel dimensions.
| Metafile rasterization DPI | Embedded PNG dimensions | SVG file size (bytes) |
| --- | --- | --- |
| 72 | 1196 × 596 | 170,221 |
| 150 | 2492 × 1242 | 423,149 |
| 300 | 4983 × 2483 | 1,027,169 |
The comparison below shows the same area of the embedded raster at the same enlarged display size. The diagonal lines show visible pixelation at 72 DPI and smoother edges at higher resolutions, while the SVG file grows. Increasing the value does not necessarily improve every detail or change every exported image.

[SVGOptions.setPicturesCompression](https://reference.aspose.com/slides/php-java/aspose.slides/svgoptions/setpicturescompression/) controls image resolution reduction and can mask the effect of changing the metafile rasterization resolution. [SVGOptions.setJpegQuality](https://reference.aspose.com/slides/php-java/aspose.slides/svgoptions/setjpegquality/) controls JPEG encoding quality, not metafile rasterization resolution.
## **Assign Stable IDs to Shapes and Text**
Provide a formatting callback to [SVGOptions.setShapeFormattingController](https://reference.aspose.com/slides/php-java/aspose.slides/svgoptions/#setShapeFormattingController) to set [SvgShape.setId](https://reference.aspose.com/slides/php-java/aspose.slides/svgshape/#setId) for each SVG shape. The callback can also set [SvgTSpan.setId](https://reference.aspose.com/slides/php-java/aspose.slides/svgtspan/#setId) values on text `tspan` elements.
PhpJavaBridge cannot invoke a PHP callback from `writeAsSvg` when it runs in stream mode. Put the formatting logic in a small Java helper class, compile it, and add the resulting JAR file to the bridge classpath. The helper can use [Shape.getOfficeInteropShapeId](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#getOfficeInteropShapeId), which is stable for the lifetime of the shape, and a repeatable counter for its text spans. See the [Java implementation of `StableSvgIdController`](https://docs.aspose.com/slides/java/render-a-slide-as-an-svg-image/#assign-stable-ids-to-shapes-and-text) for the helper code.
After adding the compiled `com.example.slides.StableSvgIdController` class to the bridge classpath, instantiate it from PHP and assign it to `SVGOptions`:
```php
$presentation = new Presentation("presentation.pptx");
$svgStream = null;
try {
$shapeFormattingController = new Java("com.example.slides.StableSvgIdController");
$svgOptions = new SVGOptions();
$svgOptions->setShapeFormattingController($shapeFormattingController);
$slide = $presentation->getSlides()->get_Item(0);
$svgStream = new Java("java.io.FileOutputStream", "slide-with-stable-ids.svg");
$slide->writeAsSvg($svgStream, $svgOptions);
} finally {
$svgStream->close();
$presentation->dispose();
}
```
## **Add SVG Event Handlers**
In a formatting callback, call [SvgShape.setEventHandler](https://reference.aspose.com/slides/php-java/aspose.slides/svgshape/#setEventHandler) with a [SvgEvent](https://reference.aspose.com/slides/php-java/aspose.slides/svgevent/) value to add a JavaScript event handler to an exported shape. Assign the callback with [SVGOptions.setShapeFormattingController](https://reference.aspose.com/slides/php-java/aspose.slides/svgoptions/#setShapeFormattingController) and define the JavaScript function in the page or SVG document that hosts the result.
As with stable IDs, implement the callback in a Java helper when PhpJavaBridge uses stream mode. The [Java implementation of `SvgEventController`](https://docs.aspose.com/slides/java/render-a-slide-as-an-svg-image/#add-svg-event-handlers) assigns an ID and an `OnClick` handler to a shape named `ActionButton`. Compile that helper, add it to the bridge classpath as `com.example.slides.SvgEventController`, and use it from PHP as follows:
```php
$presentation = new Presentation("presentation.pptx");
$svgStream = null;
try {
$shapeFormattingController = new Java("com.example.slides.SvgEventController");
$svgOptions = new SVGOptions();
$svgOptions->setShapeFormattingController($shapeFormattingController);
$slide = $presentation->getSlides()->get_Item(0);
$svgStream = new Java("java.io.FileOutputStream", "interactive-slide.svg");
$slide->writeAsSvg($svgStream, $svgOptions);
} finally {
$svgStream->close();
$presentation->dispose();
}
```
The host page can define the JavaScript function referenced by the handler. Assigning IDs and event handlers enables slide viewers, accessibility enhancements, and other interactive SVG workflows.
## **FAQ**
**When should I use [SVGOptions.setVectorizeText](https://reference.aspose.com/slides/php-java/aspose.slides/svgoptions/#setVectorizeText) instead of [SvgExternalFontsHandling.Vectorize](https://reference.aspose.com/slides/php-java/aspose.slides/svgexternalfontshandling/)?**
Use [SVGOptions.setVectorizeText](https://reference.aspose.com/slides/php-java/aspose.slides/svgoptions/#setVectorizeText) when all text must be independent of fonts. Use [SvgExternalFontsHandling.Vectorize](https://reference.aspose.com/slides/php-java/aspose.slides/svgexternalfontshandling/) when only text that uses external fonts should be converted to graphics.
**What is the best way to make an SVG smaller?**
Start by compressing embedded pictures, deleting cropped image areas, and choosing linked font files when the target environment can serve them. Test the result because lower image resolution, lower JPEG quality, and vectorized text each have different quality and size tradeoffs.
**Can I modify exported SVG elements after export?**
Yes. Assign IDs through a formatting callback, then select the matching SVG elements in your post-processing tool or browser script.
# Render Presentations with Fallback Fonts in PHP
> Render presentations with fallback fonts in Aspose.Slides for PHP via Java – keep text consistent across PPT, PPTX and ODP with step-by-step code samples.
Source: https://docs.aspose.com/slides/php-java/render-presentation-with-fallback-font/
Updated: 2026-08-13
## **Overview**
Aspose.Slides allows you to render presentations using fallback font rules. This article shows how to create a fallback font rules collection, modify its rules by removing or adding fallback fonts, and assign the collection to the `FontsManager::setFontFallBackRulesCollection` method.
Once the fallback font rules collection is assigned to the presentation's `FontsManager`, the rules are applied during operations such as saving, rendering, and converting the presentation. The example demonstrates how to use the configured rules when rendering a slide thumbnail and saving it as a PNG image.
## **Render a Slide Using Fallback Font Rules**
The following example includes these steps:
1. We [create fallback font rules collection](https://docs.aspose.com/slides/php-java/create-fallback-fonts-collection/).
1. [Remove](https://reference.aspose.com/slides/php-java/aspose.slides/FontFallBackRule#remove-java.lang.String-) a fallback font rule and [addFallBackFonts](https://reference.aspose.com/slides/php-java/aspose.slides/FontFallBackRule#addFallBackFonts-java.lang.String-) to another rule.
1. Set rules collection to [getFontsManager](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation#getFontsManager--).[getFontFallBackRulesCollection](https://reference.aspose.com/slides/php-java/aspose.slides/FontsManager#getFontFallBackRulesCollection--) method.
1. With [Presentation.save](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation#save-java.lang.String-int-) method we can save presentation in the same format, or save it in another one. After fallback font rules collection is set to [FontsManager](https://reference.aspose.com/slides/php-java/aspose.slides/FontsManager), these rules are applied during any operations over the presentation: save, render, convert, etc.
```php
# Create new instance of a rules collection
$rulesList = new FontFallBackRulesCollection();
# create a number of rules
$rulesList->add(new FontFallBackRule(0x400, 0x4ff, "Times New Roman"));
foreach($rulesList as $fallBackRule) {
# Trying to remove FallBack font "Tahoma" from loaded rules
$fallBackRule->remove("Tahoma");
# And to update of rules for specified range
if (java_values($fallBackRule->getRangeEndIndex()) >= 0x4000 && java_values($fallBackRule->getRangeStartIndex()) < 0x5000) {
$fallBackRule->addFallBackFonts("Verdana");
}
}
# Also we can remove any existing rules from list
if (java_values($rulesList->size()) > 0) {
$rulesList->remove($rulesList->get_Item(0));
}
$pres = new Presentation("input.pptx");
try {
# Assigning a prepared rules list for using
$pres->getFontsManager()->setFontFallBackRulesCollection($rulesList);
# Rendering of thumbnail with using of initialized rules collection and saving to JPEG
$slideImage = $pres->getSlides()->get_Item(0)->getImage(1.0, 1.0);
# Save the image to disk in JPEG format
try {
$slideImage->save("Slide_0.jpg", ImageFormat::Jpeg);
} finally {
if (!java_is_null($slideImage)) {
$slideImage->dispose();
}
}
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
Read more about how to [Convert PPT and PPTX to JPG in PHP](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-jpg/).
## Related articles
- [Configure Fallback Font Collections in PHP](https://docs.aspose.com/slides/php-java/create-fallback-fonts-collection/)
- [Manage Fallback Fonts for Presentations in PHP](https://docs.aspose.com/slides/php-java/fallback-font/)
- [Specify Fallback Fonts for Presentations in PHP](https://docs.aspose.com/slides/php-java/create-fallback-font/)
# Resize Shapes on Presentation Slides in PHP
> Easily resize shapes on PowerPoint and OpenDocument slides with Aspose.Slides for PHP via Java—automate slide layout adjustments and boost productivity.
Source: https://docs.aspose.com/slides/php-java/resizing-shapes-on-slide/
Updated: 2026-11-08
## **Overview**
When you change a presentation's slide size, you may also need to resize and reposition its shapes to fit the new dimensions. This article shows how to scale shapes manually and how to handle tables on slides, masters, and layouts.
## **Resize Shapes**
To preserve each shape's relative position and size, multiply its horizontal coordinates and width by the ratio of the new slide width to the original width. Apply the corresponding height ratio to its vertical coordinates and height.
The first example loads a presentation whose slides contain no tables, changes the slide size to A4, and saves the result. It uses [SlideSize::setSize](https://reference.aspose.com/slides/php-java/aspose.slides/slidesize/setsize/) with [SlideSizeScaleType::DoNotScale](https://reference.aspose.com/slides/php-java/aspose.slides/slidesizescaletype/) so that the subsequent loop controls the scaling. The ratios are unitless; shape positions and dimensions are measured in points. Different width and height ratios can distort shapes, and changing a shape's dimensions does not scale its font sizes.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SlideSizeScaleType;
use aspose\slides\SlideSizeType;
$presentation = new Presentation("sample.pptx");
try {
// Calculate independent horizontal and vertical scale factors.
$originalSize = $presentation->getSlideSize()->getSize();
$presentation->getSlideSize()->setSize(SlideSizeType::A4Paper, SlideSizeScaleType::DoNotScale);
$targetSize = $presentation->getSlideSize()->getSize();
$widthRatio = java_values($targetSize->getWidth()) / java_values($originalSize->getWidth());
$heightRatio = java_values($targetSize->getHeight()) / java_values($originalSize->getHeight());
for ($slideIndex = 0; $slideIndex < java_values($presentation->getSlides()->size()); $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
for ($shapeIndex = 0; $shapeIndex < java_values($slide->getShapes()->size()); $shapeIndex++) {
$shape = $slide->getShapes()->get_Item($shapeIndex);
$shape->setWidth(java_values($shape->getWidth()) * $widthRatio);
$shape->setHeight(java_values($shape->getHeight()) * $heightRatio);
$shape->setX(java_values($shape->getX()) * $widthRatio);
$shape->setY(java_values($shape->getY()) * $heightRatio);
}
}
$presentation->save("output.pptx", SaveFormat::Pptx);
}
finally {
$presentation->dispose();
}
```
Tables require separate handling: scale their column widths and row heights instead of assigning the table's overall width and height. Row heights may remain larger than requested if the cell content requires more space.
The second example supports tables and processes shapes on masters and layouts as well as individual slides before saving the resized presentation. Its helper handles each [Table](https://reference.aspose.com/slides/php-java/aspose.slides/table/) by scaling column widths with [Column::setWidth](https://reference.aspose.com/slides/php-java/aspose.slides/column/setwidth/) and minimum row heights with [Row::setMinimalHeight](https://reference.aspose.com/slides/php-java/aspose.slides/row/setminimalheight/). It then scales the table's position without separately scaling its overall dimensions.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SlideSizeScaleType;
use aspose\slides\SlideSizeType;
class ShapeResizer {
public function resizeShapes($shapes, $widthRatio, $heightRatio) {
$tableClass = new JavaClass("com.aspose.slides.Table");
for ($shapeIndex = 0; $shapeIndex < java_values($shapes->size()); $shapeIndex++) {
$shape = $shapes->get_Item($shapeIndex);
if (java_instanceof($shape, $tableClass)) {
$table = $shape;
// Table dimensions are controlled by column widths and row heights.
for ($columnIndex = 0; $columnIndex < java_values($table->getColumns()->size()); $columnIndex++) {
$column = $table->getColumns()->get_Item($columnIndex);
$column->setWidth(java_values($column->getWidth()) * $widthRatio);
}
for ($rowIndex = 0; $rowIndex < java_values($table->getRows()->size()); $rowIndex++) {
$row = $table->getRows()->get_Item($rowIndex);
$row->setMinimalHeight(java_values($row->getMinimalHeight()) * $heightRatio);
}
}
else {
$shape->setWidth(java_values($shape->getWidth()) * $widthRatio);
$shape->setHeight(java_values($shape->getHeight()) * $heightRatio);
}
$shape->setX(java_values($shape->getX()) * $widthRatio);
$shape->setY(java_values($shape->getY()) * $heightRatio);
}
}
}
$presentation = new Presentation("sample.pptx");
try {
// Calculate independent horizontal and vertical scale factors.
$originalSize = $presentation->getSlideSize()->getSize();
$presentation->getSlideSize()->setSize(SlideSizeType::A4Paper, SlideSizeScaleType::DoNotScale);
$targetSize = $presentation->getSlideSize()->getSize();
$widthRatio = java_values($targetSize->getWidth()) / java_values($originalSize->getWidth());
$heightRatio = java_values($targetSize->getHeight()) / java_values($originalSize->getHeight());
$resizer = new ShapeResizer();
// Resize shapes defined on masters and layouts as well as individual slides.
for ($masterIndex = 0; $masterIndex < java_values($presentation->getMasters()->size()); $masterIndex++) {
$master = $presentation->getMasters()->get_Item($masterIndex);
$resizer->resizeShapes($master->getShapes(), $widthRatio, $heightRatio);
for ($layoutSlideIndex = 0; $layoutSlideIndex < java_values($master->getLayoutSlides()->size()); $layoutSlideIndex++) {
$layoutSlide = $master->getLayoutSlides()->get_Item($layoutSlideIndex);
$resizer->resizeShapes($layoutSlide->getShapes(), $widthRatio, $heightRatio);
}
}
for ($slideIndex = 0; $slideIndex < java_values($presentation->getSlides()->size()); $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$resizer->resizeShapes($slide->getShapes(), $widthRatio, $heightRatio);
}
$presentation->save("output.pptx", SaveFormat::Pptx);
}
finally {
$presentation->dispose();
}
```
[](https://docs.aspose.com/slides/php-java/resizing-shapes-on-slide/visual-resizing-shapes-on-slide-068c15ee95ae.svg)
*In this table-aware resize, the width ratio scales X, shape width and column widths. The height ratio scales Y, shape height and minimum row heights. Font sizes stay fixed.*
## **FAQ**
**Why are shapes distorted or cut off after resizing a slide?**
If you change the slide size without scaling the shapes, they keep their original positions and dimensions and may extend beyond the slide. Scaling width and height by different ratios can also distort shapes.
**Does the provided code work for all shape types?**
The first example changes shape bounds directly and is intended for slides without tables. The second example handles tables separately. Check the resulting layout, particularly text and tables, because these examples do not scale font sizes and table content can constrain row heights.
**How do I resize tables when resizing a slide?**
Scale column widths by the width ratio and minimum row heights by the height ratio, then scale the table's position, as shown in the second example.
**Will this resizing work for master slides and layout slides?**
Yes. The second example iterates through [Presentation::getMasters](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/getmasters/) and each master's [MasterSlide::getLayoutSlides](https://reference.aspose.com/slides/php-java/aspose.slides/masterslide/getlayoutslides/) and applies the same resizing logic to their shapes.
**Can I change the orientation of a slide (portrait/landscape) along with the resizing?**
Yes. Call [SlideSize::setOrientation](https://reference.aspose.com/slides/php-java/aspose.slides/slidesize/setorientation/) after changing the slide size and before reading the target dimensions, so the scale factors reflect the final orientation.
**Is there a limit to the slide size I can set?**
You can specify custom slide dimensions with [SlideSize::setSize](https://reference.aspose.com/slides/php-java/aspose.slides/slidesize/setsize/). The supported dimensions also depend on the presentation format and the application used to open the file.
**How can I prevent shapes with a fixed aspect ratio from becoming distorted?**
Use the same scale factor for width and height. To fit the original layout within the new slide dimensions, use the smaller of the width and height ratios for both dimensions and positions. This preserves proportions but may leave unused space along one edge.
# Resources
> Discover key Aspose.Slides for PHP via Java resources — from downloads and docs to forums and blog updates—to improve working with PPT, PPTX and ODP.
Source: https://docs.aspose.com/slides/php-java/resources/
Updated: 2026-08-13
This table lists important Aspose.Slides for PHP via Java technical resources.
|**Resource**|**Description**|
| :- | :- |
|[Aspose.Slides for PHP via Java home page](https://products.aspose.com/slides/php-java/)|Product home page.|
|[Aspose.Slides blog](https://blog.aspose.com/category/slides/)|Check this often for information about new releases and useful tips about Aspose.Slides.|
|[Aspose.Slides for PHP via Java download](https://releases.aspose.com/slides/php-java/)|Download the latest version of Aspose.Slides from here. We release often.|
|[Aspose.Slides support forum](https://forum.aspose.com/c/slides/11)|Post your questions and issues here for a speedy resolution.|
|[Aspose.Slides for PHP via Java product documentation](https://docs.aspose.com/slides/php-java/)|Full online documentation that includes this documentation as well as Aspose.Slides API Reference.|
## Related articles
- [Product Support](https://docs.aspose.com/slides/php-java/product-support/)
- [Aspose.Slides for PHP via Java](https://docs.aspose.com/slides/php-java/)
- [Product Overview](https://docs.aspose.com/slides/php-java/product-overview/)
# Save Presentations in PHP
> Save PowerPoint and OpenDocument presentations to files or streams in PHP with Aspose.Slides, and configure PPTX output and progress reporting.
Source: https://docs.aspose.com/slides/php-java/save-presentation/
Updated: 2026-09-22
## **Overview**
After you create a presentation or [open an existing one](https://docs.aspose.com/slides/php-java/open-presentation/), use the [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#save) method to write the result. Aspose.Slides for PHP via Java can save a presentation to a file or stream in PowerPoint, OpenDocument, PDF, and other formats. The following sections cover the standard save operations and the options available for PPTX output.
## **Save Presentations to Files**
To save a presentation to a file, pass the output path and a [SaveFormat](https://reference.aspose.com/slides/php-java/aspose.slides/saveformat/) value to the [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#save) method. The format value determines the type of file that Aspose.Slides creates.
The following example creates a presentation and saves it as a PPTX file:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
// Add or modify presentation content here.
$presentation->save("Output.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Save Presentations in Their Original Format**
For file and stream detection examples, the behavior of newly created presentations, and the distinction between source and output formats, see [Determine the Original Presentation Format](https://docs.aspose.com/slides/php-java/detect-presentation-source-format/).
In a batch-processing application, the input format may not be known in advance. After loading a file, read its original format from the [Presentation::getSourceFormat](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getSourceFormat) method. Pass the resulting [SourceFormat](https://reference.aspose.com/slides/php-java/aspose.slides/sourceformat/) value to [SlideUtil::toSaveFormat](https://reference.aspose.com/slides/php-java/aspose.slides/slideutil/#toSaveFormat) to obtain the corresponding [SaveFormat](https://reference.aspose.com/slides/php-java/aspose.slides/saveformat/) value, and then use [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#save) to write the modified presentation.
The following complete example processes every file in an input directory, updates its title, and saves it to an output directory in the format from which it was loaded:
```php
use aspose\slides\Presentation;
use aspose\slides\SlideUtil;
$inputDirectory = __DIR__ . DIRECTORY_SEPARATOR . "Input";
$outputDirectory = __DIR__ . DIRECTORY_SEPARATOR . "Output";
if (!is_dir($outputDirectory) && !mkdir($outputDirectory, 0777, true)) {
echo("Cannot create the output directory." . PHP_EOL);
}
$inputFiles = is_dir($inputDirectory) ? scandir($inputDirectory) : false;
if ($inputFiles !== false && is_dir($outputDirectory)) {
foreach ($inputFiles as $fileName) {
$inputPath = $inputDirectory . DIRECTORY_SEPARATOR . $fileName;
if (!is_file($inputPath)) {
continue;
}
$presentation = null;
$presentationLoaded = false;
try {
$presentation = new Presentation($inputPath);
$presentationLoaded = true;
$saveFormat = SlideUtil::toSaveFormat($presentation->getSourceFormat());
$presentation->getDocumentProperties()->setTitle("Processed by the batch application");
$outputPath = $outputDirectory . DIRECTORY_SEPARATOR . $fileName;
$presentation->save($outputPath, $saveFormat);
} catch (\Throwable $exception) {
echo("Cannot process '" . $inputPath . "': " . $exception->getMessage() . PHP_EOL);
} finally {
if ($presentationLoaded) {
$presentation->dispose();
}
}
}
}
```
[SlideUtil::toSaveFormat](https://reference.aspose.com/slides/php-java/aspose.slides/slideutil/#toSaveFormat) maps PPT, PPTX, ODP, PPTM, PPSX, PPSM, POTX, POTM, PPS, POT, OTP, FODP, and PowerPoint XML to their corresponding presentation save formats. It maps presentation source formats only; it is not intended to select export formats such as PDF, HTML, TIFF, or images. Passing an unsupported or invalid [SourceFormat](https://reference.aspose.com/slides/php-java/aspose.slides/sourceformat/) value results in an [IllegalArgumentException](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/IllegalArgumentException.html).
Legacy PPT, PPS, and POT files use the same binary container. When such a presentation is loaded from a stream without a file extension, a PPS or POT file may therefore be identified as PPT. If preserving these legacy subtypes is required, retain the original filename or format metadata separately and use it when choosing the output filename and format.
## **Save Presentations to Streams**
To write a presentation without relying on a final file path, pass a writable stream and a [SaveFormat](https://reference.aspose.com/slides/php-java/aspose.slides/saveformat/) value to the [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#save) method. This approach is useful when the output must be returned from a web service, stored in a database, or processed in memory.
The following example saves a new presentation to a file stream:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$outputStream = new Java("java.io.FileOutputStream", "Output.pptx");
try {
$presentation->save($outputStream, SaveFormat::Pptx);
} finally {
$outputStream->close();
}
} finally {
$presentation->dispose();
}
```
## **Save Presentations with a Predefined View Type**
You can specify the view in which PowerPoint initially opens a saved presentation. Use the [ViewProperties::setLastView](https://reference.aspose.com/slides/php-java/aspose.slides/viewproperties/#setLastView) method with a [ViewType](https://reference.aspose.com/slides/php-java/aspose.slides/viewtype/) value before saving.
The following example configures Slide Master view as the initial view:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ViewType;
$presentation = new Presentation();
try {
$presentation->getViewProperties()->setLastView(ViewType::SlideMasterView);
$presentation->save("SlideMasterView.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Save Presentations in the Strict Office Open XML Format**
To create a PPTX file that conforms to the Strict profile of Office Open XML, create a [PptxOptions](https://reference.aspose.com/slides/php-java/aspose.slides/pptxoptions/) instance and use its [PptxOptions::setConformance](https://reference.aspose.com/slides/php-java/aspose.slides/pptxoptions/#setConformance) method with [Conformance::Iso29500_2008_Strict](https://reference.aspose.com/slides/php-java/aspose.slides/conformance/#Iso29500-2008-Strict). Then pass the options to the [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#save) method.
```php
use aspose\slides\Conformance;
use aspose\slides\PptxOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$options = new PptxOptions();
$options->setConformance(Conformance::Iso29500_2008_Strict);
$presentation = new Presentation();
try {
$presentation->save("StrictOfficeOpenXml.pptx", SaveFormat::Pptx, $options);
} finally {
$presentation->dispose();
}
```
## **Save Presentations in Office Open XML Format in Zip64 Mode**
A standard ZIP archive limits the compressed and uncompressed size of each entry, the total archive size, and the number of entries. Because a PPTX file is a ZIP archive, a very large presentation can exceed those limits. ZIP64 extensions raise the applicable size and entry-count limits.
Use the [PptxOptions::setZip64Mode](https://reference.aspose.com/slides/php-java/aspose.slides/pptxoptions/#setZip64Mode) method to control whether Aspose.Slides writes ZIP64 extensions:
- [IfNecessary](https://reference.aspose.com/slides/php-java/aspose.slides/zip64mode/#IfNecessary) uses ZIP64 only when the presentation exceeds standard ZIP limits. This is the default mode.
- [Never](https://reference.aspose.com/slides/php-java/aspose.slides/zip64mode/#Never) disables ZIP64 extensions.
- [Always](https://reference.aspose.com/slides/php-java/aspose.slides/zip64mode/#Always) always writes ZIP64 extensions.
The following example always enables ZIP64 extensions for the output presentation:
```php
use aspose\slides\PptxOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\Zip64Mode;
$presentation = new Presentation("Sample.pptx");
try {
$options = new PptxOptions();
$options->setZip64Mode(Zip64Mode::Always);
$presentation->save("OutputZip64.pptx", SaveFormat::Pptx, $options);
} finally {
$presentation->dispose();
}
```
If [Zip64Mode::Never](https://reference.aspose.com/slides/php-java/aspose.slides/zip64mode/#Never) is used and the presentation cannot fit within standard ZIP limits, the save operation throws a [PptxException](https://reference.aspose.com/slides/php-java/aspose.slides/pptxexception/).
## **Save Presentations in Office Open XML Format with Compression Levels**
For PPTX output, you can balance saving speed against file size by using the [PptxOptions::setCompressionLevel](https://reference.aspose.com/slides/php-java/aspose.slides/pptxoptions/#setCompressionLevel) method. The [CompressionLevel](https://reference.aspose.com/slides/php-java/aspose.slides/compressionlevel/) class provides these values:
- [None](https://reference.aspose.com/slides/php-java/aspose.slides/compressionlevel/#None) stores data without compression.
- [Level1](https://reference.aspose.com/slides/php-java/aspose.slides/compressionlevel/#Level1) provides the fastest compression and the largest compressed output.
- [Level2](https://reference.aspose.com/slides/php-java/aspose.slides/compressionlevel/#Level2) through [Level5](https://reference.aspose.com/slides/php-java/aspose.slides/compressionlevel/#Level5) progressively favor smaller output over saving speed.
- [Level6](https://reference.aspose.com/slides/php-java/aspose.slides/compressionlevel/#Level6) balances saving speed and file size. This is the default level.
- [Level7](https://reference.aspose.com/slides/php-java/aspose.slides/compressionlevel/#Level7) and [Level8](https://reference.aspose.com/slides/php-java/aspose.slides/compressionlevel/#Level8) further favor smaller output over saving speed.
- [Level9](https://reference.aspose.com/slides/php-java/aspose.slides/compressionlevel/#Level9) provides the strongest compression and requires the most processing time.
The following example saves a presentation without compression:
```php
use aspose\slides\CompressionLevel;
use aspose\slides\PptxOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("Sample.pptx");
try {
$options = new PptxOptions();
$options->setCompressionLevel(CompressionLevel::None);
$presentation->save("OutputNoCompression.pptx", SaveFormat::Pptx, $options);
} finally {
$presentation->dispose();
}
```
The following example uses the maximum compression level:
```php
use aspose\slides\CompressionLevel;
use aspose\slides\PptxOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("Sample.pptx");
try {
$options = new PptxOptions();
$options->setCompressionLevel(CompressionLevel::Level9);
$presentation->save("OutputMaximumCompression.pptx", SaveFormat::Pptx, $options);
} finally {
$presentation->dispose();
}
```
## **Save Presentations without Refreshing the Thumbnail**
When a presentation is saved as PPTX, the [PptxOptions::setRefreshThumbnail](https://reference.aspose.com/slides/php-java/aspose.slides/pptxoptions/#setRefreshThumbnail) method controls its document thumbnail:
- `true` regenerates the thumbnail during the save operation. This is the default value.
- `false` preserves the existing thumbnail. If the presentation has no thumbnail, Aspose.Slides does not generate one.
The following example saves a presentation without refreshing its thumbnail:
```php
use aspose\slides\PptxOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("Sample.pptx");
try {
$options = new PptxOptions();
$options->setRefreshThumbnail(false);
$presentation->save("Output.pptx", SaveFormat::Pptx, $options);
} finally {
$presentation->dispose();
}
```
Disabling thumbnail refresh can reduce the time required to save a PPTX file.
## **Save Progress Updates in Percentage**
To monitor a save operation, provide a Java proxy that implements the [IProgressCallback](https://reference.aspose.com/slides/java/com.aspose.slides/iprogresscallback/) interface and pass the proxy to the [SaveOptions::setProgressCallback](https://reference.aspose.com/slides/php-java/aspose.slides/saveoptions/#setProgressCallback) method. Aspose.Slides then calls the [IProgressCallback::reporting](https://reference.aspose.com/slides/java/com.aspose.slides/iprogresscallback/#reporting-double-) method with progress values during the export.
The following example reports the progress of a PDF export to the console:
```php
use aspose\slides\PdfOptions;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
class ExportProgressHandler {
function reporting($progressValue) {
$progress = java("java.lang.Double")->valueOf($progressValue)->intValue();
echo($progress . "% of the file has been converted." . PHP_EOL);
}
}
$progressHandler = java_closure(new ExportProgressHandler(), null, java("com.aspose.slides.IProgressCallback"));
$options = new PdfOptions();
$options->setProgressCallback($progressHandler);
$presentation = new Presentation("Sample.pptx");
try {
$presentation->save("Output.pdf", SaveFormat::Pdf, $options);
} finally {
$presentation->dispose();
}
```
Aspose provides a free [PowerPoint Splitter](https://products.aspose.app/slides/splitter) built with the Aspose.Slides API. It saves selected slides from a presentation as separate PPT or PPTX files.
## **FAQ**
**Does Aspose.Slides support incremental or “fast save”?**
No. Each save operation writes a complete output file rather than updating only the changed parts.
**Can multiple threads save the same Presentation instance?**
No. A [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) instance [is not thread-safe](https://docs.aspose.com/slides/php-java/multithreading/). Access and save each instance from only one thread at a time.
**What happens to hyperlinks and externally linked files when I save a presentation?**
[Hyperlinks](https://docs.aspose.com/slides/php-java/manage-hyperlinks/) remain in the presentation. Aspose.Slides does not copy externally linked files, so the saved presentation must still be able to access their locations.
**Can I save document metadata such as the author, title, company, and creation date?**
Yes. Set the appropriate [document properties](https://docs.aspose.com/slides/php-java/presentation-properties/) before saving, and Aspose.Slides writes them to the output file.
# Manage Script-Specific Theme Fonts in PHP
> Inspect, add, replace, and remove script-specific font mappings in PowerPoint themes with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/script-specific-font-mappings/
Updated: 2026-08-25
## **Overview**
A presentation theme can select different font families for different writing systems. This allows multilingual text that still uses theme fonts to follow one coordinated font scheme while using suitable fonts for Cyrillic, Arabic, Japanese, Georgian, Thaana, and other scripts.
The theme's [FontScheme](https://reference.aspose.com/slides/php-java/aspose.slides/fontscheme/) contains a major font collection, typically used for headings, and a minor font collection, typically used for body text. In addition to their Latin and East Asian font settings, both [Fonts](https://reference.aspose.com/slides/php-java/aspose.slides/fonts/) collections expose mappings from writing-system tags to font family names.
This article shows how to inspect and modify those mappings in the presentation's master theme and verify that the changes survive a save-and-reload cycle.
## **Understand Script Tags**
The script font methods use four-letter BCP 47 script subtags to identify writing systems. Common values include:
| Script tag | Writing system |
|---|---|
| `Cyrl` | Cyrillic |
| `Arab` | Arabic |
| `Hans` | Simplified Chinese |
| `Jpan` | Japanese |
| `Geor` | Georgian |
| `Thaa` | Thaana |
These mappings belong to the theme font scheme, not to individual text portions. A presentation may define different mappings for the major and minor collections, and it may omit mappings for some scripts.
## **Access and Inspect Script Font Mappings**
Use [Presentation::getMasterTheme](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getMasterTheme) to access the presentation-level theme. The [MasterTheme::getFontScheme](https://reference.aspose.com/slides/php-java/aspose.slides/mastertheme/#getFontScheme), [FontScheme::getMajor](https://reference.aspose.com/slides/php-java/aspose.slides/fontscheme/#getMajor), and [FontScheme::getMinor](https://reference.aspose.com/slides/php-java/aspose.slides/fontscheme/#getMinor) methods provide access to the two [Fonts](https://reference.aspose.com/slides/php-java/aspose.slides/fonts/) collections.
Call [Fonts::getScriptFontMap](https://reference.aspose.com/slides/php-java/aspose.slides/fonts/#getScriptFontMap) to retrieve all mappings from a collection. To look up one writing system, call [Fonts::getScriptFont](https://reference.aspose.com/slides/php-java/aspose.slides/fonts/#getScriptFont) with its script tag. `Fonts::getScriptFont` returns `null` when that collection does not define the requested mapping.
## **Modify Mappings and Verify Persistence**
Use [Fonts::setScriptFont](https://reference.aspose.com/slides/php-java/aspose.slides/fonts/#setScriptFont) to create a mapping or replace its current font family. Use [Fonts::removeScriptFont](https://reference.aspose.com/slides/php-java/aspose.slides/fonts/#removeScriptFont) to remove a mapping.
The following end-to-end example reads all existing major and minor mappings, looks up the Japanese major font, changes the Cyrillic major font, removes the Thaana minor mapping, saves the presentation, and reopens it to verify both changes. To make the removal step independent of the initial theme, the example first creates a Thaana mapping only when one is not already defined.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$fontScheme = $presentation->getMasterTheme()->getFontScheme();
$majorFonts = $fontScheme->getMajor();
$minorFonts = $fontScheme->getMinor();
echo "Existing major mappings:" . PHP_EOL;
$majorMappings = $majorFonts->getScriptFontMap()->iterator();
while (java_values($majorMappings->hasNext())) {
$mapping = $majorMappings->next();
echo " " . java_values($mapping->getKey()) . ": " . java_values($mapping->getValue()) . PHP_EOL;
}
echo "Existing minor mappings:" . PHP_EOL;
$minorMappings = $minorFonts->getScriptFontMap()->iterator();
while (java_values($minorMappings->hasNext())) {
$mapping = $minorMappings->next();
echo " " . java_values($mapping->getKey()) . ": " . java_values($mapping->getValue()) . PHP_EOL;
}
$japaneseFont = $majorFonts->getScriptFont("Jpan");
if (java_is_null($japaneseFont)) {
echo "No major Japanese font is defined." . PHP_EOL;
} else {
echo "Major Japanese font: " . java_values($japaneseFont) . PHP_EOL;
}
$majorFonts->setScriptFont("Cyrl", "Arial");
if (java_is_null($minorFonts->getScriptFont("Thaa"))) {
$minorFonts->setScriptFont("Thaa", "Arial");
}
$minorFonts->removeScriptFont("Thaa");
$presentation->save("script-font-mappings.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
$savedPresentation = new Presentation("script-font-mappings.pptx");
try {
$savedMajorFonts = $savedPresentation->getMasterTheme()->getFontScheme()->getMajor();
$savedMinorFonts = $savedPresentation->getMasterTheme()->getFontScheme()->getMinor();
$savedCyrillicFont = $savedMajorFonts->getScriptFont("Cyrl");
$savedThaanaFont = $savedMinorFonts->getScriptFont("Thaa");
if (!java_is_null($savedCyrillicFont) && java_values($savedCyrillicFont) === "Arial") {
echo "The Cyrillic mapping was preserved." . PHP_EOL;
} else {
echo "The Cyrillic mapping was not preserved." . PHP_EOL;
}
if (java_is_null($savedThaanaFont)) {
echo "The Thaana mapping removal was preserved." . PHP_EOL;
} else {
echo "The Thaana mapping still exists." . PHP_EOL;
}
} finally {
$savedPresentation->dispose();
}
```
The verification uses the same `null` behavior as an ordinary lookup: after the removal is saved, `Fonts::getScriptFont("Thaa")` returns `null` for the minor collection.
## **Distinguish Theme Mappings from Other Font Settings**
Script-specific theme mappings participate in font selection, but they solve a different problem from direct text formatting, substitution, and fallback:
| Mechanism | Purpose | Effect of changing a theme mapping |
|---|---|---|
| Script-specific theme font mapping | Selects a major or minor theme font for a writing system. | Text that still uses the corresponding theme font can resolve to the new mapped family. |
| Font assigned explicitly to a text portion | Fixes the requested font family on that portion instead of relying on the theme. | The portion may remain unchanged because its direct formatting overrides the theme choice. |
| Font substitution | Replaces a requested font when that font is unavailable or when a substitution rule applies. | It acts after a font has been requested; it does not redefine the theme's script mapping. |
| Font fallback | Supplies glyphs that the selected font does not contain, often for specific Unicode ranges. | It fills missing glyph coverage; it does not change the stored theme mapping. |
For more information about the last two mechanisms, see [Font Substitution](https://docs.aspose.com/slides/php-java/font-substitution/) and [Fallback Fonts](https://docs.aspose.com/slides/php-java/fallback-font/).
Changing a mapping in [Presentation::getMasterTheme](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getMasterTheme) affects only content whose effective formatting still depends on that theme. Text can instead inherit a theme override from a master, layout, or slide, or use an explicitly assigned font. Inspect those levels when the visible result does not follow the presentation-level mapping.
## **Make Mapped Fonts Available and Validate the Result**
A script mapping stores a font family name; it does not install or load the corresponding font file. For consistent rendering and export, every mapped font must be installed in the environment or supplied to Aspose.Slides through a custom source such as [FontsLoader::loadExternalFonts](https://reference.aspose.com/slides/php-java/aspose.slides/fontsloader/#loadExternalFonts) or [LoadOptions::getDocumentLevelFontSources](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/#getDocumentLevelFontSources). See [Custom Fonts](https://docs.aspose.com/slides/php-java/custom-font/) for the available loading options.
Verifying the saved mapping confirms only that the theme definition was preserved. It does not prove that the font is available, contains all required glyphs, or produces the intended layout. Render representative text for every required writing system to an image or PDF and inspect the output. This catches missing fonts, incomplete glyph coverage, fallback behavior, and layout changes before the presentation is distributed. See [Convert PowerPoint Presentations](https://docs.aspose.com/slides/php-java/convert-powerpoint/) for rendering and export examples.
## **FAQ**
**What does `Fonts::getScriptFont` return when a script is not mapped?**
[Fonts::getScriptFont](https://reference.aspose.com/slides/php-java/aspose.slides/fonts/#getScriptFont) returns `null` when the requested script mapping is not defined in that major or minor font collection.
**Does `Fonts::setScriptFont` add a second mapping when the script already exists?**
No. [Fonts::setScriptFont](https://reference.aspose.com/slides/php-java/aspose.slides/fonts/#setScriptFont) creates the mapping when it is missing and replaces the mapped font family when the same script tag is already present.
**Why did changing a theme mapping not change some text?**
The text may have an explicitly assigned font, inherit a different theme through an override, or be affected by substitution or fallback during rendering. A presentation-level script mapping controls only text whose effective formatting still refers to that theme font collection.
**Is saving and reopening enough to validate multilingual output?**
No. Reopening verifies persistence of the theme data. Also render representative text from each required writing system to confirm that the mapped fonts are available and contain the necessary glyphs.
# Search and Replace Text in PowerPoint Presentations in PHP
> Search, highlight, and replace text in PowerPoint presentations while collecting every match with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/search-and-replace-text/
Updated: 2026-08-27
## **Overview**
Aspose.Slides for PHP via Java can search, highlight, and replace text in an individual text frame or across an entire presentation. Each operation can also notify an application about every match through a result callback. This makes it possible to update a presentation and simultaneously build an audit trail containing the matched text, its context, position, text frame, and slide number.
These capabilities are useful for review, redaction, terminology checks, template cleanup, and automated reporting workflows.
In the first examples below, we use a file named "sample.pptx", which contains a single text box on the first slide with the following text:

## **Choose the Search Scope**
Use methods on [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/) to limit an operation to one text frame. Use methods on [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) to process all applicable text in the presentation.
| Operation | One text frame | Entire presentation |
|---|---|---|
| Highlight literal text | [TextFrame::highlightText](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#highlightText) | [Presentation::highlightText](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#highlightText) |
| Highlight regular-expression matches | [TextFrame::highlightRegex](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#highlightRegex) | [Presentation::highlightRegex](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#highlightRegex) |
| Replace literal text | [TextFrame::replaceText](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#replaceText) | [Presentation::replaceText](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#replaceText) |
| Replace regular-expression matches | [TextFrame::replaceRegex](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#replaceRegex) | [Presentation::replaceRegex](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#replaceRegex) |
## **Configure Text Matching**
For literal-text operations, use [TextSearchOptions](https://reference.aspose.com/slides/php-java/aspose.slides/textsearchoptions/) to control matching:
- [TextSearchOptions::setWholeWordsOnly](https://reference.aspose.com/slides/php-java/aspose.slides/textsearchoptions/#setWholeWordsOnly) limits matches to complete words.
- [TextSearchOptions::setCaseSensitive](https://reference.aspose.com/slides/php-java/aspose.slides/textsearchoptions/#setCaseSensitive) controls whether character case must match.
- [TextSearchOptions::setIncludeNotes](https://reference.aspose.com/slides/php-java/aspose.slides/textsearchoptions/#setIncludeNotes) includes slide notes in presentation-level search, replacement, and highlighting operations.
Regular-expression operations use a Java `Pattern`, so matching rules such as case sensitivity and word boundaries are defined by the expression and its flags.
## **Identify the Owner of a Text Frame**
Generic text-processing workflows often receive a [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/) while searching, replacing, validating, or exporting text. Use [TextFrame::getParentShape](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#getParentShape) and [TextFrame::getParentCell](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#getParentCell) to determine which presentation object owns the text frame.
The expected values depend on the owner:
| Text frame owner | `getParentShape` | `getParentCell` |
|---|---|---|
| An AutoShape or another text-containing shape | The owning [Shape](https://reference.aspose.com/slides/php-java/aspose.slides/shape/) | `null` |
| A table cell | `null` | The owning [Cell](https://reference.aspose.com/slides/php-java/aspose.slides/cell/) |
Both methods provide read-only navigation. Calling them does not move the text frame or change its owner. Generic code should check both values with `java_is_null` and handle the possibility that neither owner is available.
The following example uses [SlideUtil::getAllTextFrames](https://reference.aspose.com/slides/php-java/aspose.slides/slideutil/#getAllTextFrames) to iterate through the text frames in a presentation. For shapes, it reports the shape name, Java runtime type, and containing slide. For table cells, it reports the zero-based column and row coordinates and the containing slide.
```php
use aspose\slides\Presentation;
use aspose\slides\SlideUtil;
$presentation = new Presentation("presentation.pptx");
$arrayClass = new java_class("java.lang.reflect.Array");
try {
$textFrames = SlideUtil::getAllTextFrames($presentation, false);
$textFrameCount = java_values($arrayClass->getLength($textFrames));
for ($textFrameIndex = 0; $textFrameIndex < $textFrameCount; $textFrameIndex++) {
$textFrame = $textFrames[$textFrameIndex];
$ownerShape = $textFrame->getParentShape();
if (!java_is_null($ownerShape)) {
$shapeName = java_values($ownerShape->getName());
$shapeName = $shapeName === "" ? "(unnamed)" : $shapeName;
$shapeType = java_values($ownerShape->getClass()->getSimpleName());
$baseSlide = $ownerShape->getSlide();
$slideClassName = java_values($baseSlide->getClass()->getName());
if ($slideClassName === "com.aspose.slides.Slide") {
$slideLabel = "slide " . java_values($baseSlide->getSlideNumber());
} elseif ($slideClassName === "com.aspose.slides.NotesSlide") {
$slideLabel = "notes for slide " . java_values($baseSlide->getParentSlide()->getSlideNumber());
} else {
$slideLabel = java_values($baseSlide->getClass()->getSimpleName());
}
echo("Shape: " . $shapeName . "; type: " . $shapeType . "; " . $slideLabel . "\n");
continue;
}
$ownerCell = $textFrame->getParentCell();
if (!java_is_null($ownerCell)) {
$baseSlide = $ownerCell->getSlide();
$slideClassName = java_values($baseSlide->getClass()->getName());
if ($slideClassName === "com.aspose.slides.Slide") {
$slideLabel = "slide " . java_values($baseSlide->getSlideNumber());
} elseif ($slideClassName === "com.aspose.slides.NotesSlide") {
$slideLabel = "notes for slide " . java_values($baseSlide->getParentSlide()->getSlideNumber());
} else {
$slideLabel = java_values($baseSlide->getClass()->getSimpleName());
}
echo("Table cell: column " . java_values($ownerCell->getFirstColumnIndex()) . ", row " . java_values($ownerCell->getFirstRowIndex()) . "; " . $slideLabel . "\n");
continue;
}
echo("The text frame owner is not available as a shape or table cell.\n");
}
} finally {
$presentation->dispose();
}
```
For SmartArt content, iterate through the shapes in [SmartArtNode::getShapes](https://reference.aspose.com/slides/php-java/aspose.slides/smartartnode/#getShapes) and access each [SmartArtShape::getTextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/smartartshape/#getTextFrame). The text frame can be traced to its associated shape through [TextFrame::getParentShape](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#getParentShape), while [TextFrame::getParentCell](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#getParentCell) returns `null`. Therefore, the shape branch in the example also handles text from SmartArt nodes.
## **Collect Match Information with a Callback**
Pass a Java proxy callback to a highlighting or replacement method to receive a notification for every match. The callback method receives the related text frame, the source text, the matched text, and the match position.
The callback does not receive a slide number directly. The implementation below derives it from the parent slide and also handles text found in slide notes. The result array uses `null` when text is associated with another slide type.
```php
class TextSearchCallback {
private $results = [];
public function getResults() {
return $this->results;
}
public function foundResult($textFrame, $sourceText, $foundText, $textPosition) {
$slideNumber = $this->getSlideNumber($textFrame);
$this->results[] = [
"textFrame" => $textFrame,
"sourceText" => java_values($sourceText),
"foundText" => java_values($foundText),
"textPosition" => java_values($textPosition),
"slideNumber" => $slideNumber
];
}
private function getSlideNumber($textFrame) {
$parentShape = $textFrame->getParentShape();
$parentCell = $textFrame->getParentCell();
if (!java_is_null($parentShape)) {
$parentSlide = $parentShape->getSlide();
} elseif (!java_is_null($parentCell)) {
$parentSlide = $parentCell->getSlide();
} else {
$parentSlide = $textFrame->getSlide();
}
if (java_is_null($parentSlide)) {
return null;
}
$parentSlideClass = $parentSlide->getClass();
$classNameValue = $parentSlideClass->getName();
$className = java_values($classNameValue);
if ($className === "com.aspose.slides.Slide") {
$slideNumber = $parentSlide->getSlideNumber();
return java_values($slideNumber);
}
if ($className === "com.aspose.slides.NotesSlide") {
$slide = $parentSlide->getParentSlide();
$slideNumber = $slide->getSlideNumber();
return java_values($slideNumber);
}
return null;
}
}
```
Create a proxy for this PHP object before passing it to an operation:
```php
$callbackHandler = new TextSearchCallback();
$callbackInterface = java("com.aspose.slides.IFindResultCallback");
$callback = java_closure(
$callbackHandler,
null,
$callbackInterface
);
```
For replacement operations, `foundText` contains the original matched text, so the callback can record exactly which terms were replaced.
## **Highlight Text**
Use the [TextFrame::highlightText](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#highlightText) method to highlight literal-text matches in a text frame. Pass [TextSearchOptions](https://reference.aspose.com/slides/php-java/aspose.slides/textsearchoptions/) to control the search.
The code example below highlights all occurrences of the characters **"try"** and then highlights only the complete word **"to"**.
```php
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->get_Item(0);
$callbackHandler = new TextSearchCallback();
$callbackInterface = java("com.aspose.slides.IFindResultCallback");
$callback = java_closure(
$callbackHandler,
null,
$callbackInterface
);
$substringSearchOptions = new TextSearchOptions();
$substringSearchOptions->setCaseSensitive(false);
$substringHighlightColor = new Java("java.awt.Color", 173, 216, 230);
// Highlight every occurrence of "try" in the text frame.
$shape->getTextFrame()->highlightText(
"try",
$substringHighlightColor,
$substringSearchOptions,
$callback
);
$wholeWordSearchOptions = new TextSearchOptions();
$wholeWordSearchOptions->setWholeWordsOnly(true);
$wholeWordSearchOptions->setCaseSensitive(false);
$wholeWordHighlightColor = new Java("java.awt.Color", 238, 130, 238);
// Highlight only the complete word "to".
$shape->getTextFrame()->highlightText(
"to",
$wholeWordHighlightColor,
$wholeWordSearchOptions,
$callback
);
foreach ($callbackHandler->getResults() as $result) {
echo(
"Found '" . $result["foundText"] . "' at position " .
$result["textPosition"] . " on slide " .
$result["slideNumber"] . ".\n"
);
}
$presentation->save("highlighted_text.pptx", SaveFormat::Pptx);
}
finally {
$presentation->dispose();
}
```
The result:

## **Highlight Text Using Regular Expressions**
The [TextFrame::highlightRegex](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#highlightRegex) method highlights text matches found by a regular expression in a text frame.
The following code highlights all words containing seven or more characters:
```php
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->get_Item(0);
$regex = java("java.util.regex.Pattern")->compile("\\b[^\\s]{7,}\\b");
$highlightColor = java("java.awt.Color")->YELLOW;
$shape->getTextFrame()->highlightRegex($regex, $highlightColor, null);
$presentation->save("highlighted_text_using_regex.pptx", SaveFormat::Pptx);
}
finally {
$presentation->dispose();
}
```
The result:

## **Highlight Text Across a Presentation**
Use [Presentation::highlightText](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#highlightText) and [Presentation::highlightRegex](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#highlightRegex) to search all applicable text frames in a presentation. The following example highlights a literal term and all email addresses:
```php
$presentation = new Presentation("presentation.pptx");
try {
$searchOptions = new TextSearchOptions();
$searchOptions->setWholeWordsOnly(true);
$searchOptions->setCaseSensitive(false);
$termHighlightColor = java("java.awt.Color")->ORANGE;
$presentation->highlightText(
"confidential",
$termHighlightColor,
$searchOptions,
null
);
$patternClass = java("java.util.regex.Pattern");
$emailPattern = "\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}\\b";
$emailRegex = $patternClass->compile(
$emailPattern,
$patternClass->CASE_INSENSITIVE
);
$emailHighlightColor = java("java.awt.Color")->YELLOW;
$presentation->highlightRegex($emailRegex, $emailHighlightColor, null);
$presentation->save("highlighted_presentation.pptx", SaveFormat::Pptx);
}
finally {
$presentation->dispose();
}
```
## **Replace Text in a Text Frame**
Use [TextFrame::replaceText](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#replaceText) for literal text and [TextFrame::replaceRegex](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#replaceRegex) for pattern-based replacement. These methods update matched text within the existing text frame, which retains the surrounding portion formatting instead of rebuilding the text frame from a plain string.
The following example standardizes a spelling variant and then replaces version labels:
```php
$presentation = new Presentation("presentation.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->get_Item(0);
$searchOptions = new TextSearchOptions();
$searchOptions->setWholeWordsOnly(true);
$searchOptions->setCaseSensitive(false);
$shape->getTextFrame()->replaceText(
"colour",
"color",
$searchOptions,
null
);
$patternClass = java("java.util.regex.Pattern");
$versionPattern = "\\bv\\d+(?:\\.\\d+)*\\b";
$versionRegex = $patternClass->compile(
$versionPattern,
$patternClass->CASE_INSENSITIVE
);
$shape->getTextFrame()->replaceRegex(
$versionRegex,
"current version",
null
);
$presentation->save("updated_text_frame.pptx", SaveFormat::Pptx);
}
finally {
$presentation->dispose();
}
```
If one match spans portions with different formatting, review the output to confirm which formatting should apply to the replacement text.
## **Replace Text Across a Presentation**
Use [Presentation::replaceText](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#replaceText) and [Presentation::replaceRegex](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#replaceRegex) to apply the same operations across the presentation. This is useful for template cleanup, terminology updates, and redaction.
```php
$presentation = new Presentation("presentation.pptx");
try {
$searchOptions = new TextSearchOptions();
$searchOptions->setWholeWordsOnly(true);
$searchOptions->setCaseSensitive(true);
$presentation->replaceText(
"Contoso",
"Example Corp",
$searchOptions,
null
);
$accountNumberRegex = java("java.util.regex.Pattern")->compile(
"\\bACCT-\\d{6}\\b"
);
$presentation->replaceRegex(
$accountNumberRegex,
"ACCT-REDACTED",
null
);
$presentation->save("updated_presentation.pptx", SaveFormat::Pptx);
}
finally {
$presentation->dispose();
}
```
## **Group Matches for Reporting**
Because every result stores its slide number and text frame, applications can group matches for audit, reporting, or review workflows. The following example groups the collected results first by slide and then by text frame:
```php
$matchesBySlide = [];
$systemClass = java("java.lang.System");
foreach ($callbackHandler->getResults() as $result) {
$slideNumber = $result["slideNumber"];
$slideLabel = $slideNumber === null ? "Other" : (string) $slideNumber;
$textFrame = $result["textFrame"];
$textFrameHash = $systemClass->identityHashCode($textFrame);
$textFrameKey = (string) java_values($textFrameHash);
if (!isset($matchesBySlide[$slideLabel])) {
$matchesBySlide[$slideLabel] = [];
}
if (!isset($matchesBySlide[$slideLabel][$textFrameKey])) {
$matchesBySlide[$slideLabel][$textFrameKey] = [
"textFrame" => $textFrame,
"matches" => []
];
}
$matchesBySlide[$slideLabel][$textFrameKey]["matches"][] = $result;
}
foreach ($matchesBySlide as $slideLabel => $textFrameGroups) {
echo("Slide: " . $slideLabel . "\n");
foreach ($textFrameGroups as $textFrameGroup) {
$textFrame = $textFrameGroup["textFrame"];
echo(" Text frame: " . $textFrame->getText() . "\n");
foreach ($textFrameGroup["matches"] as $result) {
echo(
" '" . $result["foundText"] . "' at position " .
$result["textPosition"] . "; context: '" .
$result["sourceText"] . "'\n"
);
}
}
}
```
## **FAQ**
**How can I search only one text box instead of the entire presentation?**
Get the shape's text frame and call [TextFrame::highlightText](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#highlightText), [TextFrame::highlightRegex](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#highlightRegex), [TextFrame::replaceText](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#replaceText), or [TextFrame::replaceRegex](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#replaceRegex) on that text frame. Presentation-level methods process all applicable text frames instead.
**How can I match complete words with the correct capitalization?**
Set [TextSearchOptions::setWholeWordsOnly](https://reference.aspose.com/slides/php-java/aspose.slides/textsearchoptions/#setWholeWordsOnly) and [TextSearchOptions::setCaseSensitive](https://reference.aspose.com/slides/php-java/aspose.slides/textsearchoptions/#setCaseSensitive) to `true`, and pass the options to a literal-text highlighting or replacement method. For regular expressions, define word boundaries and case sensitivity in the Java `Pattern` itself.
**Can search and replacement include text in slide notes?**
Yes. Set [TextSearchOptions::setIncludeNotes](https://reference.aspose.com/slides/php-java/aspose.slides/textsearchoptions/#setIncludeNotes) to `true` when using a presentation-level literal-text operation.
**How can I create a report without scanning the presentation a second time?**
Pass a Java proxy callback to the highlighting or replacement operation. It receives every match while the operation runs, so the application can store the source text, matched text, position, text frame, and derived slide number for later grouping or export.
**Does replacing text preserve its formatting?**
[TextFrame::replaceText](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#replaceText) and [TextFrame::replaceRegex](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#replaceRegex) modify matched text within the existing text frame and retain the surrounding portion formatting. If a match spans portions with different formatting, inspect the result to ensure the replacement uses the desired style.
# Manage Sensitivity Labels in PowerPoint Presentations in PHP
> Read, add, update, remove, and migrate Microsoft Purview sensitivity labels in PowerPoint PPTX presentations in PHP.
Source: https://docs.aspose.com/slides/php-java/sensitivity-labels/
Updated: 2026-08-13
## **Overview**
Microsoft Purview sensitivity labels help organizations classify and govern documents. During automated presentation processing, an application may need to preserve an existing label, apply a label selected by a policy, update its state, or migrate label metadata written by an older Microsoft Information Protection (MIP) workflow.
Aspose.Slides for PHP via Java exposes modern sensitivity label metadata through [Presentation::getSensitivityLabels](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getSensitivityLabels). This method returns a [SensitivityLabelCollection](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabelcollection/) that can be inspected and modified before the presentation is saved as PPTX.
Sensitivity label identifiers and policy information are defined by your Microsoft Purview configuration. Validate label availability and policy requirements in your environment before adding or migrating metadata. The [SensitivityLabel::getContentMarkTypes](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/#getContentMarkTypes) values describe the content markings associated with a label; they do not by themselves add visible text or shapes to slides.
## **Understand Sensitivity Label Properties**
Each [SensitivityLabel](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/) contains the following metadata:
| Methods | Purpose |
| --- | --- |
| [SensitivityLabel::getId](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/#getId) and [SensitivityLabel::setId](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/#setId) | Get or set the sensitivity label identifier in the Purview policy. |
| [SensitivityLabel::getSiteId](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/#getSiteId) and [SensitivityLabel::setSiteId](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/#setSiteId) | Get or set the site associated with the label policy. |
| [SensitivityLabel::isEnabled](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/#isEnabled) and [SensitivityLabel::setEnabled](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/#setEnabled) | Get or set whether the label is enabled. |
| [SensitivityLabel::isRemoved](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/#isRemoved) and [SensitivityLabel::setRemoved](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/#setRemoved) | Get or set whether the label has been removed. Set the value to `true` when the removal state must be retained in the metadata. |
| [SensitivityLabel::getAssignmentMethodType](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/#getAssignmentMethodType) and [SensitivityLabel::setAssignmentMethodType](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/#setAssignmentMethodType) | Get or set whether the label was applied automatically or through a user decision. |
| [SensitivityLabel::getContentMarkTypes](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/#getContentMarkTypes) | Get the content marking types associated with the label. |
The [SensitivityLabelAssignmentType](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabelassignmenttype/) class defines how a label was assigned:
- [SensitivityLabelAssignmentType::Standard](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabelassignmenttype/) represents a default or automatically applied label.
- [SensitivityLabelAssignmentType::Privileged](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabelassignmenttype/) represents a label applied through a user decision, including manually applied, recommended, and mandatory labels.
The [SensitivityLabelContentType](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabelcontenttype/) class defines the marking associated with a label:
| Value | Meaning |
| --- | --- |
| [SensitivityLabelContentType::None](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabelcontenttype/) | The label was applied by default or automatically. |
| [SensitivityLabelContentType::Header](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabelcontenttype/) | Header content marking is associated with the label. |
| [SensitivityLabelContentType::Footer](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabelcontenttype/) | Footer content marking is associated with the label. |
| [SensitivityLabelContentType::Watermark](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabelcontenttype/) | Watermark content marking is associated with the label. |
| [SensitivityLabelContentType::Encryption](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabelcontenttype/) | Encryption protection is associated with the label. |
Multiple marking types can be associated with one label.
## **List Existing Sensitivity Labels**
Read the modern label collection from [Presentation::getSensitivityLabels](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getSensitivityLabels) and enumerate it. The following example lists every property and content marking stored for each label:
```php
$presentation = new Presentation("presentation.pptx");
try {
$sensitivityLabels = $presentation->getSensitivityLabels();
$sensitivityLabelCount = java_values($sensitivityLabels->getCount());
for ($labelIndex = 0; $labelIndex < $sensitivityLabelCount; $labelIndex++) {
$sensitivityLabel = $sensitivityLabels->get_Item($labelIndex);
echo "Label ID: " . java_values($sensitivityLabel->getId()) . PHP_EOL;
echo "Site ID: " . java_values($sensitivityLabel->getSiteId()->toString()) . PHP_EOL;
echo "Enabled: " . (java_values($sensitivityLabel->isEnabled()) ? "true" : "false") . PHP_EOL;
echo "Removed: " . (java_values($sensitivityLabel->isRemoved()) ? "true" : "false") . PHP_EOL;
echo "Assignment method: " . java_values($sensitivityLabel->getAssignmentMethodType()) . PHP_EOL;
$contentMarkIterator = $sensitivityLabel->getContentMarkTypes()->iterator();
while (java_values($contentMarkIterator->hasNext())) {
$contentMarkType = java_values($contentMarkIterator->next());
echo "Content marking: " . $contentMarkType . PHP_EOL;
}
}
} finally {
$presentation->dispose();
}
```
## **Add a Sensitivity Label with Content Marking**
Use [SensitivityLabelCollection::add](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabelcollection/#add) with the label identifier, site identifier, enabled state, and assignment method. After the method returns the new [SensitivityLabel](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/), add the required marking values through the list returned by [SensitivityLabel::getContentMarkTypes](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/#getContentMarkTypes).
The following example adds a manually selected label associated with footer and watermark markings, and then saves the result as PPTX:
```php
$presentation = new Presentation("presentation.pptx");
try {
$sensitivityLabels = $presentation->getSensitivityLabels();
$labelIdentifier = "{11111111-2222-3333-4444-555555555555}";
$UUID = new JavaClass("java.util.UUID");
$siteIdentifier = $UUID->fromString("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");
$isEnabled = true;
$assignmentMethod = SensitivityLabelAssignmentType::Privileged;
$sensitivityLabel = $sensitivityLabels->add(
$labelIdentifier,
$siteIdentifier,
$isEnabled,
$assignmentMethod
);
$contentMarkTypes = $sensitivityLabel->getContentMarkTypes();
$contentMarkTypes->addItem(SensitivityLabelContentType::Footer);
$contentMarkTypes->addItem(SensitivityLabelContentType::Watermark);
$presentation->save("presentation_with_label.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Update a Sensitivity Label**
The [SensitivityLabel](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/) values are read/write, except that the list returned by [SensitivityLabel::getContentMarkTypes](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/#getContentMarkTypes) is modified through its list operations. After locating the required label, you can update its identifier, site identifier, enabled state, assignment method, removal state, and content marking types. Save the presentation to persist the changes.
The following example updates the enabled state and assignment method of the first label:
```php
$presentation = new Presentation("presentation.pptx");
try {
$sensitivityLabels = $presentation->getSensitivityLabels();
$sensitivityLabelCount = java_values($sensitivityLabels->getCount());
if ($sensitivityLabelCount > 0) {
$sensitivityLabel = $sensitivityLabels->get_Item(0);
$sensitivityLabel->setEnabled(true);
$sensitivityLabel->setAssignmentMethodType(SensitivityLabelAssignmentType::Privileged);
}
$presentation->save("presentation_with_updated_label.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Mark a Sensitivity Label as Removed**
To preserve the fact that a label was removed, find the label and call [SensitivityLabel::setRemoved](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/#setRemoved) with `true`. This retains the label entry while recording its removed state. If you instead need to delete an entry from the modern collection, use [SensitivityLabelCollection::removeAt](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabelcollection/#removeAt); use [SensitivityLabelCollection::clear](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabelcollection/#clear) to delete every entry.
The following example marks a specific label as removed and saves the updated presentation:
```php
$presentation = new Presentation("presentation.pptx");
try {
$sensitivityLabels = $presentation->getSensitivityLabels();
$targetLabelIdentifier = "{11111111-2222-3333-4444-555555555555}";
$sensitivityLabelCount = java_values($sensitivityLabels->getCount());
for ($labelIndex = 0; $labelIndex < $sensitivityLabelCount; $labelIndex++) {
$sensitivityLabel = $sensitivityLabels->get_Item($labelIndex);
$labelIdentifier = java_values($sensitivityLabel->getId());
$isTargetLabel = strcasecmp($labelIdentifier, $targetLabelIdentifier) === 0;
if ($isTargetLabel) {
$sensitivityLabel->setRemoved(true);
break;
}
}
$presentation->save("presentation_with_removed_label.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Read and Migrate Legacy MIP Sensitivity Labels**
Older MIP-based workflows can store sensitivity label metadata in custom document properties instead of the modern label collection. Read that metadata with [DocumentProperties::getSensitivityLabels](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/#getSensitivityLabels). The method parses the legacy custom properties and returns a Java array of [SensitivityLabel](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/) objects.
To migrate the metadata, add each returned label to the modern [SensitivityLabelCollection](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabelcollection/) through [SensitivityLabelCollection::add](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabelcollection/#add). Because adding a duplicate label identifier raises an exception, the example checks the destination collection before copying each label. You can add further validation to confirm that each legacy label still exists in the current Purview policy.
```php
$presentation = new Presentation("presentation_with_legacy_labels.pptx");
try {
$legacySensitivityLabels = $presentation->getDocumentProperties()->getSensitivityLabels();
$modernSensitivityLabels = $presentation->getSensitivityLabels();
$Array = new JavaClass("java.lang.reflect.Array");
$legacyLabelCount = java_values($Array->getLength($legacySensitivityLabels));
for ($legacyLabelIndex = 0; $legacyLabelIndex < $legacyLabelCount; $legacyLabelIndex++) {
$legacySensitivityLabel = $legacySensitivityLabels[$legacyLabelIndex];
$legacyLabelIdentifier = java_values($legacySensitivityLabel->getId());
$labelAlreadyExists = false;
$modernLabelCount = java_values($modernSensitivityLabels->getCount());
for ($modernLabelIndex = 0; $modernLabelIndex < $modernLabelCount; $modernLabelIndex++) {
$modernSensitivityLabel = $modernSensitivityLabels->get_Item($modernLabelIndex);
$modernLabelIdentifier = java_values($modernSensitivityLabel->getId());
$labelAlreadyExists = strcasecmp(
$modernLabelIdentifier,
$legacyLabelIdentifier
) === 0;
if ($labelAlreadyExists) {
break;
}
}
if (!$labelAlreadyExists) {
$modernSensitivityLabels->add($legacySensitivityLabel);
}
}
$presentation->save("presentation_with_modern_labels.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The migration copies the parsed label objects into the modern collection. It does not require clearing all custom document properties, so unrelated document metadata remains intact. Use [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#save) with [SaveFormat::Pptx](https://reference.aspose.com/slides/php-java/aspose.slides/saveformat/) to write the modern label metadata to a PPTX file.
## **FAQ**
**Does adding a content marking type create a visible header, footer, or watermark on slides?**
No. Values added through the list returned by [SensitivityLabel::getContentMarkTypes](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/#getContentMarkTypes) describe the markings associated with the sensitivity label. They do not create visible text or shapes in the presentation. Add the corresponding slide content separately if your workflow must render those markings.
**What is the difference between marking a label as removed and deleting it from the collection?**
Calling [SensitivityLabel::setRemoved](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/#setRemoved) with `true` keeps the label entry and records its removed state. Calling [SensitivityLabelCollection::removeAt](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabelcollection/#removeAt) deletes the entry from the modern collection. Choose the operation that matches your organization's metadata retention requirements.
**Can a presentation contain both legacy MIP metadata and modern sensitivity labels?**
Yes. Legacy labels can remain in custom document properties while modern labels are available through [Presentation::getSensitivityLabels](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getSensitivityLabels). Use [DocumentProperties::getSensitivityLabels](https://reference.aspose.com/slides/php-java/aspose.slides/documentproperties/#getSensitivityLabels) to read the legacy metadata and migrate only the valid labels that are not already present in the modern collection.
**What happens when a label with the same identifier is added more than once?**
[SensitivityLabelCollection::add](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabelcollection/#add) raises an exception when the collection already contains a label with the same identifier. Check existing values returned by [SensitivityLabel::getId](https://reference.aspose.com/slides/php-java/aspose.slides/sensitivitylabel/#getId) before adding or migrating labels.
**Which output format should be used to preserve updated sensitivity labels?**
Save the presentation as PPTX by calling [Presentation::save](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#save) with [SaveFormat::Pptx](https://reference.aspose.com/slides/php-java/aspose.slides/saveformat/), as shown in the examples above.
# Apply Shape Animations in Presentations Using PHP
> Learn how to add, inspect, and customize shape animations, timing, sounds, after-animation behavior, and animated text with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/shape-animation/
Updated: 2026-10-26
## **Overview**
To work with the individual behaviors inside an effect or edit motion-path segments, see [Custom Animation](https://docs.aspose.com/slides/php-java/custom-animation/).
Aspose.Slides for PHP via Java represents slide animations as effects in a slide timeline. An effect has a target shape, an animation type and subtype, a trigger, timing settings, and optional properties such as sound or after-animation behavior.
The timeline contains two kinds of sequences:
- The **main sequence** plays as the slide advances.
- An **interactive sequence** starts when its trigger shape is clicked.
Because text boxes, pictures, charts, tables, and other slide objects are shapes, you use the same [Sequence::addEffect](https://reference.aspose.com/slides/php-java/aspose.slides/sequence/addeffect/) method for most slide content. The available effects are listed in the [EffectType](https://reference.aspose.com/slides/php-java/aspose.slides/effecttype/) class.
## **Add Shape Animations**
To add an animation, get the slide's main sequence and call [Sequence::addEffect](https://reference.aspose.com/slides/php-java/aspose.slides/sequence/addeffect/) with the target shape, effect type, subtype, and trigger. For an effect that starts when another shape is clicked, create an interactive sequence whose trigger is that other shape.
The following example creates both types of animation and saves the result to `shape-animations.pptx`.
```php
use aspose\slides\EffectSubtype;
use aspose\slides\EffectTriggerType;
use aspose\slides\EffectType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$targetShape = $slide->getShapes()->addAutoShape(ShapeType::RoundCornerRectangle, 120, 100, 320, 80);
$targetShape->addTextFrame("Click to animate this shape");
$mainSequence = $slide->getTimeline()->getMainSequence();
$entranceEffect = $mainSequence->addEffect($targetShape, EffectType::Fade, EffectSubtype::None, EffectTriggerType::OnClick);
$entranceEffect->getTiming()->setDuration(1.5);
$triggerShape = $slide->getShapes()->addAutoShape(ShapeType::Bevel, 20, 20, 100, 40);
$triggerShape->addTextFrame("Move");
$interactiveSequence = $slide->getTimeline()->getInteractiveSequences()->add($triggerShape);
$interactiveSequence->addEffect($targetShape, EffectType::PathFootball, EffectSubtype::None, EffectTriggerType::OnClick);
$presentation->save("shape-animations.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The trigger controls when an effect starts:
- [EffectTriggerType::OnClick](https://reference.aspose.com/slides/php-java/aspose.slides/effecttriggertype/) waits for a click in the main sequence, or for a click on the trigger shape in an interactive sequence.
- [EffectTriggerType::WithPrevious](https://reference.aspose.com/slides/php-java/aspose.slides/effecttriggertype/) starts with the preceding effect.
- [EffectTriggerType::AfterPrevious](https://reference.aspose.com/slides/php-java/aspose.slides/effecttriggertype/) starts when the preceding effect finishes.
To animate a picture, chart, or another shape type, pass that object to [Sequence::addEffect](https://reference.aspose.com/slides/php-java/aspose.slides/sequence/addeffect/) instead of `$targetShape`. For chart-specific grouping options, see [Animated Charts](https://docs.aspose.com/slides/php-java/animated-charts/).
## **Read Shape Animations**
Use [Sequence::getEffectsByShape](https://reference.aspose.com/slides/php-java/aspose.slides/sequence/geteffectsbyshape/) when you know the target shape. To inspect every effect, enumerate the main sequence and every interactive sequence. Enumeration avoids assuming that a sequence contains an effect at index `0`.
The following example creates a shape with main-sequence and interactive effects, gets the effects that target the shape, and then enumerates every sequence on the slide.
```php
use aspose\slides\EffectSubtype;
use aspose\slides\EffectTriggerType;
use aspose\slides\EffectType;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
function printSequence($label, $sequence)
{
$effectCount = java_values($sequence->getCount());
echo " " . $label . ": " . $effectCount . " effect(s)" . PHP_EOL;
for ($effectIndex = 0; $effectIndex < $effectCount; $effectIndex++) {
$effect = $sequence->get_Item($effectIndex);
$targetShape = $effect->getTargetShape();
$targetName = java_is_null($targetShape) ? "unknown" : java_values($targetShape->getName());
$effectType = java_values($effect->getType());
$effectSubtype = java_values($effect->getSubtype());
$triggerType = java_values($effect->getTiming()->getTriggerType());
echo " type: " . $effectType . "; subtype: " . $effectSubtype . "; target: " . $targetName . "; trigger: " . $triggerType . PHP_EOL;
}
}
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$targetShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 120, 100, 320, 80);
$targetShape->addTextFrame("Animated shape");
$mainSequence = $slide->getTimeline()->getMainSequence();
$mainSequence->addEffect($targetShape, EffectType::Fade, EffectSubtype::None, EffectTriggerType::OnClick);
$triggerShape = $slide->getShapes()->addAutoShape(ShapeType::Bevel, 20, 20, 100, 40);
$triggerShape->addTextFrame("Move");
$interactiveSequence = $slide->getTimeline()->getInteractiveSequences()->add($triggerShape);
$interactiveSequence->addEffect($targetShape, EffectType::PathFootball, EffectSubtype::None, EffectTriggerType::OnClick);
$targetEffects = $mainSequence->getEffectsByShape($targetShape);
$Array = new JavaClass("java.lang.reflect.Array");
echo "The main sequence contains " . java_values($Array->getLength($targetEffects)) . " effect(s) for " . java_values($targetShape->getName()) . "." . PHP_EOL;
printSequence("Main sequence", $mainSequence);
$interactiveSequences = $slide->getTimeline()->getInteractiveSequences();
$interactiveCount = java_values($interactiveSequences->getCount());
for ($interactiveIndex = 0; $interactiveIndex < $interactiveCount; $interactiveIndex++) {
$sequence = $interactiveSequences->get_Item($interactiveIndex);
$sequenceTrigger = $sequence->getTriggerShape();
$triggerName = java_is_null($sequenceTrigger) ? "unknown" : java_values($sequenceTrigger->getName());
printSequence("Interactive sequence " . ($interactiveIndex + 1) . ", trigger: " . $triggerName, $sequence);
}
} finally {
$presentation->dispose();
}
```
If you only need the effects for one shape, first identify the shape by name, placeholder type, or another stable property; then call [Sequence::getEffectsByShape](https://reference.aspose.com/slides/php-java/aspose.slides/sequence/geteffectsbyshape/). Do not assume that [ShapeCollection::get_Item](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/get_item/) at index `0` is always the intended object.
## **Remove All Animations from a Shape**
Use [Sequence::removeByShape](https://reference.aspose.com/slides/php-java/aspose.slides/sequence/removebyshape/) to remove effects targeting a particular shape. Each call affects only the sequence on which it is invoked. To remove the shape's effects throughout a slide's timeline, call it on [AnimationTimeLine::getMainSequence](https://reference.aspose.com/slides/php-java/aspose.slides/animationtimeline/getmainsequence/) and on every sequence in [AnimationTimeLine::getInteractiveSequences](https://reference.aspose.com/slides/php-java/aspose.slides/animationtimeline/getinteractivesequences/).
The example expects a presentation file with two shapes named `Target` and `Other` on the first slide. Both shapes have effects in the main sequence and in an interactive sequence triggered by clicking `Target`. It finds the target by name, removes its effects from all these sequences, and saves the presentation.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("animated-shapes.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$targetShape = null;
$shapes = $slide->getShapes();
$shapeCount = java_values($shapes->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $shapes->get_Item($shapeIndex);
if (java_values($shape->getName()) === "Target") {
$targetShape = $shape;
break;
}
}
if ($targetShape !== null) {
$slide->getTimeline()->getMainSequence()->removeByShape($targetShape);
$interactiveSequences = $slide->getTimeline()->getInteractiveSequences();
$interactiveCount = java_values($interactiveSequences->getCount());
for ($sequenceIndex = 0; $sequenceIndex < $interactiveCount; $sequenceIndex++) {
$sequence = $interactiveSequences->get_Item($sequenceIndex);
$sequence->removeByShape($targetShape);
}
$presentation->save("shape-animations-removed.pptx", SaveFormat::Pptx);
} else {
echo "The target shape was not found." . PHP_EOL;
}
} finally {
$presentation->dispose();
}
```
The `Target` shape remains on the slide, and effects targeting `Other` are preserved in both sequences. An effect's [Effect::getTargetShape](https://reference.aspose.com/slides/php-java/aspose.slides/effect/gettargetshape/) is distinct from a sequence's [Sequence::getTriggerShape](https://reference.aspose.com/slides/php-java/aspose.slides/sequence/gettriggershape/): removing effects targeting `Target` does not remove every animation triggered by it. In this example, clicking `Target` still starts the interactive effect for `Other`.
## **Work with Inherited Placeholder Effects**
A placeholder on a normal slide can inherit animation behavior from the corresponding placeholder on its layout slide and master slide. [Shape::getBasePlaceholder](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getbaseplaceholder/) returns that parent placeholder, or `null` when no parent exists.
In the following example presentation, the footer has **Random Bars** on the normal slide, **Split** on the layout slide, and **Fly In** on the master slide.



The next example uses a placeholder hierarchy from a new presentation. It adds effects to a master placeholder, a layout placeholder, and the corresponding placeholder on a normal slide. Every call to [Shape::getBasePlaceholder](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getbaseplaceholder/) is checked before the returned shape is used.
```php
use aspose\slides\EffectSubtype;
use aspose\slides\EffectTriggerType;
use aspose\slides\EffectType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SlideLayoutType;
function findLayoutPlaceholderWithBase($layoutSlide)
{
$shapes = $layoutSlide->getShapes();
$shapeCount = java_values($shapes->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $shapes->get_Item($shapeIndex);
if (!java_is_null($shape->getBasePlaceholder())) {
return $shape;
}
}
return null;
}
function findSlidePlaceholderWithBase($slide, $expectedBase)
{
$shapes = $slide->getShapes();
$shapeCount = java_values($shapes->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $shapes->get_Item($shapeIndex);
$basePlaceholder = $shape->getBasePlaceholder();
if (!java_is_null($basePlaceholder) && java_values($basePlaceholder->equals($expectedBase))) {
return $shape;
}
}
return null;
}
function printEffects($source, $effects)
{
$Array = new JavaClass("java.lang.reflect.Array");
echo $source . ": " . java_values($Array->getLength($effects)) . " effect(s)" . PHP_EOL;
foreach ($effects as $effect) {
echo " type: " . java_values($effect->getType()) . "; subtype: " . java_values($effect->getSubtype()) . PHP_EOL;
}
}
$presentation = new Presentation();
try {
$layoutSlide = $presentation->getLayoutSlides()->getByType(SlideLayoutType::TitleAndObject);
$layoutPlaceholder = findLayoutPlaceholderWithBase($layoutSlide);
if ($layoutPlaceholder === null) {
throw new RuntimeException("The layout slide does not contain a placeholder linked to its master slide.");
}
$masterPlaceholder = $layoutPlaceholder->getBasePlaceholder();
$layoutSlide->getMasterSlide()->getTimeline()->getMainSequence()->addEffect($masterPlaceholder, EffectType::Fly, EffectSubtype::Bottom, EffectTriggerType::OnClick);
$layoutSlide->getTimeline()->getMainSequence()->addEffect($layoutPlaceholder, EffectType::Split, EffectSubtype::VerticalIn, EffectTriggerType::OnClick);
$slide = $presentation->getSlides()->addEmptySlide($layoutSlide);
$slidePlaceholder = findSlidePlaceholderWithBase($slide, $layoutPlaceholder);
if ($slidePlaceholder === null) {
throw new RuntimeException("The slide does not contain a placeholder linked to its layout slide.");
}
$slide->getTimeline()->getMainSequence()->addEffect($slidePlaceholder, EffectType::RandomBars, EffectSubtype::Horizontal, EffectTriggerType::OnClick);
printEffects("Normal slide", $slide->getTimeline()->getMainSequence()->getEffectsByShape($slidePlaceholder));
$baseLayoutPlaceholder = $slidePlaceholder->getBasePlaceholder();
if (!java_is_null($baseLayoutPlaceholder)) {
printEffects("Layout slide", $layoutSlide->getTimeline()->getMainSequence()->getEffectsByShape($baseLayoutPlaceholder));
$baseMasterPlaceholder = $baseLayoutPlaceholder->getBasePlaceholder();
if (!java_is_null($baseMasterPlaceholder)) {
printEffects("Master slide", $layoutSlide->getMasterSlide()->getTimeline()->getMainSequence()->getEffectsByShape($baseMasterPlaceholder));
}
}
$presentation->save("placeholder-animations.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Change Animation Timing**
The PowerPoint **Timing** dialog maps to the properties of [Timing](https://reference.aspose.com/slides/php-java/aspose.slides/timing/).

- **Start** maps to [Timing::getTriggerType](https://reference.aspose.com/slides/php-java/aspose.slides/timing/gettriggertype/).
- **Duration** maps to [Timing::getDuration](https://reference.aspose.com/slides/php-java/aspose.slides/timing/getduration/), in seconds.
- **Delay** maps to [Timing::getTriggerDelayTime](https://reference.aspose.com/slides/php-java/aspose.slides/timing/gettriggerdelaytime/), in seconds.
- **Repeat** maps to [Timing::getRepeatCount](https://reference.aspose.com/slides/php-java/aspose.slides/timing/getrepeatcount/), [Timing::getRepeatUntilNextClick](https://reference.aspose.com/slides/php-java/aspose.slides/timing/getrepeatuntilnextclick/), or [Timing::getRepeatUntilEndSlide](https://reference.aspose.com/slides/php-java/aspose.slides/timing/getrepeatuntilendslide/).
- **Rewind when done playing** maps to [Timing::getRewind](https://reference.aspose.com/slides/php-java/aspose.slides/timing/getrewind/).
This independent example adds an effect, changes its timing through the object returned by [Sequence::addEffect](https://reference.aspose.com/slides/php-java/aspose.slides/sequence/addeffect/), and saves the result. Keeping the returned [Effect](https://reference.aspose.com/slides/php-java/aspose.slides/effect/) reference avoids an unnecessary collection index.
```php
use aspose\slides\EffectSubtype;
use aspose\slides\EffectTriggerType;
use aspose\slides\EffectType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 120, 100, 320, 80);
$shape->addTextFrame("Timed animation");
$effect = $slide->getTimeline()->getMainSequence()->addEffect($shape, EffectType::Fade, EffectSubtype::None, EffectTriggerType::OnClick);
$effect->getTiming()->setTriggerType(EffectTriggerType::OnClick);
$effect->getTiming()->setDuration(2.0);
$effect->getTiming()->setTriggerDelayTime(0.5);
$effect->getTiming()->setRepeatUntilNextClick(false);
$effect->getTiming()->setRepeatUntilEndSlide(false);
$effect->getTiming()->setRepeatCount(2.0);
$effect->getTiming()->setRewind(true);
$presentation->save("shape-animation-timing.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Use one repeat mode intentionally. Combining a repeat count with an "until" flag can produce confusing results in different viewers. When changing repeat modes, set [Timing::setRepeatUntilNextClick](https://reference.aspose.com/slides/php-java/aspose.slides/timing/setrepeatuntilnextclick/) and [Timing::setRepeatUntilEndSlide](https://reference.aspose.com/slides/php-java/aspose.slides/timing/setrepeatuntilendslide/) before [Timing::setRepeatCount](https://reference.aspose.com/slides/php-java/aspose.slides/timing/setrepeatcount/), because setting either flag also changes the active repeat mode.
## **Add and Extract Animation Sounds**
An animation effect can reference embedded audio through [Effect::getSound](https://reference.aspose.com/slides/php-java/aspose.slides/effect/getsound/). [Effect::setStopPreviousSound](https://reference.aspose.com/slides/php-java/aspose.slides/effect/setstopprevioussound/) tells an effect to stop audio started by an earlier effect.
### **Add a Sound to an Effect**
The following example expects a local audio file named `animation-sound.wav`. It creates two effects, embeds that file as the sound for the first effect, and configures the second effect to stop the sound. It uses the objects returned by [Sequence::addEffect](https://reference.aspose.com/slides/php-java/aspose.slides/sequence/addeffect/), so no sequence index is required.
```php
use aspose\slides\EffectSubtype;
use aspose\slides\EffectTriggerType;
use aspose\slides\EffectType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$Files = new JavaClass("java.nio.file.Files");
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$firstShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 80, 100, 240, 80);
$secondShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 400, 100, 240, 80);
$firstShape->addTextFrame("Starts sound");
$secondShape->addTextFrame("Stops sound");
$sequence = $slide->getTimeline()->getMainSequence();
$firstEffect = $sequence->addEffect($firstShape, EffectType::Fade, EffectSubtype::None, EffectTriggerType::OnClick);
$secondEffect = $sequence->addEffect($secondShape, EffectType::Fade, EffectSubtype::None, EffectTriggerType::OnClick);
$baseDirectory = getcwd();
$audioPath = (new Java("java.io.File", $baseDirectory . DIRECTORY_SEPARATOR . "animation-sound.wav"))->toPath();
$audioData = $Files->readAllBytes($audioPath);
$effectSound = $presentation->getAudios()->addAudio($audioData);
$firstEffect->setSound($effectSound);
$secondEffect->setStopPreviousSound(true);
$presentation->save($baseDirectory . DIRECTORY_SEPARATOR . "shape-animation-sound.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Extract Embedded Effect Sounds**
The following example expects a local presentation named `presentation-with-animation-sounds.pptx`. It scans both main and interactive sequences and writes every embedded effect sound to the `extracted-animation-sounds` directory. The extension is selected from the audio MIME type exposed by [Audio::getContentType](https://reference.aspose.com/slides/php-java/aspose.slides/audio/getcontenttype/).
```php
use aspose\slides\Presentation;
function getAudioExtension($contentType)
{
$normalizedType = strtolower($contentType === null ? "" : java_values($contentType));
if ($normalizedType === "audio/mpeg") {
return ".mp3";
}
if ($normalizedType === "audio/mp4") {
return ".m4a";
}
if ($normalizedType === "audio/ogg") {
return ".ogg";
}
if ($normalizedType === "audio/wav" || $normalizedType === "audio/x-wav") {
return ".wav";
}
return ".bin";
}
function saveSounds($sequence, $outputDirectory, $soundIndex)
{
$effectCount = java_values($sequence->getCount());
for ($effectIndex = 0; $effectIndex < $effectCount; $effectIndex++) {
$effect = $sequence->get_Item($effectIndex);
$sound = $effect->getSound();
if (java_is_null($sound)) {
continue;
}
$extension = getAudioExtension($sound->getContentType());
$outputPath = $outputDirectory->resolve("effect-sound-" . $soundIndex . $extension);
$outputStream = new Java("java.io.FileOutputStream", $outputPath->toFile());
try {
$outputStream->write($sound->getBinaryData());
} finally {
$outputStream->close();
}
$soundIndex++;
}
return $soundIndex;
}
$baseDirectory = getcwd();
$inputPath = (new Java("java.io.File", $baseDirectory . DIRECTORY_SEPARATOR . "presentation-with-animation-sounds.pptx"))->toPath();
$outputDirectoryName = $baseDirectory . DIRECTORY_SEPARATOR . "extracted-animation-sounds";
if (!is_dir($outputDirectoryName)) {
mkdir($outputDirectoryName, 0777, true);
}
$outputDirectory = (new Java("java.io.File", $outputDirectoryName))->toPath();
$presentation = new Presentation($inputPath->toString());
try {
$soundIndex = 1;
$slides = $presentation->getSlides();
$slideCount = java_values($slides->size());
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $slides->get_Item($slideIndex);
$soundIndex = saveSounds($slide->getTimeline()->getMainSequence(), $outputDirectory, $soundIndex);
$interactiveSequences = $slide->getTimeline()->getInteractiveSequences();
$interactiveCount = java_values($interactiveSequences->getCount());
for ($sequenceIndex = 0; $sequenceIndex < $interactiveCount; $sequenceIndex++) {
$sequence = $interactiveSequences->get_Item($sequenceIndex);
$soundIndex = saveSounds($sequence, $outputDirectory, $soundIndex);
}
}
echo "Extracted " . ($soundIndex - 1) . " sound file(s) to " . java_values($outputDirectory->toAbsolutePath()->toString()) . "." . PHP_EOL;
} finally {
$presentation->dispose();
}
```
For large audio objects, use [Audio::getStream](https://reference.aspose.com/slides/php-java/aspose.slides/audio/getstream/) and copy the stream to a file instead of loading the entire object into a byte array.
## **Set After-Animation Behavior**
The **After animation** option controls what happens to a shape after its effect finishes.

The [AfterAnimationType](https://reference.aspose.com/slides/php-java/aspose.slides/afteranimationtype/) class supports leaving the shape unchanged, changing its color, hiding it after the animation, or hiding it on the next click. When the type is [AfterAnimationType::Color](https://reference.aspose.com/slides/php-java/aspose.slides/afteranimationtype/), set [Effect::getAfterAnimationColor](https://reference.aspose.com/slides/php-java/aspose.slides/effect/getafteranimationcolor/) as well.
This independent example creates an effect, sets its after-animation behavior through the returned effect object, and saves the result.
```php
use aspose\slides\AfterAnimationType;
use aspose\slides\EffectSubtype;
use aspose\slides\EffectTriggerType;
use aspose\slides\EffectType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 120, 100, 320, 80);
$shape->addTextFrame("Dim after animation");
$effect = $slide->getTimeline()->getMainSequence()->addEffect($shape, EffectType::Fade, EffectSubtype::None, EffectTriggerType::OnClick);
$effect->setAfterAnimationType(AfterAnimationType::Color);
$effect->getAfterAnimationColor()->setColor(java("java.awt.Color")->LIGHT_GRAY);
$presentation->save("shape-animation-after-effect.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Changing the type away from [AfterAnimationType::Color](https://reference.aspose.com/slides/php-java/aspose.slides/afteranimationtype/) clears the after-animation color setting.
## **Animate Text**
Text animation has two related controls:
- [TextAnimation::getBuildType](https://reference.aspose.com/slides/php-java/aspose.slides/textanimation/getbuildtype/) controls whether paragraphs appear together or by paragraph level.
- [Effect::getAnimateTextType](https://reference.aspose.com/slides/php-java/aspose.slides/effect/getanimatetexttype/) controls whether text appears all at once, by word, or by letter. [Effect::getDelayBetweenTextParts](https://reference.aspose.com/slides/php-java/aspose.slides/effect/getdelaybetweentextparts/) sets the delay between words or letters. A positive value is a percentage of the effect duration; a negative value is a delay in seconds.
The following independent example animates the words in a text box. [BuildType::AsOneObject](https://reference.aspose.com/slides/php-java/aspose.slides/buildtype/) disables paragraph-by-paragraph building so that the word setting applies to the entire text frame.
```php
use aspose\slides\AnimateTextType;
use aspose\slides\BuildType;
use aspose\slides\EffectSubtype;
use aspose\slides\EffectTriggerType;
use aspose\slides\EffectType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$textBox = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 80, 80, 560, 100);
$textBox->addTextFrame("Aspose.Slides animates this sentence word by word.");
$effect = $slide->getTimeline()->getMainSequence()->addEffect($textBox, EffectType::Fade, EffectSubtype::None, EffectTriggerType::OnClick);
$effect->getTextAnimation()->setBuildType(BuildType::AsOneObject);
$effect->setAnimateTextType(AnimateTextType::ByWord);
$effect->setDelayBetweenTextParts(20.0);
$presentation->save("animated-text.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
To build a text box by paragraph, set [BuildType::ByLevelParagraphs1](https://reference.aspose.com/slides/php-java/aspose.slides/buildtype/) (or another paragraph level). To target a single paragraph with its own effect, use the [Sequence::addEffect](https://reference.aspose.com/slides/php-java/aspose.slides/sequence/addeffect/) overload that accepts a [Paragraph](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/). See [Animated Text](https://docs.aspose.com/slides/php-java/animated-text/) for paragraph-level examples.
## **Export and Compatibility Notes**
- Saving to PPT or PPTX preserves the animation model, but the final playback is controlled by the presentation viewer.
- PDF and static images do not play animations. Use [HTML5 export](https://docs.aspose.com/slides/php-java/export-to-html5/), animated GIF, or [video conversion](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-video/) when the output must show motion.
- For HTML5, enable [Html5Options::setAnimateShapes](https://reference.aspose.com/slides/php-java/aspose.slides/html5options/setanimateshapes/) and, when needed, [Html5Options::setAnimateTransitions](https://reference.aspose.com/slides/php-java/aspose.slides/html5options/setanimatetransitions/).
- Video rendering supports many common entrance, emphasis, exit, and motion-path effects, but not every PowerPoint effect is supported. Check the current [supported animations and effects](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-video/#supported-animations-and-effects) and test critical presentations with your target Aspose.Slides version.
- Advanced custom effects and effects imported from other presentation formats may be preserved in the file but render differently in PowerPoint, HTML5, or video. Validate the exported result rather than relying only on the effect name.
## **FAQ**
**Why does an animation appear in PowerPoint but not in a PDF?**
PDF is a static format, so animations and slide transitions do not play. Export to HTML5, animated GIF, or video when motion must be preserved.
**Why does an effect play differently in a video?**
Video export renders animations rather than storing the original PowerPoint behavior. Some advanced effects are unsupported or approximated. Review the supported-effects table and test the actual presentation before production use.
**Does moving a shape forward or backward change its animation order?**
No. Shape z-order controls overlap, while sequence order and triggers control animation playback. Change the timeline if you need a different playback order.
## Related articles
- [Animate PowerPoint Text in PHP](https://docs.aspose.com/slides/php-java/animated-text/)
# Apply Shape Effects in Presentations Using PHP
> Transform your PPT and PPTX files with advanced shape effects using Aspose.Slides for PHP via Java—create striking, professional slides in seconds.
Source: https://docs.aspose.com/slides/php-java/shape-effect/
Updated: 2026-11-04
## **Introduction**
While effects in PowerPoint can be used to make a shape stand out, they differ from [fills](https://docs.aspose.com/slides/php-java/shape-formatting/#gradient-fill) or outlines. Using PowerPoint effects, you can create convincing reflections on a shape, spread a shape's glow, etc.

PowerPoint provides six effects that can be applied to shapes. You can apply one or more effects to a shape.
Some combinations of effects look better than others. For this reason, PowerPoint provides options under **Preset**. The Preset options are combinations of two or more effects that are known to look good. This way, by selecting a preset, you won't have to waste time testing or combining different effects to find a nice combination.
Aspose.Slides provides properties and methods under the [EffectFormat](https://reference.aspose.com/slides/php-java/aspose.slides/effectformat/) class that allow you to apply the same effects to shapes in PowerPoint presentations.
## **Apply a Shadow Effect**
Aspose.Slides for PHP via Java supports outer and inner shadows for shapes. You can customize their color, direction, distance, and blur radius to match your presentation's design.
### **Apply an Outer Shadow**
Use an outer shadow to make a card or panel stand out against the slide background. The shadow extends beyond the shape's edges, creating the impression that the shape is raised above the slide. Adjust its color, direction, distance, and blur radius to match the lighting and styling of your template.
This PHP code shows how to apply the [outer shadow effect](https://reference.aspose.com/slides/php-java/aspose.slides/effectformat/#getOuterShadowEffect) to a rectangle:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::RoundCornerRectangle, 20, 20, 200, 100);
$shape->getEffectFormat()->enableOuterShadowEffect();
$shadowColor = new Java("java.awt.Color", 169, 169, 169);
$shape->getEffectFormat()->getOuterShadowEffect()->getShadowColor()->setColor($shadowColor);
$shape->getEffectFormat()->getOuterShadowEffect()->setDistance(10);
$shape->getEffectFormat()->getOuterShadowEffect()->setDirection(45);
$presentation->save("shadow_effect.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```

### **Apply an Inner Shadow**
When reproducing a template's visual styling, use an inner shadow to give a card or panel a recessed appearance. An outer shadow extends outside the shape and makes it appear raised, while an inner shadow shades the inside of its edges.
Call [enableInnerShadowEffect](https://reference.aspose.com/slides/php-java/aspose.slides/effectformat/#enableInnerShadowEffect), then configure the shadow returned by [getInnerShadowEffect](https://reference.aspose.com/slides/php-java/aspose.slides/effectformat/#getInnerShadowEffect). Larger blur radius values produce softer edges.
This PHP example creates a light blue card with a dark gray inner shadow and saves it as a PPTX file. The shadow direction is 225 degrees, its distance is 7 points, and its blur radius is 6 points:
```php
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 20, 200, 100);
$shape->getFillFormat()->setFillType(FillType::Solid);
$fillColor = new Java("java.awt.Color", 173, 216, 230);
$shape->getFillFormat()->getSolidFillColor()->setColor($fillColor);
$shape->getLineFormat()->getFillFormat()->setFillType(FillType::NoFill);
$shape->getEffectFormat()->enableInnerShadowEffect();
$shadow = $shape->getEffectFormat()->getInnerShadowEffect();
$shadowColor = new Java("java.awt.Color", 105, 105, 105);
$shadow->getShadowColor()->setColor($shadowColor);
$shadow->setDirection(225);
$shadow->setDistance(7);
$shadow->setBlurRadius(6);
$presentation->save("inner_shadow_effect.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```

To remove the inner shadow, call [disableInnerShadowEffect](https://reference.aspose.com/slides/php-java/aspose.slides/effectformat/#disableInnerShadowEffect) on the shape's effect format.
## **Apply a Reflection Effect**
To apply a reflection effect in Aspose.Slides for PHP via Java, you can add a mirror-like reflection to shapes, adjusting parameters such as distance, transparency, and size. This effect enhances the aesthetic of your presentations by giving shapes a more polished and sophisticated look. It’s easy to implement with simple code, enabling quick application across multiple elements for a consistent design.
This PHP code shows how to apply the [reflection effect](https://reference.aspose.com/slides/php-java/aspose.slides/effectformat/#getReflectionEffect) to a shape:
```php
use aspose\slides\Presentation;
use aspose\slides\RectangleAlignment;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::RoundCornerRectangle, 20, 20, 200, 100);
$shape->getEffectFormat()->enableReflectionEffect();
$shape->getEffectFormat()->getReflectionEffect()->setRectangleAlign(RectangleAlignment::Bottom);
$shape->getEffectFormat()->getReflectionEffect()->setDirection(90);
$shape->getEffectFormat()->getReflectionEffect()->setDistance(40);
$shape->getEffectFormat()->getReflectionEffect()->setBlurRadius(2);
$presentation->save("reflection_effect.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```

## **Apply a Glow Effect**
To apply a glow effect to a shape in Aspose.Slides for PHP via Java, you can add a soft, luminous aura around shapes, adjusting properties like color and size. This effect helps make shapes stand out and adds an attractive, eye-catching visual element to your presentation. It's easy to implement with minimal code, enhancing the overall look of your slides.
This PHP code shows how to apply the [glow effect](https://reference.aspose.com/slides/php-java/aspose.slides/effectformat/#getGlowEffect) to a shape:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::RoundCornerRectangle, 20, 20, 200, 100);
$shape->getEffectFormat()->enableGlowEffect();
$shape->getEffectFormat()->getGlowEffect()->getColor()->setColor(java("java.awt.Color")->MAGENTA);
$shape->getEffectFormat()->getGlowEffect()->setRadius(15);
$presentation->save("glow_effect.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```

## **Apply a Soft Edges Effect**
To apply a soft edges effect in Aspose.Slides for PHP via Java, you can create a smooth, blurred transition around the edges of a shape. This effect adds a more subtle and refined look, perfect for designs that need a gentle, softer appearance. You can easily adjust parameters like radius to achieve the desired effect across various shapes in your presentation.
This PHP code shows how to apply the [soft edges effect](https://reference.aspose.com/slides/php-java/aspose.slides/effectformat/#getSoftEdgeEffect) to a shape:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::RoundCornerRectangle, 20, 20, 200, 150);
$shape->getEffectFormat()->enableSoftEdgeEffect();
$shape->getEffectFormat()->getSoftEdgeEffect()->setRadius(8);
$presentation->save("soft_edges_effect.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```

## **Apply a Blur Effect**
Use shape blur to soften a shape's fill and outline while keeping the shape editable. Call [setBlurEffect](https://reference.aspose.com/slides/php-java/aspose.slides/effectformat/#setBlurEffect) on the shape's effect format. The radius is measured in points (1/72 inch): use a nonnegative value, with larger values producing stronger blur. A radius of zero leaves the appearance unchanged.
The [getGrow](https://reference.aspose.com/slides/php-java/aspose.slides/blur/#getGrow) setting controls the visible bounds of the effect. With `false`, the blur is clipped to the original painted bounds, including the outline. With `true`, the blur can extend beyond those bounds. Neither setting changes the shape's position or dimensions.
The comparison below uses the same fill, outline, and shape dimensions throughout. The top row uses `grow = false`; the bottom row uses `grow = true`.

This PHP example creates an orange rectangle with a dark blue outline, applies a 5-point blur, and then updates it to a 15-point blur by calling [setBlurEffect](https://reference.aspose.com/slides/php-java/aspose.slides/effectformat/#setBlurEffect) again. It saves both blurred states, then calls [disableBlurEffect](https://reference.aspose.com/slides/php-java/aspose.slides/effectformat/#disableBlurEffect) and saves the shape without blur.
```php
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 80, 160, 100);
$shape->getFillFormat()->setFillType(FillType::Solid);
$fillColor = new Java("java.awt.Color", 255, 165, 0);
$shape->getFillFormat()->getSolidFillColor()->setColor($fillColor);
$shape->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$lineColor = new Java("java.awt.Color", 0, 0, 139);
$shape->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor($lineColor);
$shape->getLineFormat()->setWidth(8);
$shape->getEffectFormat()->setBlurEffect(5, false);
$presentation->save("shape_blur_5.pptx", SaveFormat::Pptx);
$shape->getEffectFormat()->setBlurEffect(15, true);
$presentation->save("shape_blur_15.pptx", SaveFormat::Pptx);
$shape->getEffectFormat()->disableBlurEffect();
$presentation->save("shape_blur_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Shape blur affects the fill and outline together. A soft edges effect fades the shape's edges, while shadow blur softens only the shadow. Image transformation effects operate on image content; this example applies blur directly to the shape's effect format without converting the shape to an image.
## **FAQ**
**Can I apply multiple effects to the same shape?**
Yes, you can combine different effects, such as shadow, reflection, and glow, on a single shape to create a more dynamic appearance.
**What shapes can I apply effects to?**
You can apply effects to various shapes, including autoshapes, charts, tables, pictures, SmartArt objects, OLE objects, and more.
**Can I apply effects to grouped shapes?**
Yes, you can apply effects to grouped shapes. The effect will apply to the entire group.
## Related articles
- [Create and Apply WordArt Effects in PHP](https://docs.aspose.com/slides/php-java/wordart/)
# Get Shape Effective Properties from Presentations in PHP
> Learn how to use Aspose.Slides for PHP via Java to distinguish local, inherited, and effective shape formatting in PowerPoint presentations.
Source: https://docs.aspose.com/slides/php-java/shape-effective-properties/
Updated: 2026-11-08
## **Understand Local, Inherited, and Effective Properties**
PowerPoint formatting can come from several places. The value stored directly on an object is its **local value**. If that value is not set, PowerPoint looks at parent formatting sources, such as a paragraph default, a text style, a layout or master slide, a theme, or presentation-level defaults. Those values are **inherited values**. The value that remains after the entire hierarchy is resolved is the **effective value**—the value used to render the object.
For example, a text portion may not define its own font height. Its local [getFontHeight](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/) value is then `NAN`, which means "not set here." The portion can inherit a height from its paragraph, the presentation's default text style, or another applicable source. Calling [getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/portionformat/geteffective/) on the portion format returns the final resolved height.
Use the two kinds of formatting data for different purposes:
- Read or change a local format object, such as [PortionFormat](https://reference.aspose.com/slides/php-java/aspose.slides/portionformat/), when you need to control where a value is defined.
- Read an effective data object, such as the [data returned by PortionFormat.getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/portionformat/geteffective/), when you need the final, rendered result. Effective data is read-only.
Before running the examples, [install Aspose.Slides for PHP via Java](https://docs.aspose.com/slides/php-java/installation/).
## **Compare Local, Inherited, and Effective Values**
The following complete example creates a shape and applies font heights at the presentation, paragraph, and portion levels. Each step prints the values defined at those levels and the resulting effective value for the same text portion. It also demonstrates why effective data must be read again after formatting changes.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
function formatLocalValue($value)
{
return $value === null || is_nan($value) ? "" : (string)$value;
}
function printFontHeights($caption, $presentation, $paragraph, $portion)
{
$presentationValue = java_values($presentation->getDefaultTextStyle()->getLevel(0)->getDefaultPortionFormat()->getFontHeight());
$paragraphValue = java_values($paragraph->getParagraphFormat()->getDefaultPortionFormat()->getFontHeight());
$localValue = java_values($portion->getPortionFormat()->getFontHeight());
// Read effective data after the preceding changes.
$effectiveValue = java_values($portion->getPortionFormat()->getEffective()->getFontHeight());
echo $caption . PHP_EOL;
echo " Presentation default: " . formatLocalValue($presentationValue) . PHP_EOL;
echo " Paragraph default: " . formatLocalValue($paragraphValue) . PHP_EOL;
echo " Portion local: " . formatLocalValue($localValue) . PHP_EOL;
echo " Portion effective: " . $effectiveValue . PHP_EOL;
}
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 500, 80, false);
$textFrame = $shape->addTextFrame("Effective formatting");
$paragraph = $textFrame->getParagraphs()->get_Item(0);
$portion = $paragraph->getPortions()->get_Item(0);
// Define inherited values at two different levels.
$presentation->getDefaultTextStyle()->getLevel(0)->getDefaultPortionFormat()->setFontHeight(20);
$paragraph->getParagraphFormat()->getDefaultPortionFormat()->setFontHeight(28);
printFontHeights("The portion inherits from the paragraph", $presentation, $paragraph, $portion);
// A local value on the portion overrides both inherited values.
$portion->getPortionFormat()->setFontHeight(36);
printFontHeights("A local value overrides inherited values", $presentation, $paragraph, $portion);
// Changing an inherited value does not override an existing local value.
$paragraph->getParagraphFormat()->getDefaultPortionFormat()->setFontHeight(30);
printFontHeights("The local value still has priority", $presentation, $paragraph, $portion);
// Clear the local value. The portion now inherits from the paragraph again.
$portion->getPortionFormat()->setFontHeight(NAN);
printFontHeights("The local value is cleared", $presentation, $paragraph, $portion);
// Clear the paragraph value. The presentation default now supplies the result.
$paragraph->getParagraphFormat()->getDefaultPortionFormat()->setFontHeight(NAN);
printFontHeights("The paragraph value is cleared", $presentation, $paragraph, $portion);
$presentation->save("effective-properties.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The priority in this example is portion local formatting, then paragraph formatting, then the presentation default. Other objects can have different inheritance chains, but the principle is the same: a more specific explicit value wins, and [getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/portionformat/geteffective/) returns the final result.
[](https://docs.aspose.com/slides/php-java/shape-effective-properties/visual-shape-effective-properties-b9645b4ca164.svg)
*Verified .NET 26.11 values for the article’s sequence: 28 → 36 → 36 → 30 → 20 points. A set portion value wins over the paragraph; clearing it restores inheritance. “Unset” is not zero. Other properties can use different inheritance chains, so read their effective data after changes.*
## **Get Effective Text Properties**
Text formatting is split across several objects:
- [TextFrameFormat.getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/geteffective/) resolves text-frame properties such as margins, anchoring, autofit, and vertical text direction.
- [TextStyle.getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/textstyle/geteffective/) resolves paragraph formatting for each text style level.
- [ParagraphFormat.getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/geteffective/) resolves paragraph properties such as alignment, indentation, and bullets.
- [PortionFormat.getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/portionformat/geteffective/) resolves character properties such as font height, typeface, color, bold, and italic.
For the next example, `text-formatting.pptx` must contain at least one slide and one [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/) with a non-empty text frame. The AutoShape can appear at any position in the shape collection; the code searches for a suitable object and validates it before use.
```php
use aspose\slides\Presentation;
function formatEffectiveValue($javaValue)
{
$value = java_values($javaValue);
if ($value === null) {
return "";
}
if (is_bool($value)) {
return $value ? "true" : "false";
}
return (string)$value;
}
function hasNonEmptyText($shape)
{
$textFrame = $shape->getTextFrame();
if (java_is_null($textFrame)) {
return false;
}
if (java_values($textFrame->getParagraphs()->getCount()) === 0) {
return false;
}
return java_values($textFrame->getParagraphs()->get_Item(0)->getPortions()->getCount()) > 0;
}
function findAutoShapeWithText($slide)
{
$autoShapeClass = new JavaClass("com.aspose.slides.AutoShape");
$shapeCount = java_values($slide->getShapes()->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$candidate = $slide->getShapes()->get_Item($shapeIndex);
if (java_instanceof($candidate, $autoShapeClass) && hasNonEmptyText($candidate)) {
return $candidate;
}
}
return null;
}
$presentation = new Presentation("text-formatting.pptx");
try {
if (java_values($presentation->getSlides()->size()) === 0) {
throw new RuntimeException("The presentation contains no slides.");
}
$shape = findAutoShapeWithText($presentation->getSlides()->get_Item(0));
if ($shape === null) {
throw new RuntimeException("The first slide must contain an AutoShape with non-empty text.");
}
$textFrame = $shape->getTextFrame();
$paragraph = $textFrame->getParagraphs()->get_Item(0);
$portion = $paragraph->getPortions()->get_Item(0);
$textFrameEffective = $textFrame->getTextFrameFormat()->getEffective();
$paragraphEffective = $paragraph->getParagraphFormat()->getEffective();
$portionEffective = $portion->getPortionFormat()->getEffective();
echo "Text frame margins:" . PHP_EOL;
echo " Left: " . formatEffectiveValue($textFrameEffective->getMarginLeft()) . PHP_EOL;
echo " Top: " . formatEffectiveValue($textFrameEffective->getMarginTop()) . PHP_EOL;
echo " Right: " . formatEffectiveValue($textFrameEffective->getMarginRight()) . PHP_EOL;
echo " Bottom: " . formatEffectiveValue($textFrameEffective->getMarginBottom()) . PHP_EOL;
echo "Paragraph alignment: " . formatEffectiveValue($paragraphEffective->getAlignment()) . PHP_EOL;
echo "Font height: " . formatEffectiveValue($portionEffective->getFontHeight()) . PHP_EOL;
echo "Bold: " . formatEffectiveValue($portionEffective->getFontBold()) . PHP_EOL;
$effectiveTextStyle = $textFrame->getTextFrameFormat()->getTextStyle()->getEffective();
for ($level = 0; $level < 9; $level++) {
$levelEffective = $effectiveTextStyle->getLevel($level);
echo "Level " . $level . " indent: " . formatEffectiveValue($levelEffective->getIndent()) . PHP_EOL;
}
} finally {
$presentation->dispose();
}
```
## **Get Effective 3D Properties**
[ThreeDFormat.getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/geteffective/) returns one effective data object that groups all resolved 3D settings. Its [getCamera](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/geteffective/), [getLightRig](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/geteffective/), [getBevelTop](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/geteffective/), and [getBevelBottom](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/geteffective/) methods expose the corresponding effective data. Reading these related settings together makes it easier to understand the final 3D appearance of a shape.
For this example, `shape-3d.pptx` must contain at least one shape on its first slide. Apply 3D camera, lighting, or bevel settings to that shape if you want the output to contain values other than the defaults.
```php
use aspose\slides\Presentation;
function formatEffectiveValue($javaValue)
{
$value = java_values($javaValue);
return $value === null ? "" : (string)$value;
}
$presentation = new Presentation("shape-3d.pptx");
try {
if (java_values($presentation->getSlides()->size()) === 0 || java_values($presentation->getSlides()->get_Item(0)->getShapes()->size()) === 0) {
throw new RuntimeException("The first slide must contain a shape.");
}
$shape = $presentation->getSlides()->get_Item(0)->getShapes()->get_Item(0);
$threeDEffective = $shape->getThreeDFormat()->getEffective();
echo "Camera:" . PHP_EOL;
echo " Type: " . formatEffectiveValue($threeDEffective->getCamera()->getCameraType()) . PHP_EOL;
echo " Field of view: " . formatEffectiveValue($threeDEffective->getCamera()->getFieldOfViewAngle()) . PHP_EOL;
echo " Zoom: " . formatEffectiveValue($threeDEffective->getCamera()->getZoom()) . PHP_EOL;
echo "Light rig:" . PHP_EOL;
echo " Type: " . formatEffectiveValue($threeDEffective->getLightRig()->getLightType()) . PHP_EOL;
echo " Direction: " . formatEffectiveValue($threeDEffective->getLightRig()->getDirection()) . PHP_EOL;
echo "Top bevel:" . PHP_EOL;
echo " Type: " . formatEffectiveValue($threeDEffective->getBevelTop()->getBevelType()) . PHP_EOL;
echo " Width: " . formatEffectiveValue($threeDEffective->getBevelTop()->getWidth()) . PHP_EOL;
echo " Height: " . formatEffectiveValue($threeDEffective->getBevelTop()->getHeight()) . PHP_EOL;
} finally {
$presentation->dispose();
}
```
## **Get Effective Table Formatting**
Table formatting can come from the table style and from formats applied to the whole table, a column, a row, or an individual cell. For conflicts among explicitly defined fills, the priority is cell, row, column, and then whole table. The effective format of a cell is the final format used to draw that cell.
For this example, `table-formatting.pptx` must contain at least one table on its first slide. The table must have at least one row and one column. The code searches for a [Table](https://reference.aspose.com/slides/php-java/aspose.slides/table/) instead of assuming that `getShapes()->get_Item(0)` is a table.
```php
use aspose\slides\Presentation;
function findTable($slide)
{
$tableClass = new JavaClass("com.aspose.slides.Table");
$shapeCount = java_values($slide->getShapes()->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $slide->getShapes()->get_Item($shapeIndex);
if (java_instanceof($shape, $tableClass)) {
return $shape;
}
}
return null;
}
$presentation = new Presentation("table-formatting.pptx");
try {
if (java_values($presentation->getSlides()->size()) === 0) {
throw new RuntimeException("The presentation contains no slides.");
}
$table = findTable($presentation->getSlides()->get_Item(0));
if ($table === null) {
throw new RuntimeException("The first slide must contain a table.");
}
if (java_values($table->getRows()->size()) === 0 || java_values($table->getColumns()->size()) === 0) {
throw new RuntimeException("The table must contain at least one cell.");
}
$tableEffective = $table->getTableFormat()->getEffective();
$rowEffective = $table->getRows()->get_Item(0)->getRowFormat()->getEffective();
$columnEffective = $table->getColumns()->get_Item(0)->getColumnFormat()->getEffective();
$cellEffective = $table->get_Item(0, 0)->getCellFormat()->getEffective();
echo "Table fill: " . java_values($tableEffective->getFillFormat()->getFillType()) . PHP_EOL;
echo "Row fill: " . java_values($rowEffective->getFillFormat()->getFillType()) . PHP_EOL;
echo "Column fill: " . java_values($columnEffective->getFillFormat()->getFillType()) . PHP_EOL;
echo "Final cell fill: " . java_values($cellEffective->getFillFormat()->getFillType()) . PHP_EOL;
} finally {
$presentation->dispose();
}
```
If you need the color rather than only the fill type, first check the effective [getFillType](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/geteffective/) value, and then read the method that applies to that type—for example, [getSolidFillColor](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/geteffective/) for a solid fill.
## **Re-read Effective Data After Changes**
Effective data describes the formatting hierarchy at the time it is resolved. Call `getEffective` again after changing anything that can participate in that hierarchy, including:
- the object's local formatting;
- paragraph or text-frame defaults;
- a table style, table, column, row, or cell format;
- layout or master slide formatting;
- theme data or presentation-level defaults;
- the layout or master assigned to a slide.
Do not keep an effective data object as a permanent snapshot. Aspose.Slides may cache some effective data internally, and a later `getEffective` call can refresh that data. If you need to compare values before and after a change, copy the scalar values you need—such as a font height, color, alignment, or bevel width—into your own variables before making the change.
To change a value, update the appropriate local format object and then call `getEffective` to verify the result. Effective data objects themselves are read-only.
## **FAQ**
**How can I tell which level supplied an effective value?**
Effective data contains the final value, not its source. Inspect the applicable local objects from the most specific level outward. For text, this can include the portion, paragraph, text frame, layout, master, theme, and presentation defaults. Undefined values such as `NAN` or `null` indicate that the search continues to another level.
**What happens when no level defines a property?**
Aspose.Slides resolves the appropriate PowerPoint or library default. That resolved value appears in the effective data even though no local object explicitly defines it.
**Why does an effective value sometimes equal the local value?**
The local value won the inheritance calculation. This is expected when the property is explicitly set on the object and no more specific rule overrides it.
**When should I use local data instead of effective data?**
Use local data to inspect or edit a specific formatting level. Use effective data when you need the final appearance after inheritance, theme rules, and applicable styles have been resolved. The [complete comparison example](https://docs.aspose.com/slides/php-java/shape-effective-properties/#compare-local-inherited-and-effective-values) demonstrates both in the same workflow.
# Format PowerPoint Shapes in PHP
> Learn how to format PowerPoint shapes in PHP using Aspose.Slides—set fill, line, and effect styles for PPT and PPTX files with precision and full control.
Source: https://docs.aspose.com/slides/php-java/shape-formatting/
Updated: 2026-11-05
## **Introduction**
Format shapes in PowerPoint by adjusting their outlines, fills, and effects. Aspose.Slides for PHP via Java lets you control these settings programmatically, including transparency, rotation, and 3D formatting.

Aspose.Slides for PHP via Java provides classes and methods that allow you to format shapes using the same options available in PowerPoint.
## **Format Lines**
Use [Shape::getLineFormat](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#getLineFormat) to control a shape’s outline. This example creates an unfilled rectangle with a blue, dashed outline. [LineFormat::setStyle](https://reference.aspose.com/slides/php-java/aspose.slides/lineformat/#setStyle) selects a thick-thin compound line, while [LineFormat::setWidth](https://reference.aspose.com/slides/php-java/aspose.slides/lineformat/#setWidth) sets its width to 7 points and [LineFormat::setDashStyle](https://reference.aspose.com/slides/php-java/aspose.slides/lineformat/#setDashStyle) selects the dash pattern.
```php
use aspose\slides\FillType;
use aspose\slides\LineDashStyle;
use aspose\slides\LineStyle;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 150, 75);
$shape->getFillFormat()->setFillType(FillType::NoFill);
$shape->getLineFormat()->setStyle(LineStyle::ThickThin);
$shape->getLineFormat()->setWidth(7);
$shape->getLineFormat()->setDashStyle(LineDashStyle::Dash);
$shape->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$shape->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLUE);
$presentation->save("formatted_lines.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

### **Set Custom Line Dash Patterns**
Use [LineFormat::setCustomDashPattern](https://reference.aspose.com/slides/php-java/aspose.slides/lineformat/#setCustomDashPattern) when predefined line styles do not provide the dash lengths and gaps you need, for example for branded outlines or technical diagrams. Assigning a pattern automatically changes the line dash style to [LineDashStyle::Custom](https://reference.aspose.com/slides/php-java/aspose.slides/linedashstyle/).
Array entries alternate between dash and gap lengths, starting with a dash. Each value is a multiple of the line width: `[4, 2]` at a width of 3 points produces a 12-point dash followed by a 6-point gap. Use pairs of finite, nonnegative values to define complete dash-and-gap segments. The example uses positive values to keep every dash and gap visible.
This example creates five blue lines with the same length and flat caps. The first three compare patterns at a width of 3 points. The fourth repeats the first pattern at twice the width, doubling both the dash and gap lengths. The fifth switches from a custom pattern to a solid line.
```php
use aspose\slides\FillType;
use aspose\slides\LineArrowheadStyle;
use aspose\slides\LineCapStyle;
use aspose\slides\LineDashStyle;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\SlideSizeScaleType;
$presentation = new Presentation();
try {
$presentation->getSlideSize()->setSize(600, 300, SlideSizeScaleType::DoNotScale);
$slide = $presentation->getSlides()->get_Item(0);
$patterns = [
[4, 2],
[1, 2],
[6, 2, 1, 2],
[4, 2],
[4, 2]
];
$lineColor = new Java("java.awt.Color", 0, 0, 139);
for ($i = 0; $i < count($patterns); $i++) {
$line = $slide->getShapes()->addAutoShape(ShapeType::Line, 50, 50 + $i * 50, 500, 0);
$line->getLineFormat()->setWidth($i == 3 ? 6 : 3);
$line->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$line->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor($lineColor);
$line->getLineFormat()->setCapStyle(LineCapStyle::Flat);
$line->getLineFormat()->setBeginArrowheadStyle(LineArrowheadStyle::None);
$line->getLineFormat()->setEndArrowheadStyle(LineArrowheadStyle::None);
$line->getLineFormat()->setCustomDashPattern($patterns[$i]);
}
// Return the last line to a solid style.
$slide->getShapes()->get_Item(4)->getLineFormat()->setDashStyle(LineDashStyle::Solid);
$presentation->save("custom_dash_patterns.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
To return to a predefined dashed style instead, pass [LineDashStyle::Dash](https://reference.aspose.com/slides/php-java/aspose.slides/linedashstyle/) to [LineFormat::setDashStyle](https://reference.aspose.com/slides/php-java/aspose.slides/lineformat/#setDashStyle). The selected style controls the line's appearance.
The result in PowerPoint, from top to bottom: **{4, 2}, 3 pt**; **{1, 2}, 3 pt**; **{6, 2, 1, 2}, 3 pt**; **{4, 2}, 6 pt**; and **Solid, 3 pt**.

### **Set Line Caps**
Use [LineFormat::setCapStyle](https://reference.aspose.com/slides/php-java/aspose.slides/lineformat/#setCapStyle) to set the ends of an open line. The [LineCapStyle](https://reference.aspose.com/slides/php-java/aspose.slides/linecapstyle/) class provides three explicit cap styles:
- `Flat`: The stroke stops at the endpoint.
- `Round`: A semicircular cap extends beyond the endpoint by half the line width.
- `Square`: A square cap extends beyond the endpoint by half the line width.
The class also includes `NotDefined`, which means that no cap style is explicitly assigned.
Caps are different from arrowheads, which add symbols to line ends, and joins, which control corners between line segments. This example disables arrowheads through [LineFormat::setBeginArrowheadStyle](https://reference.aspose.com/slides/php-java/aspose.slides/lineformat/#setBeginArrowheadStyle) and [LineFormat::setEndArrowheadStyle](https://reference.aspose.com/slides/php-java/aspose.slides/lineformat/#setEndArrowheadStyle) so that only the cap shapes are compared.
The following example creates three otherwise identical horizontal lines, 20 points wide. From top to bottom, they use flat, round, and square caps. Their endpoints have the same horizontal coordinates; the round and square caps extend 10 points beyond each endpoint.
```php
use aspose\slides\FillType;
use aspose\slides\LineArrowheadStyle;
use aspose\slides\LineCapStyle;
use aspose\slides\LineDashStyle;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\SlideSizeScaleType;
$presentation = new Presentation();
try {
$presentation->getSlideSize()->setSize(500, 240, SlideSizeScaleType::DoNotScale);
$slide = $presentation->getSlides()->get_Item(0);
$capStyles = [LineCapStyle::Flat, LineCapStyle::Round, LineCapStyle::Square];
for ($i = 0; $i < count($capStyles); $i++) {
$line = $slide->getShapes()->addAutoShape(ShapeType::Line, 100, 50 + $i * 70, 300, 0);
$line->getLineFormat()->setWidth(20);
$line->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$lineColor = new Java("java.awt.Color", 0, 0, 139);
$line->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor($lineColor);
$line->getLineFormat()->setDashStyle(LineDashStyle::Solid);
$line->getLineFormat()->setCapStyle($capStyles[$i]);
$line->getLineFormat()->setBeginArrowheadStyle(LineArrowheadStyle::None);
$line->getLineFormat()->setEndArrowheadStyle(LineArrowheadStyle::None);
}
$presentation->save("line_caps.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result in PowerPoint, from top to bottom: **Flat**, **Round**, and **Square**.

## **Apply Sketch Effects to Shape Lines**
A sketch effect makes a shape line look hand-drawn. Use [Shape::getLineFormat](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#getLineFormat) to access the line settings, [LineFormat::getSketchFormat](https://reference.aspose.com/slides/php-java/aspose.slides/lineformat/#getSketchFormat) to access the sketch settings, and [SketchFormat::setSketchType](https://reference.aspose.com/slides/php-java/aspose.slides/sketchformat/#setSketchType) to select a value from the [LineSketchType](https://reference.aspose.com/slides/php-java/aspose.slides/linesketchtype/) class.
The following PHP code shows how to apply a [LineSketchType::Curved](https://reference.aspose.com/slides/php-java/aspose.slides/linesketchtype/) effect, read the explicitly assigned value, and remove the effect with [LineSketchType::None](https://reference.aspose.com/slides/php-java/aspose.slides/linesketchtype/):
```php
use aspose\slides\LineSketchType;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 200, 100);
$sketchFormat = $shape->getLineFormat()->getSketchFormat();
$sketchFormat->setSketchType(LineSketchType::Curved);
$explicitSketchType = $sketchFormat->getSketchType();
echo "Explicit sketch type: " . $explicitSketchType . PHP_EOL;
$sketchFormat->setSketchType(LineSketchType::None);
} finally {
$presentation->dispose();
}
```
The value returned by [SketchFormat::getSketchType](https://reference.aspose.com/slides/php-java/aspose.slides/sketchformat/#getSketchType) represents the setting assigned directly to the shape. If the line formatting can be inherited from a theme, master slide, or layout slide, use [LineFormat::getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/lineformat/#getEffective), access the returned object’s `getSketchFormat` method, and read its `getSketchType` value. The effective value reflects the formatting that is actually applied after inheritance is resolved. This example requires an existing presentation with at least one shape on its first slide and prints both values:
```php
use aspose\slides\Presentation;
$presentation = new Presentation("presentation.pptx");
try {
$shape = $presentation->getSlides()->get_Item(0)->getShapes()->get_Item(0);
$lineFormat = $shape->getLineFormat();
$explicitSketchType = $lineFormat->getSketchFormat()->getSketchType();
$effectiveLineFormat = $lineFormat->getEffective();
$effectiveSketchType = $effectiveLineFormat->getSketchFormat()->getSketchType();
echo "Explicit sketch type: " . $explicitSketchType . PHP_EOL;
echo "Effective sketch type: " . $effectiveSketchType . PHP_EOL;
} finally {
$presentation->dispose();
}
```
## **Format Join Styles**
Here are the three join type options:
* Round
* Miter
* Bevel
The join style controls how two outline segments meet at a corner. Use **Round** for rounded corners, **Miter** for sharp corners, or **Bevel** for flattened corners.

This example creates three black rectangles with blue outlines 15 points wide. It sets [LineFormat::setJoinStyle](https://reference.aspose.com/slides/php-java/aspose.slides/lineformat/#setJoinStyle) to the miter, bevel, and round values of [LineJoinStyle](https://reference.aspose.com/slides/php-java/aspose.slides/linejoinstyle/), respectively, to compare how the corners are drawn.
```php
use aspose\slides\FillType;
use aspose\slides\LineJoinStyle;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$miterShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 20, 150, 75);
$bevelShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 210, 20, 150, 75);
$roundShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 135, 150, 75);
$miterShape->getFillFormat()->setFillType(FillType::Solid);
$miterShape->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$bevelShape->getFillFormat()->setFillType(FillType::Solid);
$bevelShape->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$roundShape->getFillFormat()->setFillType(FillType::Solid);
$roundShape->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$miterShape->getLineFormat()->setWidth(15);
$bevelShape->getLineFormat()->setWidth(15);
$roundShape->getLineFormat()->setWidth(15);
$miterShape->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$miterShape->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLUE);
$bevelShape->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$bevelShape->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLUE);
$roundShape->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$roundShape->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLUE);
$miterShape->getLineFormat()->setJoinStyle(LineJoinStyle::Miter);
$bevelShape->getLineFormat()->setJoinStyle(LineJoinStyle::Bevel);
$roundShape->getLineFormat()->setJoinStyle(LineJoinStyle::Round);
$miterShape->getTextFrame()->setText("Miter Join Style");
$bevelShape->getTextFrame()->setText("Bevel Join Style");
$roundShape->getTextFrame()->setText("Round Join Style");
$presentation->save("join_styles.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Limit Miter Joins at Sharp Corners**
Use [LineFormat::setMiterLimit](https://reference.aspose.com/slides/php-java/aspose.slides/lineformat/#setMiterLimit) with [LineFormat::setJoinStyle](https://reference.aspose.com/slides/php-java/aspose.slides/lineformat/#setJoinStyle) set to [LineJoinStyle::Miter](https://reference.aspose.com/slides/php-java/aspose.slides/linejoinstyle/) to limit how far a sharp corner can extend.
The limit is a ratio of the distance between the inner and outer corners of the join to the line width. For example, a value of `8` permits a miter length of up to eight times the line width; it is not a measurement in points. If the corner would exceed the limit, PowerPoint uses a beveled join at that corner. A larger limit allows sharper points. The setting affects miter joins only, and changing it has no visible effect when the corner remains within both limits.
This example creates two identical, unfilled triangles with outlines 20 points wide. The left triangle uses a limit of `2`, and the right uses `8`. Each triangle is 80 points wide and 160 points high, giving its top corner a miter-length-to-line-width ratio of approximately `4.12`. Consequently, PowerPoint bevels the left apex and preserves the right apex.
```php
use aspose\slides\FillType;
use aspose\slides\LineJoinStyle;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\SlideSizeScaleType;
$presentation = new Presentation();
try {
$presentation->getSlideSize()->setSize(500, 320, SlideSizeScaleType::DoNotScale);
$slide = $presentation->getSlides()->get_Item(0);
$miterLimits = [2, 8];
for ($i = 0; $i < count($miterLimits); $i++) {
$triangle = $slide->getShapes()->addAutoShape(ShapeType::Triangle, 90 + $i * 240, 110, 80, 160);
$triangle->getFillFormat()->setFillType(FillType::NoFill);
$triangle->getLineFormat()->setWidth(20);
$triangle->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$lineColor = new Java("java.awt.Color", 0, 0, 139);
$triangle->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor($lineColor);
$triangle->getLineFormat()->setJoinStyle(LineJoinStyle::Miter);
$triangle->getLineFormat()->setMiterLimit($miterLimits[$i]);
}
$presentation->save("miter_limits.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result in PowerPoint: **Miter limit 2** on the left and **miter limit 8** on the right.

## **Gradient Fill**
A gradient fill blends colors across a shape. This example fills an ellipse with a linear gradient at a 45-degree angle from red to purple using [FillFormat::getGradientFormat](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/#getGradientFormat). The [GradientStopCollection::addPresetColor](https://reference.aspose.com/slides/php-java/aspose.slides/gradientstopcollection/#addPresetColor) method places the color stops at 0 and 1, the beginning and end of the gradient. Clearing the existing stops ensures that only these two colors are used.
```php
use aspose\slides\FillType;
use aspose\slides\GradientShape;
use aspose\slides\Presentation;
use aspose\slides\PresetColor;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Ellipse, 50, 50, 150, 75);
$shape->getFillFormat()->setFillType(FillType::Gradient);
$shape->getFillFormat()->getGradientFormat()->setGradientShape(GradientShape::Linear);
$shape->getFillFormat()->getGradientFormat()->setLinearGradientAngle(45);
$shape->getFillFormat()->getGradientFormat()->getGradientStops()->clear();
$shape->getFillFormat()->getGradientFormat()->getGradientStops()->addPresetColor(1.0, PresetColor::Purple);
$shape->getFillFormat()->getGradientFormat()->getGradientStops()->addPresetColor(0.0, PresetColor::Red);
$presentation->save("gradient_fill.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

If a gradient looks different in an exported image than it does in PowerPoint, see [Choose a Gradient Rendering Style](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-png/#choose-a-gradient-rendering-style). You can select a rendering style without changing the gradient fill stored in the presentation.
### **Set the Linear Gradient Angle**
Use [GradientFormat::setLinearGradientAngle](https://reference.aspose.com/slides/php-java/aspose.slides/gradientformat/#setLinearGradientAngle) to control the orientation of a [GradientShape::Linear](https://reference.aspose.com/slides/php-java/aspose.slides/gradientshape/) fill. The angle is measured in degrees and increases clockwise: `0` runs from left to right, `90` from top to bottom, `180` from right to left, and `270` from bottom to top. Fractional angles are supported. Finite angles outside `[0, 360)` are normalized to one revolution; for example, `-45` becomes `315` and `360` becomes `0`.
This example creates six rectangles with identical red, green, and blue stops at positions `0`, `0.5`, and `1`. Scaling is disabled so that the angle can be compared independently of the rectangles' proportions. The angles, from left to right, are `0`, `45`, and `90` in the first row, and `135`, `180`, and `270` in the second row.
```php
use aspose\slides\FillType;
use aspose\slides\GradientShape;
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\SlideSizeScaleType;
$presentation = new Presentation();
try {
$presentation->getSlideSize()->setSize(720, 400, SlideSizeScaleType::DoNotScale);
$slide = $presentation->getSlides()->get_Item(0);
$angles = [0, 45, 90, 135, 180, 270];
for ($i = 0; $i < count($angles); $i++) {
$x = 30 + ($i % 3) * 230;
$y = 30 + intdiv($i, 3) * 190;
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, $x, $y, 200, 150);
$shape->getLineFormat()->getFillFormat()->setFillType(FillType::NoFill);
$shape->getFillFormat()->setFillType(FillType::Gradient);
$gradient = $shape->getFillFormat()->getGradientFormat();
$gradient->setGradientShape(GradientShape::Linear);
$gradient->getGradientStops()->clear();
$gradient->getGradientStops()->add(0, java("java.awt.Color")->RED);
$gradient->getGradientStops()->add(0.5, java("java.awt.Color")->GREEN);
$gradient->getGradientStops()->add(1, java("java.awt.Color")->BLUE);
$gradient->setLinearGradientScaled(NullableBool::False);
$gradient->setLinearGradientAngle($angles[$i]);
}
$presentation->save("linear_gradient_angles.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result in PowerPoint:

### **Scale a Linear Gradient with the Shape**
[GradientFormat::setLinearGradientScaled](https://reference.aspose.com/slides/php-java/aspose.slides/gradientformat/#setLinearGradientScaled) accepts a [NullableBool](https://reference.aspose.com/slides/php-java/aspose.slides/nullablebool/) value. Set it explicitly to `False` to keep the geometric gradient angle as the shape's proportions change, or to `True` to scale the gradient with the shape's width and height. With scaling enabled, the visible angle can differ from the assigned angle on a non-square shape.
The following example uses a `45`-degree angle and the same color stops as the angle comparison. The left column uses `False`; the right column uses `True`. Each column contains a wide rectangle above a tall rectangle. Both start with the same wide dimensions; changing the second rectangle's width and height demonstrates how the fill responds to resizing without changing its gradient settings.
```php
use aspose\slides\FillType;
use aspose\slides\GradientShape;
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\SlideSizeScaleType;
$presentation = new Presentation();
try {
$presentation->getSlideSize()->setSize(720, 460, SlideSizeScaleType::DoNotScale);
$slide = $presentation->getSlides()->get_Item(0);
$scalingOptions = [NullableBool::False, NullableBool::True];
for ($column = 0; $column < count($scalingOptions); $column++) {
for ($row = 0; $row < 2; $row++) {
$x = 30 + $column * 360;
$y = $row == 0 ? 30 : 150;
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, $x, $y, 300, 90);
$shape->getLineFormat()->getFillFormat()->setFillType(FillType::NoFill);
$shape->getFillFormat()->setFillType(FillType::Gradient);
$gradient = $shape->getFillFormat()->getGradientFormat();
$gradient->setGradientShape(GradientShape::Linear);
$gradient->getGradientStops()->clear();
$gradient->getGradientStops()->add(0, java("java.awt.Color")->RED);
$gradient->getGradientStops()->add(0.5, java("java.awt.Color")->GREEN);
$gradient->getGradientStops()->add(1, java("java.awt.Color")->BLUE);
$gradient->setLinearGradientAngle(45);
$gradient->setLinearGradientScaled($scalingOptions[$column]);
if ($row == 1) {
$shape->setWidth(90);
$shape->setHeight(280);
}
}
}
$presentation->save("linear_gradient_scaling.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result in PowerPoint, with scaling disabled on the left and enabled on the right:

With scaling disabled, the diagonal color bands keep the same orientation in both rectangles. With scaling enabled, the bands stretch with the shape's proportions. This helps reproduce a template's gradient when adapting a shape to a different size. On a square, enabling scaling does not change the appearance of this `45`-degree gradient.
Both the angle and scaling settings apply to linear gradients. They do not control [GradientShape::Radial or GradientShape::Rectangle](https://reference.aspose.com/slides/php-java/aspose.slides/gradientshape/) fills.
### **Combine the Angle with Gradient Direction**
[GradientFormat::setGradientDirection](https://reference.aspose.com/slides/php-java/aspose.slides/gradientformat/#setGradientDirection) selects a gradient style from the [GradientDirection](https://reference.aspose.com/slides/php-java/aspose.slides/gradientdirection/) class; it is not a substitute for a numeric angle. For a linear gradient, the corner styles can change the area over which the colors are distributed without changing the angle assigned through [setLinearGradientAngle](https://reference.aspose.com/slides/php-java/aspose.slides/gradientformat/#setLinearGradientAngle). Keep the direction unchanged when comparing angles or scaling.
The following example applies the same settings in opposite orders. The two rectangles have the same appearance: assigning the direction before or after the angle does not change the result.
```php
use aspose\slides\FillType;
use aspose\slides\GradientDirection;
use aspose\slides\GradientShape;
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
for ($i = 0; $i < 2; $i++) {
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 30, 30 + $i * 140, 320, 100);
$shape->getLineFormat()->getFillFormat()->setFillType(FillType::NoFill);
$shape->getFillFormat()->setFillType(FillType::Gradient);
$gradient = $shape->getFillFormat()->getGradientFormat();
$gradient->setGradientShape(GradientShape::Linear);
$gradient->getGradientStops()->clear();
$gradient->getGradientStops()->add(0, java("java.awt.Color")->RED);
$gradient->getGradientStops()->add(0.5, java("java.awt.Color")->GREEN);
$gradient->getGradientStops()->add(1, java("java.awt.Color")->BLUE);
$gradient->setLinearGradientScaled(NullableBool::True);
if ($i == 0) {
$gradient->setGradientDirection(GradientDirection::FromCorner1);
$gradient->setLinearGradientAngle(30);
} else {
$gradient->setLinearGradientAngle(30);
$gradient->setGradientDirection(GradientDirection::FromCorner1);
}
}
$presentation->save("linear_gradient_direction.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Pattern Fill**
A pattern fill applies a two-color design, such as dots, stripes, or checks. This example uses [PatternFormat::setPatternStyle](https://reference.aspose.com/slides/php-java/aspose.slides/patternformat/#setPatternStyle) to select a trellis pattern. [PatternFormat::getBackColor](https://reference.aspose.com/slides/php-java/aspose.slides/patternformat/#getBackColor) supplies the light gray background, and [PatternFormat::getForeColor](https://reference.aspose.com/slides/php-java/aspose.slides/patternformat/#getForeColor) supplies the yellow pattern color.
```php
use aspose\slides\FillType;
use aspose\slides\PatternStyle;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 150, 75);
$shape->getFillFormat()->setFillType(FillType::Pattern);
$shape->getFillFormat()->getPatternFormat()->setPatternStyle(PatternStyle::Trellis);
$shape->getFillFormat()->getPatternFormat()->getBackColor()->setColor(java("java.awt.Color")->LIGHT_GRAY);
$shape->getFillFormat()->getPatternFormat()->getForeColor()->setColor(java("java.awt.Color")->YELLOW);
$presentation->save("pattern_fill.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

## **Picture Fill**
A picture fill uses an image inside a shape. This example requires a local image and uses [Images::fromFile](https://reference.aspose.com/slides/php-java/aspose.slides/images/#fromFile) to load it into the presentation’s image collection. Setting [PictureFillFormat::setPictureFillMode](https://reference.aspose.com/slides/php-java/aspose.slides/picturefillformat/#setPictureFillMode) to the tiled mode repeats the image within the rectangle. The source image used here is shown below:

```php
use aspose\slides\FillType;
use aspose\slides\Images;
use aspose\slides\PictureFillMode;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 255, 130);
$shape->getFillFormat()->setFillType(FillType::Picture);
$shape->getFillFormat()->getPictureFillFormat()->setPictureFillMode(PictureFillMode::Tile);
$image = Images::fromFile("lotus.png");
try {
$picture = $presentation->getImages()->addImage($image);
} finally {
$image->dispose();
}
$shape->getFillFormat()->getPictureFillFormat()->getPicture()->setImage($picture);
$presentation->save("picture_fill.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

### **Tile Picture As Texture**
If you want to set a tiled picture as a texture and customize the tiling behavior, you can use the following methods of the [PictureFillFormat](https://reference.aspose.com/slides/php-java/aspose.slides/picturefillformat/) class:
- [setPictureFillMode](https://reference.aspose.com/slides/php-java/aspose.slides/picturefillformat/#setPictureFillMode): Sets the picture fill mode—either `Tile` or `Stretch`.
- [setTileAlignment](https://reference.aspose.com/slides/php-java/aspose.slides/picturefillformat/#setTileAlignment): Specifies the alignment of the tiles within the shape.
- [setTileFlip](https://reference.aspose.com/slides/php-java/aspose.slides/picturefillformat/#setTileFlip): Controls whether the tile is flipped horizontally, vertically, or both.
- [setTileOffsetX](https://reference.aspose.com/slides/php-java/aspose.slides/picturefillformat/#setTileOffsetX): Sets the horizontal offset of the tile (in points) from the shape’s origin.
- [setTileOffsetY](https://reference.aspose.com/slides/php-java/aspose.slides/picturefillformat/#setTileOffsetY): Sets the vertical offset of the tile (in points) from the shape’s origin.
- [setTileScaleX](https://reference.aspose.com/slides/php-java/aspose.slides/picturefillformat/#setTileScaleX): Defines the horizontal scale of the tile as a percentage.
- [setTileScaleY](https://reference.aspose.com/slides/php-java/aspose.slides/picturefillformat/#setTileScaleY): Defines the vertical scale of the tile as a percentage.
This example requires a local image and configures [PictureFillFormat](https://reference.aspose.com/slides/php-java/aspose.slides/picturefillformat/) to repeat it at 50% of its original size. Offsets of −32 points shift the tiles horizontally and vertically; bottom-right alignment and flipping in both directions determine how the repeated texture is arranged.
```php
use aspose\slides\FillType;
use aspose\slides\Images;
use aspose\slides\PictureFillMode;
use aspose\slides\Presentation;
use aspose\slides\RectangleAlignment;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\TileFlip;
$presentation = new Presentation();
try {
$firstSlide = $presentation->getSlides()->get_Item(0);
$shape = $firstSlide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 190, 95);
$shape->getFillFormat()->setFillType(FillType::Picture);
$sourceImage = Images::fromFile("lotus.png");
try {
$presentationImage = $presentation->getImages()->addImage($sourceImage);
} finally {
$sourceImage->dispose();
}
$pictureFillFormat = $shape->getFillFormat()->getPictureFillFormat();
$pictureFillFormat->getPicture()->setImage($presentationImage);
$pictureFillFormat->setPictureFillMode(PictureFillMode::Tile);
$pictureFillFormat->setTileOffsetX(-32);
$pictureFillFormat->setTileOffsetY(-32);
$pictureFillFormat->setTileScaleX(50);
$pictureFillFormat->setTileScaleY(50);
$pictureFillFormat->setTileAlignment(RectangleAlignment::BottomRight);
$pictureFillFormat->setTileFlip(TileFlip::FlipBoth);
$presentation->save("tile.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

## **Solid Color Fill**
A solid fill gives a shape a single, uniform color. This example sets [FillFormat::setFillType](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/#setFillType) to the solid fill mode and assigns yellow through [FillFormat::getSolidFillColor](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/#getSolidFillColor), then saves the rectangle in a presentation.
```php
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 150, 75);
$shape->getFillFormat()->setFillType(FillType::Solid);
$shape->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->YELLOW);
$presentation->save("solid_color_fill.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

### **Copy Colors While Preserving Theme References**
Use [ColorFormat::copyFrom](https://reference.aspose.com/slides/php-java/aspose.slides/colorformat/#copyFrom) to copy a color definition, including its color type, theme reference, and transformations. This is useful when transferring a fill color between shapes that should continue to follow the presentation theme. The method copies only the color: it does not copy the fill type, outline, or other shape formatting. Set the destination's fill type explicitly with [FillFormat::setFillType](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/#setFillType).
This example creates three rectangles, from left to right: the source, a theme-aware copy, and a fixed RGB copy. The source uses [ColorFormat::setSchemeColor](https://reference.aspose.com/slides/php-java/aspose.slides/colorformat/#setSchemeColor) to reference the first accent color and adds a tint through [ColorOperationCollection::add](https://reference.aspose.com/slides/php-java/aspose.slides/coloroperationcollection/#add). The RGB copy uses the source's effective fill color so all three initially look identical. Calling [ColorFormat::setColor](https://reference.aspose.com/slides/php-java/aspose.slides/colorformat/#setColor) sets a fixed RGB value and clears any existing color transformations.
```php
use aspose\slides\ColorTransformOperation;
use aspose\slides\FillType;
use aspose\slides\ImageFormat;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SchemeColor;
use aspose\slides\ShapeType;
use aspose\slides\SlideSizeScaleType;
$presentation = new Presentation();
try {
$presentation->getSlideSize()->setSize(660, 220, SlideSizeScaleType::DoNotScale);
$slide = $presentation->getSlides()->get_Item(0);
$initialAccent = new Java("java.awt.Color", 65, 105, 225);
$presentation->getMasterTheme()->getColorScheme()->getAccent1()->setColor($initialAccent);
$source = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 30, 40, 180, 140);
$themeCopy = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 240, 40, 180, 140);
$rgbCopy = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 450, 40, 180, 140);
foreach ([$source, $themeCopy, $rgbCopy] as $shape) {
$shape->getFillFormat()->setFillType(FillType::Solid);
$shape->getLineFormat()->getFillFormat()->setFillType(FillType::NoFill);
}
$sourceColor = $source->getFillFormat()->getSolidFillColor();
$sourceColor->setSchemeColor(SchemeColor::Accent1);
$sourceColor->getColorTransform()->add(ColorTransformOperation::Tint, 0.75);
$themeCopy->getFillFormat()->getSolidFillColor()->copyFrom($sourceColor);
$rgbCopy->getFillFormat()->getSolidFillColor()->setColor($source->getFillFormat()->getEffective()->getSolidFillColor());
$before = $slide->getImage(1.0, 1.0);
try {
$before->save("color-copy-before.png", ImageFormat::Png);
} finally {
$before->dispose();
}
// Theme references follow the new accent color; the fixed RGB value does not.
$updatedAccent = new Java("java.awt.Color", 255, 69, 0);
$presentation->getMasterTheme()->getColorScheme()->getAccent1()->setColor($updatedAccent);
$after = $slide->getImage(1.0, 1.0);
try {
$after->save("color-copy-after.png", ImageFormat::Png);
} finally {
$after->dispose();
}
$presentation->save("copied_colors.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Before the theme change, all three fills match:

After the theme change, the source and the theme-aware copy follow the new accent color and retain their tint. The fixed RGB copy remains blue:

The copied definition is independent of the source. Subsequently changing the source's theme reference, assigning another color, or adding or removing its transformations does not change the destination. A theme change still affects both shapes because each independently refers to the same theme color.
Saving and reopening the PPTX preserves the copied color's type returned by [ColorFormat::getColorType](https://reference.aspose.com/slides/php-java/aspose.slides/colorformat/#getColorType), theme reference, and transformation collection returned by [ColorFormat::getColorTransform](https://reference.aspose.com/slides/php-java/aspose.slides/colorformat/#getColorTransform); it does not flatten the definition to RGB.
When copying between different theme contexts, such as presentations with different accent palettes, the copied reference resolves against the destination's theme. The same reference and transformations can therefore produce a different visible color. See [Presentation Theme](https://docs.aspose.com/slides/php-java/presentation-theme/) for more about configuring theme colors.
## **Use the Slide Background as a Shape Fill**
Use [AutoShape::setUseBackgroundFill](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/#setUseBackgroundFill) when a shape should match the slide background, for example in a presentation template. Set the fill type with [FillFormat::setFillType](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/#setFillType) to [FillType::NotDefined](https://reference.aspose.com/slides/php-java/aspose.slides/filltype/) first to remove any explicit fill. With this combination, the shape uses the slide background instead of its style fill. Enabling the flag alone does not remove an existing explicit fill.
This differs from [FillType::NoFill](https://reference.aspose.com/slides/php-java/aspose.slides/filltype/): background fill covers objects behind the shape with the corresponding area of the slide background, while no fill leaves those objects visible. A gradient remains aligned with the slide rather than restarting inside each shape.
The following example creates a master background inherited by the slide and places a magenta band behind three rectangles. The left rectangle uses the background, the middle rectangle has no fill, and the right rectangle switches from background fill to an explicit orange fill.
```php
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\GradientShape;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\SlideSizeScaleType;
$presentation = new Presentation();
try {
$presentation->getSlideSize()->setSize(720, 400, SlideSizeScaleType::DoNotScale);
$slide = $presentation->getSlides()->get_Item(0);
// Inherit the gradient from the master.
$slide->getBackground()->setType(BackgroundType::NotDefined);
$slide->getLayoutSlide()->getBackground()->setType(BackgroundType::NotDefined);
$background = $slide->getLayoutSlide()->getMasterSlide()->getBackground();
$background->setType(BackgroundType::OwnBackground);
$background->getFillFormat()->setFillType(FillType::Gradient);
$gradient = $background->getFillFormat()->getGradientFormat();
$gradient->setGradientShape(GradientShape::Linear);
$gradient->setLinearGradientAngle(0);
$gradient->getGradientStops()->clear();
$startColor = new Java("java.awt.Color", 0, 0, 139);
$gradient->getGradientStops()->add(0, $startColor);
$endColor = new Java("java.awt.Color", 135, 206, 250);
$gradient->getGradientStops()->add(1, $endColor);
// Add this object first so it appears behind the rectangles.
$band = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 25, 150, 670, 100);
$band->getFillFormat()->setFillType(FillType::Solid);
$band->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->MAGENTA);
$band->getLineFormat()->getFillFormat()->setFillType(FillType::NoFill);
$backgroundShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 100, 160, 200);
$backgroundShape->getFillFormat()->setFillType(FillType::NotDefined);
$backgroundShape->setUseBackgroundFill(true);
$noFillShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 280, 100, 160, 200);
$noFillShape->getFillFormat()->setFillType(FillType::NoFill);
$explicitShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 510, 100, 160, 200);
$explicitShape->getFillFormat()->setFillType(FillType::NotDefined);
$explicitShape->setUseBackgroundFill(true);
// Disable background fill before applying an explicit fill.
$explicitShape->setUseBackgroundFill(false);
$explicitShape->getFillFormat()->setFillType(FillType::Solid);
$fillColor = new Java("java.awt.Color", 255, 165, 0);
$explicitShape->getFillFormat()->getSolidFillColor()->setColor($fillColor);
$presentation->save("background_fill.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result, from left to right: **background fill**, **no fill**, and **explicit fill**. The magenta band is hidden by the left and right rectangles but remains visible through the middle rectangle.

The same behavior applies to a background defined directly on the slide or inherited from a layout. The shape uses the slide's resolved background; the example leaves both the slide and layout backgrounds undefined so the master supplies it.
## **Set Transparency**
For a solid fill, the color’s alpha component controls opacity: 0 is fully transparent and 255 is fully opaque. This example uses an alpha value of 128 for a yellow rectangle, making it approximately 50% transparent so the rectangle underneath remains visible. The color is assigned through [FillFormat::getSolidFillColor](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/#getSolidFillColor).
```php
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$solidShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 150, 75);
$transparentShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 80, 80, 150, 75);
$transparentShape->getFillFormat()->setFillType(FillType::Solid);
$fillColor = new Java("java.awt.Color", 255, 255, 0, 128);
$transparentShape->getFillFormat()->getSolidFillColor()->setColor($fillColor);
$presentation->save("shape_transparency.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

## **Rotate Shapes**
Use [Shape::setRotation](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#setRotation) to rotate a shape in the slide plane. The angle is measured in degrees; this example rotates a rectangle 5 degrees clockwise and saves the presentation.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 150, 75);
$shape->setRotation(5);
$presentation->save("shape_rotation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

## **Add 3D Bevel Effects**
Use [Shape::getThreeDFormat](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#getThreeDFormat) to give a shape depth and beveled edges. This example creates a green ellipse with an orange outline, sets [ThreeDFormat::setDepth](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/#setDepth) to 4 points, and applies a circular top bevel with a width and height of 6 points through [ThreeDFormat::getBevelTop](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/#getBevelTop). A front-facing orthographic camera and three-point lighting make the bevel visible.
```php
use aspose\slides\BevelPresetType;
use aspose\slides\CameraPresetType;
use aspose\slides\FillType;
use aspose\slides\LightRigPresetType;
use aspose\slides\LightingDirection;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Ellipse, 50, 50, 100, 100);
$shape->getFillFormat()->setFillType(FillType::Solid);
$fillColor = new Java("java.awt.Color", 0, 128, 0);
$shape->getFillFormat()->getSolidFillColor()->setColor($fillColor);
$shape->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$lineColor = new Java("java.awt.Color", 255, 165, 0);
$shape->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor($lineColor);
$shape->getLineFormat()->setWidth(2.0);
$shape->getThreeDFormat()->setDepth(4);
$shape->getThreeDFormat()->getBevelTop()->setBevelType(BevelPresetType::Circle);
$shape->getThreeDFormat()->getBevelTop()->setHeight(6);
$shape->getThreeDFormat()->getBevelTop()->setWidth(6);
$shape->getThreeDFormat()->getCamera()->setCameraType(CameraPresetType::OrthographicFront);
$shape->getThreeDFormat()->getLightRig()->setLightType(LightRigPresetType::ThreePt);
$shape->getThreeDFormat()->getLightRig()->setDirection(LightingDirection::Top);
$presentation->save("3D_bevel_effect.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

## **Add 3D Rotation Effects**
A shape’s 3D view is controlled by its camera settings. This example uses [Camera::setRotation](https://reference.aspose.com/slides/php-java/aspose.slides/camera/#setRotation) with latitude, longitude, and revolution angles of 40, 35, and 20 degrees, respectively. It selects an isometric camera through [Camera::setCameraType](https://reference.aspose.com/slides/php-java/aspose.slides/camera/#setCameraType) and balanced lighting through [LightRig::setLightType](https://reference.aspose.com/slides/php-java/aspose.slides/lightrig/#setLightType), then saves the formatted rectangle.
```php
use aspose\slides\CameraPresetType;
use aspose\slides\LightRigPresetType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 150, 75);
$autoShape->getTextFrame()->setText("Hello, Aspose!");
$autoShape->getThreeDFormat()->getCamera()->setCameraType(CameraPresetType::IsometricLeftUp);
$autoShape->getThreeDFormat()->getCamera()->setRotation(40, 35, 20);
$autoShape->getThreeDFormat()->getLightRig()->setLightType(LightRigPresetType::Balanced);
$presentation->save("3D_rotation_effect.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

## **Control Black-and-White Rendering for Shapes**
The [Shape::setBlackWhiteMode](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#setBlackWhiteMode) method specifies how an individual shape is rendered when a presentation is viewed or processed in black-and-white mode. It does not enable black-and-white display by itself, and it does not change the shape's fill, line, or other formatting in normal color mode.
Use a value from the [BlackWhiteMode](https://reference.aspose.com/slides/php-java/aspose.slides/blackwhitemode/) class to select the desired behavior. For example, `Automatic` lets the rendering application choose the conversion, `Gray` and `LightGray` use gray coloring, `BlackWhite` uses only black and white, `Black` and `White` force a single color, `Color` preserves normal coloring, and `Hidden` omits the shape in black-and-white mode. `NotDefined` means that no shape-level mode is assigned.
This example creates an orange rectangle and sets [Shape::setBlackWhiteMode](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#setBlackWhiteMode) to gray. The saved shape retains its orange fill for normal color display and requests gray coloring from applications that honor black-and-white display settings:
```php
use aspose\slides\BlackWhiteMode;
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 200, 100);
$shape->getFillFormat()->setFillType(FillType::Solid);
$fillColor = new Java("java.awt.Color", 255, 165, 0);
$shape->getFillFormat()->getSolidFillColor()->setColor($fillColor);
$shape->setBlackWhiteMode(BlackWhiteMode::Gray);
$presentation->save("shape_black_white_mode.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
In normal color mode, the rectangle retains its orange fill. In a black-and-white display workflow, it uses gray coloring because its mode is set to `Gray`. This lets you preserve a full-color slide while defining a distinct appearance for printing, previewing, or other workflows that honor the presentation's black-and-white display settings.
## **Reset Formatting**
Use [Slide::reset](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#reset) to restore the position, size, and formatting of slide placeholders from their corresponding layout placeholders. This example requires an existing presentation with layout-linked placeholders and resets every slide before saving. Shapes without corresponding layout placeholders are not reset.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("sample.pptx");
try {
for ($i = 0; $i < java_values($presentation->getSlides()->size()); $i++) {
$slide = $presentation->getSlides()->get_Item($i);
$slide->reset();
}
$presentation->save("reset_formatting.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **FAQ**
**Does shape formatting affect the final presentation file size?**
Colors, line styles, and effect settings generally add little data compared with embedded images and media. Picture fills can increase the file size because their images are stored in the presentation.
**How can I detect shapes on a slide that share identical formatting so I can group them?**
Compare each shape’s key formatting properties—fill, line, and effect settings. If all corresponding values match, treat their styles as identical and logically group those shapes, which simplifies later style management.
**Can I save a set of custom shape styles to a separate file for reuse in other presentations?**
Yes. Store sample shapes with the desired styles in a template slide deck or a .POTX template file. When creating a new presentation, open the template, clone the styled shapes you need, and reapply their formatting wherever required.
## Related articles
- [Manage Presentation Backgrounds in PHP](https://docs.aspose.com/slides/php-java/presentation-background/)
# Manage Presentation Shapes in PHP
> Learn how to identify, adjust, clone, remove, hide, reorder, export, align, and flip presentation shapes with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/shape-manipulations/
Updated: 2026-09-25
## **Overview**
Aspose.Slides for PHP via Java represents the shapes on a slide as an ordered [ShapeCollection](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/). The collection is both the place where you find and modify shapes and the source of their stacking order: index `0` is the backmost shape, while the last index is the frontmost shape.
This article follows that model. It first explains how to identify a shape reliably and modify preset shape adjustment points, then shows how to clone, remove, hide, and reorder shapes. The final sections cover layout-level formatting, SVG export, alignment, and flip settings. Each example is independent, so you can use only the operations your workflow requires.
## **Identify and Find Shapes**
Collection indexes are convenient while processing a known file, but they are not stable identifiers. Adding, removing, or reordering a shape can change its index. Choose an identifier according to how the presentation is authored and maintained:
- [Name](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getname/) is useful for developer-controlled templates and is easy to inspect in PowerPoint's Selection Pane. Names can be edited and are not guaranteed to be unique, so establish a naming convention if code depends on them.
- [AlternativeText](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getalternativetext/) is useful when an accessibility description or an author-supplied tag already identifies the shape. It is visible to users, may be localized or rewritten for accessibility, and is not guaranteed to be unique. Do not silently repurpose meaningful accessibility text as a database key.
- [OfficeInteropShapeId](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getofficeinteropshapeid/) is a read-only identifier that is unique within a slide and corresponds to the shape ID used by PowerPoint interop. Use it when integrating with PowerPoint or when you need an unambiguous reference during the lifetime of a shape. A cloned or recreated shape is a different shape and receives its own ID.
The related [Shape::getUniqueId](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getuniqueid/) method returns an identifier with presentation scope, but that identifier is intended for add-ins and can be reassigned. It should not be treated as a permanent external key. If long-term identity is essential, keep the mapping in application data and validate that the expected shape still exists.
For a practical example of reading and updating both the alternative text title and description, see [Manage Alternative Text Titles and Descriptions](https://docs.aspose.com/slides/php-java/presentation-accessibility/). Use alternative text to explain the visual's meaning to readers, and keep it separate from shape names used by code to find shapes.
The following example searches by name with an exact comparison and reports the slide-scoped interop ID. When the template does not contain the expected shape, the code reports that result instead of continuing with the wrong object.
```php
use aspose\slides\Presentation;
$presentation = new Presentation("input.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$targetShape = null;
$shapes = $slide->getShapes();
$shapeCount = java_values($shapes->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $shapes->get_Item($shapeIndex);
$shapeName = java_values($shape->getName());
if ($shapeName === "RevenueChart") {
$targetShape = $shape;
break;
}
}
if ($targetShape === null) {
echo "The shape 'RevenueChart' was not found on slide 1." . PHP_EOL;
} else {
$shapeName = java_values($targetShape->getName());
$interopId = java_values($targetShape->getOfficeInteropShapeId());
echo "Found " . $shapeName . "; interop ID: " . $interopId . PHP_EOL;
}
} finally {
$presentation->dispose();
}
```
When an operation is specific to a shape type, check the runtime class before using type-specific members. This example updates text and alternative text only if the named object is an [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/).
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("input.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$candidate = null;
$shapes = $slide->getShapes();
$shapeCount = java_values($shapes->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $shapes->get_Item($shapeIndex);
$shapeName = java_values($shape->getName());
if ($shapeName === "StatusLabel") {
$candidate = $shape;
break;
}
}
$autoShapeClass = new JavaClass("com.aspose.slides.AutoShape");
if ($candidate !== null && java_instanceof($candidate, $autoShapeClass)) {
$candidate->getTextFrame()->setText("Approved");
$candidate->setAlternativeText("Approval status: approved");
$presentation->save("identified-shape.pptx", SaveFormat::Pptx);
} else {
echo "'StatusLabel' is missing or is not an AutoShape." . PHP_EOL;
}
} finally {
$presentation->dispose();
}
```
## **Identify and Modify Preset Shape Adjustments**
Preset geometry shapes can expose adjustment points that control features such as corner size, arrow proportions, or arc angles. Access them through the read-only [GeometryShape::getAdjustments](https://reference.aspose.com/slides/php-java/aspose.slides/geometryshape/#getAdjustments) collection. The collection itself is supplied by the shape, but each [AdjustValue](https://reference.aspose.com/slides/php-java/aspose.slides/adjustvalue/) contains a value that can be changed.
Do not rely only on a fixed collection index. Iterate through the adjustments and inspect the read-only [AdjustValue::getType](https://reference.aspose.com/slides/php-java/aspose.slides/adjustvalue/#getType) method, whose [ShapeAdjustmentType](https://reference.aspose.com/slides/php-java/aspose.slides/shapeadjustmenttype/) value describes what the adjustment controls. The read-only [AdjustValue::getName](https://reference.aspose.com/slides/php-java/aspose.slides/adjustvalue/getname/) method provides additional identification information and is especially useful when a preset contains more than one adjustment with the same semantic type.
Use the value method that matches the adjustment's meaning:
| Adjustment type | Purpose | Value to change |
|---|---|---|
| `CornerSize` | Size of rounded corners | [setRawValue](https://reference.aspose.com/slides/php-java/aspose.slides/adjustvalue/setrawvalue/) |
| `ArrowTailThickness` | Thickness of an arrow tail | `setRawValue` |
| `ArrowheadLength` | Length of an arrowhead | `setRawValue` |
| `ArrowheadWidth` | Width of an arrowhead | `setRawValue` |
| `StartAngle` | Start angle of a pie or arc | [setAngleValue](https://reference.aspose.com/slides/php-java/aspose.slides/adjustvalue/setanglevalue/) |
| `EndAngle` | End angle of a pie or arc | `setAngleValue` |
`getType` and `getName` return read-only information. `getRawValue` and `setRawValue` work with an integer in the preset's native geometry units, while `getAngleValue` and `setAngleValue` work with an angle in degrees. The number, order, meaning, and valid range of adjustments depend on the preset [GeometryShape::getShapeType](https://reference.aspose.com/slides/php-java/aspose.slides/geometryshape/#getShapeType). A value that is valid for one preset may be invalid or have a different effect for another.
When `getType` returns `ShapeAdjustmentType::Custom`, the API does not recognize a standard semantic meaning. Inspect `getName`, the preset type, and the existing value, and leave the adjustment unchanged unless the expected meaning and range are known. Even for recognized types, check whether the same type occurs more than once before selecting a value. The [Connector](https://docs.aspose.com/slides/php-java/connector/) article shows this situation with connector bend adjustments.
The following complete example creates default and modified versions of three preset shapes. It iterates through every adjustment, reports its name and type, changes size-related values through `setRawValue`, changes angles through `setAngleValue`, and saves the result. The left column retains the default geometry; the right column shows the adjusted rounded rectangle, four-way arrow, and pie.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeAdjustmentType;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
// Add headers for the default and adjusted shape columns.
$defaultColumnLabel = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 40, 20, 250, 30);
$defaultColumnLabel->getTextFrame()->setText("Default preset geometry");
$adjustedColumnLabel = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 390, 20, 250, 30);
$adjustedColumnLabel->getTextFrame()->setText("Modified adjustment values");
$slide->getShapes()->addAutoShape(ShapeType::RoundCornerRectangle, 80, 70, 160, 70);
$modifiedRoundedRectangle = $slide->getShapes()->addAutoShape(ShapeType::RoundCornerRectangle, 430, 70, 160, 70);
$modifiedRoundedRectangle->setName("ModifiedRoundedRectangle");
$slide->getShapes()->addAutoShape(ShapeType::QuadArrow, 80, 180, 160, 110);
$modifiedArrow = $slide->getShapes()->addAutoShape(ShapeType::QuadArrow, 430, 180, 160, 110);
$modifiedArrow->setName("ModifiedQuadArrow");
$slide->getShapes()->addAutoShape(ShapeType::Pie, 95, 330, 130, 130);
$modifiedPie = $slide->getShapes()->addAutoShape(ShapeType::Pie, 445, 330, 130, 130);
$modifiedPie->setName("ModifiedPie");
$shapesToAdjust = [
$modifiedRoundedRectangle,
$modifiedArrow,
$modifiedPie
];
foreach ($shapesToAdjust as $shape) {
$adjustmentCount = java_values($shape->getAdjustments()->size());
for ($adjustmentIndex = 0; $adjustmentIndex < $adjustmentCount; $adjustmentIndex++) {
$adjustment = $shape->getAdjustments()->get_Item($adjustmentIndex);
$shapeName = java_values($shape->getName());
$adjustmentName = java_values($adjustment->getName());
$adjustmentType = java_values($adjustment->getType());
echo $shapeName . " / " . $adjustmentName . ": " . $adjustmentType . PHP_EOL;
switch ($adjustmentType) {
case ShapeAdjustmentType::CornerSize:
$adjustment->setRawValue(5000);
break;
case ShapeAdjustmentType::ArrowTailThickness:
$adjustment->setRawValue(25000);
break;
case ShapeAdjustmentType::ArrowheadLength:
$adjustment->setRawValue(30000);
break;
case ShapeAdjustmentType::ArrowheadWidth:
$adjustment->setRawValue(40000);
break;
case ShapeAdjustmentType::StartAngle:
$adjustment->setAngleValue(30);
break;
case ShapeAdjustmentType::EndAngle:
$adjustment->setAngleValue(300);
break;
case ShapeAdjustmentType::Custom:
echo "Custom adjustment '" . $adjustmentName . "' was not changed." . PHP_EOL;
break;
}
}
}
$presentation->save("preset-shape-adjustments.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Checking the semantic type before changing a value makes the code explicit about its intent and avoids assuming that a particular collection index has the same meaning across different preset shapes.
## **Modify the Shape Collection**
The add, clone, remove, and reorder methods operate on the collection immediately. If an operation changes the number or order of shapes, do not continue to rely on indexes captured before that operation.
### **Clone a Shape**
[ShapeCollection::addClone](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/addclone/) creates an independent copy and appends it to the target collection. [ShapeCollection::insertClone](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/insertclone/) also creates a copy but places it at a specified z-order index. The overloads that accept coordinates move the clone without changing its size; overloads with width and height can resize it as well.
The example creates a destination slide, clones a labeled rectangle to the front, and inserts a second clone at the back. Changes to either clone do not modify the source shape.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\SlideLayoutType;
$presentation = new Presentation();
try {
$sourceSlide = $presentation->getSlides()->get_Item(0);
$sourceShape = $sourceSlide->getShapes()->addAutoShape(ShapeType::Rectangle, 40, 40, 180, 60);
$sourceShape->setName("SourceLabel");
$sourceShape->getTextFrame()->setText("Source");
$blankLayout = $presentation->getMasters()->get_Item(0)->getLayoutSlides()->getByType(SlideLayoutType::Blank);
$destinationSlide = $presentation->getSlides()->addEmptySlide($blankLayout);
$frontCloneShape = $destinationSlide->getShapes()->addClone($sourceShape, 80, 80);
$frontCloneShape->setName("FrontClone");
$autoShapeClass = new JavaClass("com.aspose.slides.AutoShape");
if (java_instanceof($frontCloneShape, $autoShapeClass)) {
$frontCloneShape->getTextFrame()->setText("Front clone");
} else {
echo "The front clone is not an AutoShape; its text was not changed." . PHP_EOL;
}
$backCloneShape = $destinationSlide->getShapes()->insertClone(0, $sourceShape, 80, 180);
$backCloneShape->setName("BackClone");
if (java_instanceof($backCloneShape, $autoShapeClass)) {
$backCloneShape->getTextFrame()->setText("Back clone");
} else {
echo "The back clone is not an AutoShape; its text was not changed." . PHP_EOL;
}
$presentation->save("cloned-shapes.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Cloning copies the shape's content and formatting, including its name and alternative text. Assign new logical identifiers to the clone when those values must be unique. Resources used by complex shapes are handled by the presentation, but a clone remains a new collection item with a new shape identity.
### **Remove Shapes**
[ShapeCollection::remove](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/remove/) deletes a specific shape object from its collection. When removing multiple matches during indexed iteration, traverse from the end so that each remaining index stays valid.
This example removes every shape with a designated name. It reads the shape at the current index, not a fixed collection item, and it does not cast the shape unnecessarily.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$keepShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 40, 40, 140, 60);
$keepShape->setName("Keep");
$firstTemporaryShape = $slide->getShapes()->addAutoShape(ShapeType::Ellipse, 220, 40, 80, 80);
$firstTemporaryShape->setName("Temporary");
$secondTemporaryShape = $slide->getShapes()->addAutoShape(ShapeType::Triangle, 340, 40, 100, 80);
$secondTemporaryShape->setName("Temporary");
$shapeCount = java_values($slide->getShapes()->size());
for ($shapeIndex = $shapeCount - 1; $shapeIndex >= 0; $shapeIndex--) {
$shape = $slide->getShapes()->get_Item($shapeIndex);
$shapeName = java_values($shape->getName());
if ($shapeName === "Temporary") {
$slide->getShapes()->remove($shape);
}
}
$presentation->save("removed-shapes.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
After removal, the shape count and the indexes of later shapes change. References to unaffected shapes remain more reliable than saved indexes. Also consider connectors, animations, and other presentation features that may refer to the removed object; removing a visible shape can change more than the slide's appearance.
### **Hide a Shape**
Setting [Shape::setHidden](https://reference.aspose.com/slides/php-java/aspose.slides/shape/sethidden/) to `true` keeps the shape in the collection but prevents it from appearing in the normal slide show. Its index, formatting, and content remain available to code, so hiding is appropriate for optional elements that may be restored later.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$visibleShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 40, 40, 160, 60);
$visibleShape->setName("VisibleLabel");
$optionalShape = $slide->getShapes()->addAutoShape(ShapeType::Moon, 240, 40, 100, 100);
$optionalShape->setName("OptionalDecoration");
$shapes = $slide->getShapes();
$shapeCount = java_values($shapes->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $shapes->get_Item($shapeIndex);
$shapeName = java_values($shape->getName());
if ($shapeName === "OptionalDecoration") {
$shape->setHidden(true);
}
}
$presentation->save("hidden-shape.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Hiding is not deletion or security. The object can still be discovered and unhidden by a user or by code, and it remains part of the presentation file.
### **Change the Z-Order**
Overlapping shapes are painted in collection order. [ShapeCollection::reorder](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/reorder/) moves an existing shape to a target index without cloning it. Index `0` is the back; `size() - 1` is the front.
```php
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$blueRectangle = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 220, 120);
$blueRectangle->setName("BlueRectangle");
$blueRectangle->getFillFormat()->setFillType(FillType::Solid);
$blueRectangle->getFillFormat()->getSolidFillColor()->setColor(new Java("java.awt.Color", 0, 0, 255));
$orangeEllipse = $slide->getShapes()->addAutoShape(ShapeType::Ellipse, 180, 140, 220, 120);
$orangeEllipse->setName("OrangeEllipse");
$orangeEllipse->getFillFormat()->setFillType(FillType::Solid);
$orangeEllipse->getFillFormat()->getSolidFillColor()->setColor(new Java("java.awt.Color", 255, 165, 0));
$frontIndex = java_values($slide->getShapes()->size()) - 1;
$slide->getShapes()->reorder($frontIndex, $blueRectangle);
$presentation->save("reordered-shapes.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The rectangle is created first and initially sits behind the ellipse. Moving it to the final index puts it in front. Finalize z-order after adding or cloning all related shapes, because those operations append or insert new collection items and can alter the intended stack.
## **Inspect Shapes on Layout Slides**
Normal slides, layout slides, and master slides have separate shape collections. A shape in a layout collection is not the same object as a similarly positioned shape on a normal slide. Inspect layout shapes when you need to understand or change formatting supplied by a layout.
The following example reads each layout shape's [FillFormat](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getfillformat/) and [LineFormat](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getlineformat/) without assuming that every shape is an `AutoShape`.
```php
use aspose\slides\Presentation;
$presentation = new Presentation("input.pptx");
try {
$layoutSlides = $presentation->getLayoutSlides();
$layoutSlideCount = java_values($layoutSlides->size());
for ($layoutIndex = 0; $layoutIndex < $layoutSlideCount; $layoutIndex++) {
$layoutSlide = $layoutSlides->get_Item($layoutIndex);
$layoutShapes = $layoutSlide->getShapes();
$layoutShapeCount = java_values($layoutShapes->size());
for ($shapeIndex = 0; $shapeIndex < $layoutShapeCount; $shapeIndex++) {
$shape = $layoutShapes->get_Item($shapeIndex);
$fillType = java_values($shape->getFillFormat()->getFillType());
$lineWidth = java_values($shape->getLineFormat()->getWidth());
$layoutName = java_values($layoutSlide->getName());
$shapeName = java_values($shape->getName());
echo $layoutName . " / " . $shapeName . ": fill=" . $fillType . ", line width=" . $lineWidth . PHP_EOL;
}
}
} finally {
$presentation->dispose();
}
```
Editing a layout can affect multiple slides that use it. Before changing a layout shape, determine whether a normal slide inherits the object or contains a local override, and test every slide that uses that layout.
## **Export a Shape to SVG**
[Shape::writeAsSvg](https://reference.aspose.com/slides/php-java/aspose.slides/shape/writeassvg/) writes one shape's rendered content to a stream. The result contains the shape, not the entire slide background or neighboring shapes.
```php
use aspose\slides\Presentation;
$presentation = new Presentation("input.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapeCount = java_values($slide->getShapes()->size());
if ($shapeCount === 0) {
echo "Slide 1 does not contain a shape to export." . PHP_EOL;
} else {
$shape = $slide->getShapes()->get_Item(0);
$svgStream = null;
try {
$svgStream = new Java("java.io.FileOutputStream", "shape.svg");
$shape->writeAsSvg($svgStream);
} catch (JavaException $exception) {
echo "The SVG file could not be written: " . $exception->getMessage() . PHP_EOL;
} finally {
if ($svgStream !== null && !java_is_null($svgStream)) {
$svgStream->close();
}
}
}
} finally {
$presentation->dispose();
}
```
Keep the presentation open while rendering. The output depends on the shape's formatting and on resources such as fonts and images. If you need the whole composition, export the slide rather than an individual shape. The caller owns the stream and must close it.
## **Align Shapes**
The [SlideUtil::alignShapes](https://reference.aspose.com/slides/php-java/aspose.slides/slideutil/alignshapes/) overloads align either all shapes or selected collection indexes. [ShapesAlignmentType](https://reference.aspose.com/slides/php-java/aspose.slides/shapesalignmenttype/) specifies the edge, center line, or distribution mode. Set `alignToSlide` to `true` to use the slide edges; set it to `false` to align the selected shapes relative to one another.
This example aligns three shapes to the top edge of the slide. The returned shape references are converted to their current indexes immediately before alignment.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\ShapesAlignmentType;
use aspose\slides\SlideUtil;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$firstShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 60, 80, 120, 50);
$secondShape = $slide->getShapes()->addAutoShape(ShapeType::Ellipse, 240, 160, 120, 50);
$thirdShape = $slide->getShapes()->addAutoShape(ShapeType::Triangle, 420, 240, 120, 50);
$firstShape->setName("FirstAlignedShape");
$secondShape->setName("SecondAlignedShape");
$thirdShape->setName("ThirdAlignedShape");
$shapeIndexes = [
java_values($slide->getShapes()->indexOf($firstShape)),
java_values($slide->getShapes()->indexOf($secondShape)),
java_values($slide->getShapes()->indexOf($thirdShape))
];
SlideUtil::alignShapes(ShapesAlignmentType::AlignTop, true, $slide, $shapeIndexes);
$presentation->save("aligned-shapes.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Alignment changes positions, not z-order. Relative alignment normally needs at least two shapes, while horizontal or vertical distribution needs enough shapes to define spacing. Recompute indexes if you modify the collection before calling the method.
## **Flip a Shape**
The [ShapeFrame](https://reference.aspose.com/slides/php-java/aspose.slides/shapeframe/) class stores position, size, horizontal and vertical flip settings, and rotation. Its `getFlipH` and `getFlipV` values use [NullableBool](https://reference.aspose.com/slides/php-java/aspose.slides/nullablebool/): `True` enables the flip, `False` disables it, and `NotDefined` preserves the unspecified/default state.
The input presentation below contains one unflipped shape.

The example preserves every other frame value and replaces only the two flip settings. This is important because assigning a new [Frame](https://reference.aspose.com/slides/php-java/aspose.slides/shape/setframe/) replaces the complete frame.
```php
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeFrame;
$presentation = new Presentation("sample.pptx");
try {
$shape = $presentation->getSlides()->get_Item(0)->getShapes()->get_Item(0);
$frame = $shape->getFrame();
$horizontalFlip = java_values($frame->getFlipH());
$verticalFlip = java_values($frame->getFlipV());
echo "Horizontal flip before change: " . $horizontalFlip . PHP_EOL;
echo "Vertical flip before change: " . $verticalFlip . PHP_EOL;
$shape->setFrame(new ShapeFrame($frame->getX(), $frame->getY(), $frame->getWidth(), $frame->getHeight(), NullableBool::True, NullableBool::True, $frame->getRotation()));
$presentation->save("flipped-shape.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The saved shape is mirrored horizontally and vertically while keeping its position, size, and rotation.

## **FAQ**
**Should I use a collection index as a shape identifier?**
Only for short-lived processing when the collection will not change before the index is used. Prefer a validated `Name` or `AlternativeText` convention for authored templates, or `OfficeInteropShapeId` for slide-scoped interop work.
**Does hiding a shape remove it from the z-order?**
No. A hidden shape remains in the collection at the same index. It can be found, reordered, edited, or made visible again.
**Why did a cloned shape appear in front of another shape?**
`addClone` appends the clone to the end of the collection, which is the front of the z-order. Use `insertClone` to choose the initial index or `reorder` after all shapes have been added.
**Can I use a fixed index to identify a preset shape adjustment?**
Only after validating the exact preset and collection layout. Prefer iterating through `GeometryShape::getAdjustments` and checking `AdjustValue::getType`; use `AdjustValue::getName` as additional information when the same semantic type appears more than once.
# Shape Types in Aspose.Slides for PHP via Java
> Learn every shape type in Aspose.Slides for PHP via Java, with clear examples to create, format, and edit shapes in PPT and PPTX presentations.
Source: https://docs.aspose.com/slides/php-java/shape-types/
Updated: 2025-11-30
---
lastmod: 2025-11-30T13:47:17+04:00
title: Shape Types in Aspose.Slides for PHP via Java
linktitle: Shape Types
type: docs
weight: 10
url: /php-java/shape-types/
keywords:
- shape
- connector
- ellipse
- group
- line
- rectangle
- PowerPoint
- presentation
- PHP
- Aspose.Slides
description: "Learn every shape type in Aspose.Slides for PHP via Java, with clear examples to create, format, and edit shapes in PPT and PPTX presentations."
---
## Related articles
- [Manage PowerPoint Shapes in PHP](https://docs.aspose.com/slides/php-java/powerpoint-shapes/)
- [Connector](https://docs.aspose.com/slides/php-java/examples/elements/connector/)
- [Add Ellipses to Presentations in PHP](https://docs.aspose.com/slides/php-java/ellipse/)
# Apply or Change Slide Layouts in PHP
> Apply, create, and modify slide layouts in Aspose.Slides for PHP via Java, add placeholders, remove unused layouts, and control footer visibility.
Source: https://docs.aspose.com/slides/php-java/slide-layout/
Updated: 2026-11-08
## **Overview**
A slide layout defines the positions and formatting of placeholders such as titles, text, pictures, charts, and tables. Applying a layout gives slides a consistent structure while allowing each slide to contain its own content.
The most common layouts include:
- **Title Slide**: Contains title and subtitle placeholders.
- **Title and Content**: Contains a title placeholder and a general-purpose content placeholder.
- **Blank**: Contains no content placeholders and is useful when every shape will be positioned manually.
## **Understand Layout Inheritance**
A presentation has three related levels:
1. A [master slide](https://reference.aspose.com/slides/php-java/aspose.slides/masterslide/) defines the theme, shared formatting, backgrounds, and common objects.
1. A [layout slide](https://reference.aspose.com/slides/php-java/aspose.slides/layoutslide/) belongs to a master and defines a particular arrangement of placeholders.
1. A [normal slide](https://reference.aspose.com/slides/php-java/aspose.slides/slide/) uses one layout and stores the content entered for that slide.
A normal slide inherits theme and formatting from its layout, and the layout inherits from its master. A value set directly on a normal slide overrides the inherited value at that level. When a normal slide is created, its placeholder shapes are generated from the selected layout, while the content entered into those placeholders belongs to the normal slide.
Add required placeholders to a layout before creating slides from it. Adding another placeholder to a layout later does not automatically add a corresponding placeholder shape to existing normal slides.
This relationship has two important consequences:
- Changing inherited formatting or existing placeholder geometry on a layout can update every slide that depends on it. Before editing a layout that is already in use, inspect its dependent slides and review the resulting presentation.
- A layout that is still used by a slide cannot be removed. Reassign its dependent slides to another layout first, or remove only unused layouts.
For more information about the top level of this hierarchy, see [Slide Master](https://docs.aspose.com/slides/php-java/slide-master/).
To hide inherited logos or decorative master shapes on one slide or through a shared layout, see [Control the Visibility of Master Graphics](https://docs.aspose.com/slides/php-java/slide-master/). The example compares two slides using the same master.
[](https://docs.aspose.com/slides/php-java/slide-layout/visual-master-layout-slides-68f75c126f65.svg)
*The master supplies shared design, the layout supplies placeholder structure, and each slide owns its content. Existing inherited settings can update dependent slides. Add required placeholders before creating slides: a placeholder added later to the layout is not automatically inserted into existing slides.*
## **Select and Apply a Slide Layout**
Use a layout type when the presentation follows standard PowerPoint layout definitions. Layout names are user-editable and can be localized, so name-based selection is less reliable unless you control the source template.
The following example looks for **Title and Content** on the first master. If that layout is unavailable, it deliberately falls back to **Blank**. The second null check is necessary because a presentation can contain only custom layouts. The selected layout is then applied to the first normal slide through the [Slide.setLayoutSlide](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#setLayoutSlide) method.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SlideLayoutType;
$presentation = new Presentation("input.pptx");
try {
$layoutSlides = $presentation->getMasters()->get_Item(0)->getLayoutSlides();
$targetLayout = $layoutSlides->getByType(SlideLayoutType::TitleAndObject);
if (java_is_null($targetLayout)) {
$targetLayout = $layoutSlides->getByType(SlideLayoutType::Blank);
}
if (java_is_null($targetLayout)) {
throw new \RuntimeException("The first master does not contain a suitable layout slide.");
}
$presentation->getSlides()->get_Item(0)->setLayoutSlide($targetLayout);
$presentation->save("output-with-new-layout.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Changing a slide's layout does not remove ordinary shapes added directly to the slide. However, placeholder positions, inherited formatting, and the correspondence between existing placeholders and the new layout can change, so inspect the output when switching between substantially different layouts.
## **Add a Layout Slide**
Selection and creation are separate operations. The previous example selects an existing layout; it does not create one. To create a layout, call the [MasterLayoutSlideCollection.add](https://reference.aspose.com/slides/php-java/aspose.slides/masterlayoutslidecollection/#add) method on the target master's layout collection.
The following example always adds a new **Title and Content** layout named `Report Title and Content`, then adds a normal slide based on it. Layout names must be unique within the collection.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SlideLayoutType;
$presentation = new Presentation("input.pptx");
try {
$masterSlide = $presentation->getMasters()->get_Item(0);
$reportLayout = $masterSlide->getLayoutSlides()->add(SlideLayoutType::TitleAndObject, "Report Title and Content");
$presentation->getSlides()->addEmptySlide($reportLayout);
$presentation->save("output-with-report-layout.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Add a layout only when the template genuinely needs another reusable structure. If a suitable layout already exists, select and reuse it instead of creating a duplicate.
## **Add Placeholders to a Layout Slide**
The [LayoutSlide.getPlaceholderManager](https://reference.aspose.com/slides/php-java/aspose.slides/layoutslide/#getPlaceholderManager) method provides a [LayoutPlaceholderManager](https://reference.aspose.com/slides/php-java/aspose.slides/layoutplaceholdermanager/) for adding placeholder shapes to a layout.
| PowerPoint Placeholder | `LayoutPlaceholderManager` Method |
| ----------------------------------- | --------------------------------- |
|  | [`addContentPlaceholder(float x, float y, float width, float height)`](https://reference.aspose.com/slides/php-java/aspose.slides/layoutplaceholdermanager/#addContentPlaceholder) |
|  | [`addVerticalContentPlaceholder(float x, float y, float width, float height)`](https://reference.aspose.com/slides/php-java/aspose.slides/layoutplaceholdermanager/#addVerticalContentPlaceholder) |
|  | [`addTextPlaceholder(float x, float y, float width, float height)`](https://reference.aspose.com/slides/php-java/aspose.slides/layoutplaceholdermanager/#addTextPlaceholder) |
|  | [`addVerticalTextPlaceholder(float x, float y, float width, float height)`](https://reference.aspose.com/slides/php-java/aspose.slides/layoutplaceholdermanager/#addVerticalTextPlaceholder) |
|  | [`addPicturePlaceholder(float x, float y, float width, float height)`](https://reference.aspose.com/slides/php-java/aspose.slides/layoutplaceholdermanager/#addPicturePlaceholder) |
|  | [`addChartPlaceholder(float x, float y, float width, float height)`](https://reference.aspose.com/slides/php-java/aspose.slides/layoutplaceholdermanager/#addChartPlaceholder) |
|  | [`addTablePlaceholder(float x, float y, float width, float height)`](https://reference.aspose.com/slides/php-java/aspose.slides/layoutplaceholdermanager/#addTablePlaceholder) |
|  | [`addSmartArtPlaceholder(float x, float y, float width, float height)`](https://reference.aspose.com/slides/php-java/aspose.slides/layoutplaceholdermanager/#addSmartArtPlaceholder) |
|  | [`addMediaPlaceholder(float x, float y, float width, float height)`](https://reference.aspose.com/slides/php-java/aspose.slides/layoutplaceholdermanager/#addMediaPlaceholder) |
|  | [`addOnlineImagePlaceholder(float x, float y, float width, float height)`](https://reference.aspose.com/slides/php-java/aspose.slides/layoutplaceholdermanager/#addOnlineImagePlaceholder) |
The following example verifies that the **Blank** layout exists, adds four placeholders to it, and then creates a normal slide that uses the modified layout. The order is intentional: the placeholders are added before the normal slide is created, so Aspose.Slides can generate the corresponding placeholder shapes on that slide.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SlideLayoutType;
$presentation = new Presentation();
try {
$blankLayout = $presentation->getLayoutSlides()->getByType(SlideLayoutType::Blank);
if (java_is_null($blankLayout)) {
throw new \RuntimeException("The presentation does not contain a Blank layout slide.");
}
$placeholderManager = $blankLayout->getPlaceholderManager();
$placeholderManager->addContentPlaceholder(20, 20, 310, 270);
$placeholderManager->addVerticalTextPlaceholder(350, 20, 350, 270);
$placeholderManager->addChartPlaceholder(20, 310, 310, 180);
$placeholderManager->addTablePlaceholder(350, 310, 350, 180);
$presentation->getSlides()->addEmptySlide($blankLayout);
$presentation->save("output-with-placeholders.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

Changing inherited formatting or the geometry of existing layout placeholders can affect dependent slides. A newly added layout placeholder is not backfilled into existing normal slides. Test layout changes on a copy of the presentation and inspect every dependent slide.
## **Remove Unused Layout Slides**
Use the [Compress.removeUnusedLayoutSlides](https://reference.aspose.com/slides/php-java/aspose.slides/compress/#removeUnusedLayoutSlides) method to remove layouts that no normal slide references. The method leaves layouts that are still in use intact.
```php
use aspose\slides\Compress;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("input.pptx");
try {
Compress::removeUnusedLayoutSlides($presentation);
$presentation->save("output-without-unused-layouts.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
To remove one specific layout, first use its [hasDependingSlides](https://reference.aspose.com/slides/php-java/aspose.slides/layoutslide/#hasDependingSlides) or [getDependingSlides](https://reference.aspose.com/slides/php-java/aspose.slides/layoutslide/#getDependingSlides) method. Reassign any dependent slides before calling [LayoutSlide.remove](https://reference.aspose.com/slides/php-java/aspose.slides/layoutslide/#remove). Attempting to remove a used layout raises a [PptxEditException](https://reference.aspose.com/slides/php-java/aspose.slides/pptxeditexception/).
## **Control Footer Visibility on a Layout Slide**
A layout has its own footer, slide-number, and date-time placeholders. Use the [LayoutSlide.getHeaderFooterManager](https://reference.aspose.com/slides/php-java/aspose.slides/layoutslide/#getHeaderFooterManager) method to control those placeholders for one layout. This is useful when, for example, content layouts should show footers but title layouts should not.
The following example selects a layout safely and makes its footer elements visible:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\SlideLayoutType;
$presentation = new Presentation("input.pptx");
try {
$layoutSlide = $presentation->getLayoutSlides()->getByType(SlideLayoutType::TitleAndObject);
if (java_is_null($layoutSlide)) {
$layoutSlide = $presentation->getLayoutSlides()->getByType(SlideLayoutType::Blank);
}
if (java_is_null($layoutSlide)) {
throw new \RuntimeException("The presentation does not contain a suitable layout slide.");
}
$headerFooterManager = $layoutSlide->getHeaderFooterManager();
$headerFooterManager->setFooterVisibility(true);
$headerFooterManager->setSlideNumberVisibility(true);
$headerFooterManager->setDateTimeVisibility(true);
$headerFooterManager->setFooterText("Footer text");
$headerFooterManager->setDateTimeText("Date and time text");
$presentation->save("output-with-layout-footers.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Control Footer Visibility on a Master and Its Child Layouts**
To apply consistent footer settings across a master hierarchy, use the [MasterSlide.getHeaderFooterManager](https://reference.aspose.com/slides/php-java/aspose.slides/masterslide/#getHeaderFooterManager) method. The propagation methods of [MasterSlideHeaderFooterManager](https://reference.aspose.com/slides/php-java/aspose.slides/masterslideheaderfootermanager/) operate on the master and its dependent layout slides and normal slides; they do not target just one normal slide.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("input.pptx");
try {
$headerFooterManager = $presentation->getMasters()->get_Item(0)->getHeaderFooterManager();
$headerFooterManager->setFooterAndChildFootersVisibility(true);
$headerFooterManager->setSlideNumberAndChildSlideNumbersVisibility(true);
$headerFooterManager->setDateTimeAndChildDateTimesVisibility(true);
$headerFooterManager->setFooterAndChildFootersText("Footer text");
$headerFooterManager->setDateTimeAndChildDateTimesText("Date and time text");
$presentation->save("output-with-master-footers.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **FAQ**
**What Is the Difference Between a Master Slide and a Layout Slide?**
A master slide defines the presentation's theme and shared formatting. A layout slide belongs to a master and defines one reusable arrangement of placeholders. Normal slides use those layouts and store slide-specific content.
**Can I Copy a Layout Slide from One Presentation to Another?**
Yes. Add a copy to the destination collection with the [addClone](https://reference.aspose.com/slides/php-java/aspose.slides/globallayoutslidecollection/#addClone) method. When copying between presentations, also verify fonts, themes, images, and other resources used by the source layout.
**What Happens When I Modify a Layout That Is Already in Use?**
Dependent slides inherit the layout changes unless they override the affected formatting or objects locally. Placeholder geometry and inherited styling can therefore change on many slides at once. Use [getDependingSlides](https://reference.aspose.com/slides/php-java/aspose.slides/layoutslide/#getDependingSlides) to identify the affected slides before editing the layout.
**What Happens If I Remove a Layout That Is Still in Use?**
Aspose.Slides throws a [PptxEditException](https://reference.aspose.com/slides/php-java/aspose.slides/pptxeditexception/). Reassign the dependent slides first, or use [removeUnusedLayoutSlides](https://reference.aspose.com/slides/php-java/aspose.slides/compress/#removeUnusedLayoutSlides) to remove only unreferenced layouts.
## Related articles
- [Manage Presentation Headers and Footers in PHP](https://docs.aspose.com/slides/php-java/presentation-header-and-footer/)
- [Manage Presentation Slide Masters in PHP](https://docs.aspose.com/slides/php-java/slide-master/)
# Manage Presentation Slide Masters in PHP
> Manage slide masters in Aspose.Slides for PHP via Java: access, edit, clone, compare, and remove master slides in PowerPoint and OpenDocument presentations.
Source: https://docs.aspose.com/slides/php-java/slide-master/
Updated: 2026-09-28
## **Overview**
A **slide master** defines shared design settings for a group of slides. It can contain common shapes, logos, backgrounds, text styles, theme settings, and footer settings. In PowerPoint, editing a slide master is the usual way to keep a presentation consistent without repeating the same formatting on every slide.
Aspose.Slides for PHP via Java supports the same model. A presentation can contain one or more master slides, and each master slide can contain several layout slides. Normal slides do not usually refer to a master slide directly. Instead, a normal slide uses a layout slide, and that layout slide belongs to a master slide.
The hierarchy is:
1. **Slide master** - defines the shared design and theme.
1. **Layout slide** - defines a specific arrangement of placeholders and layout-level formatting.
1. **Normal slide** - contains the actual presentation content and uses one layout slide.

In Aspose.Slides, a slide master is represented by the [MasterSlide](https://reference.aspose.com/slides/php-java/aspose.slides/masterslide/) class. All master slides in a presentation are available through the [Presentation.getMasters](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getMasters) method, which returns a [MasterSlideCollection](https://reference.aspose.com/slides/php-java/aspose.slides/masterslidecollection/) object.
When the same property is defined at more than one level, the more specific level wins. For example, if a master slide and a layout slide both define a background, slides based on that layout use the layout background. For more information about layout slides, see [Apply or Change Slide Layouts](https://docs.aspose.com/slides/php-java/slide-layout/).
## **Access Slide Masters**
In PowerPoint, you can open the Slide Master view from **View** > **Slide Master**.

In Aspose.Slides, use the `getMasters` method to access master slides:
```php
$presentation = new Presentation("presentation.pptx");
try {
$firstMasterSlide = $presentation->getMasters()->get_Item(0);
$masterSlideCount = $presentation->getMasters()->size();
$firstMasterLayoutSlideCount = $firstMasterSlide->getLayoutSlides()->size();
echo "Master slides: " . $masterSlideCount . PHP_EOL;
echo "Layouts in the first master: " . $firstMasterLayoutSlideCount . PHP_EOL;
} finally {
$presentation->dispose();
}
```
You can also get the master slide used by a normal slide through its layout:
```php
$presentation = new Presentation("presentation.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$layoutSlide = $slide->getLayoutSlide();
$masterSlide = $layoutSlide->getMasterSlide();
$masterSlideName = $masterSlide->getName();
echo $masterSlideName . PHP_EOL;
} finally {
$presentation->dispose();
}
```
## **What a Slide Master Contains**
A master slide is a slide-like object. It extends [BaseSlide](https://reference.aspose.com/slides/php-java/aspose.slides/baseslide/), so it exposes many of the same slide properties used by normal and layout slides. Master-specific members are listed on the [MasterSlide](https://reference.aspose.com/slides/php-java/aspose.slides/masterslide/) API page.
Commonly used master slide members include:
| Member | Purpose |
| --- | --- |
| `getBackground` | Sets the master-level slide background. |
| `getShapes` | Stores shapes placed on the master, such as logos, picture frames, and shared text. |
| `getLayoutSlides` | Stores the layout slides that belong to the master. |
| `getThemeManager` | Provides access to the master theme APIs. |
| `getHeaderFooterManager` | Controls headers, footers, dates, and slide numbers for the master and its child layouts. |
| `getDependingSlides` | Returns normal slides that depend on the master through their layouts. |
## **Add an Image to a Slide Master**
When you add an image to a master slide, it appears on slides that use layouts from that master. This is useful for logos, watermarks, decorative bands, and other repeated visual elements.
The following example adds a logo to the first master slide:
```php
$presentation = new Presentation("presentation.pptx");
try {
$masterSlide = $presentation->getMasters()->get_Item(0);
$logoImage = Images::fromFile("logo.png");
try {
$presentationImage = $presentation->getImages()->addImage($logoImage);
} finally {
$logoImage->dispose();
}
$masterSlide->getShapes()->addPictureFrame(
ShapeType::Rectangle,
20,
20,
80,
80,
$presentationImage
);
$presentation->save("presentation-with-logo.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
For more information about picture frames, see [Picture Frame](https://docs.aspose.com/slides/php-java/picture-frame/).
## **Control the Visibility of Master Graphics**
Use [BaseSlide::setShowMasterShapes](https://reference.aspose.com/slides/php-java/aspose.slides/baseslide/#setShowMasterShapes) to hide inherited master graphics, such as logos or decorative shapes, without deleting them from the master. Pass `false` to [Slide::setShowMasterShapes](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#setShowMasterShapes) on the slide that should omit those graphics and keep it `true` on slides that should display them.
The following self-contained example creates a blue decorative band on a master and two slides that use the same blank layout. The band is visible on the first slide and hidden on the second. No input presentation or image is required.
```php
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\SlideLayoutType;
$presentation = new Presentation();
try {
$masterSlide = $presentation->getMasters()->get_Item(0);
$layoutSlide = $masterSlide->getLayoutSlides()->getByType(SlideLayoutType::Blank);
$layoutSlide->setShowMasterShapes(true);
$slideHeight = java_values($presentation->getSlideSize()->getSize()->getHeight());
$band = $masterSlide->getShapes()->addAutoShape(ShapeType::Rectangle, 0, 0, 60, $slideHeight);
$bandColor = new Java("java.awt.Color", 70, 130, 180);
$band->getFillFormat()->setFillType(FillType::Solid);
$band->getFillFormat()->getSolidFillColor()->setColor($bandColor);
$band->getLineFormat()->getFillFormat()->setFillType(FillType::NoFill);
$visibleSlide = $presentation->getSlides()->get_Item(0);
$visibleSlide->setLayoutSlide($layoutSlide);
$visibleSlide->getShapes()->clear();
$hiddenSlide = $presentation->getSlides()->addEmptySlide($layoutSlide);
$visibleSlide->setShowMasterShapes(true);
$hiddenSlide->setShowMasterShapes(false);
$presentation->save("master-graphics.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The example uses the **Blank** layout supplied with a new presentation and removes the initial slide's own placeholders.
### **Choose the Scope of the Setting**
A normal slide uses its master through [Slide::getLayoutSlide](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#getLayoutSlide) and [LayoutSlide::getMasterSlide](https://reference.aspose.com/slides/php-java/aspose.slides/layoutslide/#getMasterSlide). Setting the property on an individual slide affects only that slide. Passing `false` to [LayoutSlide::setShowMasterShapes](https://reference.aspose.com/slides/php-java/aspose.slides/layoutslide/#setShowMasterShapes) hides master graphics for slides that use that shared layout, even if their own setting is `true`. To hide graphics on just one slide, change the slide property and leave the shared layout unchanged.
The setting is not supported as a visibility control on the master slide itself. On a master, [getShowMasterShapes](https://reference.aspose.com/slides/php-java/aspose.slides/masterslide/#getShowMasterShapes) always returns `false`, and passing `true` to [setShowMasterShapes](https://reference.aspose.com/slides/php-java/aspose.slides/masterslide/#setShowMasterShapes) raises an exception. Apply it to a normal slide or a layout instead.
### **Distinguish Graphics from the Background**
| Operation | Effect |
| --- | --- |
| Hide master graphics | Controls the visibility of inherited master shapes without deleting them or changing the slide's own shapes. |
| Change the slide background fill | Changes the background color, gradient, or image. Master graphics are separate shapes and can remain visible over that background. See [Presentation Background](https://docs.aspose.com/slides/php-java/presentation-background/). |
| Delete a shape from the master | Removes the shared source shape, so it is no longer available to any slide using that master. |
## **Work with Placeholders**
Placeholders are normally defined on layout slides. The master slide provides the shared style and theme that those layouts inherit, while each layout decides which placeholders are available and where they are placed.
In PowerPoint, placeholder commands are available in Slide Master view.

To add new placeholders with Aspose.Slides, work with the layout slide that belongs to the master:
```php
$presentation = new Presentation("presentation.pptx");
try {
$masterSlide = $presentation->getMasters()->get_Item(0);
$blankLayoutSlideName = "Custom Blank";
$blankLayoutSlide = $masterSlide->getLayoutSlides()->add(
SlideLayoutType::Blank,
$blankLayoutSlideName
);
$blankLayoutSlide->getPlaceholderManager()->addTextPlaceholder(
60,
120,
600,
80
);
$presentation->getSlides()->addEmptySlide($blankLayoutSlide);
$presentation->save("presentation-with-placeholder.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
You can also format placeholder shapes that already exist on a master slide. The following example finds the title placeholder and applies a linear gradient fill:
```php
$presentation = new Presentation("presentation.pptx");
try {
$masterSlide = $presentation->getMasters()->get_Item(0);
$titlePlaceholder = findPlaceholder($masterSlide, PlaceholderType::Title);
if (!java_is_null($titlePlaceholder)) {
$redGradientColor = java("java.awt.Color")->RED;
$purpleGradientColor = new Java("java.awt.Color", 128, 0, 128);
$fillFormat = $titlePlaceholder->getFillFormat();
$fillFormat->setFillType(FillType::Gradient);
$gradientFormat = $fillFormat->getGradientFormat();
$gradientFormat->setGradientShape(GradientShape::Linear);
$gradientStops = $gradientFormat->getGradientStops();
$gradientStops->add(0, $redGradientColor);
$gradientStops->add(255, $purpleGradientColor);
}
$presentation->save("presentation-title-style.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
function findPlaceholder($masterSlide, $placeholderType)
{
$shapesCount = java_values($masterSlide->getShapes()->size());
for ($shapeIndex = 0; $shapeIndex < $shapesCount; $shapeIndex++) {
$shape = $masterSlide->getShapes()->get_Item($shapeIndex);
$placeholder = $shape->getPlaceholder();
if (!java_is_null($placeholder) && java_values($placeholder->getType()) == $placeholderType) {
return $shape;
}
}
return null;
}
```

For more placeholder and text formatting options, see [Set Prompt Text in Placeholder](https://docs.aspose.com/slides/php-java/manage-placeholder/) and [Text Formatting](https://docs.aspose.com/slides/php-java/text-formatting/).
## **Change a Slide Master Background**
A master background is inherited by layouts and slides that do not override it. The following example sets a solid background color for the first master slide:
```php
$presentation = new Presentation("presentation.pptx");
try {
$masterSlide = $presentation->getMasters()->get_Item(0);
$forestGreenColor = new Java("java.awt.Color", 34, 139, 34);
$background = $masterSlide->getBackground();
$background->setType(BackgroundType::OwnBackground);
$fillFormat = $background->getFillFormat();
$fillFormat->setFillType(FillType::Solid);
$fillFormat->getSolidFillColor()->setColor($forestGreenColor);
$presentation->save("presentation-master-background.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
For related topics, see [Presentation Background](https://docs.aspose.com/slides/php-java/presentation-background/) and [Presentation Theme](https://docs.aspose.com/slides/php-java/presentation-theme/).
## **Clone a Slide Master to Another Presentation**
Use `addClone` from [MasterSlideCollection](https://reference.aspose.com/slides/php-java/aspose.slides/masterslidecollection/) to copy a master slide into another presentation. The copied master can then be used by layouts and slides in the destination presentation.
```php
$sourcePresentation = new Presentation("source.pptx");
$destinationPresentation = new Presentation("destination.pptx");
try {
$sourceMasterSlide = $sourcePresentation->getMasters()->get_Item(0);
$clonedMasterSlide = $destinationPresentation->getMasters()->addClone($sourceMasterSlide);
$destinationPresentation->save("destination-with-master.pptx", SaveFormat::Pptx);
} finally {
$destinationPresentation->dispose();
$sourcePresentation->dispose();
}
```
If you need to clone normal slides together with their master, see [Clone Slides](https://docs.aspose.com/slides/php-java/clone-slides/).
## **Add Multiple Slide Masters**
A presentation can contain multiple master slides. This is useful when different sections require different branding, page structure, or theme settings.

The following example clones the default master, gives the clone a different background, creates a layout under that cloned master, and adds a new slide based on that layout:
```php
$presentation = new Presentation("presentation.pptx");
try {
$defaultMasterSlide = $presentation->getMasters()->get_Item(0);
$sectionMasterSlide = $presentation->getMasters()->addClone($defaultMasterSlide);
$lightSteelBlueColor = new Java("java.awt.Color", 176, 196, 222);
$background = $sectionMasterSlide->getBackground();
$background->setType(BackgroundType::OwnBackground);
$fillFormat = $background->getFillFormat();
$fillFormat->setFillType(FillType::Solid);
$fillFormat->getSolidFillColor()->setColor($lightSteelBlueColor);
$sourceBlankLayout = $defaultMasterSlide->getLayoutSlides()->get_Item(0);
$sectionBlankLayout = $sectionMasterSlide->getLayoutSlides()->addClone($sourceBlankLayout);
$presentation->getSlides()->addEmptySlide($sectionBlankLayout);
$presentation->save("presentation-with-multiple-masters.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Compare Slide Masters**
Master slides can be compared with the `equals` method inherited from [BaseSlide](https://reference.aspose.com/slides/php-java/aspose.slides/baseslide/). The comparison checks structure and static content, such as shapes, text, formatting, animations, and other slide settings. It does not compare unique identifiers, such as slide IDs, or dynamic placeholder values, such as the current date.
```php
$firstPresentation = new Presentation("first.pptx");
$secondPresentation = new Presentation("second.pptx");
try {
$firstPresentationMasterCount = java_values($firstPresentation->getMasters()->size());
$secondPresentationMasterCount = java_values($secondPresentation->getMasters()->size());
for ($firstMasterIndex = 0; $firstMasterIndex < $firstPresentationMasterCount; $firstMasterIndex++) {
for ($secondMasterIndex = 0; $secondMasterIndex < $secondPresentationMasterCount; $secondMasterIndex++) {
$firstMasterSlide = $firstPresentation->getMasters()->get_Item($firstMasterIndex);
$secondMasterSlide = $secondPresentation->getMasters()->get_Item($secondMasterIndex);
$areMasterSlidesEqual = $firstMasterSlide->equals($secondMasterSlide);
if ($areMasterSlidesEqual) {
echo "first.pptx master #" . $firstMasterIndex .
" equals second.pptx master #" . $secondMasterIndex . PHP_EOL;
}
}
}
} finally {
$secondPresentation->dispose();
$firstPresentation->dispose();
}
```
For more information, see [Compare Presentation Slides](https://docs.aspose.com/slides/php-java/compare-slides/).
## **Set Slide Master View as the Default View**
Use the `setLastView` method on [ViewProperties](https://reference.aspose.com/slides/php-java/aspose.slides/viewproperties/) to control the view that PowerPoint opens first. The following example opens the presentation in Slide Master view:
```php
$presentation = new Presentation("presentation.pptx");
try {
$presentation->getViewProperties()->setLastView(ViewType::SlideMasterView);
$presentation->save("presentation-master-view.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
For more view settings, see [Save Presentation](https://docs.aspose.com/slides/php-java/save-presentation/).
## **Remove Unused Master Slides**
Presentations sometimes contain master slides that are no longer used by any normal slides. Removing unused masters can reduce file size and simplify template maintenance.
Use `removeUnused` from [MasterSlideCollection](https://reference.aspose.com/slides/php-java/aspose.slides/masterslidecollection/) to remove unused masters from the `getMasters` collection:
```php
$presentation = new Presentation("presentation.pptx");
try {
$presentation->getMasters()->removeUnused(true);
$presentation->save("presentation-clean.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
You can also use the low-code `removeUnusedMasterSlides` method from the [Compress](https://reference.aspose.com/slides/php-java/aspose.slides/compress/) class:
```php
$presentation = new Presentation("presentation.pptx");
try {
Compress::removeUnusedMasterSlides($presentation);
$presentation->save("presentation-clean.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **FAQ**
**What is the difference between a slide master and a layout slide?**
A slide master defines shared design settings such as theme, background, common shapes, and text styles. A layout slide belongs to a master slide and defines a specific arrangement of placeholders. A normal slide uses a layout slide, so it inherits from both the layout and the master.
**Can one presentation contain several slide masters?**
Yes. A presentation can contain several slide masters. Use multiple masters when different sections need different visual systems or branding.
**Should I add placeholders to a master slide or a layout slide?**
In most cases, add placeholders to layout slides. Put shared visual elements and shared formatting on the master slide, then put content placeholders on the layouts that normal slides will use.
**Can I delete a master slide that is still used?**
No. A master slide that has dependent slides cannot be safely removed directly. First move those slides to layouts under another master, or use an unused-master cleanup method that removes only masters that are not in use.
## Related articles
- [Master Slide](https://docs.aspose.com/slides/php-java/examples/elements/master-slide/)
- [Apply or Change Slide Layouts in PHP](https://docs.aspose.com/slides/php-java/slide-layout/)
- [Layout Slide](https://docs.aspose.com/slides/php-java/examples/elements/layout-slide/)
# Manage Slide Sections in Presentations with PHP
> Manage slide sections with Aspose.Slides for PHP via Java: create, rename, reorder, retrieve, and process section slides in PPTX presentations.
Source: https://docs.aspose.com/slides/php-java/slide-section/
Updated: 2026-08-25
## **Introduction**
Sections organize consecutive slides into named groups without changing the slide content. With Aspose.Slides for PHP via Java, you can create, reorder, rename, inspect, and remove sections through the [Presentation::getSections](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation/#getSections) method.
Sections are especially useful when:
- a large presentation needs to be divided into logical topics or chapters;
- different groups of slides are assigned to different collaborators;
- slides need to be processed, moved, or merged as groups.
Choose concise section names that describe the purpose of the grouped slides. Because sections are part of the presentation structure, use the section APIs to determine membership instead of deriving it from slide positions.
## **Create and Manage Sections**
Use [SectionCollection::addSection](https://reference.aspose.com/slides/php-java/aspose.slides/SectionCollection/#addSection) to create a section by specifying its name and starting slide. Aspose.Slides determines which slides belong to the section from the presentation's current section structure.
The same [SectionCollection](https://reference.aspose.com/slides/php-java/aspose.slides/SectionCollection/) also lets you:
- move a section together with its slides by using [SectionCollection::reorderSectionWithSlides](https://reference.aspose.com/slides/php-java/aspose.slides/SectionCollection/#reorderSectionWithSlides);
- remove only the section definition with [SectionCollection::removeSection](https://reference.aspose.com/slides/php-java/aspose.slides/SectionCollection/#removeSection), which retains its slides;
- remove a section and its slides with [SectionCollection::removeSectionWithSlides](https://reference.aspose.com/slides/php-java/aspose.slides/SectionCollection/#removeSectionWithSlides);
- add an empty section at the end with [SectionCollection::appendEmptySection](https://reference.aspose.com/slides/php-java/aspose.slides/SectionCollection/#appendEmptySection).
The following example creates two sections, moves one of them, removes it together with its slides, and appends an empty section:
```php
use aspose\slides\Presentation;
$presentation = new Presentation();
try {
$titleSlide = $presentation->getSlides()->get_Item(0);
$layoutSlide = $presentation->getLayoutSlides()->get_Item(0);
$presentation->getSlides()->addEmptySlide($layoutSlide);
$resultsSlide = $presentation->getSlides()->addEmptySlide($layoutSlide);
$presentation->getSlides()->addEmptySlide($layoutSlide);
$presentation->getSections()->addSection("Introduction", $titleSlide);
$resultsSection = $presentation->getSections()->addSection("Results", $resultsSlide);
$presentation->getSections()->reorderSectionWithSlides($resultsSection, 0);
$presentation->getSections()->removeSectionWithSlides($resultsSection);
$presentation->getSections()->appendEmptySection("Appendix");
} finally {
$presentation->dispose();
}
```
After these operations, the presentation contains the `Introduction` section with its slides and an empty `Appendix` section. The `Results` section and its slides have been removed.
## **Rename Sections**
To rename a section, call its [Section::setName](https://reference.aspose.com/slides/php-java/aspose.slides/Section/#setName) method. The section's slides and position remain unchanged.
The following example creates a section and changes its name:
```php
use aspose\slides\Presentation;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$section = $presentation->getSections()->addSection("Overview", $slide);
$section->setName("Introduction");
} finally {
$presentation->dispose();
}
```
## **Retrieve Slides from Sections**
The [Presentation::getSections](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation/#getSections) method returns a [SectionCollection](https://reference.aspose.com/slides/php-java/aspose.slides/SectionCollection/) that you can process by index. For each [Section](https://reference.aspose.com/slides/php-java/aspose.slides/Section/), call [Section::getSlidesListOfSection](https://reference.aspose.com/slides/php-java/aspose.slides/Section/#getSlidesListOfSection) to obtain the slides that currently belong to it. The method returns a [SectionSlideCollection](https://reference.aspose.com/slides/php-java/aspose.slides/SectionSlideCollection/), which provides a count and indexed access.
The following example creates two populated sections and one empty section, then prints each section's [name](https://reference.aspose.com/slides/php-java/aspose.slides/Section/#getName), [identifier](https://reference.aspose.com/slides/php-java/aspose.slides/Section/#getSectionId), [starting slide](https://reference.aspose.com/slides/php-java/aspose.slides/Section/#getStartedFromSlide), slide count, and slide numbers. It uses [SectionCollection::get_Item](https://reference.aspose.com/slides/php-java/aspose.slides/SectionCollection/#get_Item) and [SectionSlideCollection::get_Item](https://reference.aspose.com/slides/php-java/aspose.slides/SectionSlideCollection/#get_Item) for indexed access. For the empty section, the returned collection has a size of zero and `get_Item` is not called.
```php
use aspose\slides\Presentation;
$presentation = new Presentation();
try {
$firstSlide = $presentation->getSlides()->get_Item(0);
$layoutSlide = $presentation->getLayoutSlides()->get_Item(0);
$presentation->getSlides()->addEmptySlide($layoutSlide);
$thirdSlide = $presentation->getSlides()->addEmptySlide($layoutSlide);
$presentation->getSections()->addSection("Introduction", $firstSlide);
$presentation->getSections()->addSection("Details", $thirdSlide);
$presentation->getSections()->appendEmptySection("Appendix");
$sections = $presentation->getSections();
$sectionCount = java_values($sections->size());
for ($sectionIndex = 0; $sectionIndex < $sectionCount; $sectionIndex++) {
$section = $sections->get_Item($sectionIndex);
$sectionSlides = $section->getSlidesListOfSection();
$startingSlide = java_is_null($section->getStartedFromSlide()) ? "none" : java_values($section->getStartedFromSlide()->getSlideNumber());
$slideCount = java_values($sectionSlides->size());
echo "Section: " . java_values($section->getName()) . PHP_EOL;
echo "ID: " . java_values($section->getSectionId()) . PHP_EOL;
echo "Starting slide: " . $startingSlide . PHP_EOL;
echo "Slide count: " . $slideCount . PHP_EOL;
if ($slideCount > 0) {
echo "First slide via get_Item: " . java_values($sectionSlides->get_Item(0)->getSlideNumber()) . PHP_EOL;
}
echo "Slide numbers:";
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $sectionSlides->get_Item($slideIndex);
echo " " . java_values($slide->getSlideNumber());
}
echo PHP_EOL;
}
} finally {
$presentation->dispose();
}
```
Section membership is determined by the presentation's section structure. Do not calculate a section's range manually from [Section::getStartedFromSlide](https://reference.aspose.com/slides/php-java/aspose.slides/Section/#getStartedFromSlide), slide indexes, and the next section's starting slide.
Structural edits can change both the slides returned for a section and their slide numbers. This includes reordering slides, cloning a slide into a section, moving a section together with its slides, removing slides, and removing sections. The next example calls [Section::getSlidesListOfSection](https://reference.aspose.com/slides/php-java/aspose.slides/Section/#getSlidesListOfSection) after every such change instead of retaining assumptions about the section's former boundaries.
```php
use aspose\slides\Presentation;
$presentation = new Presentation();
try {
$firstSlide = $presentation->getSlides()->get_Item(0);
$layoutSlide = $presentation->getLayoutSlides()->get_Item(0);
$presentation->getSlides()->addEmptySlide($layoutSlide);
$thirdSlide = $presentation->getSlides()->addEmptySlide($layoutSlide);
$presentation->getSlides()->addEmptySlide($layoutSlide);
$firstSection = $presentation->getSections()->addSection("First", $firstSlide);
$secondSection = $presentation->getSections()->addSection("Second", $thirdSlide);
$printSectionSlides = function ($label, $section) {
$sectionSlides = $section->getSlidesListOfSection();
$slideCount = java_values($sectionSlides->size());
echo $label . " (" . $slideCount . " slides):";
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $sectionSlides->get_Item($slideIndex);
echo " " . java_values($slide->getSlideNumber());
}
echo PHP_EOL;
};
$printSectionSlides("Initially", $firstSection);
$slidesBeforeClone = $firstSection->getSlidesListOfSection();
$presentation->getSlides()->addClone($slidesBeforeClone->get_Item(0), $firstSection);
$printSectionSlides("After cloning into the section", $firstSection);
$slidesBeforeReorder = $firstSection->getSlidesListOfSection();
$firstSectionPosition = java_values($slidesBeforeReorder->get_Item(0)->getSlideNumber()) - 1;
$lastSlideIndex = java_values($slidesBeforeReorder->size()) - 1;
$presentation->getSlides()->reorder($firstSectionPosition, $slidesBeforeReorder->get_Item($lastSlideIndex));
$printSectionSlides("After reordering slides", $firstSection);
$presentation->getSections()->reorderSectionWithSlides($firstSection, 1);
$printSectionSlides("After moving the section", $firstSection);
$slidesBeforeRemoval = $firstSection->getSlidesListOfSection();
$presentation->getSlides()->remove($slidesBeforeRemoval->get_Item(0));
$printSectionSlides("After removing a slide", $firstSection);
$presentation->getSections()->removeSectionWithSlides($secondSection);
$remainingSections = $presentation->getSections();
$remainingSectionCount = java_values($remainingSections->size());
for ($sectionIndex = 0; $sectionIndex < $remainingSectionCount; $sectionIndex++) {
$section = $remainingSections->get_Item($sectionIndex);
$printSectionSlides("Remaining section", $section);
}
} finally {
$presentation->dispose();
}
```
Call [Section::getSlidesListOfSection](https://reference.aspose.com/slides/php-java/aspose.slides/Section/#getSlidesListOfSection) again whenever slides or sections are reordered, cloned, moved, or removed. This keeps subsequent processing aligned with the current presentation structure.
The PPT (PowerPoint 97–2003) format does not preserve section metadata. Use this workflow with a format that supports sections, such as PPTX; converting to PPT removes the section structure needed for later iteration.
## **FAQ**
**Are sections preserved when saving to the PPT (PowerPoint 97–2003) format?**
No. The PPT format does not support section metadata, so section grouping is lost when saving to .ppt.
**Can an entire section be "hidden"?**
No. A section has no visibility state. To hide its contents, call [Slide::setHidden](https://reference.aspose.com/slides/php-java/aspose.slides/Slide/#setHidden) for each slide in the section.
**How can I find the section that contains a slide?**
Loop through the collection returned by [Presentation::getSections](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation/#getSections), call [Section::getSlidesListOfSection](https://reference.aspose.com/slides/php-java/aspose.slides/Section/#getSlidesListOfSection) for each section, and compare the returned slides with the target slide. For a non-empty section, [Section::getStartedFromSlide](https://reference.aspose.com/slides/php-java/aspose.slides/Section/#getStartedFromSlide) returns its first slide; for an empty section, it returns `null`.
## Related articles
- [Section](https://docs.aspose.com/slides/php-java/examples/elements/section/)
# Change the Presentation Slide Size in PHP
> Learn how to quickly resize slides in PPT, PPTX and ODP files with PHP and Aspose.Slides, optimize presentations for any screen without losing quality.
Source: https://docs.aspose.com/slides/php-java/slide-size/
Updated: 2026-11-08
## **Introduction**
Aspose.Slides provides comprehensive tools to adjust the slide size and aspect ratio in PowerPoint presentations, critical for both printing and on-screen display.
Popular Slide Sizes and Ratios:
- **Standard (4:3 Aspect Ratio)**: Ideal for older screens and devices.
- **Widescreen (16:9 Aspect Ratio)**: Recommended for modern projectors and displays.
Ensure consistency throughout your presentation as a single slide size and aspect ratio apply to all slides. For optimal results, set your slide dimensions at the beginning of your presentation creation process to avoid complications.
By default, presentations created with Aspose.Slides use the standard 4:3 aspect ratio.
Notes and handout pages have separate dimensions from regular slides. See [Notes Page Size](https://docs.aspose.com/slides/php-java/notes-size/) to change their size and orientation.
## **Change the Slide Size in Presentations**
This sample code shows you how to change the slide size in a presentation using Aspose.Slides:
```php
$pres = new Presentation("pres-4x3-aspect-ratio.pptx");
try {
$pres->getSlideSize()->setSize(SlideSizeType::OnScreen16x9, SlideSizeScaleType::DoNotScale);
$pres->save("pres-4x3-aspect-ratio.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Specify Custom Slide Sizes in Presentations**
If you find the common slide sizes (4:3 and 16:9) unsuitable for your work, you may decide to use a specific or unique slide size. For example, if you plan to print full-size slides from your presentation on a custom page layout or if you intend to display your presentation on certain screen types, you are likely to benefit from using a custom size setting for your presentation.
This sample code shows you how to use Aspose.Slides for PHP via Java to specify a custom slide size for a presentation:
```php
$pres = new Presentation("pres.pptx");
try {
$pres->getSlideSize()->setSize(780, 540, SlideSizeScaleType::DoNotScale);// A4 paper size
$pres->save("pres-a4-slide-size.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **Handle Slide Content After Resizing**
After you change the slide size for a presentation, the slides’ contents (images or objects, for example) may become distorted. By default, the objects get automatically resized to fit the new slide size. However, when changing a presentation's slide size, you can specify a setting that determines how Aspose.Slides deals with the contents on the slides.
Depending on what you intend to do or achieve, you can use any of these settings:
- `DoNotScale`
If you do NOT want the objects on the slides to be resized, use this setting.
- `EnsureFit`
If you want to scale to a smaller slide size and you need Aspose.Slides to scale down the slides’ objects to ensure they all fit on slides (this way, you avoid losing content), use this setting.
- `Maximize`
If you want to scale to a larger slide size and you need Aspose.Slides to enlarge the slides’ objects to make them proportional to the new slide size, use this setting.
This sample code shows you how to use the `Maximize` setting when changing the size of a presentation’s slide:
```php
$pres = new Presentation("pres.pptx");
try {
$pres->getSlideSize()->setSize(SlideSizeType::Ledger, SlideSizeScaleType::Maximize);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
[](https://docs.aspose.com/slides/php-java/slide-size/visual-slide-size-1dbb49bb41cc.svg)
*One .NET fixture resized to the same 600 × 300-point canvas in each mode. The figure uses one display scale throughout. Dashed marks show where shape frames extend beyond the canvas.*
## **FAQ**
**Can I set a custom slide size using units other than inches (for example, points or millimeters)?**
Yes. Aspose.Slides uses points internally, where 1 point equals 1/72 of an inch. You can convert any unit (such as millimeters or centimeters) to points and use the converted values to define slide width and height.
**Will a very large custom slide size affect performance and memory usage during rendering?**
Yes. Larger slide dimensions (in points) combined with higher rendering scale lead to increased memory consumption and longer processing times. Aim for a practical slide size and adjust rendering scale only as needed to achieve the desired output quality.
**Can I define one non-standard slide size and then merge slides from presentations that have different sizes?**
You can’t [merge presentations](https://docs.aspose.com/slides/php-java/merge-presentation/) while they have different slide sizes — first, resize one presentation to match the other. When changing the slide size, you can choose how existing content is handled via the [SlideSizeScaleType](https://reference.aspose.com/slides/php-java/aspose.slides/slidesizescaletype/) option. After aligning sizes, you can merge slides while preserving formatting.
**Can I generate thumbnails for individual shapes or specific regions of a slide, and will they respect the new slide size?**
Yes. Aspose.Slides can render thumbnails for [entire slides](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#getImage) as well as for [selected shapes](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#getImage). The resulting images reflect the current slide size and aspect ratio, ensuring consistent framing and geometry.
# Slide Text Extraction: PPT, PPTX, ODP Essentials
> Turn slides into data: extract text from PPT, PPTX, and ODP for search, automation, and accessibility, with format insights—usable in PHP and cloud platforms.
Source: https://docs.aspose.com/slides/php-java/slide-text-extraction-ppt-pptx-odp-essentials/
Updated: 2025-12-01
## **Introduction**
Extracting text from presentation files is critical for **automating business processes**, **data analytics**, and **streamlining document workflows**. In today’s digital landscape, many organizations need **rapid access** to information contained in slides. Whether for **search indexing**, **content analysis**, **accessibility**, or **localization**, reliable text extraction ensures that valuable slide content can be reused, processed, and analyzed across various systems.
## **Practical Applications of Text Extraction**
- **Automating Document Workflows**: Seamlessly integrate PPTX and ODP files into corporate document management systems (DMS) like SharePoint, Alfresco, or 1C:Document Management.
- **Search Indexing**: Create high-speed search systems by indexing extracted text, enabling quick retrieval of pertinent data from large presentation archives.
- **Content Analysis**: Automatically identify key phrases, topics, and trends to aid marketing and analytics teams in forecasting and strategic decision-making.
- **Accessibility and Localization**: Generate subtitles, translate slides into multiple languages, or integrate content with screen-reading software for improved access.
- **Text Positioning and Visual Analysis**: Beyond text itself, analyzing layout and positioning helps ensure proper slide structure, formatting, and alignment with corporate guidelines.
This article explores several popular presentation file formats and how each affects the text extraction process.
## **Overview of Presentation Formats**
### **PPT (Legacy PowerPoint Format)**
Originally used by Microsoft PowerPoint until 2007, **PPT** was prevalent in **MS Office 97–2003**. As a **binary format**, PPT is more difficult to process without specialized tools than modern XML-based formats.
**Main Difficulties in Text Extraction**
- Proprietary binary structure makes **data access** challenging without the official Microsoft API or specialized libraries.
- **Text may appear** in multiple locations (slides, notes, comments), requiring a comprehensive approach to extraction.
- **Encoding and font conflicts** can arise when dealing with custom characters.
### **PPTX (Open XML Specification)**
Introduced in **PowerPoint 2007**, **PPTX** is built on **Office Open XML**, an XML-based standard that simplifies text extraction.
**File Structure Basics**
- PPTX files are **ZIP archives** containing multiple **XML documents**.
- Slides, notes sections, and metadata each reside in separate **XML files**.
**Extracting Text from Structured XML**
PPTX allows more efficient text extraction due to its clear XML organization:
- **Text resides in `ppt/slides/slideX.xml`** within `` tags.
- **Notes and comments** are found in `ppt/notesSlides/`.
- **Retaining formatting** may require parsing additional XML attributes.
### **ODP (OpenDocument Presentation)**
Based on the **OpenDocument Format (ODF)**, **ODP** is commonly used in open-source office suites such as **LibreOffice Impress**.
**Differences from PPTX**
- Relies on **OpenDocument XML**, not Open XML.
- Structurally similar but **uses different tags and a distinct hierarchy**.
- Text is often stored in **content.xml** within `` elements.
## **Conclusion**
A solid grasp of presentation file structures is paramount for successful text extraction. Although **PPTX and ODP** offer XML-based transparency, older **PPT** files demand additional steps due to their binary nature. Specialized tools and libraries designed for each format help automate and optimize the extraction process, ensuring that extracted data can power a broad array of use cases—from robust indexing to comprehensive accessibility solutions.
## Related articles
- [Extracting Text from PPT, PPTX, ODP](https://docs.aspose.com/slides/php-java/extracting-text-from-ppt-pptx-odp-on-cloud-platforms/)
# Manage Slide Transitions in Presentations Using PHP
> Apply slide transitions, configure automatic slide advancement, and customize Morph and other transition effects with Aspose.Slides for PHP via Java.
Source: https://docs.aspose.com/slides/php-java/slide-transition/
Updated: 2026-11-17
## **Overview**
Slide transitions control how slides appear during a slide show. With Aspose.Slides for PHP via Java, you can choose a transition effect for each slide, configure advancement by mouse click or timer, and adjust options specific to an effect. This article uses PHP examples to apply transitions, set exact transition durations, manage slide timing, and create a Morph transition between two slides. The examples also show how to save the settings to a PPTX file.
## **Add Slide Transition**
To apply a transition, load a presentation with the [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) class and access the slide's transition settings through [getSlideShowTransition](https://reference.aspose.com/slides/php-java/aspose.slides/baseslide/#getSlideShowTransition). Use [setType](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setType) with a value from the [TransitionType](https://reference.aspose.com/slides/php-java/aspose.slides/transitiontype/) enumeration, then save the presentation.
The following example applies a Circle transition to the first slide and a Comb transition to the second. Use an `input.pptx` file with at least two slides.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TransitionType;
$presentation = new Presentation("input.pptx");
try {
if (java_values($presentation->getSlides()->size()) >= 2) {
$presentation->getSlides()->get_Item(0)->getSlideShowTransition()->setType(TransitionType::Circle);
$presentation->getSlides()->get_Item(1)->getSlideShowTransition()->setType(TransitionType::Comb);
$presentation->save("slide-transitions.pptx", SaveFormat::Pptx);
} else {
echo "The input presentation must contain at least two slides." . PHP_EOL;
}
} finally {
$presentation->dispose();
}
```
## **Wheel Transition**
The [setSpokes](https://reference.aspose.com/slides/php-java/aspose.slides/wheeltransition/#setSpokes) method controls how many radial sectors reveal the destination slide. Use [setType](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setType) to select Wheel from [TransitionType](https://reference.aspose.com/slides/php-java/aspose.slides/transitiontype/), then call [getValue](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#getValue) to access the [WheelTransition](https://reference.aspose.com/slides/php-java/aspose.slides/wheeltransition/) settings.
The example creates two identical pairs of slides. Each pair starts with a black slide and ends with a slide covered by a gold rectangle. Slide 2 uses one spoke and slide 4 uses eight. Both transitions use the same slow speed, set with [setSpeed](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setSpeed), and an explicit duration of 8,000 milliseconds, set with [setDuration](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setDuration).
```php
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\TransitionSpeed;
use aspose\slides\TransitionType;
use java\awt\Color;
$presentation = new Presentation();
try {
$slides = $presentation->getSlides();
$width = java_values($presentation->getSlideSize()->getSize()->getWidth());
$height = java_values($presentation->getSlideSize()->getSize()->getHeight());
$blackSlide = $slides->get_Item(0);
$blackSlide->getShapes()->clear();
$background = $blackSlide->getBackground();
$background->setType(BackgroundType::OwnBackground);
$background->getFillFormat()->setFillType(FillType::Solid);
$black = new Color(0, 0, 0);
$background->getFillFormat()->getSolidFillColor()->setColor($black);
$destinationSlide = $slides->addClone($blackSlide);
$rectangle = $destinationSlide->getShapes()->addAutoShape(ShapeType::Rectangle, 0, 0, $width, $height);
$rectangle->getFillFormat()->setFillType(FillType::Solid);
$gold = new Color(255, 215, 0);
$rectangle->getFillFormat()->getSolidFillColor()->setColor($gold);
$rectangle->getTextFrame()->setText("Wheel transition");
$slides->addClone($blackSlide);
$slides->addClone($destinationSlide);
foreach ([1 => 1, 3 => 8] as $slideIndex => $spokes) {
$transition = $slides->get_Item($slideIndex)->getSlideShowTransition();
$transition->setType(TransitionType::Wheel);
$transition->getValue()->setSpokes($spokes);
$transition->setSpeed(TransitionSpeed::Slow);
$transition->setDuration(8000);
}
$presentation->save("wheel-transitions.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Open the saved presentation in PowerPoint and start the slide show. Advance from slide 1 to slide 2 to see a single clockwise sweep. Then advance from slide 3 to slide 4 to see eight radial sectors reveal the same rectangle simultaneously.
## **Add Advanced Slide Transition**
You can configure how long a slide remains on screen and whether a mouse click advances the slide show. The following methods control this behavior:
- [setAdvanceOnClick](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setAdvanceOnClick) allows the viewer to advance by clicking the mouse.
- [setAdvanceAfter](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setAdvanceAfter) enables automatic advancement.
- [setAdvanceAfterTime](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setAdvanceAfterTime) specifies the delay before automatic advancement, in milliseconds.
Enable both click and timed advancement to let the viewer move on with a click or wait for the timer. To use only the timer, pass `false` to [setAdvanceOnClick](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setAdvanceOnClick). The delay controls when the slide show advances; it does not set the duration of the visual transition effect.
This example assigns different effects to the first three slides and enables automatic advancement after 3, 5, and 7 seconds, respectively. Mouse clicks can also advance these slides. Use an `input.pptx` file with at least three slides.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TransitionType;
$presentation = new Presentation("input.pptx");
try {
if (java_values($presentation->getSlides()->size()) >= 3) {
$firstTransition = $presentation->getSlides()->get_Item(0)->getSlideShowTransition();
$firstTransition->setType(TransitionType::Circle);
$firstTransition->setAdvanceOnClick(true);
$firstTransition->setAdvanceAfter(true);
$firstTransition->setAdvanceAfterTime(3000);
$secondTransition = $presentation->getSlides()->get_Item(1)->getSlideShowTransition();
$secondTransition->setType(TransitionType::Comb);
$secondTransition->setAdvanceOnClick(true);
$secondTransition->setAdvanceAfter(true);
$secondTransition->setAdvanceAfterTime(5000);
$thirdTransition = $presentation->getSlides()->get_Item(2)->getSlideShowTransition();
$thirdTransition->setType(TransitionType::Zoom);
$thirdTransition->setAdvanceOnClick(true);
$thirdTransition->setAdvanceAfter(true);
$thirdTransition->setAdvanceAfterTime(7000);
$presentation->save("advanced-transitions.pptx", SaveFormat::Pptx);
} else {
echo "The input presentation must contain at least three slides." . PHP_EOL;
}
} finally {
$presentation->dispose();
}
```
To check whether timed advancement is enabled, call [getAdvanceAfter](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#getAdvanceAfter). A stored delay alone does not indicate that the timer is active.
The next example opens the file saved above, reports each enabled timer, and disables automatic advancement for slides with a delay greater than two seconds. It enables mouse clicks for those slides and saves the updated settings.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("advanced-transitions.pptx");
try {
for ($slideIndex = 0; $slideIndex < java_values($presentation->getSlides()->size()); $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$transition = $slide->getSlideShowTransition();
if (java_values($transition->getAdvanceAfter())) {
echo "Slide " . java_values($slide->getSlideNumber()) . ": advance after " . java_values($transition->getAdvanceAfterTime()) . " ms." . PHP_EOL;
if (java_values($transition->getAdvanceAfterTime()) > 2000) {
$transition->setAdvanceAfter(false);
$transition->setAdvanceOnClick(true);
}
}
}
$presentation->save("adjusted-transitions.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Control Transition Timing Precisely**
Use [setDuration](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setDuration) to specify the exact length of a transition effect in milliseconds. The slide's [getSlideShowTransition](https://reference.aspose.com/slides/php-java/aspose.slides/baseslide/#getSlideShowTransition) method exposes these settings through [SlideShowTransition](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/):
| Method | Purpose |
| --- | --- |
| [setDuration](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setDuration) | Sets the duration of the transition effect itself, in milliseconds. |
| [setAdvanceAfterTime](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setAdvanceAfterTime) | Sets the delay before the slide advances automatically, in milliseconds. Pass `true` to [setAdvanceAfter](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setAdvanceAfter) to activate this timer. |
| [setSpeed](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setSpeed) | Selects a predefined speed category from [TransitionSpeed](https://reference.aspose.com/slides/php-java/aspose.slides/transitionspeed/): Slow, Medium, or Fast. It is used when an exact duration is not specified. |
[setDuration](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setDuration) controls only the transition effect; it does not determine how long the slide remains visible. Configure the automatic advancement delay separately. When no explicit duration is set, Aspose.Slides determines the effect duration from the transition type and the [getSpeed](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#getSpeed) value.
[](https://docs.aspose.com/slides/php-java/slide-transition/visual-slide-transition-1f705a740cf6.svg)
*The shared example gives each slide a 750-ms Fade transition and separately enables automatic advancement at 5,000 ms. Transition duration controls the effect; advancement controls when to leave the slide. These bars are schematic settings, not a measured combined timeline.*
### **Apply the Same Duration to Every Slide**
For consistent pacing, apply the same effect and exact duration to every slide. This example loads `input.pptx`, selects Fade from [TransitionType](https://reference.aspose.com/slides/php-java/aspose.slides/transitiontype/), and gives each transition a duration of 750 milliseconds. It separately enables automatic advancement after 5,000 milliseconds and disables advancement by mouse click, then saves the result as PPTX.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TransitionType;
$presentation = new Presentation("input.pptx");
try {
for ($slideIndex = 0; $slideIndex < java_values($presentation->getSlides()->size()); $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$transition = $slide->getSlideShowTransition();
$transition->setType(TransitionType::Fade);
$transition->setDuration(750);
// Configure automatic advancement independently of the effect duration.
$transition->setAdvanceAfter(true);
$transition->setAdvanceAfterTime(5000);
$transition->setAdvanceOnClick(false);
}
$presentation->save("precise-transitions.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
### **Set Different Durations for Individual Slides**
Different slides can use different effect durations. For example, use a brief transition for a title slide and a longer transition for a section introduction. This example sets 500 milliseconds for the first slide and 1,200 milliseconds for the second. Use an `input.pptx` file with at least two slides.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TransitionType;
$presentation = new Presentation("input.pptx");
try {
if (java_values($presentation->getSlides()->size()) >= 2) {
$firstTransition = $presentation->getSlides()->get_Item(0)->getSlideShowTransition();
$firstTransition->setType(TransitionType::Fade);
$firstTransition->setDuration(500);
$secondTransition = $presentation->getSlides()->get_Item(1)->getSlideShowTransition();
$secondTransition->setType(TransitionType::Push);
$secondTransition->setDuration(1200);
$presentation->save("individual-transition-durations.pptx", SaveFormat::Pptx);
} else {
echo "The input presentation must contain at least two slides." . PHP_EOL;
}
} finally {
$presentation->dispose();
}
```
### **Coordinate Transitions with Animated Output**
When preparing an [animated GIF](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-animated-gif/), [HTML5 presentation](https://docs.aspose.com/slides/php-java/export-to-html5/), or [video](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-video/), set exact transition durations before export to match the intended pacing. For example, use a 600-millisecond fade between scenes, and adjust each slide's advancement delay separately to allow time for its narration or content.
For GIF and video, coordinate the output frame rate with the effect duration: 600 milliseconds corresponds to 18 frames at 30 frames per second. In HTML5, enable animated transitions in the export settings. Check the chosen export format's supported effects and timing options, and preview the output to confirm synchronization.
### **Read an Existing Transition Duration**
Call [getDuration](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#getDuration) before modifying the transition to determine whether an explicit value is stored. A value of `-1` means no explicit duration is set; a nonnegative value specifies the stored duration in milliseconds. The unset value is not the calculated playback duration: Aspose.Slides uses the transition type and the [getSpeed](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#getSpeed) value to determine that duration. Setting a transition type can initialize a duration, so inspect the original settings first.
```php
use aspose\slides\Presentation;
$presentation = new Presentation("input.pptx");
try {
for ($slideIndex = 0; $slideIndex < java_values($presentation->getSlides()->size()); $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$transition = $slide->getSlideShowTransition();
$duration = java_values($transition->getDuration());
if ($duration >= 0) {
echo "Slide " . java_values($slide->getSlideNumber()) . ": stored transition duration is " . $duration . " ms." . PHP_EOL;
} else {
echo "Slide " . java_values($slide->getSlideNumber()) . ": no explicit duration; timing depends on transition type " . java_values($transition->getType()) . " and speed " . java_values($transition->getSpeed()) . "." . PHP_EOL;
}
}
} finally {
$presentation->dispose();
}
```
## **Morph Transition**
The Morph transition animates changes between objects on consecutive slides. To create a simple Morph effect, clone a slide, move or resize an object on the clone, and apply the Morph transition to the second slide. This gives the transition corresponding objects to animate between their original and modified states.
The following example creates a slide with a text rectangle, clones the slide, and changes the rectangle's position and size on the clone. It then selects Morph from the [TransitionType](https://reference.aspose.com/slides/php-java/aspose.slides/transitiontype/) enumeration for the second slide. Open the saved file in a presentation viewer that supports Morph to see the effect during a slide show.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\TransitionType;
$presentation = new Presentation();
try {
$firstSlide = $presentation->getSlides()->get_Item(0);
$rectangle = $firstSlide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 400, 100);
$rectangle->getTextFrame()->setText("Morph transition");
$secondSlide = $presentation->getSlides()->addClone($firstSlide);
$movedRectangle = $secondSlide->getShapes()->get_Item(0);
$movedRectangle->setX(java_values($movedRectangle->getX()) + 100);
$movedRectangle->setY(java_values($movedRectangle->getY()) + 50);
$movedRectangle->setWidth(java_values($movedRectangle->getWidth()) - 200);
$movedRectangle->setHeight(java_values($movedRectangle->getHeight()) - 10);
$secondSlide->getSlideShowTransition()->setType(TransitionType::Morph);
$presentation->save("morph-transition.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Morph Transition Types**
The [TransitionMorphType](https://reference.aspose.com/slides/php-java/aspose.slides/transitionmorphtype/) enumeration controls how Morph matches and animates content:
- [ByObject](https://reference.aspose.com/slides/php-java/aspose.slides/transitionmorphtype/#ByObject) treats each shape as a whole object.
- [ByWord](https://reference.aspose.com/slides/php-java/aspose.slides/transitionmorphtype/#ByWord) animates text by matching words where possible.
- [ByChar](https://reference.aspose.com/slides/php-java/aspose.slides/transitionmorphtype/#ByChar) animates text by matching characters where possible.
Use [setType](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setType) to select Morph before accessing [getValue](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#getValue). The value then provides a [MorphTransition](https://reference.aspose.com/slides/php-java/aspose.slides/morphtransition/) object, whose [setMorphType](https://reference.aspose.com/slides/php-java/aspose.slides/morphtransition/#setMorphType) method selects the matching mode.
This example opens the presentation created in the previous section and configures the second slide to use word-based Morph animation.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TransitionMorphType;
use aspose\slides\TransitionType;
$presentation = new Presentation("morph-transition.pptx");
try {
if (java_values($presentation->getSlides()->size()) >= 2) {
$transition = $presentation->getSlides()->get_Item(1)->getSlideShowTransition();
$transition->setType(TransitionType::Morph);
$morphTransition = $transition->getValue();
if (!java_is_null($morphTransition)) {
$morphTransition->setMorphType(TransitionMorphType::ByWord);
$presentation->save("morph-by-word.pptx", SaveFormat::Pptx);
} else {
echo "Morph transition options are unavailable." . PHP_EOL;
}
} else {
echo "The input presentation must contain at least two slides." . PHP_EOL;
}
} finally {
$presentation->dispose();
}
```
## **Set Transition Effects**
Some transitions expose additional options, such as direction or whether the effect starts from a black screen. The available options depend on the transition selected with [setType](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setType). Set the type first, then use the appropriate transition object from [getValue](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#getValue).
The following example applies a Cut transition to the first slide of `input.pptx`. It calls [setFromBlack](https://reference.aspose.com/slides/php-java/aspose.slides/optionalblacktransition/#setFromBlack) through [OptionalBlackTransition](https://reference.aspose.com/slides/php-java/aspose.slides/optionalblacktransition/) so that the transition starts from a black screen.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TransitionType;
$presentation = new Presentation("input.pptx");
try {
$transition = $presentation->getSlides()->get_Item(0)->getSlideShowTransition();
$transition->setType(TransitionType::Cut);
$cutTransition = $transition->getValue();
if (!java_is_null($cutTransition)) {
$cutTransition->setFromBlack(true);
$presentation->save("cut-from-black.pptx", SaveFormat::Pptx);
} else {
echo "Cut transition options are unavailable." . PHP_EOL;
}
} finally {
$presentation->dispose();
}
```
## **FAQ**
**Can I control the playback speed of a slide transition?**
Yes. Prefer [setDuration](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setDuration) when you need an exact effect duration in milliseconds. Use [setSpeed](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setSpeed) when a predefined [TransitionSpeed](https://reference.aspose.com/slides/php-java/aspose.slides/transitionspeed/) category—Slow, Medium, or Fast—is sufficient and no explicit duration is set. These settings control the transition effect independently of the automatic advancement delay.
**Can I attach audio to a transition and make it loop?**
Yes. Assign embedded audio with [setSound](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setSound), pass StartSound from the [TransitionSoundMode](https://reference.aspose.com/slides/php-java/aspose.slides/transitionsoundmode/) enumeration to [setSoundMode](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setSoundMode), and enable [setSoundLoop](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setSoundLoop) with `true`. The audio loops until the next sound event in the slide show.
**What's the fastest way to apply the same transition to every slide?**
Loop through the presentation's [getSlides](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getSlides) collection and call [setType](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#setType) with the same value for each slide's transition. Set any timing and effect options in the same loop to keep the behavior consistent across slides.
**How can I check which transition is currently set on a slide?**
Call [getType](https://reference.aspose.com/slides/php-java/aspose.slides/slideshowtransition/#getType) on the slide's [getSlideShowTransition](https://reference.aspose.com/slides/php-java/aspose.slides/baseslide/#getSlideShowTransition) result. It returns a value from the [TransitionType](https://reference.aspose.com/slides/php-java/aspose.slides/transitiontype/) enumeration; None means that no transition effect is applied.
## Related articles
- [SlideTransition](https://docs.aspose.com/slides/php-java/examples/elements/slide-transition/)
# Slides on Cloud Platforms
> See how Aspose.Slides runs on major cloud platforms, with deployment tips, scaling guidance, and best practices for processing PowerPoint and OpenDocument.
Source: https://docs.aspose.com/slides/php-java/slides-on-cloud-platforms/
Updated: 2025-12-01
---
lastmod: 2025-12-01T11:46:27+04:00
title: Slides on Cloud Platforms
type: docs
weight: 40
url: /php-java/slides-on-cloud-platforms/
keywords:
- cloud platforms
- cloud integration
- PowerPoint automation
- text extraction
- Google integration
- PowerPoint
- OpenDocument
- presentation
- PHP
- Aspose.Slides
description: "See how Aspose.Slides runs on major cloud platforms, with deployment tips, scaling guidance, and best practices for processing PowerPoint and OpenDocument."
---
## Related articles
- [Extracting Text from PPT, PPTX, ODP](https://docs.aspose.com/slides/php-java/extracting-text-from-ppt-pptx-odp-on-cloud-platforms/)
# Manage Superscript and Subscript in Presentations Using PHP
> Master superscript and subscript in Aspose.Slides for PHP via Java and elevate your presentations with professional text formatting for maximum impact.
Source: https://docs.aspose.com/slides/php-java/superscript-and-subscript/
Updated: 2026-08-02
## **Overview**
Aspose.Slides provides features for integrating superscript and subscript text into your PowerPoint (PPT, PPTX) and OpenDocument (ODP) presentations. Whether you need to highlight chemical formulas, mathematical equations, or annotate content with footnotes, these specialized formatting options help maintain clarity and precision. In this article, you'll learn how to seamlessly apply superscript and subscript styles and ensure professional results in every slide.
## **Manage Superscript and Subscript Text**
You can add superscript and subscript text inside any paragraph portion. For adding Superscript or Subscript text in Aspose.Slides text frame one must use the [**setEscapement**](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setEscapement) method of [PortionFormat](https://reference.aspose.com/slides/php-java/aspose.slides/PortionFormat) class.
This property returns or sets the superscript or subscript text (value from -100% (subscript) to 100% (superscript). For example:
- Create an instance of [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/Presentation) class.
- Obtain the reference of a slide by using its Index.
- Add an [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/) of [Rectangle](https://reference.aspose.com/slides/php-java/aspose.slides/ShapeType#Rectangle) type to the slide.
- Access the [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/) associated with the [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/).
- Clear existing Paragraphs
- Create a new paragraph object for holding superscript text and add it to the [IParagraphs collection](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/#getParagraphs) of the [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/).
- Create a new portion object
- Set Escapement property for the portion between 0 to 100 for adding superscript. (0 mean no superscript)
- Set some text for [Portion](https://reference.aspose.com/slides/php-java/aspose.slides/Portion) and then add that in portion collection of paragraph.
- Create a new paragraph object for holding subscript text and add it to the IParagraphs collection of the ITextFrame.
- Create a new portion object
- Set Escapement property for portion between 0 to -100 for adding superscript. (0 mean no subscript)
- Set some text for [Portion](https://reference.aspose.com/slides/php-java/aspose.slides/Portion) and then add that in portion collection of paragraph.
- Save the presentation as a PPTX file.
The implementation of the above steps is given below.
```php
# Instantiate a Presentation class that represents a PPTX
$pres = new Presentation();
try {
# Get slide
$slide = $pres->getSlides()->get_Item(0);
# Create text box
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 200, 100);
$textFrame = $shape->getTextFrame();
$textFrame->getParagraphs()->clear();
# Create paragraph for superscript text
$superPar = new Paragraph();
# Create portion with usual text
$portion1 = new Portion();
$portion1->setText("SlideTitle");
$superPar->getPortions()->add($portion1);
# Create portion with superscript text
$superPortion = new Portion();
$superPortion->getPortionFormat()->setEscapement(30);
$superPortion->setText("TM");
$superPar->getPortions()->add($superPortion);
# Create paragraph for subscript text
$paragraph2 = new Paragraph();
# Create portion with usual text
$portion2 = new Portion();
$portion2->setText("a");
$paragraph2->getPortions()->add($portion2);
# Create portion with subscript text
$subPortion = new Portion();
$subPortion->getPortionFormat()->setEscapement(-25);
$subPortion->setText("i");
$paragraph2->getPortions()->add($subPortion);
# Add paragraphs to text box
$textFrame->getParagraphs()->add($superPar);
$textFrame->getParagraphs()->add($paragraph2);
$pres->save("formatText.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
```
## **FAQ**
### Will superscript and subscript be preserved when exporting to PDF or other formats?
Yes, Aspose.Slides properly retains superscript and subscript formatting when exporting presentations to PDF, PPT/PPTX, images, and other supported formats. The specialized formatting remains intact in all output files.
### Can superscript and subscript be combined with other formatting styles such as bold or italics?
Yes, Aspose.Slides allows you to mix various text styles within a single portion of text. You can enable bold, italics, underline, and simultaneously apply superscript or subscript by configuring the corresponding properties in [PortionFormat](https://reference.aspose.com/slides/php-java/aspose.slides/portionformat/).
### Do superscript and subscript formatting work for text inside tables, charts, or SmartArt?
Yes, Aspose.Slides supports formatting within most objects, including tables and chart elements. When working with SmartArt, you need to access the appropriate elements (such as [SmartArtNode](https://reference.aspose.com/slides/php-java/aspose.slides/smartartnode/)) and their text containers, and then configure the [PortionFormat](https://reference.aspose.com/slides/php-java/aspose.slides/portionformat/) properties in a similar manner.
## Related articles
- [Manage Presentation Text in PHP](https://docs.aspose.com/slides/php-java/manage-text/)
# Supported File Formats
> Discover all file formats Aspose.Slides for PHP via Java can open, save, and convert — including PPT, PPTX and ODP — with clear import/export support notes.
Source: https://docs.aspose.com/slides/php-java/supported-file-formats/
Updated: 2026-08-02
## **Overview**
Aspose.Slides supports presentation files from Microsoft PowerPoint 97 through Office 365, including Microsoft PowerPoint for Mac. This article lists the PowerPoint versions supported by the library and provides a table of file formats that can be loaded, saved, or both.
The article also answers common questions about PDF compliance, font embedding, password-protected files, custom fonts, font fallback, and XPS export options.
## **Supported Microsoft PowerPoint Versions**
- Microsoft PowerPoint 97
- Microsoft PowerPoint 2000
- Microsoft PowerPoint XP
- Microsoft PowerPoint 2003
- Microsoft PowerPoint 2007
- Microsoft PowerPoint 2010
- Microsoft PowerPoint 2013
- Microsoft PowerPoint 2016
- Microsoft PowerPoint 2019
- Microsoft PowerPoint for MAC
- Office 365
## **Supported File Formats**
This table contains the file formats that Aspose.Slides for PHP via Java can load and save:
|**Format**|**Description**|**Load**|**Save**|**Remarks**|
| :- | :- | :- | :- | :- |
|[PPT](https://docs.fileformat.com/presentation/ppt/)|PowerPoint 97-2003 Presentation|✓|✓| |
|[POT](https://docs.fileformat.com/presentation/pot/)|PowerPoint 97-2003 Template|✓|✓| |
|[PPS](https://docs.fileformat.com/presentation/pps/)|PowerPoint 97-2003 Show|✓|✓| |
|[PPTX](https://docs.fileformat.com/presentation/pptx/)|PowerPoint Presentation|✓|✓| |
|[POTX](https://docs.fileformat.com/presentation/potx/)|PowerPoint Template|✓|✓| |
|[PPSX ](https://docs.fileformat.com/presentation/ppsx/)|PowerPoint Show|✓|✓| |
|[PPTM](https://docs.fileformat.com/presentation/pptm/)|PowerPoint Macro-Enabled Presentation|✓|✓| |
|[PPSM](https://docs.fileformat.com/presentation/ppsm/)|PowerPoint Macro-Enabled Show|✓|✓| |
|[POTM](https://docs.fileformat.com/presentation/potm/)|PowerPoint Macro-Enabled Template|✓|✓| |
|[ODP/FODP](https://docs.fileformat.com/presentation/odp/)|OpenDocument Presentation|✓|✓| |
|[OTP](https://docs.fileformat.com/presentation/otp/)|OpenDocument Presentation Template|✓|✓| |
|[TIFF](https://docs.fileformat.com/image/tiff/)|Tag Image File Format| |✓| |
|[EMF](https://docs.fileformat.com/image/emf/)|Enhanced Metafile Format| |✓| |
|[PDF](https://docs.fileformat.com/pdf/)|Portable Document Format|✓|✓| |
|[XPS](https://docs.fileformat.com/page-description-language/xps/)|XML Paper Specification| |✓| |
|[JPEG](https://docs.fileformat.com/image/jpeg/)|Joint Photographic Experts Group| |✓| |
|[PNG](https://docs.fileformat.com/image/png/)|Portable Network Graphics| |✓| |
|[GIF](https://docs.fileformat.com/image/gif/)|Graphics Interchange Format| |✓| |
|[BMP](https://docs.fileformat.com/image/bmp/)|Device Independent Bitmap| |✓| |
|[SVG](https://docs.fileformat.com/page-description-language/svg/)|Scalable Vector Graphics| |✓| |
|[SWF](https://docs.fileformat.com/page-description-language/swf/)|Small Web Format| |✓| |
|[HTML](https://docs.fileformat.com/web/html/)|Hypertext Markup Language|✓|✓| |
|[XAML](https://docs.fileformat.com/web/xaml/)|Extensible Application Markup Language| |✓| |
|[MD](https://docs.fileformat.com/word-processing/md/)|Markdown| |✓| |
|[XML](https://docs.fileformat.com/web/xml/)|PowerPoint XML Presentation| |✓| |
## **FAQ**
### Can I save presentations to PDF that meet archival and accessibility standards (PDF/A and PDF/UA)?
Yes. Aspose.Slides supports exporting to PDF with compliance levels such as PDF/A-2a, PDF/A-2b, PDF/A-2u, PDF/A-3a, PDF/A-3b, as well as PDF/UA through the [compliance](https://reference.aspose.com/slides/php-java/aspose.slides/pdfoptions/setcompliance/) setting in [PDF export options](https://reference.aspose.com/slides/php-java/aspose.slides/pdfoptions/).
### Does the library support font embedding when exporting to PDF, with fine-grained control over what gets embedded?
Yes. You can control whether fonts are fully embedded or subsetted (only used glyphs), specify how common system fonts are treated, and configure behavior for ASCII text through [PDF export options](https://reference.aspose.com/slides/php-java/aspose.slides/pdfoptions/).
### Can I detect whether a file is password-protected before actually loading it?
Yes. Using the [factory-based inspection API](https://reference.aspose.com/slides/php-java/aspose.slides/presentationfactory/), you can query a presentation file to determine if it is password-protected without opening it fully.
### Are there font fallback mechanisms and support for custom fonts?
Yes. The library supports [loading](https://docs.aspose.com/slides/php-java/custom-font/) and [embedding](https://docs.aspose.com/slides/php-java/embedded-font/) custom fonts and provides font [fallback rules](https://docs.aspose.com/slides/php-java/fallback-font/) to prevent missing glyphs during rendering and conversion.
### Can I export slides to XPS, and are there options to tune the XPS output?
Yes. [Export to XPS](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-xps/) is supported, and you can adjust relevant [save options](https://reference.aspose.com/slides/php-java/aspose.slides/xpsoptions/) to control the output quality and content of the XPS document.
## Related articles
- [Convert Presentations to Multiple Formats in PHP](https://docs.aspose.com/slides/php-java/convert-presentation/)
# System Requirements
> Discover Aspose.Slides for PHP via Java system requirements. Ensure seamless PowerPoint and OpenDocument support on Windows, Linux, and macOS.
Source: https://docs.aspose.com/slides/php-java/system-requirements/
Updated: 2026-08-02
## **Introduction**
Aspose.Slides for PHP via Java does not require any third party product such as Microsoft PowerPoint to be installed. Aspose.Slides itself is an engine for creating, modifying, converting, and rendering of documents in various formats, including Microsoft PowerPoint presentation formats.
## **Supported Operating Systems**
Aspose.Slides for Java supports any 32-bit or 64-bit operating system that runs the Java runtime including, but not limited:
### **Windows**
- Microsoft Windows 2003 Server ( x64, x86)
- Microsoft Windows 2008 Server ( x64, x86)
- Microsoft Windows 2012 Server ( x64, x86)
- Microsoft Windows 2012 R2 Server ( x64, x86)
- Microsoft Windows 2016 Server ( x64, x86)
- Microsoft Windows 2019 Server ( x64, x86)
- Microsoft Windows Vista ( x64, x86)
- Microsoft Windows XP ( x64, x86)
- Microsoft Windows 7 ( x64, x86)
- Microsoft Windows 8, 8.1 ( x64, x86)
- Microsoft Windows 10 ( x64, x86)
### **Linux**
- Linux (Ubuntu, OpenSUSE, CentOS and others)
### **Mac**
- Mac OS X
## **FAQ**
### Do I need Microsoft PowerPoint installed for conversions and rendering?
No, PowerPoint is not required; Aspose.Slides is a standalone engine for [creating](https://docs.aspose.com/slides/php-java/create-presentation/), modifying, [converting](https://docs.aspose.com/slides/php-java/convert-presentation/), and [rendering](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-png/) presentations.
### Which fonts are needed for correct rendering?
In practice, the fonts used in the presentation or proper [substitutes](https://docs.aspose.com/slides/php-java/font-substitution/) must be available. To ensure consistent rendering on Linux/macOS, it is advisable to install common font packages.
### Why does a custom font render as a fallback or missing text on Linux?
If the font file has inconsistent or corrupted name-table entries, the Linux font-matching stack (FreeType/fontconfig) may select an invalid record, causing the font to be unresolved. Using a font version with corrected name-table records or installing a consistent replacement resolves the issue.
# Tagged Image File Format (TIFF)
>
Source: https://docs.aspose.com/slides/php-java/tagged-image-file-format-tiff/
Updated: 2026-01-23
## **About TIFF**
The [Tagged Image File Format](https://en.wikipedia.org/wiki/TIFF) which is known for storing multiple images in one document was originally created by Aldus. This format is widely supported by scanning, faxing and other image manipulation applications.
## **TIFF in Aspose.Slides for PHP via Java**
Any document that can be loaded in Aspose.Slide for Java can also be converted to TIFF document directly by Aspose.Slides for PHP via Java eliminating requirement of any third party component. Further, you can optionally define the size of the images in the resulting TIFF document. You can find information about exporting the presentation documents to TIFF documents through Aspose.Slides for PHP via Java in [this topic](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-tiff/).
**A Presentation Document Converted to TIFF Document through Aspose.Slides for PHP via Java**
 **
# Technical Articles
> Technical articles for Aspose.Slides for PHP via Java: OLE, chart, HTML export, threading, and more—best practices for the PPT, PPTX and ODP formats.
Source: https://docs.aspose.com/slides/php-java/technical-articles/
Updated: 2025-12-01
---
lastmod: 2025-12-01T11:46:27+04:00
title: Technical Articles
type: docs
weight: 270
url: /php-java/technical-articles/
keywords:
- technical article
- OLE object
- worksheet resizing
- embed Excel cnart
- chart resizing
- prevent editing
- shape lock
- extract image
- slide backgroud
- export presentation
- externally linked image
- warning callback
- font substitution
- resize shape
- interruptable library
- background task
- multithreading
- API limitations
- integrate Excel data
- PowerPoint
- OpenDocument
- presentation
- PHP
- Aspose.Slides
description: "Technical articles for Aspose.Slides for PHP via Java: OLE, chart, HTML export, threading, and more—best practices for the PPT, PPTX and ODP formats."
---
# Technical Support
> Get fast, free technical support for Aspose.Slides for PHP, learn how to report issues effectively, and keep your PPT, PPTX and ODP projects running smoothly.
Source: https://docs.aspose.com/slides/php-java/technical-support/
Updated: 2026-08-13
## **Overview**
This article explains how to get support for Aspose.Slides and how to report issues effectively. It describes the main support channel, provides recommendations for submitting a problem, and points to useful technical resources such as the product page, blog, downloads, support forum, documentation, and API Reference. The article also answers common questions about paid support, issue escalation, and support for older library versions.
## **Technical support**
Aspose provides unlimited free technical support for all its products. The support is available to all users, including evaluation.
If you need help with Aspose.Slides for PHP via Java, consider the following:
- The main avenue for support is the Aspose.Forums. Post your question in the Aspose.Slides forum and it will be answered within a few hours. The questions are answered directly by the Aspose.Slides support team.
- Please note, Aspose does not provide technical support over the phone. Phone support is only available for sales and purchase questions.
- When expecting a reply in the forums, please allow for time zone differences.
If you have an issue with Aspose.Slides for PHP via Java, follow these simple steps to make sure it is resolved in the most efficient way:
- Make sure you use the latest Aspose.Slides for PHP via Java version before reporting the issue, see Aspose.Slides download to find out about the latest version.
- Have a look through the forums, this documentation and API Reference before reporting the issue; maybe your question was already answered.
- When reporting an issue, please include the original document and possibly a fragment of your code that causes the problem. If you need to attach multiple files, zip them into one. It is safe to attach your documents in Aspose.Forums since only you and Aspose developers will have access to the attached files.
- Please try to report one issue per thread. If you have another issue, report it in a separate thread.
## **FAQ**
### What paid support tiers are available and how do they differ?
[Developer, Business, and Enterprise](https://helpdesk.aspose.com/kb/faq/1-Introduction-to-Paid-Support-Services). They differ by the number of incidents included, response priority, and available communication channels.
### Can I escalate a bug directly to the engineering team?
Yes. [Paid support](https://helpdesk.aspose.com/) allows escalation to the developers when an issue requires deeper investigation.
### Are older library versions supported, and do you release fixes for them?
You can use older versions, but fixes are provided for the current release; patches for legacy versions are not issued.
## Related articles
- [Product Support](https://docs.aspose.com/slides/php-java/product-support/)
- [Product Overview](https://docs.aspose.com/slides/php-java/product-overview/)
- [Resources](https://docs.aspose.com/slides/php-java/resources/)
# Manage Text Fields in PowerPoint Presentations in PHP
> Create, inspect, modify, and remove text fields in PowerPoint presentations with Aspose.Slides for PHP via Java. Preserve formatting and verify saved PPTX and PPT files.
Source: https://docs.aspose.com/slides/php-java/text-fields/
Updated: 2026-09-21
## **Overview**
A text paragraph consists of portions. An ordinary [Portion](https://reference.aspose.com/slides/php-java/aspose.slides/portion/) contains literal text; a field portion also has a [Field](https://reference.aspose.com/slides/php-java/aspose.slides/field/) whose type identifies an automatically updated value, such as a slide number or date. Two portions can display the same characters while only one contains a field.
Use [Portion::getField](https://reference.aspose.com/slides/php-java/aspose.slides/portion/#getField) to distinguish them: it is `null` for ordinary text. [Portion::addField](https://reference.aspose.com/slides/php-java/aspose.slides/portion/#addField) converts an existing portion into a field. Keep a label and its dynamic value in separate portions so that converting the value does not also replace the label.
This guide covers fields inside text, their formatting, and saving them in PPTX and PPT. For text frames and paragraphs, see [Manage Text](https://docs.aspose.com/slides/php-java/manage-text/).
## **Create a Slide Number Field**
The following complete example creates a text box containing a literal `Slide ` label followed by an automatically updated number. It sets the number's size, weight, and color before adding the field, then reopens the saved presentation and checks the field type, text, and formatting. No input file is required.
```php
use aspose\slides\FieldType;
use aspose\slides\FillType;
use aspose\slides\NullableBool;
use aspose\slides\Portion;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 40, 40, 240, 50);
$shape->addTextFrame("Slide ");
$paragraph = $shape->getTextFrame()->getParagraphs()->get_Item(0);
$numberPortion = new Portion();
$numberColor = new Java("java.awt.Color", 0, 0, 139);
$numberPortion->getPortionFormat()->setFontHeight(24);
$numberPortion->getPortionFormat()->setFontBold(NullableBool::True);
$numberPortion->getPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$numberPortion->getPortionFormat()->getFillFormat()->getSolidFillColor()->setColor($numberColor);
$paragraph->getPortions()->add($numberPortion);
$numberPortion->addField(FieldType::getSlideNumber());
$presentation->save("slide_number.pptx", SaveFormat::Pptx);
$reopened = new Presentation("slide_number.pptx");
try {
$savedShape = $reopened->getSlides()->get_Item(0)->getShapes()->get_Item(0);
$savedNumber = $savedShape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(1);
$savedField = $savedNumber->getField();
$hasNumberField = !java_is_null($savedField) && java_values(FieldType::getSlideNumber()->getInternalString()) === java_values($savedField->getType()->getInternalString());
$format = $savedNumber->getPortionFormat();
$formattingPreserved = java_values($format->getFontHeight()) == 24 && java_values($format->getFontBold()) == NullableBool::True;
$formattingPreserved = $formattingPreserved && java_values($format->getFillFormat()->getSolidFillColor()->getColor()->getRGB()) == java_values($numberColor->getRGB());
echo "Text: " . $savedShape->getTextFrame()->getText() . PHP_EOL;
echo "Slide number field: " . ($hasNumberField ? "true" : "false") . PHP_EOL;
echo "Formatting preserved: " . ($formattingPreserved ? "true" : "false") . PHP_EOL;
} finally {
$reopened->dispose();
}
} finally {
$presentation->dispose();
}
```
The new presentation starts with slide number 1, so the text is `Slide 1`, and both checks print `true`. The number remains a field after reopening; it is not a literal `1`. The indices in the verification refer to the shape and portions created by this example.
## **Choose a Field Type**
[FieldType](https://reference.aspose.com/slides/php-java/aspose.slides/fieldtype/) provides the following methods for obtaining predefined values. Pass the appropriate value to [addField](https://reference.aspose.com/slides/php-java/aspose.slides/portion/#addField).
| Method | Purpose |
|---|---|
| [getSlideNumber](https://reference.aspose.com/slides/php-java/aspose.slides/fieldtype/#getSlideNumber) | The current slide number. |
| [getDateTime](https://reference.aspose.com/slides/php-java/aspose.slides/fieldtype/#getDateTime) | Date/time in the rendering application's default format. |
| [getDateTime1](https://reference.aspose.com/slides/php-java/aspose.slides/fieldtype/#getDateTime1)–[getDateTime9](https://reference.aspose.com/slides/php-java/aspose.slides/fieldtype/#getDateTime9) | Predefined date or combined date/time formats. |
| [getDateTime10](https://reference.aspose.com/slides/php-java/aspose.slides/fieldtype/#getDateTime10)–[getDateTime13](https://reference.aspose.com/slides/php-java/aspose.slides/fieldtype/#getDateTime13) | Predefined time formats, with options for seconds and a 12-hour clock. |
| [getHeader](https://reference.aspose.com/slides/php-java/aspose.slides/fieldtype/#getHeader) | A header field; see the placeholder and format limitations below. |
| [getFooter](https://reference.aspose.com/slides/php-java/aspose.slides/fieldtype/#getFooter) | A footer field. |
For example, [getDateTime3](https://reference.aspose.com/slides/php-java/aspose.slides/fieldtype/#getDateTime3) represents a day, full month name, and year in English. These are predefined field formats, not arbitrary PHP date-format strings. The language set with [setLanguageId](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setLanguageId) and the application processing the presentation can affect the displayed result.
## **Create a Field from an Internal String**
The string overload of [addField](https://reference.aspose.com/slides/php-java/aspose.slides/portion/#addField) accepts an internal field identifier. Use it when preserving an identifier supplied by another application that has no predefined value. You can also construct a [FieldType](https://reference.aspose.com/slides/php-java/aspose.slides/fieldtype/#FieldType) from the identifier. [FieldType::getInternalString](https://reference.aspose.com/slides/php-java/aspose.slides/fieldtype/#getInternalString) exposes that identifier for inspection.
This example stores an application-specific `custom-report-id` field with the fallback text `Report-042`. The identifier does not register a calculation: Aspose.Slides does not generate report IDs for an unknown type. The application that understands this identifier must supply its meaning and update its value.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$shape = $presentation->getSlides()->get_Item(0)->getShapes()->addAutoShape(ShapeType::Rectangle, 40, 40, 300, 50);
$shape->addTextFrame("Report-042");
$portion = $shape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
$portion->addField("custom-report-id");
$presentation->save("custom_field.pptx", SaveFormat::Pptx);
$reopened = new Presentation("custom_field.pptx");
try {
$savedShape = $reopened->getSlides()->get_Item(0)->getShapes()->get_Item(0);
$savedPortion = $savedShape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
$savedField = $savedPortion->getField();
$typeName = java_is_null($savedField) ? "ordinary text" : java_values($savedField->getType()->getInternalString());
echo "Type: " . $typeName . PHP_EOL;
echo "Text: " . $savedPortion->getText() . PHP_EOL;
} finally {
$reopened->dispose();
}
} finally {
$presentation->dispose();
}
```
After this PPTX round trip, the type is `custom-report-id` and the text is `Report-042`. Passing a string such as `Y-m-d` would name a field type; it would not configure a custom date format. For a fixed date in an arbitrary format, use ordinary text.
## **Inspect, Modify, and Remove Date/Time Fields**
Change an existing field through [Field::setType](https://reference.aspose.com/slides/php-java/aspose.slides/field/#setType). Check that the field exists before accessing its type. To stop automatic updates, call [Portion::removeField](https://reference.aspose.com/slides/php-java/aspose.slides/portion/#removeField). This keeps the portion and its current text while removing the field association. If you need a specific fixed value, assign that text after removing the field.
For the API setting associated with date/time field processing, see [Presentation::setCurrentDateTime](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#setCurrentDateTime). The example below uses an explicit approval date when converting a field to ordinary text.
Download [sample.pptx](https://docs.aspose.com/slides/php-java/text-fields/sample.pptx) and place it in the JavaBridge working directory, or pass its absolute path to the presentation constructor. It contains two named text shapes, `UpdatedAt` and `ApprovedDate`, each with a date/time field, plus ordinary text labels. The following example walks top-level text shapes on regular slides. It changes date/time fields to a long-date format and makes them italic, while preserving their other formatting. Only fields in `ApprovedDate` become fixed text.
The sample recognizes the built-in internal identifiers `datetime` and `datetime1` through `datetime13`. Groups, tables, notes, layouts, and masters require traversal of their own text containers and are outside this example's scope.
```php
use aspose\slides\FieldType;
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("sample.pptx");
try {
$approvalDate = new DateTimeImmutable("2030-04-05");
$autoShapeClass = new JavaClass("com.aspose.slides.AutoShape");
for ($slideIndex = 0; $slideIndex < java_values($presentation->getSlides()->size()); $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
for ($shapeIndex = 0; $shapeIndex < java_values($slide->getShapes()->size()); $shapeIndex++) {
$shape = $slide->getShapes()->get_Item($shapeIndex);
if (!java_instanceof($shape, $autoShapeClass)) {
continue;
}
$textShape = $shape;
if (java_is_null($textShape->getTextFrame())) {
continue;
}
for ($paragraphIndex = 0; $paragraphIndex < java_values($textShape->getTextFrame()->getParagraphs()->getCount()); $paragraphIndex++) {
$paragraph = $textShape->getTextFrame()->getParagraphs()->get_Item($paragraphIndex);
for ($portionIndex = 0; $portionIndex < java_values($paragraph->getPortions()->getCount()); $portionIndex++) {
$portion = $paragraph->getPortions()->get_Item($portionIndex);
$field = $portion->getField();
if (java_is_null($field)) {
continue;
}
$typeName = java_values($field->getType()->getInternalString());
$isDateTime = $typeName != null && preg_match("/\Adatetime([1-9]|1[0-3])?\z/", $typeName) === 1;
if (!$isDateTime) {
continue;
}
$field->setType(FieldType::getDateTime3());
$portion->getPortionFormat()->setLanguageId("en-US");
$portion->getPortionFormat()->setFontItalic(NullableBool::True);
if (java_values($textShape->getName()) === "ApprovedDate") {
$portion->removeField();
$fixedDate = $approvalDate->format("d F Y");
$portion->setText($fixedDate);
}
}
}
}
}
$presentation->save("updated_dates.pptx", SaveFormat::Pptx);
$reopened = new Presentation("updated_dates.pptx");
try {
for ($shapeIndex = 0; $shapeIndex < java_values($reopened->getSlides()->get_Item(0)->getShapes()->size()); $shapeIndex++) {
$shape = $reopened->getSlides()->get_Item(0)->getShapes()->get_Item($shapeIndex);
if (!java_instanceof($shape, $autoShapeClass)) {
continue;
}
$textShape = $shape;
if (java_is_null($textShape->getTextFrame())) {
continue;
}
if (java_values($textShape->getName()) !== "UpdatedAt" && java_values($textShape->getName()) !== "ApprovedDate") {
continue;
}
$portion = $textShape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
$field = $portion->getField();
$typeName = java_is_null($field) ? "ordinary text" : java_values($field->getType()->getInternalString());
echo $textShape->getName() . ": " . $typeName . "; " . $portion->getText() . PHP_EOL;
echo "Italic: " . $portion->getPortionFormat()->getFontItalic() . PHP_EOL;
}
} finally {
$reopened->dispose();
}
} finally {
$presentation->dispose();
}
```
After reopening, `UpdatedAt` has type `datetime3` and remains dynamic. `ApprovedDate` has no field and contains `05 April 2030`. Both date portions are italic, and their original font size, bold setting, and color remain intact. The ordinary text labels are unchanged. The verification reads the first portion of the two known shapes in the supplied sample.
## **Preserve Text Formatting**
Work with the existing portion when adding a field, changing its type, or removing it. These operations retain that portion's formatting. Use [Portion::getPortionFormat](https://reference.aspose.com/slides/php-java/aspose.slides/portion/#getPortionFormat) to change only the required properties, as the examples do for color or italics.
Avoid rebuilding an entire text frame just to update one field: doing so can lose the original portion boundaries and their individual formatting. Also distinguish explicitly set formatting from formatting inherited from the paragraph, layout, or theme. See [Text Formatting](https://docs.aspose.com/slides/php-java/text-formatting/) for broader formatting options.
## **Fields and Header/Footer Placeholders**
A field is part of a text portion. A placeholder is a shape with a presentation role, such as a footer or slide number. Adding a field to an ordinary text box does not turn that shape into a placeholder.
The header/footer managers control placeholder text and visibility on slides, layouts, and masters, including propagation to dependent slides. A number field in a custom text box can therefore be useful even when you are not using the slide-number placeholder. Conversely, changing placeholder visibility does not remove a field from an unrelated text box.
The predefined header and footer types do not create the corresponding placeholders or supply their content. In particular, a regular PowerPoint slide has no header placeholder; headers belong to notes pages and handouts. Do not assume that a header or footer field in an arbitrary shape will automatically obtain the text configured through a placeholder manager. For that workflow, see [Presentation Headers and Footers](https://docs.aspose.com/slides/php-java/presentation-header-and-footer/).
## **PPTX and PPT Limitations**
Check both the field type and its resulting text after saving and reopening. Preserving an identifier does not prove that an application can calculate or display its value.
| Format | Field behavior and limitations |
|---|---|
| PPTX | Stores internal field identifiers alongside field text. In round-trip checks, the predefined types and the custom identifier used above survived saving and reopening. The unknown custom type retained its fallback text; it did not acquire automatic calculation logic. Another application may treat unsupported identifiers differently. |
| PPT | Uses legacy field representations and has more limited compatibility. In round-trip checks, slide-number and predefined date/time fields survived saving and reopening. A custom field in an ordinary slide text box reopened with its identifier but with `*` as its text; a header field in the same context also produced `*`. Do not rely on custom fields or unsupported field contexts retaining their visible text. |
For portable, fixed output, convert unsupported fields to ordinary text and explicitly assign the value you want before saving. This preserves the chosen text but intentionally stops automatic updates. Test the target application as well when its own field recalculation is part of your workflow.
## **FAQ**
**How can I tell whether a displayed number or date is a field?**
Inspect [Portion::getField](https://reference.aspose.com/slides/php-java/aspose.slides/portion/#getField). A non-null value identifies a field; the displayed text alone cannot tell you.
**Does removing a field remove its text or formatting?**
No. [removeField](https://reference.aspose.com/slides/php-java/aspose.slides/portion/#removeField) converts the existing portion to ordinary text. Assign an explicit value afterward if you need a particular frozen date or fallback value.
**Can an internal string define a new date format or formula?**
No. It identifies a field type. An unknown identifier does not provide an evaluator or a PHP date-format pattern. Use a supported predefined type or format a value yourself as ordinary text.
**Why check a presentation again after saving it?**
Field identifiers, calculated text, and formatting are separate things to verify. Format conversion can change the visible result even when the field identifier is still present.
# Format Presentation Text in PHP
> Format and style text in PowerPoint and OpenDocument presentations using Aspose.Slides for PHP via Java. Customize fonts, colors, alignment, and more.
Source: https://docs.aspose.com/slides/php-java/text-formatting/
Updated: 2026-11-05
## **Overview**
This article shows how to format text in PowerPoint and OpenDocument presentations using Aspose.Slides for PHP via Java. It covers background colors, transparency, character spacing, font properties, rotation, paragraph spacing, autofit behavior, text anchoring, tab stops, and language settings.
Unless stated otherwise, the examples use [sample.pptx](https://docs.aspose.com/slides/php-java/text-formatting/sample.pptx). The first shape on its first slide is a text box, and its first paragraph contains the text shown below. Both slide and shape indices are zero-based. Examples that select bold portions use effective formatting, including inherited bold formatting:

To find and highlight literal text or regular-expression matches, see [Search and Replace Text](https://docs.aspose.com/slides/php-java/search-and-replace-text/).
## **Set Text Background Color**
Use [ParagraphFormat::getDefaultPortionFormat](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#getDefaultPortionFormat) to set the default highlight color for a paragraph, or use [BasePortionFormat::getHighlightColor](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#getHighlightColor) for individual text portions.
The following example sets a light gray highlight as the default for the first paragraph. Explicit highlight colors on individual portions take precedence over this default:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->get_Item(0);
$paragraph = $autoShape->getTextFrame()->getParagraphs()->get_Item(0);
$highlightColor = java("java.awt.Color")->LIGHT_GRAY;
// Set the highlight color for the entire paragraph.
$paragraph->getParagraphFormat()->getDefaultPortionFormat()->getHighlightColor()->setColor($highlightColor);
$presentation->save("gray_paragraph.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

The code example below demonstrates how to set the background color for **text portions with a bold font**:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->get_Item(0);
$paragraph = $autoShape->getTextFrame()->getParagraphs()->get_Item(0);
$highlightColor = java("java.awt.Color")->LIGHT_GRAY;
$portionCount = java_values($paragraph->getPortions()->getCount());
for ($portionIndex = 0; $portionIndex < $portionCount; $portionIndex++) {
$portion = $paragraph->getPortions()->get_Item($portionIndex);
if (java_values($portion->getPortionFormat()->getEffective()->getFontBold())) {
// Set the highlight color for the text portion.
$portion->getPortionFormat()->getHighlightColor()->setColor($highlightColor);
}
}
$presentation->save("gray_text_portions.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

## **Align Text Paragraphs**
Use [ParagraphFormat::setAlignment](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setAlignment) to set paragraph alignment within a text frame. The value can be centered, left-aligned, right-aligned, justified, and so on.
The following code example shows how to align the paragraph to the **center**:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TextAlignment;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->get_Item(0);
$paragraph = $autoShape->getTextFrame()->getParagraphs()->get_Item(0);
// Set the alignment of the paragraph to center.
$paragraph->getParagraphFormat()->setAlignment(TextAlignment::Center);
$presentation->save("aligned_paragraph.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

## **Align Fonts Within a Line**
Use [ParagraphFormat::setFontAlignment](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setFontAlignment) to vertically align text portions of different font sizes within a line. This setting applies to the entire paragraph and controls alignment within each of its lines.
The following self-contained example creates four labeled text boxes on one slide. Each paragraph contains the same text at 18, 36, and 54 points, with a different font alignment. It uses Arial, disables autofit and wrapping, and keeps the text frames large enough for a single line.
```php
use aspose\slides\FillType;
use aspose\slides\FontAlignment;
use aspose\slides\FontData;
use aspose\slides\NullableBool;
use aspose\slides\Paragraph;
use aspose\slides\Portion;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\TextAlignment;
use aspose\slides\TextAnchorType;
use aspose\slides\TextAutofitType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$alignments = [FontAlignment::Baseline, FontAlignment::Top, FontAlignment::Center, FontAlignment::Bottom];
$alignmentNames = ["Baseline", "Top", "Center", "Bottom"];
$fontSizes = [18, 36, 54];
$font = new FontData("Arial");
$gray = java("java.awt.Color")->GRAY;
$black = java("java.awt.Color")->BLACK;
for ($i = 0; $i < count($alignments); $i++) {
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 30, 20 + $i * 130, 660, 120);
$shape->getFillFormat()->setFillType(FillType::NoFill);
$shape->getLineFormat()->getFillFormat()->setFillType(FillType::NoFill);
$textFrame = $shape->getTextFrame();
$textFrame->getTextFrameFormat()->setAnchoringType(TextAnchorType::Top);
$textFrame->getTextFrameFormat()->setAutofitType(TextAutofitType::None);
$textFrame->getTextFrameFormat()->setWrapText(NullableBool::False);
$label = $textFrame->getParagraphs()->get_Item(0);
$label->setText($alignmentNames[$i]);
$label->getParagraphFormat()->setAlignment(TextAlignment::Left);
$label->getParagraphFormat()->getDefaultPortionFormat()->setFontHeight(14);
$label->getParagraphFormat()->getDefaultPortionFormat()->setLatinFont($font);
$label->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$label->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->getSolidFillColor()->setColor($gray);
$paragraph = new Paragraph();
$paragraph->getParagraphFormat()->setFontAlignment($alignments[$i]);
$paragraph->getParagraphFormat()->setAlignment(TextAlignment::Left);
$paragraph->getParagraphFormat()->getDefaultPortionFormat()->setLatinFont($font);
$paragraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$paragraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat()->getSolidFillColor()->setColor($black);
foreach ($fontSizes as $fontSize) {
$portion = new Portion("Ag ");
$portion->getPortionFormat()->setFontHeight($fontSize);
$paragraph->getPortions()->add($portion);
}
$textFrame->getParagraphs()->add($paragraph);
}
$presentation->save("font_alignment.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

Font alignment uses font metrics, so the visible edges of individual letters do not necessarily line up exactly. The example includes both an uppercase letter and a descender to help show the difference between baseline and bottom alignment. Font availability and substitution, the characters used, and the difference in font sizes affect the result. Frame dimensions, margins, line spacing, wrapping, and autofit also affect layout; use the same fonts and layout settings when comparing modes.
This setting differs from [ParagraphFormat::setAlignment](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setAlignment), which controls horizontal paragraph alignment, and [TextFrameFormat::setAnchoringType](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#setAnchoringType), which positions the text block vertically within its shape. Superscript and subscript formatting through [BasePortionFormat::setEscapement](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setEscapement) shifts individual portions relative to the baseline instead of setting font alignment for the paragraph's lines.
## **Set Transparency for Text**
Text transparency is controlled through the alpha component of the color assigned to [BasePortionFormat::getFillFormat](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#getFillFormat). In the examples below, `alpha = 50` is an ARGB alpha-channel value on the 0–255 scale, not a transparency percentage.
The code example below shows how to apply transparency to the **entire paragraph**:
```php
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$alpha = 50;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->get_Item(0);
$paragraph = $autoShape->getTextFrame()->getParagraphs()->get_Item(0);
$fillFormat = $paragraph->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat();
// Set the fill color of the text to a transparent color.
$fillFormat->setFillType(FillType::Solid);
$transparentColor = new Java("java.awt.Color", 0, 0, 0, $alpha);
$fillFormat->getSolidFillColor()->setColor($transparentColor);
$presentation->save("transparent_paragraph.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

The following code example shows how to apply transparency to **text portions with a bold font**:
```php
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$alpha = 50;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->get_Item(0);
$paragraph = $autoShape->getTextFrame()->getParagraphs()->get_Item(0);
$transparentColor = new Java("java.awt.Color", 0, 0, 0, $alpha);
$portionCount = java_values($paragraph->getPortions()->getCount());
for ($portionIndex = 0; $portionIndex < $portionCount; $portionIndex++) {
$portion = $paragraph->getPortions()->get_Item($portionIndex);
if (java_values($portion->getPortionFormat()->getEffective()->getFontBold())) {
// Set the transparency of the text portion.
$fillFormat = $portion->getPortionFormat()->getFillFormat();
$fillFormat->setFillType(FillType::Solid);
$fillFormat->getSolidFillColor()->setColor($transparentColor);
}
}
$presentation->save("transparent_text_portions.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

## **Set Character Spacing for Text**
Use [BasePortionFormat::setSpacing](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setSpacing) to expand or condense spacing between characters in a text box. The examples add 3 points of spacing; negative values condense the text.
The following PHP code shows how to expand the character spacing in the **entire paragraph**:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->get_Item(0);
$paragraph = $autoShape->getTextFrame()->getParagraphs()->get_Item(0);
// Note: Use negative values to compress the character spacing.
$paragraph->getParagraphFormat()->getDefaultPortionFormat()->setSpacing(3); // Expand character spacing.
$presentation->save("character_spacing_in_paragraph.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

The code example below shows how to expand the character spacing in **text portions with a bold font**:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->get_Item(0);
$paragraph = $autoShape->getTextFrame()->getParagraphs()->get_Item(0);
$portionCount = java_values($paragraph->getPortions()->getCount());
for ($portionIndex = 0; $portionIndex < $portionCount; $portionIndex++) {
$portion = $paragraph->getPortions()->get_Item($portionIndex);
if (java_values($portion->getPortionFormat()->getEffective()->getFontBold())) {
// Note: Use negative values to compress the character spacing.
$portion->getPortionFormat()->setSpacing(3); // Expand character spacing.
}
}
$presentation->save("character_spacing_in_text_portions.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

### **Disable Kerning for Specific Fonts**
In some cases, text rendered by Aspose.Slides may look slightly tighter than the same text displayed in PowerPoint. This can happen because PowerPoint may ignore kerning data for certain fonts, even when the font contains valid kerning information and kerning is enabled in PowerPoint settings.
To make the rendered output closer to PowerPoint in such cases, you can disable kerning for text portions that use the affected font. Set [BasePortionFormat::setKerningMinimalSize](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setKerningMinimalSize) to a value larger than the actual font size. This example requires "presentation.pptx" with a text box as the first shape on the first slide. It checks effective font names, including inherited fonts, and sets a 100-point threshold for portions that use Roboto. This disables kerning for matching portions with a font size below 100 points:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("presentation.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->get_Item(0);
$targetFont = "Roboto";
$paragraphCount = java_values($autoShape->getTextFrame()->getParagraphs()->getCount());
for ($paragraphIndex = 0; $paragraphIndex < $paragraphCount; $paragraphIndex++) {
$paragraph = $autoShape->getTextFrame()->getParagraphs()->get_Item($paragraphIndex);
$portionCount = java_values($paragraph->getPortions()->getCount());
for ($portionIndex = 0; $portionIndex < $portionCount; $portionIndex++) {
$portion = $paragraph->getPortions()->get_Item($portionIndex);
$portionFormat = $portion->getPortionFormat()->getEffective();
$latinFont = $portionFormat->getLatinFont();
$eastAsianFont = $portionFormat->getEastAsianFont();
$complexScriptFont = $portionFormat->getComplexScriptFont();
if ((!java_is_null($latinFont) && $latinFont->getFontName() == $targetFont) ||
(!java_is_null($eastAsianFont) && $eastAsianFont->getFontName() == $targetFont) ||
(!java_is_null($complexScriptFont) && $complexScriptFont->getFontName() == $targetFont)) {
$portion->getPortionFormat()->setKerningMinimalSize(100);
}
}
}
$presentation->save("output.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
For matching text below the threshold, this setting prevents kerning and can help align Aspose.Slides rendering with PowerPoint’s visual output for fonts affected by this PowerPoint-specific behavior.
## **Manage Text Font Properties**
Font properties can be set at the paragraph level through [ParagraphFormat::getDefaultPortionFormat](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#getDefaultPortionFormat) or on individual portions through [PortionFormat](https://reference.aspose.com/slides/php-java/aspose.slides/portionformat/).
The following example sets the first paragraph’s default font to 12-point Times New Roman with bold, italic, and dotted underline formatting. Explicit formatting on individual portions takes precedence over these defaults.
```php
use aspose\slides\FontData;
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TextUnderlineType;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->get_Item(0);
$paragraph = $autoShape->getTextFrame()->getParagraphs()->get_Item(0);
$defaultPortionFormat = $paragraph->getParagraphFormat()->getDefaultPortionFormat();
$font = new FontData("Times New Roman");
// Set the font properties for the paragraph.
$defaultPortionFormat->setFontHeight(12);
$defaultPortionFormat->setFontBold(NullableBool::True);
$defaultPortionFormat->setFontItalic(NullableBool::True);
$defaultPortionFormat->setFontUnderline(TextUnderlineType::Dotted);
$defaultPortionFormat->setLatinFont($font);
$presentation->save("font_properties_for_paragraph.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

The following example applies 13-point Times New Roman, italic formatting, and a dotted underline to portions whose effective formatting is bold:
```php
use aspose\slides\FontData;
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TextUnderlineType;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->get_Item(0);
$paragraph = $autoShape->getTextFrame()->getParagraphs()->get_Item(0);
$font = new FontData("Times New Roman");
$portionCount = java_values($paragraph->getPortions()->getCount());
for ($portionIndex = 0; $portionIndex < $portionCount; $portionIndex++) {
$portion = $paragraph->getPortions()->get_Item($portionIndex);
if (java_values($portion->getPortionFormat()->getEffective()->getFontBold())) {
// Set the font properties for the text portion.
$portionFormat = $portion->getPortionFormat();
$portionFormat->setFontHeight(13);
$portionFormat->setFontItalic(NullableBool::True);
$portionFormat->setFontUnderline(TextUnderlineType::Dotted);
$portionFormat->setLatinFont($font);
}
}
$presentation->save("font_properties_for_text_portions.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

## **Control Text Height Normalization**
Use [BasePortionFormat::setNormaliseHeight](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setNormaliseHeight) when reproducing template typography or investigating differences in character height. In PowerPoint, enabling normalization stretches or compresses individual characters vertically to give them a uniform visible height within the text portion. It does not guarantee equal text heights across different fonts.
Set the property to [NullableBool::True or False](https://reference.aspose.com/slides/php-java/aspose.slides/nullablebool/) to explicitly enable or disable normalization. `NullableBool::NotDefined` leaves the local setting unset so that the portion inherits its value, for example, from the paragraph's [getDefaultPortionFormat](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#getDefaultPortionFormat). It does not mean `False`. Use [PortionFormat::getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/portionformat/#getEffective) and read `getNormaliseHeight` on the returned effective formatting data to obtain the resolved Boolean value.
The following self-contained example requires **Arial** to be installed. It creates two text blocks containing the same uppercase letters, lowercase letters, descenders, and accented characters at 54 points. Both paragraphs enable normalization by default. The top portion explicitly disables it; the bottom portion inherits it. The frame sizes, margins, and paragraph spacing are identical, with wrapping and autofit disabled to keep the comparison consistent. The example prints `False: false` and `NotDefined: true`, then saves "text_height_normalization.pptx".
```php
use aspose\slides\FillType;
use aspose\slides\FontData;
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\TextAlignment;
use aspose\slides\TextAnchorType;
use aspose\slides\TextAutofitType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$settings = [NullableBool::False, NullableBool::NotDefined];
$settingNames = ["False", "NotDefined"];
for ($i = 0; $i < count($settings); $i++) {
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 30, 60 + $i * 200, 660, 150);
$shape->getFillFormat()->setFillType(FillType::NoFill);
$shape->getLineFormat()->getFillFormat()->setFillType(FillType::NoFill);
$textFrame = $shape->getTextFrame();
$textFrame->setText("Hxgjpq ÅÉ 0123");
$textFrame->getTextFrameFormat()->setAutofitType(TextAutofitType::None);
$textFrame->getTextFrameFormat()->setWrapText(NullableBool::False);
$textFrame->getTextFrameFormat()->setAnchoringType(TextAnchorType::Top);
$textFrame->getTextFrameFormat()->setMarginTop(0);
$textFrame->getTextFrameFormat()->setMarginLeft(0);
$paragraph = $textFrame->getParagraphs()->get_Item(0);
$paragraph->getParagraphFormat()->setAlignment(TextAlignment::Left);
$paragraph->getParagraphFormat()->setSpaceBefore(0);
$paragraph->getParagraphFormat()->setSpaceAfter(0);
$paragraph->getParagraphFormat()->setSpaceWithin(100);
$paragraph->getParagraphFormat()->getDefaultPortionFormat()->setNormaliseHeight(NullableBool::True);
$portion = $paragraph->getPortions()->get_Item(0);
$font = new FontData("Arial");
$portion->getPortionFormat()->setLatinFont($font);
$portion->getPortionFormat()->setFontHeight(54);
$portion->getPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$black = java("java.awt.Color")->BLACK;
$portion->getPortionFormat()->getFillFormat()->getSolidFillColor()->setColor($black);
$portion->getPortionFormat()->setNormaliseHeight($settings[$i]);
$normaliseHeight = java_values($portion->getPortionFormat()->getEffective()->getNormaliseHeight());
echo $settingNames[$i], ": ", $normaliseHeight ? "true" : "false", PHP_EOL;
}
$presentation->save("text_height_normalization.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The comparison below was exported from the saved presentation. The top row has normalization disabled (`False`); the bottom row inherits the enabled setting (`NotDefined` → `True`). Keep Arial installed to reproduce this appearance.

Normalization changes character height without changing the assigned [getFontHeight](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#getFontHeight) value, which specifies the font size in points. Paragraph [setSpaceWithin](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setSpaceWithin) controls line spacing, while text-frame [setAutofitType](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#setAutofitType) controls how text or its container adjusts to fit. These settings serve different purposes and can affect the overall layout independently. For more on paragraph formatting and inheritance, see [Manage Paragraph](https://docs.aspose.com/slides/php-java/manage-paragraph/).
## **Apply and Remove Strikethrough**
Use [BasePortionFormat::setStrikethroughType](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setStrikethroughType) on a text portion to display corrections, cancelled terms, or previous prices without deleting the original text. Set it to [TextStrikethroughType::Single or Double](https://reference.aspose.com/slides/php-java/aspose.slides/textstrikethroughtype/) for one or two lines through the text.
To remove strikethrough, pass [TextStrikethroughType::None](https://reference.aspose.com/slides/php-java/aspose.slides/textstrikethroughtype/#None). This explicitly disables the effect, even if the surrounding formatting specifies strikethrough. By contrast, [TextStrikethroughType::NotDefined](https://reference.aspose.com/slides/php-java/aspose.slides/textstrikethroughtype/#NotDefined) leaves the local setting undefined, allowing the portion to inherit formatting, for example, from the paragraph. It does not guarantee that strikethrough is removed. Use [PortionFormat::getEffective](https://reference.aspose.com/slides/php-java/aspose.slides/portionformat/#getEffective) to read the resulting formatting, including inherited values.
The following self-contained example creates three price comparisons. Each paragraph has separate portions for the label, previous price, and current price, so only the previous price is affected. The first row applies and then removes strikethrough; the other rows retain single and double strikethrough. Changing this setting preserves the text and its other formatting, including the bold previous price.
```php
use aspose\slides\FillType;
use aspose\slides\FontData;
use aspose\slides\NullableBool;
use aspose\slides\Paragraph;
use aspose\slides\Portion;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\TextAlignment;
use aspose\slides\TextStrikethroughType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 620, 220);
$shape->getFillFormat()->setFillType(FillType::NoFill);
$shape->getLineFormat()->getFillFormat()->setFillType(FillType::NoFill);
$shape->getTextFrame()->getParagraphs()->clear();
$labels = [ "None: ", "Single: ", "Double: " ];
foreach ($labels as $label) {
$paragraph = new Paragraph();
$paragraph->getParagraphFormat()->setAlignment(TextAlignment::Left);
$paragraph->getParagraphFormat()->setSpaceAfter(20);
$format = $paragraph->getParagraphFormat()->getDefaultPortionFormat();
$format->setFontHeight(28);
$font = new FontData("Arial");
$format->setLatinFont($font);
$format->getFillFormat()->setFillType(FillType::Solid);
$blackColor = java("java.awt.Color")->BLACK;
$format->getFillFormat()->getSolidFillColor()->setColor($blackColor);
$labelPortion = new Portion($label);
$paragraph->getPortions()->add($labelPortion);
$previousPrice = new Portion("$100");
$previousPrice->getPortionFormat()->setFontBold(NullableBool::True);
$paragraph->getPortions()->add($previousPrice);
$currentPrice = new Portion(" → $80");
$paragraph->getPortions()->add($currentPrice);
$shape->getTextFrame()->getParagraphs()->add($paragraph);
}
$paragraphs = $shape->getTextFrame()->getParagraphs();
// Apply strikethrough, then explicitly remove it from the first previous price.
$paragraphs->get_Item(0)->getPortions()->get_Item(1)->getPortionFormat()->setStrikethroughType(TextStrikethroughType::Single);
$paragraphs->get_Item(0)->getPortions()->get_Item(1)->getPortionFormat()->setStrikethroughType(TextStrikethroughType::None);
$paragraphs->get_Item(1)->getPortions()->get_Item(1)->getPortionFormat()->setStrikethroughType(TextStrikethroughType::Single);
$paragraphs->get_Item(2)->getPortions()->get_Item(1)->getPortionFormat()->setStrikethroughType(TextStrikethroughType::Double);
$presentation->save("strikethrough.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result, from top to bottom: no strikethrough, single strikethrough, and double strikethrough.

## **Set Text Rotation**
Use [TextFrameFormat::setTextVerticalType](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#setTextVerticalType) to set a predefined text orientation within a shape.
The following code example sets the text orientation in the shape to [TextVerticalType::Vertical270](https://reference.aspose.com/slides/php-java/aspose.slides/textverticaltype/), which rotates the text **90 degrees counterclockwise**:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TextVerticalType;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->get_Item(0);
$autoShape->getTextFrame()->getTextFrameFormat()->setTextVerticalType(TextVerticalType::Vertical270);
$presentation->save("text_rotation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

## **Set Custom Rotation for Text Frames**
Use [TextFrameFormat::setRotationAngle](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#setRotationAngle) to set a custom rotation angle for a [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/).
The code example below rotates the text frame by 3 degrees clockwise within the shape:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->get_Item(0);
$autoShape->getTextFrame()->getTextFrameFormat()->setRotationAngle(3);
$presentation->save("custom_text_rotation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

## **Set Line Spacing of Paragraphs**
Aspose.Slides provides [ParagraphFormat::setSpaceAfter](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setSpaceAfter), [ParagraphFormat::setSpaceBefore](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setSpaceBefore), and [ParagraphFormat::setSpaceWithin](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setSpaceWithin) to control paragraph spacing. These properties are used as follows:
* Use a positive value to specify line spacing as a percentage of the line height.
* Use a negative value to specify line spacing in points.
The following example sets spacing within the first paragraph to 200% of the line height (double spacing):
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->get_Item(0);
$paragraph = $autoShape->getTextFrame()->getParagraphs()->get_Item(0);
$paragraph->getParagraphFormat()->setSpaceWithin(200);
$presentation->save("line_spacing.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

## **Control Line Breaking**
Paragraph line-breaking rules are useful in narrow text blocks and presentations that mix Latin and East Asian text. The following methods belong to [ParagraphFormat](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/), so they apply to an entire paragraph:
- [setLatinLineBreak](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setLatinLineBreak) controls Latin line-breaking rules. In mixed text, changing it can also change where adjacent East Asian text and punctuation wrap.
- [setEastAsianLineBreak](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setEastAsianLineBreak) controls East Asian line-breaking rules, including restrictions on characters at the beginning and end of a line.
These rules do not replace [TextFrameFormat::setWrapText](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#setWrapText), which enables automatic wrapping within a text frame. They influence the layout when wrapping occurs; they do not insert line-break characters. An explicit line break forces a new line within the paragraph independently of the available width.
The following self-contained example creates a narrow text block containing Chinese and Latin text. It sets both line-breaking options explicitly and saves "line_breaking.pptx". To experiment with either rule, change the corresponding value while keeping the other settings fixed. The example uses 24-point Arial and SimSun with a 160-point frame width and zero horizontal text-frame margins. [TextFrameFormat::setAutofitType](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#setAutofitType) is called with [TextAutofitType::None](https://reference.aspose.com/slides/php-java/aspose.slides/textautofittype/) so that text size and frame dimensions remain fixed.
```php
use aspose\slides\FillType;
use aspose\slides\FontData;
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\TextAlignment;
use aspose\slides\TextAutofitType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 160, 300);
$shape->getFillFormat()->setFillType(FillType::NoFill);
$textFrame = $shape->getTextFrame();
$textFrame->getTextFrameFormat()->setWrapText(NullableBool::True);
$textFrame->getTextFrameFormat()->setAutofitType(TextAutofitType::None);
$textFrame->getTextFrameFormat()->setMarginLeft(0);
$textFrame->getTextFrameFormat()->setMarginRight(0);
$paragraph = $textFrame->getParagraphs()->get_Item(0);
$paragraph->setText("中文排版测试,PowerPoint 中文演示。");
$format = $paragraph->getParagraphFormat();
$format->setAlignment(TextAlignment::Left);
$format->getDefaultPortionFormat()->setFontHeight(24);
$latinFont = new FontData("Arial");
$format->getDefaultPortionFormat()->setLatinFont($latinFont);
$eastAsianFont = new FontData("SimSun");
$format->getDefaultPortionFormat()->setEastAsianFont($eastAsianFont);
$format->getDefaultPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$blackColor = java("java.awt.Color")->BLACK;
$format->getDefaultPortionFormat()->getFillFormat()->getSolidFillColor()->setColor($blackColor);
$format->setLatinLineBreak(NullableBool::False);
$format->setEastAsianLineBreak(NullableBool::True);
$presentation->save("line_breaking.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Control Hanging Punctuation**
[ParagraphFormat::setHangingPunctuation](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setHangingPunctuation) allows eligible punctuation to extend beyond the text line's right edge instead of occupying the next line. It applies to the entire paragraph and is different from a hanging indent.
The following self-contained example enables hanging punctuation in a 100-point-wide text frame and saves "hanging_punctuation.pptx". With 24-point Arial and zero horizontal text-frame margins, the final period stays after "sentence" and extends beyond the right text edge. Set the property to [NullableBool::False](https://reference.aspose.com/slides/php-java/aspose.slides/nullablebool/) to compare: with these settings, the period occupies a separate line. Wrapping is enabled and autofit is disabled to keep the available width fixed.
```php
use aspose\slides\FillType;
use aspose\slides\FontData;
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
use aspose\slides\TextAlignment;
use aspose\slides\TextAutofitType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 50, 50, 100, 200);
$shape->getFillFormat()->setFillType(FillType::NoFill);
$textFrame = $shape->getTextFrame();
$textFrame->getTextFrameFormat()->setWrapText(NullableBool::True);
$textFrame->getTextFrameFormat()->setAutofitType(TextAutofitType::None);
$textFrame->getTextFrameFormat()->setMarginLeft(0);
$textFrame->getTextFrameFormat()->setMarginRight(0);
$paragraph = $textFrame->getParagraphs()->get_Item(0);
$paragraph->setText("Simple text, next sentence.");
$format = $paragraph->getParagraphFormat();
$format->setAlignment(TextAlignment::Left);
$format->getDefaultPortionFormat()->setFontHeight(24);
$latinFont = new FontData("Arial");
$format->getDefaultPortionFormat()->setLatinFont($latinFont);
$format->getDefaultPortionFormat()->getFillFormat()->setFillType(FillType::Solid);
$blackColor = java("java.awt.Color")->BLACK;
$format->getDefaultPortionFormat()->getFillFormat()->getSolidFillColor()->setColor($blackColor);
$format->setHangingPunctuation(NullableBool::True);
$presentation->save("hanging_punctuation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Not every punctuation mark can hang. The [font and layout conditions described above](https://docs.aspose.com/slides/php-java/text-formatting/#control-line-breaking) also apply to this comparison: changing the font, available width, margins, or autofit settings can remove the visible difference.
## **Set Autofit Type for Text Frames**
[TextFrameFormat::setAutofitType](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#setAutofitType) determines how text behaves when it exceeds the boundaries of its container. Use it to control whether the text shrinks, overflows, or resizes the shape automatically. The following example configures the shape to resize to fit its text and saves the result to "autofit_type.pptx".
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TextAutofitType;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->get_Item(0);
$autoShape->getTextFrame()->getTextFrameFormat()->setAutofitType(TextAutofitType::Shape);
$presentation->save("autofit_type.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
To count lines after automatic wrapping and see how text or shape width changes the result, see [Count Rendered Lines](https://docs.aspose.com/slides/php-java/manage-paragraph/). Line count alone does not indicate whether text overflows its container.
## **Set Anchor of Text Frames**
[TextFrameFormat::setAnchoringType](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#setAnchoringType) defines how text is positioned vertically inside a shape, for example, at the top, middle, or bottom. The following example anchors the text to the bottom of the first shape and saves the result to "text_anchor.pptx".
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TextAnchorType;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->get_Item(0);
$autoShape->getTextFrame()->getTextFrameFormat()->setAnchoringType(TextAnchorType::Bottom);
$presentation->save("text_anchor.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Set Text Tabulation**
Use [ParagraphFormat::setDefaultTabSize](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#setDefaultTabSize) and [ParagraphFormat::getTabs](https://reference.aspose.com/slides/php-java/aspose.slides/paragraphformat/#getTabs) to configure tab stops in a paragraph. The following example sets the default tab interval to 100 points and adds a left-aligned tab stop at 30 points. These settings affect text containing tab characters.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\TabAlignment;
$presentation = new Presentation("sample.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->get_Item(0);
$paragraph = $autoShape->getTextFrame()->getParagraphs()->get_Item(0);
$paragraph->getParagraphFormat()->setDefaultTabSize(100);
$paragraph->getParagraphFormat()->getTabs()->add(30, TabAlignment::Left);
$presentation->save("paragraph_tabs.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The result:

## **Set Proofing Language**
Aspose.Slides provides [BasePortionFormat::setLanguageId](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#setLanguageId), which allows you to set the proofing language for a text portion. The proofing language determines the language used for spelling and grammar checks in PowerPoint.
The following example requires "presentation.pptx" with a text box as the first shape on the first slide and at least one paragraph. It replaces the first paragraph’s contents with "1。", sets SimSun as its font, and assigns the Simplified Chinese proofing language (`zh-CN`). It saves the result to "proofing_language.pptx":
```php
use aspose\slides\FontData;
use aspose\slides\Portion;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("presentation.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->get_Item(0);
$paragraph = $autoShape->getTextFrame()->getParagraphs()->get_Item(0);
$paragraph->getPortions()->clear();
$font = new FontData("SimSun");
$textPortion = new Portion();
$textPortion->getPortionFormat()->setComplexScriptFont($font);
$textPortion->getPortionFormat()->setEastAsianFont($font);
$textPortion->getPortionFormat()->setLatinFont($font);
// Set the Id of a proofing language.
$textPortion->getPortionFormat()->setLanguageId("zh-CN");
$textPortion->setText("1。");
$paragraph->getPortions()->add($textPortion);
$presentation->save("proofing_language.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Set Default Language**
Use [LoadOptions::setDefaultTextLanguage](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/#setDefaultTextLanguage) to define the default language for text created while loading or creating a presentation. The following example creates a presentation with US English as the default text language, adds a text box, and prints `en-US` for its first text portion.
```php
use aspose\slides\LoadOptions;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$loadOptions = new LoadOptions();
$loadOptions->setDefaultTextLanguage("en-US");
$presentation = new Presentation($loadOptions);
try {
$slide = $presentation->getSlides()->get_Item(0);
// Add a new rectangle shape with text.
$shape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 20, 150, 50);
$shape->getTextFrame()->setText("Sample text");
// Check the first portion language.
$portion = $shape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
echo $portion->getPortionFormat()->getLanguageId();
} finally {
$presentation->dispose();
}
```
## **Set Default Text Style**
To apply default text formatting at the presentation level, use [Presentation::getDefaultTextStyle](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/#getDefaultTextStyle).
The following example sets a 14-point bold font as the default for top-level paragraphs in a new presentation and saves it to "default_text_style.pptx". Text can inherit these defaults unless more specific formatting overrides them.
```php
use aspose\slides\NullableBool;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
// Get the top level paragraph format.
$paragraphFormat = $presentation->getDefaultTextStyle()->getLevel(0);
if (!java_is_null($paragraphFormat)) {
$paragraphFormat->getDefaultPortionFormat()->setFontHeight(14);
$paragraphFormat->getDefaultPortionFormat()->setFontBold(NullableBool::True);
}
$presentation->save("default_text_style.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Extract Text with the All-Caps Effect**
In PowerPoint, applying the **All Caps** font effect makes text appear in uppercase on the slide even when it was originally typed in lowercase. When you retrieve such a text portion with Aspose.Slides, the library returns the text exactly as it was entered. To match the displayed text, check [TextCapType](https://reference.aspose.com/slides/php-java/aspose.slides/textcaptype/) and convert the returned string to uppercase when the value is `All`.
This example requires "sample2.pptx" with a text box as the first shape on the first slide. Its first paragraph’s first portion contains "Hello, Aspose!" with the All Caps effect applied, as shown below.

The code example below shows how to extract the text with the **All Caps** effect applied:
```php
use aspose\slides\Presentation;
use aspose\slides\TextCapType;
$presentation = new Presentation("sample2.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->get_Item(0);
$textPortion = $autoShape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
$originalText = $textPortion->getText();
echo "Original text: ", $originalText, "\n";
$textFormat = $textPortion->getPortionFormat()->getEffective();
if (java_values($textFormat->getTextCapType()) === TextCapType::All) {
$text = strtoupper($originalText);
echo "All-Caps effect: ", $text, "\n";
}
} finally {
$presentation->dispose();
}
```
Output:
```text
Original text: Hello, Aspose!
All-Caps effect: HELLO, ASPOSE!
```
## **FAQ**
**How do I modify text in a table on a slide?**
To modify text in a table on a slide, use [Table](https://reference.aspose.com/slides/php-java/aspose.slides/table/). Iterate through the cells and update each cell through [Cell::getTextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/cell/#getTextFrame) and paragraph formatting through [Paragraph::getParagraphFormat](https://reference.aspose.com/slides/php-java/aspose.slides/paragraph/#getParagraphFormat).
**How do I apply a gradient color to text on a PowerPoint slide?**
To apply a gradient color to text, use [BasePortionFormat::getFillFormat](https://reference.aspose.com/slides/php-java/aspose.slides/baseportionformat/#getFillFormat). Set [FillFormat::setFillType](https://reference.aspose.com/slides/php-java/aspose.slides/fillformat/#setFillType) to [FillType::Gradient](https://reference.aspose.com/slides/php-java/aspose.slides/filltype/) and configure the gradient stops, direction, and transparency.
# Add Trend Lines to Presentation Charts in PHP
> Quickly add and customize trend lines in PowerPoint charts with Aspose.Slides for PHP via Java — a practical guide to engage your audience.
Source: https://docs.aspose.com/slides/php-java/trend-line/
Updated: 2026-10-16
## **Overview**
This article explains how to add trend lines to presentation charts by using Aspose.Slides. It shows how to create a chart, add trend lines to chart series, and work with several trend line types, including exponential, linear, logarithmic, moving average, polynomial, and power.
It also describes how to add a custom line to a chart by inserting a line shape, and includes a short FAQ about forward and backward trend line projection values and whether trend lines are preserved during export to PDF or SVG and when rendering charts as images.
## **Add a Trend Line**
Use [TrendlineCollection::add](https://reference.aspose.com/slides/php-java/aspose.slides/trendlinecollection/add/) to add a trend line to a chart series, selecting its type with [TrendlineType](https://reference.aspose.com/slides/php-java/aspose.slides/trendlinetype/). The example creates a clustered column chart with default data and adds two trend lines to each of its three series.
The exponential trend line hides its equation and R-squared value through [setDisplayEquation](https://reference.aspose.com/slides/php-java/aspose.slides/trendline/setdisplayequation/) and [setDisplayRSquaredValue](https://reference.aspose.com/slides/php-java/aspose.slides/trendline/setdisplayrsquaredvalue/), while the linear trend line is red. The logarithmic trend line uses [addTextFrameForOverriding](https://reference.aspose.com/slides/php-java/aspose.slides/trendline/addtextframeforoverriding/) for a custom label. The moving average uses a [setPeriod](https://reference.aspose.com/slides/php-java/aspose.slides/trendline/setperiod/) of three data points and a custom [setTrendlineName](https://reference.aspose.com/slides/php-java/aspose.slides/trendline/settrendlinename/).
The polynomial trend line has an order of three, set through [setOrder](https://reference.aspose.com/slides/php-java/aspose.slides/trendline/setorder/), and extends one category forward through [setForward](https://reference.aspose.com/slides/php-java/aspose.slides/trendline/setforward/). The power trend line extends one category backward through [setBackward](https://reference.aspose.com/slides/php-java/aspose.slides/trendline/setbackward/).
```php
use aspose\slides\Presentation;
use aspose\slides\ChartType;
use aspose\slides\TrendlineType;
use aspose\slides\FillType;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 20, 20, 500, 400);
$firstSeries = $chart->getChartData()->getSeries()->get_Item(0);
$exponentialTrendline = $firstSeries->getTrendLines()->add(TrendlineType::Exponential);
$exponentialTrendline->setDisplayEquation(false);
$exponentialTrendline->setDisplayRSquaredValue(false);
$linearTrendline = $firstSeries->getTrendLines()->add(TrendlineType::Linear);
$linearTrendline->getFormat()->getLine()->getFillFormat()->setFillType(FillType::Solid);
$linearTrendline->getFormat()->getLine()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->RED);
$secondSeries = $chart->getChartData()->getSeries()->get_Item(1);
$logarithmicTrendline = $secondSeries->getTrendLines()->add(TrendlineType::Logarithmic);
$logarithmicTrendline->addTextFrameForOverriding("New log trend line");
$movingAverageTrendline = $secondSeries->getTrendLines()->add(TrendlineType::MovingAverage);
$movingAverageTrendline->setPeriod(3);
$movingAverageTrendline->setTrendlineName("New TrendLine Name");
$thirdSeries = $chart->getChartData()->getSeries()->get_Item(2);
$polynomialTrendline = $thirdSeries->getTrendLines()->add(TrendlineType::Polynomial);
$polynomialTrendline->setForward(1);
$polynomialTrendline->setOrder(3);
$powerTrendline = $thirdSeries->getTrendLines()->add(TrendlineType::Power);
$powerTrendline->setBackward(1);
$presentation->save("ChartTrendLines.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Set a Trend Line Intercept**
Use [setIntercept](https://reference.aspose.com/slides/php-java/aspose.slides/trendline/setintercept/) to fix a trend line's Y value at X = 0. This setting is supported for linear, exponential, and polynomial trend lines.
For example, a production cost model may need to start at known fixed costs of 100, even when measurements at nonzero production volumes suggest a different baseline. For a linear trend line, fixing the intercept constrains the equation `y = ax + b` to `b = 100`; the slope is fitted to the data under that constraint. It does not simply move an already fitted line. Axis crossing settings control where the chart axes meet, not the coefficients of the fitted trend line.
The following example creates a scatter (XY) chart with production volumes from 1 to 4 and costs of 170, 200, 230, and 260. It saves the chart with the default automatic intercept, sets the intercept to 100, and saves a second PPTX. The two files differ only in the intercept setting. The trend line displays its equation and extends back to X = 0.
```php
use aspose\slides\Presentation;
use aspose\slides\ChartType;
use aspose\slides\TrendlineType;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ScatterWithMarkers, 20, 20, 480, 210);
$chart->setLegend(false);
$chart->getChartData()->getSeries()->clear();
$chart->getChartData()->getCategories()->clear();
$workbook = $chart->getChartData()->getChartDataWorkbook();
$workbook->clear(0);
$nameCell = $workbook->getCell(0, 0, 1, "Production cost");
$series = $chart->getChartData()->getSeries()->add($nameCell, ChartType::ScatterWithMarkers);
$costs = [170, 200, 230, 260];
for ($i = 0; $i < count($costs); $i++) {
$xCell = $workbook->getCell(0, $i + 1, 0, $i + 1);
$yCell = $workbook->getCell(0, $i + 1, 1, $costs[$i]);
$series->getDataPoints()->addDataPointForScatterSeries($xCell, $yCell);
}
$trendline = $series->getTrendLines()->add(TrendlineType::Linear);
$trendline->setDisplayEquation(true);
$trendline->setBackward(1);
$presentation->save("AutomaticIntercept.pptx", SaveFormat::Pptx);
$trendline->setIntercept(100);
$presentation->save("FixedIntercept.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
With automatic calculation, these data produce `y = 30x + 140`. Setting the intercept to 100 instead produces approximately `y = 43.33x + 100`: the fitted value at zero matches the known baseline, while the line no longer passes through every data point.
| Automatic intercept | Fixed intercept of 100 |
| --- | --- |
|  |  |
Both images use the same data and axis scales. The trend lines are extended back to X = 0 to show their intercepts.
By default, [getIntercept](https://reference.aspose.com/slides/php-java/aspose.slides/trendline/getintercept/) returns `NaN`, which represents an unspecified intercept rather than zero. The intercept is then calculated automatically from the data.
## **Add a Custom Line**
A custom line is a shape drawn over the chart rather than a trend line calculated from series data. This example uses [ShapeCollection::addAutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/addautoshape/) to add a horizontal line to the slide over the chart. The line's position is specified in slide coordinates, measured in points, so it starts at the chart's left edge and sits halfway down the chart. Its width matches the chart's width. The [getLineFormat](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getlineformat/) gives the line a solid red color.
```php
use aspose\slides\Presentation;
use aspose\slides\ChartType;
use aspose\slides\FillType;
use aspose\slides\ShapeType;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$chart = $slide->getShapes()->addChart(ChartType::ClusteredColumn, 100, 100, 500, 400);
$lineY = java_values($chart->getY()) + java_values($chart->getHeight()) / 2;
$line = $slide->getShapes()->addAutoShape(ShapeType::Line, $chart->getX(), $lineY, $chart->getWidth(), 0);
$line->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$line->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->RED);
$presentation->save("AddCustomLines.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **FAQ**
**What do 'forward' and 'backward' mean for a trend line?**
They are the lengths of the trend line projected forward/backward: for scatter (XY) charts — in axis units; for non-scatter charts — in number of categories. Only non-negative values are allowed.
**Will the trend line be preserved when exporting the presentation to PDF or SVG, or when rendering a slide to an image?**
Yes. Aspose.Slides converts presentations to [PDF](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-pdf/) or [SVG](https://docs.aspose.com/slides/php-java/render-a-slide-as-an-svg-image/) and renders charts to images; trend lines, as part of the chart, are preserved during these operations. A method is also available to [export an image of the chart](https://docs.aspose.com/slides/php-java/create-shape-thumbnails/) itself.
# Manage Video Frames in Presentations Using PHP
> Learn to programmatically add and extract video frames in PowerPoint and OpenDocument slides using Aspose.Slides for PHP via Java. Fast how-to guide.
Source: https://docs.aspose.com/slides/php-java/video-frame/
Updated: 2026-10-09
## **Introduction**
Videos can help explain ideas and engage an audience. Aspose.Slides for PHP via Java lets you add video frames to slides, adjust playback settings, manage captions, and extract embedded video data.
PowerPoint supports local videos and links to online videos, such as YouTube videos.
To represent video data and video frames, Aspose.Slides provides the [Video](https://reference.aspose.com/slides/php-java/aspose.slides/video/) class, [VideoFrame](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/) class, and other relevant types.
## **Create an Embedded Video Frame**
If the video file you want to add to your slide is stored locally, you can create a video frame to embed the video in your presentation.
This example embeds a local video on the first slide of an existing presentation and saves the result. Frame coordinates and dimensions are in points. The stream stays open until saving finishes because [LoadingStreamBehavior::KeepLocked](https://reference.aspose.com/slides/php-java/aspose.slides/loadingstreambehavior/) keeps it locked while the presentation uses it.
```php
use aspose\slides\LoadingStreamBehavior;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("presentation.pptx");
$videoStream = null;
try {
$videoStream = new Java("java.io.FileInputStream", "video.mp4");
$slide = $presentation->getSlides()->get_Item(0);
$video = $presentation->getVideos()->addVideo($videoStream, LoadingStreamBehavior::KeepLocked);
$slide->getShapes()->addVideoFrame(10, 10, 150, 250, $video);
$presentation->save("embedded_video.pptx", SaveFormat::Pptx);
} finally {
if ($videoStream !== null) {
$videoStream->close();
}
$presentation->dispose();
}
```
You can also pass a local video path directly to [addVideoFrame](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/#addVideoFrame). This example embeds the video on the first slide of a new presentation. The video must remain accessible until the presentation is saved.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$slide->getShapes()->addVideoFrame(50, 150, 300, 150, "video.avi");
$presentation->save("video_from_path.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Create a Video Frame with Video from a Web Source**
Microsoft [PowerPoint](https://support.microsoft.com/en-us/powerpoint/training/insert-a-video-from-youtube-or-another-site) supports online videos in presentations. You can create a video frame that links to an online video, such as a YouTube video.
This example adds a YouTube video link and thumbnail to the first slide. Replace the video identifier to use another video. The [setPlayMode](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/#setPlayMode) method requests automatic playback. Downloading the thumbnail and playing the video require internet access. The presentation viewer must also support online video playback.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\VideoPlayModePreset;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$videoId = "aqz-KE-bpKQ";
$videoUrl = "https://www.youtube.com/embed/" . $videoId;
$videoFrame = $slide->getShapes()->addVideoFrame(10, 10, 427, 240, $videoUrl);
$videoFrame->setPlayMode(VideoPlayModePreset::Auto);
$thumbnailUrl = "https://img.youtube.com/vi/" . $videoId . "/hqdefault.jpg";
$thumbnailLocation = new Java("java.net.URL", $thumbnailUrl);
$thumbnailStream = $thumbnailLocation->openStream();
try {
$thumbnail = $presentation->getImages()->addImage($thumbnailStream);
$videoFrame->getPictureFormat()->getPicture()->setImage($thumbnail);
} finally {
$thumbnailStream->close();
}
$presentation->save("online_video.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Play a Video in Full-Screen Mode**
In a training presentation, you can play a software demonstration in full-screen mode so the audience can see the details. Call [setFullScreenMode](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/#setFullScreenMode) with `true` to enable this behavior during playback.
This example opens a presentation, finds the first [VideoFrame](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/) on the first slide, and enables full-screen playback. The input presentation must contain at least one slide with an existing video frame on the first slide.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("training.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapeCount = java_values($slide->getShapes()->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $slide->getShapes()->get_Item($shapeIndex);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.VideoFrame"))) {
$videoFrame = $shape;
$videoFrame->setFullScreenMode(true);
break;
}
}
$presentation->save("full_screen_video.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Full-screen playback controls how the video is displayed. Independently, [setPlayMode](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/#setPlayMode) controls whether it starts automatically or on click, and [setPlayLoopMode](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/#setPlayLoopMode) controls whether it repeats. To choose the start behavior, set the playback mode to [VideoPlayModePreset::Auto or VideoPlayModePreset::OnClick](https://reference.aspose.com/slides/php-java/aspose.slides/videoplaymodepreset/). The example preserves the existing start and loop settings.
## **Rewind a Video After Playback**
In a training presentation, returning a demonstration video to its beginning makes it ready for the presenter to play again. Call [setRewindVideo](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/#setRewindVideo) with `true` to return the video to the beginning after playback finishes.
This example opens a presentation, finds the first [VideoFrame](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/) on the first slide, and enables rewinding. It disables looping so playback can finish and sets playback to start on click. The input presentation must contain at least one slide with an existing video frame on the first slide.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\VideoPlayModePreset;
$presentation = new Presentation("training.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapeCount = java_values($slide->getShapes()->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $slide->getShapes()->get_Item($shapeIndex);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.VideoFrame"))) {
$videoFrame = $shape;
$videoFrame->setRewindVideo(true);
$videoFrame->setPlayLoopMode(false);
$videoFrame->setPlayMode(VideoPlayModePreset::OnClick);
break;
}
}
$presentation->save("rewind_video.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
Rewinding returns the video to its beginning without starting it again. In contrast, calling [setPlayLoopMode](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/#setPlayLoopMode) with `true` repeats playback automatically. Keep looping disabled when you want the video to finish and remain ready to replay. [setPlayMode](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/#setPlayMode) independently controls automatic or on-click startup; this example uses [VideoPlayModePreset::OnClick](https://reference.aspose.com/slides/php-java/aspose.slides/videoplaymodepreset/) so the presenter controls when playback starts. Set the playback mode after the loop setting, as shown in the example. Rewinding works independently of [setFullScreenMode](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/#setFullScreenMode).
## **Trim a Video Frame**
Use [VideoFrame::setTrimFromStart](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/#setTrimFromStart) and [VideoFrame::setTrimFromEnd](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/#setTrimFromEnd) to skip part of the beginning or end of a video during playback. Both values are in milliseconds. Trimming changes playback settings without modifying the embedded video data.
**Set Trim Settings**
This example embeds a local video and skips the first 2.5 seconds and the last second during playback. Use a video longer than 3.5 seconds so a playable segment remains.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$videoFile = new Java("java.io.File", "video.mp4");
$videoPath = $videoFile->toPath();
$videoData = java("java.nio.file.Files")->readAllBytes($videoPath);
$video = $presentation->getVideos()->addVideo($videoData);
$videoFrame = $slide->getShapes()->addVideoFrame(50, 50, 640, 360, $video);
$videoFrame->setTrimFromStart(2500);
$videoFrame->setTrimFromEnd(1000);
$presentation->save("video_with_trim.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
**Read Trim Settings**
This example prints the trim values of the first video frame on the first slide in milliseconds. The presentation must contain at least one slide. If that slide has no video frame, nothing is printed. The preceding example produces values of 2500 and 1000.
```php
use aspose\slides\Presentation;
$presentation = new Presentation("video_with_trim.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$shapeCount = java_values($slide->getShapes()->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $slide->getShapes()->get_Item($shapeIndex);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.VideoFrame"))) {
$videoFrame = $shape;
echo "Trim from start: " . java_values($videoFrame->getTrimFromStart()) . " ms\n";
echo "Trim from end: " . java_values($videoFrame->getTrimFromEnd()) . " ms\n";
break;
}
}
} finally {
$presentation->dispose();
}
```
## **Manage Video Captions**
Aspose.Slides allows you to manage closed captions for video frames in PowerPoint presentations. Captions are stored in WebVTT format and are exposed through the [VideoFrame::getCaptionTracks](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/#getCaptionTracks) method.
**Add Captions to a Video Frame**
This example embeds a local video and adds a WebVTT caption track labeled English. The caption timestamps should match the video. The saved presentation includes both the video and its captions.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$videoFile = new Java("java.io.File", "video.mp4");
$videoPath = $videoFile->toPath();
$videoData = java("java.nio.file.Files")->readAllBytes($videoPath);
$video = $presentation->getVideos()->addVideo($videoData);
$videoFrame = $slide->getShapes()->addVideoFrame(0, 0, 100, 100, $video);
$videoFrame->getCaptionTracks()->add("English", "track.vtt");
$presentation->save("video_with_captions.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
The [CaptionsCollection](https://reference.aspose.com/slides/php-java/aspose.slides/captionscollection/) class also provides an overload that lets you add captions from a stream.
**Extract Captions from a Video Frame**
This example saves all caption tracks from video frames on the first slide as separate WebVTT files. Sequential numbers keep the output files distinct. The console reports the number of extracted tracks. The presentation must contain at least one slide.
```php
use aspose\slides\Presentation;
$presentation = new Presentation("video_with_captions.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$trackCount = 0;
$shapeCount = java_values($slide->getShapes()->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $slide->getShapes()->get_Item($shapeIndex);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.VideoFrame"))) {
$videoFrame = $shape;
$captionCount = java_values($videoFrame->getCaptionTracks()->getCount());
for ($trackIndex = 0; $trackIndex < $captionCount; $trackIndex++) {
$captionTrack = $videoFrame->getCaptionTracks()->get_Item($trackIndex);
$trackCount++;
$outputStream = new Java("java.io.FileOutputStream", "captions_" . $trackCount . ".vtt");
try {
$outputStream->write($captionTrack->getBinaryData());
} finally {
$outputStream->close();
}
}
}
}
echo "Caption tracks extracted: " . $trackCount . "\n";
} finally {
$presentation->dispose();
}
```
Each [Captions](https://reference.aspose.com/slides/php-java/aspose.slides/captions/) object exposes the caption identifier, label, binary data, and caption text as a UTF-8 string.
**Remove Captions from a Video Frame**
This example removes all captions from the video frame at the first shape position on the first slide and saves the result. It assumes that the slide and shape exist and that the shape is a video frame.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("video_with_captions.pptx");
try {
$slide = $presentation->getSlides()->get_Item(0);
$videoFrame = $slide->getShapes()->get_Item(0);
$videoFrame->getCaptionTracks()->clear();
$presentation->save("video_without_captions.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
If you need to remove only one caption track, use the [remove](https://reference.aspose.com/slides/php-java/aspose.slides/captionscollection/#remove) or [removeAt](https://reference.aspose.com/slides/php-java/aspose.slides/captionscollection/#removeAt) methods instead of [clear](https://reference.aspose.com/slides/php-java/aspose.slides/captionscollection/#clear).
## **Extract Video from a Slide**
Besides adding videos to slides, Aspose.Slides allows you to extract videos embedded in presentations.
This example extracts embedded videos from every slide into separate, numbered binary files. Linked videos are skipped because they have no embedded data. The console prints each video’s MIME type and the total count. Output uses the generic `.bin` extension; change it to match the reported media type when needed.
```php
use aspose\slides\Presentation;
$presentation = new Presentation("presentation_with_videos.pptx");
try {
$videoCount = 0;
$slideCount = java_values($presentation->getSlides()->size());
for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
$slide = $presentation->getSlides()->get_Item($slideIndex);
$shapeCount = java_values($slide->getShapes()->size());
for ($shapeIndex = 0; $shapeIndex < $shapeCount; $shapeIndex++) {
$shape = $slide->getShapes()->get_Item($shapeIndex);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.VideoFrame"))) {
$videoFrame = $shape;
$video = $videoFrame->getEmbeddedVideo();
if (java_is_null($video)) {
echo "Skipped a linked video: no embedded data is available.\n";
continue;
}
$videoCount++;
$outputStream = new Java("java.io.FileOutputStream", "extracted_video_" . $videoCount . ".bin");
try {
$outputStream->write($video->getBinaryData());
} finally {
$outputStream->close();
}
echo "Video " . $videoCount . ": " . java_values($video->getContentType()) . "\n";
}
}
}
echo "Embedded videos extracted: " . $videoCount . "\n";
} finally {
$presentation->dispose();
}
```
## **FAQ**
**Which video playback parameters can be changed for a video frame?**
You can control the [playback mode](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/#setPlayMode) (auto or on click) and [looping](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/#setPlayLoopMode). These options are available via the [VideoFrame](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/) object's methods.
**Does adding a video affect the PPTX file size?**
Yes. When you embed a local video, the binary data is included in the document, so the presentation size grows in proportion to the file size. When you link to an online video and add a thumbnail, the presentation stores the link and preview image rather than the video data, so the size increase is usually smaller.
**Can I replace the video in an existing video frame without changing its position and size?**
Yes. You can swap the [video content](https://reference.aspose.com/slides/php-java/aspose.slides/videoframe/#setEmbeddedVideo) within the frame while preserving the shape's geometry; this is a common scenario for updating media in an existing layout.
**Can the content type (MIME) of an embedded video be determined?**
Yes. An embedded video has a [content type](https://reference.aspose.com/slides/php-java/aspose.slides/video/#getContentType) that you can read and use, for example when saving it to disk.
## Related articles
- [Manage Audio in Presentations Using PHP](https://docs.aspose.com/slides/php-java/audio-frame/)
- [Video](https://docs.aspose.com/slides/php-java/examples/elements/video/)
# Add Watermarks to Presentations in PHP
> Manage text and image watermarks in PowerPoint and OpenDocument presentations in PHP to indicate a draft, confidential information, copyright, and more.
Source: https://docs.aspose.com/slides/php-java/watermark/
Updated: 2026-08-13
## **Introduction**
**A watermark** in a presentation is a text or image stamp used on a slide or throughout all presentation slides. Usually, a watermark is used to indicate that the presentation is a draft (e.g., a "Draft" watermark), that it contains confidential information (e.g., a "Confidential" watermark), to specify which company it belongs to (e.g., a "Company Name" watermark), to identify the presentation author, etc. A watermark helps to prevent copyright violations by indicating that the presentation should not be copied. Watermarks are used in both PowerPoint and OpenOffice presentation formats. In Aspose.Slides, you can add a watermark to PowerPoint PPT, PPTX, and OpenOffice ODP file formats.
In [**Aspose.Slides**](https://products.aspose.com/slides/php-java/), there are various ways you can create watermarks in PowerPoint or OpenOffice documents and modify their design and behavior. The common aspect is that to add text watermarks, you should use the [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/) class, and to add image watermarks, use the [PictureFrame](https://reference.aspose.com/slides/php-java/aspose.slides/pictureframe/) class or fill a watermark shape with an image. `PictureFrame` implements the [Shape](https://reference.aspose.com/slides/php-java/aspose.slides/shape/) class, allowing you to use all the flexible settings of the shape object. Since `ITextFrame` is not a shape and its settings are limited, it is wrapped into an [Shape](https://reference.aspose.com/slides/php-java/aspose.slides/shape/) object.
There are two ways a watermark can be applied: to a single slide or to all presentation slides. The Slide Master is used to apply a watermark to all presentation slides — the watermark is added to the Slide Master, fully designed there, and applied to all slides without affecting the permission to modify the watermark on individual slides.
A watermark is usually considered to be unavailable for editing by other users. To prevent the watermark (or rather the watermark's parent shape) from being edited, Aspose.Slides provides shape locking functionality. A specific shape can be locked on a normal slide or on a Slide Master. When the watermark shape is locked on the Slide Master, it will be locked on all presentation slides.
You can set a name for the watermark so that in the future, if you want to delete it, you can find it in the slide's shapes by name.
You can design the watermark in any way; however, there are usually common features in watermarks, such as center alignment, rotation, front position, etc. We will consider how to use these in the examples below.
## **Text Watermark**
### **Add a Text Watermark to a Slide**
To add a text watermark in PPT, PPTX, or ODP, you can first add a shape to the slide, then add a text frame to this shape. The text frame is represented by the [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/) class. This type is not inherited from [Shape](https://reference.aspose.com/slides/php-java/aspose.slides/shape/), which has a wide set of properties for positioning the watermark in a flexible way. Therefore, the [TextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/textframe/) object is wrapped in an [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/) object. To add watermark text to the shape, use the [addTextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/#addTextFrame) method as shown below.
```php
$watermarkText = "CONFIDENTIAL";
$presentation = new Presentation();
$slide = $presentation->getSlides()->get_Item(0);
$watermarkShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 400, 40);
$watermarkFrame = $watermarkShape->addTextFrame($watermarkText);
$presentation->dispose();
```
- [How to Use the TextFrame Class](https://docs.aspose.com/slides/php-java/text-formatting/)
### **Add a Text Watermark to a Presentation**
If you want to add a text watermark to the entire presentation (i.e., all slides at once), add it to the [MasterSlide](https://reference.aspose.com/slides/php-java/aspose.slides/masterslide/). The rest of the logic is the same as when adding a watermark to a single slide — create an [AutoShape](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/) object and then add the watermark to it using the [addTextFrame](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/#addTextFrame) method.
```php
$watermarkText = "CONFIDENTIAL";
$presentation = new Presentation();
$masterSlide = $presentation->getMasters()->get_Item(0);
$watermarkShape = $masterSlide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 400, 40);
$watermarkFrame = $watermarkShape->addTextFrame($watermarkText);
$presentation->dispose();
```
- [How to Use the Slide Master](https://docs.aspose.com/slides/php-java/slide-master/)
### **Set Watermark Shape Transparency**
By default, the rectangle shape is styled with fill and line colors. The following lines of code make the shape transparent.
```php
$presentation = new Presentation();
$slide = $presentation->getSlides()->get_Item(0);
$watermarkShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 400, 40);
$watermarkShape->getFillFormat()->setFillType(FillType::NoFill);
$watermarkShape->getLineFormat()->getFillFormat()->setFillType(FillType::NoFill);
$presentation->dispose();
```
### **Set the Font for a Text Watermark**
You can change the font of the text watermark as shown below.
```php
$presentation = new Presentation();
$slide = $presentation->getSlides()->get_Item(0);
$watermarkShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 400, 40);
$watermarkFrame = $watermarkShape->addTextFrame("CONFIDENTIAL");
$textFormat = $watermarkFrame->getParagraphs()->get_Item(0)->getParagraphFormat()->getDefaultPortionFormat();
$textFormat->setLatinFont(new FontData("Arial"));
$textFormat->setFontHeight(50);
$presentation->dispose();
```
### **Set the Watermark Text Color**
To set the color of the watermark text, use this code:
```php
$presentation = new Presentation();
$slide = $presentation->getSlides()->get_Item(0);
$watermarkShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 400, 40);
$watermarkFrame = $watermarkShape->addTextFrame("CONFIDENTIAL");
$alpha = 150;
$red = 200;
$green = 200;
$blue = 200;
$textColor = new Java("java.awt.Color", $red, $green, $blue, $alpha);
$fillFormat = $watermarkFrame->getParagraphs()->get_Item(0)->getParagraphFormat()->getDefaultPortionFormat()->getFillFormat();
$fillFormat->setFillType(FillType::Solid);
$fillFormat->getSolidFillColor()->setColor($textColor);
$presentation->dispose();
```
### **Center a Text Watermark**
It is possible to center the watermark on a slide, and for that, you can do the following:
```php
$watermarkText = "CONFIDENTIAL";
$presentation = new Presentation();
$slide = $presentation->getSlides()->get_Item(0);
$slideSize = $presentation->getSlideSize()->getSize();
$slideWidth = java_values($slideSize->getWidth());
$slideHeight = java_values($slideSize->getHeight());
$watermarkWidth = 400;
$watermarkHeight = 40;
$watermarkX = ($slideWidth - $watermarkWidth) / 2;
$watermarkY = ($slideHeight - $watermarkHeight) / 2;
$watermarkShape = $slide->getShapes()->addAutoShape(
ShapeType::Rectangle, $watermarkX, $watermarkY, $watermarkWidth, $watermarkHeight);
$watermarkFrame = $watermarkShape->addTextFrame($watermarkText);
$presentation->dispose();
```
The image below shows the final result.

## **Image Watermark**
### **Add an Image Watermark to a Presentation**
To add an image watermark to a presentation slide, you can do the following:
```php
$presentation = new Presentation();
$slide = $presentation->getSlides()->get_Item(0);
$watermarkShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 400, 40);
$image = Images::fromFile("watermark.png");
$picture = $presentation->getImages()->addImage($image);
$image->dispose();
$watermarkShape->getFillFormat()->setFillType(FillType::Picture);
$watermarkShape->getFillFormat()->getPictureFillFormat()->getPicture()->setImage($picture);
$watermarkShape->getFillFormat()->getPictureFillFormat()->setPictureFillMode(PictureFillMode::Stretch);
$presentation->dispose();
```
### **Lock a Watermark from Editing**
If it is necessary to prevent a watermark from being edited, use the [AutoShape.getAutoShapeLock](https://reference.aspose.com/slides/php-java/aspose.slides/autoshape/#getAutoShapeLock) method on the shape. With this property, you can protect the shape from being selected, resized, repositioned, grouped with other elements, lock its text from editing, and much more:
```php
$presentation = new Presentation();
$slide = $presentation->getSlides()->get_Item(0);
$watermarkShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 400, 40);
// Lock the watermark shape from modifying
$watermarkShape->getAutoShapeLock()->setSelectLocked(true);
$watermarkShape->getAutoShapeLock()->setSizeLocked(true);
$watermarkShape->getAutoShapeLock()->setTextLocked(true);
$watermarkShape->getAutoShapeLock()->setPositionLocked(true);
$watermarkShape->getAutoShapeLock()->setGroupingLocked(true);
$presentation->dispose();
```
### **Bring a Watermark to Front**
In Aspose.Slides, the Z-order of shapes can be set via the [ShapeCollection.reorder](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/#reorder) method. To do this, you need to call this method from the presentation slides list and pass the shape reference and its order number into the method. This way, it is possible to bring a shape to the front or send it to the back of the slide. This feature is especially useful if you need to place a watermark in front of the presentation:
```php
$presentation = new Presentation();
$slide = $presentation->getSlides()->get_Item(0);
$watermarkShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 400, 40);
$shapeCount = java_values($slide->getShapes()->size());
$slide->getShapes()->reorder($shapeCount - 1, $watermarkShape);
$presentation->dispose();
```
### **Set Watermark Rotation**
Here is a code example of how to adjust the rotation of the watermark so that it is positioned diagonally across the slide:
```php
$presentation = new Presentation();
$slide = $presentation->getSlides()->get_Item(0);
$watermarkShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 400, 40);
$slideSize = $presentation->getSlideSize()->getSize();
$slideWidth = java_values($slideSize->getWidth());
$slideHeight = java_values($slideSize->getHeight());
$diagonalAngle = atan($slideWidth / $slideHeight) * 180 / M_PI;
$watermarkShape->setRotation($diagonalAngle);
$presentation->dispose();
```
### **Set a Name for a Watermark**
Aspose.Slides allows you to set the name of a shape. By using the shape name, you can access it in the future to modify or delete it. To set the name of the watermark shape, assign it to the [AutoShape.setName](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#setName) method:
```php
$presentation = new Presentation();
$slide = $presentation->getSlides()->get_Item(0);
$watermarkShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 100, 400, 40);
$watermarkShape->setName("watermark");
$presentation->dispose();
```
### **Remove a Watermark**
To remove the watermark shape, use the [AutoShape.getName](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#getName) method to find it in the slide shapes. Then, pass the watermark shape into the [ShapeCollection.remove](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/#remove) method:
```php
$presentation = new Presentation("presentation_with_watermark.pptx");
$slide = $presentation->getSlides()->get_Item(0);
$slideShapes = $slide->getShapes()->toArray();
foreach ($slideShapes as $shape) {
if (java_values($shape->getName()) === "watermark") {
$slide->getShapes()->remove($shape);
}
}
$presentation->save("presentation_without_watermark.pptx", SaveFormat::Pptx);
$presentation->dispose();
```
## **FAQ**
### What is a watermark and why should I use it?
A watermark is a text or image overlay applied to slides that helps protect intellectual property, enhance brand recognition, or prevent unauthorized use of presentations.
### Can I add a watermark to all slides in a presentation?
Yes, Aspose.Slides allows you to programmatically add a watermark to every slide in a presentation. You can iterate through all the slides and apply the watermark settings individually.
### How can I adjust the transparency of the watermark?
You can adjust the transparency of the watermark by modifying the fill settings ([getFillFormat](https://reference.aspose.com/slides/php-java/aspose.slides/shape/getfillformat/)) of the shape. This ensures that the watermark is subtle and does not distract from the slide content.
### What image formats are supported for watermarks?
Aspose.Slides supports various image formats such as PNG, JPEG, GIF, BMP, SVG, and more.
### Can I customize the font and style of a text watermark?
Yes, you can choose any font, size, and style to match the design of your presentation and maintain brand consistency.
### How do I change the position or orientation of a watermark?
You can adjust the position and orientation of the watermark programmatically by modifying the shape's coordinates, size, and rotation properties.
# Why Not Automation
> Discover why Office automation is risky for servers and services, and see how Aspose.Slides offers safer, faster presentation processing for PowerPoint and OpenDocument.
Source: https://docs.aspose.com/slides/php-java/why-not-automation/
Updated: 2026-08-13
## **Overview**
There are several reasons Aspose components are a better alternative to automation. Some of the key reasons are:
- Security
- Stability
- Scalability/Speed
- Price
- Features
Below is a more detailed explanation of each key point.
## **Important Questions**
There are two questions we often hear at Aspose:
- Do your products require Microsoft Office to be installed in order to run?
The short, simple answer is **NO**.
Aspose components are completely independent and are not affiliated with, authorized by, sponsored by, or otherwise approved by Microsoft Corporation.
- Why should we use Aspose products instead of Microsoft Office Automation?
First, there are many [benefits you enjoy when you use Aspose.Slides](https://docs.aspose.com/slides/php-java/product-overview/).
Second, Microsoft itself strongly **advises against** using Office Automation from software solutions.
## **Security**
The following is a direct quote from a Microsoft Article:
*"Office Applications were never intended for use server-side, and therefore do not take into consideration the security problems that are faced by distributed components. Office does not authenticate incoming requests, and does not protect you from unintentionally running macros, or starting another server that might run macros, from your server-side code. Do not open files that are uploaded to the server from an anonymous Web! Based on the security settings that were last set, the server can run macros under an Administrator or System context with full privileges and compromise your network! In addition, Office uses many client-side components (such as Simple MAPI, WinInet, MSDAIPP) that can cache client authentication information in order to speed up processing. If Office is being automated server-side, one instance may service more than one client, and because authentication information has been cached for that session, it is possible that one client can use the cached credentials of another client, and thereby gain non-granted access permissions by impersonating other users."*
Aspose products are very secure. Aspose components do not pose a potential risk to vital system resources. Furthermore, when a document is opened by an Aspose component, macros are not automatically run. Aspose components were built with the goal of allowing developers to create, manipulate and save Office files. None of the risks associated with the Microsoft Office package are inherent to Aspose components.
## **Stability**
The following is a direct quote from a Microsoft Article:
*"Office 2000, Office XP and Office 2003 use Microsoft Windows Installer (MSI) technology to make installation and self-repair easier for an end user. MSI introduces the concept of "install on first use", which allows features to be dynamically installed or configured at runtime (for the system, or more often for a particular user). In a server-side environment this both slows down performance and increases the likelihood that a dialog box may appear that asks for the user to approve the install or provide an appropriate install disk. Although it is designed to increase the resiliency of Office as an end-user product, Office's implementation of MSI capabilities is counterproductive in a server-side environment. Furthermore, the stability of Office in general cannot be assured when run server-side because it has not been designed or tested for this type of use. Using Office as a service component on a network server may reduce the stability of that machine and as a consequence your network as a whole. If you plan to automate Office server-side, attempt to isolate the program to a dedicated computer that cannot affect critical functions, and that can be restarted as needed."*
Aspose components have been thoroughly tested and are extremely stable. Aspose components are used by [Companies](https://about.aspose.com/customers) such as: **IBM** , **Hilton** , **Reader's Digest** , **Bank of America** and many many more.
## **Scalability/Speed**
The following is a direct quote from a Microsoft Article:
*"Server-side components need to be highly reentrant, multi-threaded COM components with minimum overhead and high throughput for multiple clients. Office Applications are in almost all respects the exact opposite. They are non-reentrant, STA-based Automation servers that are designed to provide diverse but resource-intensive functionality for a single client. They offer little scalability as a server-side solution, and have fixed limits to important elements, such as memory, which cannot be changed through configuration. More importantly, they use global resources (such as memory mapped files, global add-ins or templates, and shared Automation servers), which can limit the number of instances that can run concurrently and lead to race conditions if they are configured in a multi-client environment. Developers who plan to run more than one instance of any Office Application at the same time need to consider* ***Pooling*** *or* ***Serializing Access*** *to the Office Application for avoiding potential* ***Deadlocks*** *or* ***Data Corruption*** *.*
Aspose components are highly scalable and lightning fast. Office applications were not designed to be simultaneously used by 100s and 1000s of users. However, Aspose components are designed for just that. Our components perform flawlessly whether on a single server, powering a single application or on a load balanced Web Form powering an enterprise wide application.
## **Price**
When an application utilizes Microsoft Office Automation, a copy of Microsoft Office must be purchased for each machine that runs the application. There are many times that an application may need to create or manipulate an office file but does not require the user to have Microsoft Office. Aspose offers a very [Cost Effective](https://purchase.aspose.com/) and royalty free redistribution license that will allow deployment to an unlimited number of users with no licensing worries.
When creating web based applications it is important to know that Microsoft Office Automation components are not priced nor licensed for server side solutions; therefore, there is no good, licensing solution for deploying web applications that utilize the Microsoft Office components. Aspose offers a very Cost Effective solution for server based applications as well.
## **Features**
Aspose components provide everything needed for managing Office files plus much more. They are designed with the philosophy of allowing developers to accomplish the greatest results with the least amount of work. Unlike Office Automation, Aspose components provide many powerful and time saving functions. For instance, [Aspose.Cells](https://products.aspose.com/cells/php-java/) offers developers the ability to import data from a **DataTable** or **DataView** directly into an Excel file. [Every Component](https://products.aspose.com/total/php-java/) in the Aspose family offers their own set of unique and powerful features.
The best part of purchasing an Aspose component (or component suites like [Aspose.Total](https://products.aspose.com/total/php-java/) ) is having access to our development teams. Our development teams realize that if there is a feature that your company needs, more than likely other companies will need it as well. While not every feature request can be added, our teams try to be very open-minded and flexible when providing assistance. That mindset is what has helped Aspose components to become as powerful as they are. If there are additional features that you need from Office Automation objects, your chances of having them added are very, very low.
## **Conclusion**
While this article has covered many of the key points why Aspose components are a better choice than Office Automation, there are many, many more. This article primarily addresses only the most key points. All of the different Aspose components offer a risk free, no obligation [Evaluation Version](https://downloads.aspose.com/slides/java) . We encourage you to take advantage of that Evaluation in order to better see what Aspose can do for your applications.
# Why Not Open XML SDK
> See why Aspose.Slides is a better choice than the free Open XML SDK: compare features, automation-free conversion, and broad support for PPT, PPTX and ODP.
Source: https://docs.aspose.com/slides/php-java/why-not-open-xml-sdk/
Updated: 2026-08-31
## **Overview**
This article explains when developers might choose Open XML SDK or Aspose.Slides for working with presentation documents. It describes Open XML SDK as a library for manipulating OOXML packages and their underlying XML elements, while Aspose.Slides is presented as a presentation processing library with a high-level object model and support for many PowerPoint-related tasks.
The article compares both options by supported formats, programming model, rendering, platform support, and common use cases. It also clarifies that Open XML SDK may be suitable for basic PPTX operations or direct access to OOXML elements, while Aspose.Slides is more appropriate for complex presentation tasks such as working with multiple PowerPoint formats, copying or cloning shapes, replacing text, applying animations, and converting presentations to PDF, TIFF, or XPS.
## **What Is Open XML SDK?**
According to the [MSDN Library](https://docs.microsoft.com/en-us/office/open-xml/open-xml-sdk), Open XML SDK is defined as:
The Open XML SDK 2.0 simplifies the task of manipulating Open XML packages and the underlying Open XML schema elements within a package. The Open XML SDK 2.0 encapsulates many common tasks that developers perform on Open
XML packages, so that you can perform complex operations with just a few lines of code.
OOXML documents are essentially zipped XML files and Open XML SDK is a collection of classes that allows you to work with the content of OOXML documents in a strongly-typed way. That is instead of unzipping a file to
extract XML, loading that XML into a DOM tree and working with XML elements and attributes directly, Open XML SDK provides classes to do that.
## **What Is Aspose.Slides?**
Aspose.Slides is a class library that allows your application to perform the following presentation processing tasks:
- Programming with a **Presentation** object model.
- High Quality conversions among all popular supported PowerPoint presentation formats, including conversion to PDF, XPS and TIFF.
- Ability to gnereate slide thumbnails in well known formats like, PNG, JPEG and BMP along with slide export to SVG.
- Ability to build presentations from scratch or by combining from one or multiple documents.
- Support for adding animations, Ole Frames, Tables, creating and managing charts.
- Availability of extensive control for Managing the text formatting on TextFrames, Paragraphs and Portions levels.
For more details about the features supported, please visit [Aspose.Slides Features](https://docs.aspose.com/slides/php-java/product-overview/).
## **Compare Open XML SDK with Aspose.Slides**
The following table compares Open XML SDK and Aspose.Slides features.
|**Feature or Feature Category**|**Open XML SDK**|**Aspose.Slides**|
| :- | :- | :- |
|Supported Presentations formats|PPTX|PPT, POT, PPS, PPTX, POTX, PPSX, ODP|
|Conversion from PPT to PPTX |No|Yes|
|
High-level programming with a Presentation Document Object Model (DOM):
- Find and replace text.
- Assemble slides in presentations.
|No|Yes|
|Detailed programming with a document object model, access to individual elements and formatting such as TextHolders, TextFrames, Paragraphs and Portions.|Yes|Yes|
|Low-level direct and full access to the underlying XML elements and attributes such as relationship identifiers, list identifiers of an OOXML document.|Yes|No|
|
Rendering:
- Render presentations to PDF, PDF Notes, XPS, TIFF images.
- Render slide thumbnails to PNG, JPEG, BMP, SVG and TIFF.
- Specify image resolution, quality, compression and other options.
|No|Yes |
|Supported platforms|Windows, .NET|Windows, Linux,UNIX, MAC, Java, PHP, Mono|
## **Conclusion**
Open XML SDK and Aspose.Slides do not compete head to head because they address quite different needs and audiences. Open XML SDK is a class library to provide a strong-typed way to work with OOXML documents. Aspose.Slides is a very useful presentations processing library that provides great support for nearly all Microsoft PowerPoint file formats.
If all you need to do is a fairly basic programming operation on a PPTX document, then Open XML SDK might be a suitable choice. With Open XML SDK you will be fairly comfortable doing simple tasks like generating a simple PPTX document or removing comments, headers/footers, extracting images or others. Some tasks can be achieved with Open XML SDK, but cannot be achieved with Aspose.Slides. For example, if you need to directly access the XML elements and attributes of an OOXML document, then you should use Open XML SDK. However, if you need to perform complex operations on documents, such as some of the following tasks, then using Aspose.Slides is your best option:
- Support older PowerPoint formats in addition to PPTX.
- Copy or clone shapes with in slides in a way that combines objects, styles and other formatting in an appropriate manner.
- Replace formatted or unformatted text.
- Applying Animations and use of connectors with shapes used.
- Convert a document to PDF, TIFF or XPS so it appears exactly like Microsoft PowerPoint would have converted it.
- Develop a .NET or Java application in both desktop and web based environments.
# Create and Apply WordArt Effects in PHP
> Create and customize WordArt effects in Aspose.Slides for PHP via Java. This step-by-step guide helps developers enhance presentations with professional text in PHP.
Source: https://docs.aspose.com/slides/php-java/wordart/
Updated: 2026-09-25
## **Overview**
WordArt effects let you style text with fills, outlines, shadows, reflections, glow, transformations, and 3D formatting. This article explains how to create and customize these effects in PowerPoint presentations using Aspose.Slides for PHP via Java, without Microsoft Office installed.
## **Create a Simple WordArt Template and Apply It to Text**
The following examples build a simple WordArt style by setting the text, font, pattern fill, and outline.
Each example creates a new presentation and adds a rectangle to its first slide; no input file is required. The first example sets the text to "Aspose.Slides". The shape position and dimensions are measured in points:
```php
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 20, 400, 200);
$textFrame = $autoShape->getTextFrame();
$portion = $textFrame->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
$portion->setText("Aspose.Slides");
} finally {
$presentation->dispose();
}
```
Set the font to Arial Black at 36 points to make the formatting more noticeable:
```php
use aspose\slides\FontData;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 20, 400, 200);
$portion = $autoShape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
$portion->setText("Aspose.Slides");
$font = new FontData("Arial Black");
$portion->getPortionFormat()->setLatinFont($font);
$portion->getPortionFormat()->setFontHeight(36);
} finally {
$presentation->dispose();
}
```
Apply a [SmallGrid](https://reference.aspose.com/slides/php-java/aspose.slides/patternstyle/#SmallGrid) pattern with a dark orange foreground and a white background, then add a black text outline with a width of 1 point:
```php
use aspose\slides\FillType;
use aspose\slides\FontData;
use aspose\slides\PatternStyle;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 20, 400, 200);
$portion = $autoShape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
$portion->setText("Aspose.Slides");
$font = new FontData("Arial Black");
$portion->getPortionFormat()->setLatinFont($font);
$portion->getPortionFormat()->setFontHeight(36);
$portion->getPortionFormat()->getFillFormat()->setFillType(FillType::Pattern);
$darkOrange = new Java("java.awt.Color", 255, 140, 0);
$portion->getPortionFormat()->getFillFormat()->getPatternFormat()->getForeColor()->setColor($darkOrange);
$portion->getPortionFormat()->getFillFormat()->getPatternFormat()->getBackColor()->setColor(java("java.awt.Color")->WHITE);
$portion->getPortionFormat()->getFillFormat()->getPatternFormat()->setPatternStyle(PatternStyle::SmallGrid);
$portion->getPortionFormat()->getLineFormat()->setWidth(1);
$portion->getPortionFormat()->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$portion->getPortionFormat()->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
} finally {
$presentation->dispose();
}
```
The resulting text:

## **Apply Other WordArt Effects**
The following examples demonstrate how to apply shadows, reflections, glow, transformations, and 3D effects to text.
### **Apply Outer Shadow Effects**
An outer shadow adds depth by placing a shadow behind the text. You can customize its color, direction, distance, blur radius, scale, and skew.
This example calls [enableOuterShadowEffect](https://reference.aspose.com/slides/php-java/aspose.slides/effectformat/#enableOuterShadowEffect--) and sets a black shadow with a 4-point blur radius, a 230-degree direction, and a 30-point distance. Scale values of 100 preserve the shadow size, while horizontal skew tilts it by 20 degrees. The alpha transform sets its opacity to 32%:
```php
use aspose\slides\ColorTransformOperation;
use aspose\slides\FontData;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 20, 400, 200);
$portion = $autoShape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
$portion->setText("Aspose.Slides");
$font = new FontData("Arial Black");
$portion->getPortionFormat()->setLatinFont($font);
$portion->getPortionFormat()->setFontHeight(36);
$portion->getPortionFormat()->getEffectFormat()->enableOuterShadowEffect();
$portion->getPortionFormat()->getEffectFormat()->getOuterShadowEffect()->getShadowColor()->setColor(java("java.awt.Color")->BLACK);
$portion->getPortionFormat()->getEffectFormat()->getOuterShadowEffect()->setScaleHorizontal(100);
$portion->getPortionFormat()->getEffectFormat()->getOuterShadowEffect()->setScaleVertical(100);
$portion->getPortionFormat()->getEffectFormat()->getOuterShadowEffect()->setBlurRadius(4);
$portion->getPortionFormat()->getEffectFormat()->getOuterShadowEffect()->setDirection(230);
$portion->getPortionFormat()->getEffectFormat()->getOuterShadowEffect()->setDistance(30);
$portion->getPortionFormat()->getEffectFormat()->getOuterShadowEffect()->setSkewHorizontal(20);
$portion->getPortionFormat()->getEffectFormat()->getOuterShadowEffect()->setSkewVertical(0);
$portion->getPortionFormat()->getEffectFormat()->getOuterShadowEffect()->getShadowColor()->getColorTransform()->add(ColorTransformOperation::SetAlpha, 0.32);
} finally {
$presentation->dispose();
}
```
The resulting text:

- When outer and preset shadows are used together, only the outer shadow is applied.
- If outer and inner shadows are used simultaneously, the resulting effect depends on the PowerPoint version. For example, in PowerPoint 2013, the effect is doubled, whereas in PowerPoint 2007, only the outer shadow is applied.
### **Apply Reflection Effects**
A reflection creates a mirrored copy of the text. Adjust its position, scale, blur, and opacity to control its appearance.
This example calls [enableReflectionEffect](https://reference.aspose.com/slides/php-java/aspose.slides/effectformat/#enableReflectionEffect--) and flips the reflection vertically with a scale of -100%. It uses a 0.5-point blur radius and a 4.72-point distance. Opacity decreases from 60% to 0.9% between positions 0% and 60% along the reflection:
```php
use aspose\slides\FontData;
use aspose\slides\Presentation;
use aspose\slides\RectangleAlignment;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 20, 400, 200);
$portion = $autoShape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
$portion->setText("Aspose.Slides");
$font = new FontData("Arial Black");
$portion->getPortionFormat()->setLatinFont($font);
$portion->getPortionFormat()->setFontHeight(36);
$portion->getPortionFormat()->getEffectFormat()->enableReflectionEffect();
$portion->getPortionFormat()->getEffectFormat()->getReflectionEffect()->setBlurRadius(0.5);
$portion->getPortionFormat()->getEffectFormat()->getReflectionEffect()->setDistance(4.72);
$portion->getPortionFormat()->getEffectFormat()->getReflectionEffect()->setStartPosAlpha(0);
$portion->getPortionFormat()->getEffectFormat()->getReflectionEffect()->setEndPosAlpha(60);
$portion->getPortionFormat()->getEffectFormat()->getReflectionEffect()->setDirection(90);
$portion->getPortionFormat()->getEffectFormat()->getReflectionEffect()->setScaleHorizontal(100);
$portion->getPortionFormat()->getEffectFormat()->getReflectionEffect()->setScaleVertical(-100);
$portion->getPortionFormat()->getEffectFormat()->getReflectionEffect()->setStartReflectionOpacity(60);
$portion->getPortionFormat()->getEffectFormat()->getReflectionEffect()->setEndReflectionOpacity(0.9);
$portion->getPortionFormat()->getEffectFormat()->getReflectionEffect()->setRectangleAlign(RectangleAlignment::BottomLeft);
} finally {
$presentation->dispose();
}
```
The resulting text:

### **Apply Glow Effects**
A glow adds a soft colored outline around the text. Adjust its color, opacity, and radius to control the effect.
This example calls [enableGlowEffect](https://reference.aspose.com/slides/php-java/aspose.slides/effectformat/#enableGlowEffect--) and applies a red glow with 54% opacity and a radius of 7 points:
```php
use aspose\slides\ColorTransformOperation;
use aspose\slides\FontData;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 20, 400, 200);
$portion = $autoShape->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
$portion->setText("Aspose.Slides");
$font = new FontData("Arial Black");
$portion->getPortionFormat()->setLatinFont($font);
$portion->getPortionFormat()->setFontHeight(36);
$portion->getPortionFormat()->getEffectFormat()->enableGlowEffect();
$portion->getPortionFormat()->getEffectFormat()->getGlowEffect()->getColor()->setColor(java("java.awt.Color")->RED);
$portion->getPortionFormat()->getEffectFormat()->getGlowEffect()->getColor()->getColorTransform()->add(ColorTransformOperation::SetAlpha, 0.54);
$portion->getPortionFormat()->getEffectFormat()->getGlowEffect()->setRadius(7);
} finally {
$presentation->dispose();
}
```
The resulting text:

### **Apply WordArt Transformations**
WordArt transformations bend, stretch, or warp a block of text.
Set [setTransform](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#setTransform-int-) to [ArchUpPour](https://reference.aspose.com/slides/php-java/aspose.slides/textshapetype/#ArchUpPour) to curve the entire text frame upward:
```php
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
use aspose\slides\TextShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 20, 400, 200);
$textFrame = $autoShape->getTextFrame();
$textFrame->setText("Aspose.Slides");
$textFrame->getTextFrameFormat()->setTransform(TextShapeType::ArchUpPour);
} finally {
$presentation->dispose();
}
```
The resulting text:

Aspose.Slides for PHP via Java provides a set of predefined [transformation types](https://reference.aspose.com/slides/php-java/aspose.slides/textshapetype/).
### **Apply 3D Effects to Shapes and Text**
You can apply 3D effects to a shape or to its text. Bevels, extrusion, lighting, and camera settings control the resulting appearance.
The following example uses [ThreeDFormat](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/) to add circular bevels, orange extrusion, and a dark red contour to the rectangle. Bevel dimensions, extrusion height, contour width, and depth are measured in points. A plastic material, balanced lighting rotated by 40 degrees around the Z axis, and a perspective camera define its appearance:
```php
use aspose\slides\BevelPresetType;
use aspose\slides\CameraPresetType;
use aspose\slides\LightRigPresetType;
use aspose\slides\LightingDirection;
use aspose\slides\MaterialPresetType;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 20, 400, 200);
$autoShape->getTextFrame()->setText("Aspose.Slides");
$autoShape->getThreeDFormat()->getBevelBottom()->setBevelType(BevelPresetType::Circle);
$autoShape->getThreeDFormat()->getBevelBottom()->setHeight(10.5);
$autoShape->getThreeDFormat()->getBevelBottom()->setWidth(10.5);
$autoShape->getThreeDFormat()->getBevelTop()->setBevelType(BevelPresetType::Circle);
$autoShape->getThreeDFormat()->getBevelTop()->setHeight(12.5);
$autoShape->getThreeDFormat()->getBevelTop()->setWidth(11);
$orange = new Java("java.awt.Color", 255, 165, 0);
$autoShape->getThreeDFormat()->getExtrusionColor()->setColor($orange);
$autoShape->getThreeDFormat()->setExtrusionHeight(6);
$darkRed = new Java("java.awt.Color", 139, 0, 0);
$autoShape->getThreeDFormat()->getContourColor()->setColor($darkRed);
$autoShape->getThreeDFormat()->setContourWidth(1.5);
$autoShape->getThreeDFormat()->setDepth(3);
$autoShape->getThreeDFormat()->setMaterial(MaterialPresetType::Plastic);
$autoShape->getThreeDFormat()->getLightRig()->setDirection(LightingDirection::Top);
$autoShape->getThreeDFormat()->getLightRig()->setLightType(LightRigPresetType::Balanced);
$autoShape->getThreeDFormat()->getLightRig()->setRotation(0, 0, 40);
$autoShape->getThreeDFormat()->getCamera()->setCameraType(CameraPresetType::PerspectiveContrastingRightFacing);
} finally {
$presentation->dispose();
}
```
The resulting shape:

This example applies similar 3D formatting to the text through [TextFrameFormat::getThreeDFormat](https://reference.aspose.com/slides/php-java/aspose.slides/textframeformat/#getThreeDFormat--). Smaller bevels shape the letter edges, while extrusion and lighting give the text depth:
```php
use aspose\slides\BevelPresetType;
use aspose\slides\CameraPresetType;
use aspose\slides\LightRigPresetType;
use aspose\slides\LightingDirection;
use aspose\slides\MaterialPresetType;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$autoShape = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 20, 20, 400, 200);
$textFrame = $autoShape->getTextFrame();
$textFrame->setText("Aspose.Slides");
$textFrame->getTextFrameFormat()->getThreeDFormat()->getBevelBottom()->setBevelType(BevelPresetType::Circle);
$textFrame->getTextFrameFormat()->getThreeDFormat()->getBevelBottom()->setHeight(3.5);
$textFrame->getTextFrameFormat()->getThreeDFormat()->getBevelBottom()->setWidth(3.5);
$textFrame->getTextFrameFormat()->getThreeDFormat()->getBevelTop()->setBevelType(BevelPresetType::Circle);
$textFrame->getTextFrameFormat()->getThreeDFormat()->getBevelTop()->setHeight(4);
$textFrame->getTextFrameFormat()->getThreeDFormat()->getBevelTop()->setWidth(4);
$orange = new Java("java.awt.Color", 255, 165, 0);
$textFrame->getTextFrameFormat()->getThreeDFormat()->getExtrusionColor()->setColor($orange);
$textFrame->getTextFrameFormat()->getThreeDFormat()->setExtrusionHeight(6);
$darkRed = new Java("java.awt.Color", 139, 0, 0);
$textFrame->getTextFrameFormat()->getThreeDFormat()->getContourColor()->setColor($darkRed);
$textFrame->getTextFrameFormat()->getThreeDFormat()->setContourWidth(1.5);
$textFrame->getTextFrameFormat()->getThreeDFormat()->setDepth(3);
$textFrame->getTextFrameFormat()->getThreeDFormat()->setMaterial(MaterialPresetType::Plastic);
$textFrame->getTextFrameFormat()->getThreeDFormat()->getLightRig()->setDirection(LightingDirection::Top);
$textFrame->getTextFrameFormat()->getThreeDFormat()->getLightRig()->setLightType(LightRigPresetType::Balanced);
$textFrame->getTextFrameFormat()->getThreeDFormat()->getLightRig()->setRotation(0, 0, 40);
$textFrame->getTextFrameFormat()->getThreeDFormat()->getCamera()->setCameraType(CameraPresetType::PerspectiveContrastingRightFacing);
} finally {
$presentation->dispose();
}
```
The resulting text:

The application of 3D effects to text or their shapes—and the interaction between these effects—is governed by specific rules. Consider a scene involving both text and the shape containing it. A 3D effect includes the object's 3D representation and the scene in which it is placed.
- If a scene is set for both the shape and the text, the shape’s scene takes priority and the text’s scene is ignored.
- If the shape lacks its own scene but has a 3D representation, the text’s scene is used.
- If the shape has no 3D effect at all, it is treated as flat, and the 3D effect is applied only to the text.
These behaviors relate to the [ThreeDFormat::getLightRig](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/#getLightRig--) and [ThreeDFormat::getCamera](https://reference.aspose.com/slides/php-java/aspose.slides/threedformat/#getCamera--) methods.
For more examples of 3D formatting, see [Create 3D Effects in Presentations Using PHP](https://docs.aspose.com/slides/php-java/3d-presentation/).
## **FAQ**
**Can I use WordArt effects with different fonts or scripts (e.g., Arabic, Chinese)?**
Yes, Aspose.Slides for PHP via Java supports Unicode and works with all major fonts and scripts. WordArt effects such as shadow, fill, and outline can be applied regardless of the language, although font availability and rendering may depend on the system fonts.
**Can I apply WordArt effects to slide master elements?**
Yes, you can apply WordArt effects to shapes on master slides, including title placeholders, footers, or background text. Changes made to the master layout will be reflected across all associated slides.
**Do WordArt effects affect presentation file size?**
Slightly. WordArt effects like shadows, glows, and gradient fills may slightly increase the file size due to added formatting metadata, but the difference is usually negligible.
**Can I preview the result of WordArt effects without saving the presentation?**
Yes, you can render slides containing WordArt to images (e.g., PNG, JPEG) using [Slide::getImage](https://reference.aspose.com/slides/php-java/aspose.slides/slide/#getImage--), or render individual shapes using [Shape::getImage](https://reference.aspose.com/slides/php-java/aspose.slides/shape/#getImage--). This lets you preview the result in memory or on screen before saving or exporting the full presentation.
## Related articles
- [Apply Shape Effects in Presentations Using PHP](https://docs.aspose.com/slides/php-java/shape-effect/)
# Working Solution for Chart Resizing in PPTX
> Fix unexpected chart resizing in PPTX when using embedded Excel OLE objects with Aspose.Slides for PHP via Java. Set fixed chart dimensions to keep the chart and OLE frame sizes consistent.
Source: https://docs.aspose.com/slides/php-java/working-solution-for-chart-resizing-in-pptx/
Updated: 2026-11-08
## **Overview**
Excel charts embedded as OLE objects in PowerPoint presentations using Aspose components can change size after their first activation. This can cause a noticeable difference in the chart's appearance before and after activation. This article explains why resizing occurs and shows how to prevent it by matching fixed chart dimensions to the OLE frame.
In [Create Excel Charts and Embed Them as OLE Objects in Presentations](https://docs.aspose.com/slides/php-java/creating-excel-chart-and-embedding-it-in-presentation-as-ole-object/), we explained how to create an Excel chart with Aspose.Cells for PHP via Java and embed it in a PowerPoint presentation using Aspose.Slides for PHP via Java. To address the [object preview issue](https://docs.aspose.com/slides/php-java/object-preview-issue-when-adding-oleobjectframe/), we assigned the chart image to the chart’s OLE object frame. In the output presentation, when you double-click the OLE object frame displaying the chart image, the Excel chart is activated. Users can edit the embedded Excel workbook and then return to the slide by clicking outside the activated workbook. The size of the OLE object frame changes when the user returns to the slide, and the resizing factor varies depending on the original sizes of both the OLE object frame and the embedded Excel workbook.
## **Cause of Resizing**
The embedded Excel workbook has its own window dimensions, which Excel tries to retain when the object is first activated. The OLE frame on the slide has independently defined dimensions. When the Excel workbook is activated, Excel and PowerPoint negotiate the object's size to maintain its proportions as part of the embedding process. Differences between the workbook window and the OLE frame can therefore cause the object to resize.
## **Working Solution**
Match the chart size to the OLE frame on the slide and keep the chart dimensions independent of the workbook window. This solution works with a new presentation or an existing template.
The example requires Aspose.Cells for PHP via Java and Aspose.Slides for PHP via Java. Configure both products with the same PHP/Java Bridge instance, load both PHP wrappers, and make both Java libraries available to the bridge. No input files are required. It creates a simple column chart on an active chart sheet and embeds the workbook in XLS format. No chart preview image is assigned; the chart becomes visible when the OLE object is activated in PowerPoint.
The example creates a new presentation with a 9.5 × 4-inch OLE frame positioned 0.5 inches from the left edge and 1 inch from the top. Slide coordinates and dimensions are in points (72 points per inch). For an existing presentation, see [Use a Template](https://docs.aspose.com/slides/php-java/working-solution-for-chart-resizing-in-pptx/#use-a-template).
## **Set a Fixed Chart Size**
Set [Chart::setSizeWithWindow](https://reference.aspose.com/cells/php/aspose.cells/chart/#sizewithwindow) to false so that the chart dimensions are independent of the workbook window. Set the [Chart::getChartObject](https://reference.aspose.com/cells/php/aspose.cells/chart/#chartobject) dimensions through [Shape::setWidth](https://reference.aspose.com/cells/php/aspose.cells/shape/#width) and [Shape::setHeight](https://reference.aspose.com/cells/php/aspose.cells/shape/#height), converting points to pixels using 96 pixels per inch: a frame measuring 684 × 288 points corresponds to a chart measuring 912 × 384 pixels. Set [Chart::setPrintSize](https://reference.aspose.com/cells/php/aspose.cells/chart/#printsize) to the CUSTOM value of [PrintSizeType](https://reference.aspose.com/cells/php/aspose.cells/printsizetype/). The example embeds the workbook with [ShapeCollection::addOleObjectFrame](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/#addOleObjectFrame) and saves a presentation with a 9.5 × 4-inch OLE frame.
Java numeric results are converted with `java_values` before they are used as PHP indices. The workbook bytes remain in a Java byte array when passed to [OleEmbeddedDataInfo](https://reference.aspose.com/slides/php-java/aspose.slides/oleembeddeddatainfo/).
```php
getWorksheets()->get(0);
$dataSheet->setName("Data");
$dataSheet->getCells()->get("A1")->putValue(10);
$dataSheet->getCells()->get("A2")->putValue(20);
$chartSheetIndex = java_values($workbook->getWorksheets()->add(SheetType::CHART));
$chartSheet = $workbook->getWorksheets()->get($chartSheetIndex);
$chartIndex = java_values($chartSheet->getCharts()->add(ChartType::COLUMN, 0, 0, 20, 10));
$chart = $chartSheet->getCharts()->get($chartIndex);
$chart->getNSeries()->add("Data!A1:A2", true);
$workbook->getWorksheets()->setActiveSheetIndex($chartSheetIndex);
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
// Slide coordinates and dimensions are in points (72 points per inch).
$width = 684; // 9.5 inches.
$height = 288; // 4 inches.
$chart->setSizeWithWindow(false);
// Convert points to chart pixels using 96 pixels per inch.
$chart->getChartObject()->setWidth((int)($width / 72 * 96));
$chart->getChartObject()->setHeight((int)($height / 72 * 96));
$chart->setPrintSize(PrintSizeType::CUSTOM);
$workbookStream = new JavaObject("java.io.ByteArrayOutputStream");
$workbook->save($workbookStream, FileFormatType::EXCEL_97_TO_2003);
$workbookBytes = $workbookStream->toByteArray();
$dataInfo = new OleEmbeddedDataInfo($workbookBytes, "xls");
$slide->getShapes()->addOleObjectFrame(36, 72, $width, $height, $dataInfo);
$presentation->save("chart-fixed-size.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
} finally {
$workbook->dispose();
}
```
[](https://docs.aspose.com/slides/php-java/working-solution-for-chart-resizing-in-pptx/visual-working-solution-for-chart-resizing-in-pptx-62dff4f20ea9.svg)
*Use the same physical dimensions for the fixed chart and OLE frame: 684 × 288 points equals 912 × 384 pixels at 96 DPI. This diagram explains the configuration; it does not show a measured first-activation result.*
## **Use a Template**
The sizing logic is the same for an existing presentation. To adapt the example:
1. Load the template presentation instead of creating an empty presentation.
1. Check that the first slide contains at least three shapes, then use the shape at index 2 as the placeholder.
1. Take the frame width and height from that shape instead of using the fixed values 684 and 288. Keep the sizing calculations unchanged.
1. Add the OLE frame at the placeholder's position instead of the fixed coordinates 36 and 72.
1. Remove the placeholder before saving the presentation.
## **FAQ**
**Why does my embedded Excel chart change size after activating it in PowerPoint?**
This happens because Excel tries to restore the original window size when first activated, whereas the OLE object frame in PowerPoint has its own dimensions. PowerPoint and Excel negotiate the size to maintain the aspect ratio, which can cause the resizing.
**How can I keep the chart and OLE frame sizes consistent?**
Set fixed chart dimensions that match the OLE frame and use a custom chart print size before embedding the workbook. The example above shows the required settings and unit conversions.
**Is matching the workbook window size sufficient?**
Matching the workbook window size alone does not reliably prevent the OLE frame from changing size after activation. Use fixed chart dimensions as shown in the example.
**Does this solution work with both template-based presentations and new presentations?**
Yes. For a template, use the placeholder's dimensions and position. For a new presentation, specify the frame dimensions and position directly.
**Can I use this example with charts created in other spreadsheet programs?**
The example uses an Excel workbook created with Aspose.Cells. It does not demonstrate activation behavior for other spreadsheet programs.
## **Related Sections**
- [Create Excel Charts and Embed Them as OLE Objects in Presentations](https://docs.aspose.com/slides/php-java/creating-excel-chart-and-embedding-it-in-presentation-as-ole-object/)
# Working Solution for Worksheet Resizing
> Fix Excel worksheet OLE resizing in presentations: two ways to keep object frames consistent—scale the frame or the sheet—across the PPT and PPTX formats.
Source: https://docs.aspose.com/slides/php-java/working-solution-for-worksheet-resizing/
Updated: 2026-11-08
Excel worksheets embedded as OLE objects in a PowerPoint presentation using Aspose components may resize unexpectedly after their first activation. This behavior creates a noticeable visual difference between the OLE object before and after activation. This article explains the issue and describes two ways to address it.
## **Background**
In the article [Manage OLE](https://docs.aspose.com/slides/php-java/manage-ole/), we explained how to add an OLE frame to a PowerPoint presentation using Aspose.Slides for PHP via Java. To address the [object preview issue](https://docs.aspose.com/slides/php-java/object-preview-issue-when-adding-oleobjectframe/), we assigned an image of the selected worksheet area to the OLE object frame. In the output presentation, when you double-click the OLE object frame displaying the worksheet image, the Excel workbook is activated. End users can make any desired changes to the actual Excel workbook and then return to the slide by clicking outside the activated Excel workbook. The size of the OLE object frame will change when the user returns to the slide. The resizing factor will vary depending on the size of the OLE object frame and the embedded Excel workbook.
## **Cause of Resizing**
Since the Excel workbook has its own window size, it tries to retain its original size upon first activation. On the other hand, the OLE object frame has its own size. According to Microsoft, when the Excel workbook is activated, Excel and PowerPoint negotiate the size to ensure it maintains the correct proportions as part of the embedding process. The resizing occurs based on the differences between the Excel window size and the OLE object frame's size and position.
## **Working Solution**
There are two possible solutions to avoid the resizing effect.
- Scale the OLE frame in the PowerPoint presentation to match the total height and width of the selected rows and columns.
- Keep the OLE frame size constant and scale the selected rows and columns to fit within it.
### **Scale the OLE Frame Size**
This approach sets the OLE frame size to match the total height and width of the selected rows and columns in the embedded Excel worksheet.
The example loads an existing Excel workbook and selects the first 10 rows and 13 columns of its first worksheet using zero-based indices. [WorksheetCollection::setOleSize](https://reference.aspose.com/cells/php/aspose.cells/worksheetcollection/#setolesize) defines the displayed range. The preview is rendered at 96 DPI, and its pixel dimensions are converted to points using 72 points per inch. [ShapeCollection::addOleObjectFrame](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/#addOleObjectFrame) embeds the modified workbook in a frame with those dimensions. The preview is assigned through [OleObjectFrame::getSubstitutePictureFormat](https://reference.aspose.com/slides/php-java/aspose.slides/oleobjectframe/#getSubstitutePictureFormat) to replace the "EMBEDDED OLE OBJECT" placeholder in the saved presentation.
```php
use aspose\cells\SaveFormat as CellsSaveFormat;
use aspose\cells\Workbook;
use aspose\slides\Images;
use aspose\slides\OleEmbeddedDataInfo;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use Java as JavaObject;
$workbook = new Workbook("sample.xlsx");
try {
$worksheet = $workbook->getWorksheets()->get(0);
$startRow = 0;
$rowCount = 10;
$startColumn = 0;
$columnCount = 13;
$lastRow = $startRow + $rowCount - 1;
$lastColumn = $startColumn + $columnCount - 1;
$workbook->getWorksheets()->setOleSize($startRow, $lastRow, $startColumn, $lastColumn);
$cellRange = $worksheet->getCells()->createRange($startRow, $startColumn, $rowCount, $columnCount);
$imageResolution = 96;
$imageStream = CreateOleImage($cellRange, $imageResolution);
// Embed the modified workbook and keep binary data in Java byte arrays.
$workbookStream = new JavaObject("java.io.ByteArrayOutputStream");
$workbook->save($workbookStream, CellsSaveFormat::XLSX);
$workbookBytes = $workbookStream->toByteArray();
$image = Images::fromStream($imageStream);
try {
$frameWidth = java_values($image->getWidth()) * 72.0 / $imageResolution;
$frameHeight = java_values($image->getHeight()) * 72.0 / $imageResolution;
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$dataInfo = new OleEmbeddedDataInfo($workbookBytes, "xlsx");
$oleFrame = $slide->getShapes()->addOleObjectFrame(10, 10, $frameWidth, $frameHeight, $dataInfo);
$previewImage = $presentation->getImages()->addImage($image);
$oleFrame->getSubstitutePictureFormat()->getPicture()->setImage($previewImage);
$oleFrame->setObjectIcon(false);
$presentation->save("output.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
} finally {
$image->dispose();
$imageStream->close();
}
} finally {
$workbook->dispose();
}
```
The preview helper sets [PageSetup::setPrintArea](https://reference.aspose.com/cells/php/aspose.cells/pagesetup/#printarea) to the selected range and removes margins, headers, and footers. With [ImageOrPrintOptions::setOnlyArea](https://reference.aspose.com/cells/php/aspose.cells/imageorprintoptions/#onlyarea) enabled, [SheetRender::toImage](https://reference.aspose.com/cells/php/aspose.cells/sheetrender/#toimage) renders the range as a PNG image. The helper returns a new input stream containing the PNG image, positioned at its beginning for use in the presentation.
```php
use aspose\cells\ImageOrPrintOptions;
use aspose\cells\ImageType;
use aspose\cells\SheetRender;
use Java as JavaObject;
function CreateOleImage($cellRange, $imageResolution) {
$pageSetup = $cellRange->getWorksheet()->getPageSetup();
$pageSetup->setPrintArea($cellRange->getAddress());
$pageSetup->setLeftMargin(0);
$pageSetup->setRightMargin(0);
$pageSetup->setTopMargin(0);
$pageSetup->setBottomMargin(0);
$pageSetup->clearHeaderFooter();
$imageOptions = new ImageOrPrintOptions();
$imageOptions->setImageType(ImageType::PNG);
$imageOptions->setVerticalResolution($imageResolution);
$imageOptions->setHorizontalResolution($imageResolution);
$imageOptions->setOnePagePerSheet(true);
$imageOptions->setOnlyArea(true);
$worksheet = $cellRange->getWorksheet();
$sheetRender = new SheetRender($worksheet, $imageOptions);
$imageStream = new JavaObject("java.io.ByteArrayOutputStream");
$sheetRender->toImage(0, $imageStream);
$imageBytes = $imageStream->toByteArray();
return new JavaObject("java.io.ByteArrayInputStream", $imageBytes);
}
```
[](https://docs.aspose.com/slides/php-java/working-solution-for-worksheet-resizing/visual-working-solution-for-worksheet-resizing-37277e3a014f.svg)
*The selected section uses approach A: preserve the selected cells and size the OLE frame to match their range. Approach B is a separate alternative. Convert 96-DPI preview pixels to slide points using 72 ÷ 96.*
### **Scale the Cell Range Size**
This approach scales the heights of the selected rows and the widths of the selected columns to match a custom OLE frame size.
The example loads an existing Excel workbook and selects the first 10 rows and 13 columns of its first worksheet using zero-based indices. [WorksheetCollection::setOleSize](https://reference.aspose.com/cells/php/aspose.cells/worksheetcollection/#setolesize) defines the displayed range, and the helper below scales that range to fit a frame 400 points wide and 100 points high. After saving the modified workbook to a stream, [ShapeCollection::addOleObjectFrame](https://reference.aspose.com/slides/php-java/aspose.slides/shapecollection/#addOleObjectFrame) embeds it at the specified size. A preview rendered at 96 DPI is assigned through [OleObjectFrame::getSubstitutePictureFormat](https://reference.aspose.com/slides/php-java/aspose.slides/oleobjectframe/#getSubstitutePictureFormat), so the saved presentation displays the selected cells instead of the default placeholder.
```php
use aspose\cells\SaveFormat as CellsSaveFormat;
use aspose\cells\Workbook;
use aspose\slides\Images;
use aspose\slides\OleEmbeddedDataInfo;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use Java as JavaObject;
$workbook = new Workbook("sample.xlsx");
try {
$worksheet = $workbook->getWorksheets()->get(0);
$startRow = 0;
$rowCount = 10;
$startColumn = 0;
$columnCount = 13;
$lastRow = $startRow + $rowCount - 1;
$lastColumn = $startColumn + $columnCount - 1;
$workbook->getWorksheets()->setOleSize($startRow, $lastRow, $startColumn, $lastColumn);
$cellRange = $worksheet->getCells()->createRange($startRow, $startColumn, $rowCount, $columnCount);
$frameWidth = 400;
$frameHeight = 100;
ScaleCellRange($cellRange, $frameWidth, $frameHeight);
$imageResolution = 96;
$imageStream = CreateOleImage($cellRange, $imageResolution);
// Embed the modified workbook and keep binary data in Java byte arrays.
$workbookStream = new JavaObject("java.io.ByteArrayOutputStream");
$workbook->save($workbookStream, CellsSaveFormat::XLSX);
$workbookBytes = $workbookStream->toByteArray();
$image = Images::fromStream($imageStream);
try {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$dataInfo = new OleEmbeddedDataInfo($workbookBytes, "xlsx");
$oleFrame = $slide->getShapes()->addOleObjectFrame(10, 10, $frameWidth, $frameHeight, $dataInfo);
$previewImage = $presentation->getImages()->addImage($image);
$oleFrame->getSubstitutePictureFormat()->getPicture()->setImage($previewImage);
$oleFrame->setObjectIcon(false);
$presentation->save("output.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
} finally {
$image->dispose();
$imageStream->close();
}
} finally {
$workbook->dispose();
}
```
The scaling helper calculates separate width and height ratios for the selected range, preserving the relative widths of its columns and the relative heights of its rows. It converts the calculated dimensions from points to inches before applying them with [Cells::setColumnWidthInch](https://reference.aspose.com/cells/php/aspose.cells/cells/#setcolumnwidthinch) and [Cells::setRowHeightInch](https://reference.aspose.com/cells/php/aspose.cells/cells/#setrowheightinch). The selected range must have nonzero width and height.
```php
use aspose\cells\CellsUnitType;
// Width and height are the expected dimensions of the cell range in points.
function ScaleCellRange($cellRange, $width, $height) {
$rangeWidth = java_values($cellRange->getWidth());
$rangeHeight = java_values($cellRange->getHeight());
$cells = $cellRange->getWorksheet()->getCells();
$columnCount = java_values($cellRange->getColumnCount());
$rowCount = java_values($cellRange->getRowCount());
$firstColumn = java_values($cellRange->getFirstColumn());
$firstRow = java_values($cellRange->getFirstRow());
for ($i = 0; $i < $columnCount; $i++) {
$columnIndex = $firstColumn + $i;
$columnWidth = java_values($cells->getColumnWidth($columnIndex, false, CellsUnitType::POINT));
$newColumnWidth = $columnWidth * $width / $rangeWidth;
$widthInInches = $newColumnWidth / 72.0;
$cells->setColumnWidthInch($columnIndex, $widthInInches);
}
for ($i = 0; $i < $rowCount; $i++) {
$rowIndex = $firstRow + $i;
$rowHeight = java_values($cells->getRowHeight($rowIndex, false, CellsUnitType::POINT));
$newRowHeight = $rowHeight * $height / $rangeHeight;
$heightInInches = $newRowHeight / 72.0;
$cells->setRowHeightInch($rowIndex, $heightInInches);
}
}
```
This preview helper renders the resized range using [SheetRender::toImage](https://reference.aspose.com/cells/php/aspose.cells/sheetrender/#toimage). It limits [PageSetup::setPrintArea](https://reference.aspose.com/cells/php/aspose.cells/pagesetup/#printarea) to that range, removes margins, headers, and footers, and returns a PNG stream positioned at its beginning.
```php
use aspose\cells\ImageOrPrintOptions;
use aspose\cells\ImageType;
use aspose\cells\SheetRender;
use Java as JavaObject;
function CreateOleImage($cellRange, $imageResolution) {
$pageSetup = $cellRange->getWorksheet()->getPageSetup();
$pageSetup->setPrintArea($cellRange->getAddress());
$pageSetup->setLeftMargin(0);
$pageSetup->setRightMargin(0);
$pageSetup->setTopMargin(0);
$pageSetup->setBottomMargin(0);
$pageSetup->clearHeaderFooter();
$imageOptions = new ImageOrPrintOptions();
$imageOptions->setImageType(ImageType::PNG);
$imageOptions->setVerticalResolution($imageResolution);
$imageOptions->setHorizontalResolution($imageResolution);
$imageOptions->setOnePagePerSheet(true);
$imageOptions->setOnlyArea(true);
$worksheet = $cellRange->getWorksheet();
$sheetRender = new SheetRender($worksheet, $imageOptions);
$imageStream = new JavaObject("java.io.ByteArrayOutputStream");
$sheetRender->toImage(0, $imageStream);
$imageBytes = $imageStream->toByteArray();
return new JavaObject("java.io.ByteArrayInputStream", $imageBytes);
}
```
## **Conclusion**
There are two approaches to fix the worksheet resizing issue. Choose the approach that best fits your requirements and use case. Both approaches work the same way, whether the presentations are created from a template or from scratch. Additionally, there is no limit on the size of the OLE object frame in this solution.
## **FAQ**
**Why does an embedded Excel worksheet change size when first activated in PowerPoint?**
This happens because Excel tries to maintain the original window size when activated, while the OLE object frame in PowerPoint has its own dimensions. PowerPoint and Excel negotiate the size to maintain the aspect ratio, which can cause the resizing.
**Is it possible to prevent this resizing issue entirely?**
Yes. By scaling the OLE frame to fit the Excel cell range size or scaling the cell range to fit the desired OLE frame size, you can prevent unwanted resizing.
**Which scaling method should I use, OLE frame scaling or cell range scaling?**
Select **OLE frame scaling** if you want to maintain the original Excel row and column sizes. Select **cell range scaling** if you want a fixed size for the OLE frame in your presentation.
**Will these solutions work if my presentation is based on a template?**
Yes. Both solutions work for presentations created from templates and from scratch.
**Is there a limit to the size of the OLE frame when using these methods?**
No. You can make the OLE object frame any size as long as you set the scale appropriately.
**Is there a way to avoid the "EMBEDDED OLE OBJECT" placeholder text in PowerPoint?**
Yes. By taking a snapshot of the target Excel cell range and setting it as the OLE frame's placeholder image, you can display a custom preview image in place of the default placeholder.
## **Related Articles**
[Creating an Excel Chart and Embedding It in a Presentation as an OLE Object](https://docs.aspose.com/slides/php-java/creating-excel-chart-and-embedding-it-in-presentation-as-ole-object/)
[Updating OLE Objects Automatically Using an MS PowerPoint Add-In](https://docs.aspose.com/slides/net/updating-ole-objects-automatically-using-ms-powerpoint-add-in/)
# Write-Protect Presentations in PHP
> Set, detect, validate, and remove write-protection passwords in PowerPoint PPT and PPTX presentations using Aspose.Slides for PHP.
Source: https://docs.aspose.com/slides/php-java/write-protected-presentation/
Updated: 2026-08-26
## **Introduction**
A write-protection password restricts modification of a presentation but does not encrypt its content. Users can load and view a write-protected presentation without the password. Depending on the application, they may also be able to edit the content and save it under a different name, so write protection should not be treated as a confidentiality mechanism.
An opening password serves a different purpose: it encrypts the presentation and is required to load its content. To encrypt a presentation or validate an opening password, see [Password-Protect Presentations](https://docs.aspose.com/slides/php-java/password-protected-presentation/).
The workflows in this article apply to both PPT and PPTX presentations. The examples use PPTX files; when saving to PPT, use the `.ppt` extension and the corresponding PPT save format.
## **Set Write Protection on a Presentation**
Use [ProtectionManager::setWriteProtection](https://reference.aspose.com/slides/php-java/aspose.slides/protectionmanager/#setWriteProtection) to assign a password for modifying a presentation. Saving the presentation persists the protection setting.
The following example sets write protection on a PPTX presentation:
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("pres.pptx");
try {
$presentation->getProtectionManager()->setWriteProtection("modify_password");
$presentation->save("write-protected-pres.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Load a Write-Protected Presentation**
Because write protection does not encrypt presentation content, no password is required to load the presentation. The password is relevant only when validating authorization to modify the protected presentation.
```php
use aspose\slides\Presentation;
$presentation = new Presentation("write-protected-pres.pptx");
try {
echo("Slide count: " . $presentation->getSlides()->size() . "\n");
} finally {
$presentation->dispose();
}
```
Do not pass a write-protection password to [LoadOptions::setPassword](https://reference.aspose.com/slides/php-java/aspose.slides/loadoptions/#setPassword). That method accepts an opening password for encrypted content. If a presentation has both protection types, supply the opening password to load it and handle the write-protection password separately.
## **Remove Write Protection from a Presentation**
Use [ProtectionManager::removeWriteProtection](https://reference.aspose.com/slides/php-java/aspose.slides/protectionmanager/#removeWriteProtection) to remove the modification restriction, then save the presentation.
```php
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("write-protected-pres.pptx");
try {
$presentation->getProtectionManager()->removeWriteProtection();
$presentation->save("write-protection-removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
```
## **Check Whether a Presentation Is Write Protected**
To inspect a file without creating a complete [Presentation](https://reference.aspose.com/slides/php-java/aspose.slides/presentation/) instance, call [PresentationFactory::getPresentationInfo](https://reference.aspose.com/slides/php-java/aspose.slides/presentationfactory/#getPresentationInfo) and inspect [PresentationInfo::isWriteProtected](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/#isWriteProtected). The method uses [NullableBool](https://reference.aspose.com/slides/php-java/aspose.slides/nullablebool/) and returns `NullableBool::True` when write protection is detected.
```php
use aspose\slides\NullableBool;
use aspose\slides\PresentationFactory;
$presentationInfo = PresentationFactory::getInstance()->getPresentationInfo("write-protected-pres.pptx");
if ($presentationInfo->isWriteProtected() == NullableBool::True) {
echo("The presentation is write protected.\n");
} else {
echo("Write protection was not detected.\n");
}
```
The stream overload of [PresentationFactory::getPresentationInfo](https://reference.aspose.com/slides/php-java/aspose.slides/presentationfactory/#getPresentationInfo) provides the same information for a presentation supplied as a stream.
## **Validate a Write-Protection Password**
Use [PresentationInfo::checkWriteProtection](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/#checkWriteProtection) to validate a modification password without loading the complete presentation. Check [PresentationInfo::isWriteProtected](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/#isWriteProtected) first so that the application requests or validates a password only when write protection is present.
```php
use aspose\slides\NullableBool;
use aspose\slides\PresentationFactory;
$presentationInfo = PresentationFactory::getInstance()->getPresentationInfo("write-protected-pres.pptx");
if ($presentationInfo->isWriteProtected() != NullableBool::True) {
echo("The presentation is not write protected.\n");
} elseif ($presentationInfo->checkWriteProtection("modify_password")) {
echo("The write-protection password is correct.\n");
} else {
echo("The write-protection password is incorrect.\n");
}
```
[PresentationInfo::checkWriteProtection](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/#checkWriteProtection) validates only the write-protection password. It does not validate an opening password or determine whether encrypted content can be loaded. Conversely, [PresentationInfo::checkPassword](https://reference.aspose.com/slides/php-java/aspose.slides/presentationinfo/#checkPassword) validates only an opening password. If a complete presentation has already been loaded, [ProtectionManager::checkWriteProtection](https://reference.aspose.com/slides/php-java/aspose.slides/protectionmanager/#checkWriteProtection) provides the equivalent write-protection check through its protection manager.
In production applications, do not log passwords or include them in diagnostic messages. Avoid unnecessary repeated validation attempts, and retain passwords in memory only as long as needed.
- [Password-Protect Presentations](https://docs.aspose.com/slides/php-java/password-protected-presentation/)
- [Read-Only Presentations](https://docs.aspose.com/slides/php-java/read-only-presentation/)
- [Digital Signature in PowerPoint](https://docs.aspose.com/slides/php-java/digital-signature-in-powerpoint/)
## **FAQ**
**Does write protection encrypt a presentation?**
No. It restricts modification but leaves the presentation content available for loading and viewing.
**Is the write-protection password required to open a presentation?**
No. Only an opening password is required to load encrypted presentation content.
**Can a presentation have both an opening password and a write-protection password?**
Yes. Supply the opening password through the load options to open the encrypted presentation, and validate the write-protection password separately when modification authorization is required.
# XML Parser Specification (XPS)
>
Source: https://docs.aspose.com/slides/php-java/xml-parser-specification-xps/
Updated: 2026-08-13
The [XML Parser Specification](https://en.wikipedia.org/wiki/Open_XML_Paper_Specification) is a page description language and a fixed-document format originally developed by Microsoft. Like PDF, XPS is designed to preserve document fidelity and provide device-independent document appearance.
## **XPS in Aspose.Slides for PHP via Java**
Any presentation document that can be loaded by Aspose.Slides for PHP via Java can be converted to XPS format. Aspose.Slides for PHP via Java uses the high-fidelity page layout and rendering engine to produce output in fixed-layout XPS document format.
You can learn about exporting the presentation documents to XPS documents through Aspose.Slides for PHP via Java in [Converting to XPS](https://docs.aspose.com/slides/php-java/convert-powerpoint-to-xps/).
**The input presentation**

**A presentation converted to XPS**
