Aspose.Slides for PHP via Java

Aspose.Slides for PHP via Java

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 sets up PHP 8.3 or earlier, Java, Tomcat and the bridge, and then installs the package from Packagist in a project folder:

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 or step 6 of Install on Windows. With Tomcat running, save this script as hello.php in the project folder and run php hello.php:

<?php
require_once("http://localhost:8080/JavaBridge/java/Java.inc");
require_once(__DIR__ . "/vendor/aspose/slides/lib/aspose.slides.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, 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. For more ways to create and fill a presentation, see Create Presentations.