Aspose.Slides  for PHP via Java

PHP PowerPoint API for Presentations

Create, read, modify, merge, clone, protect, and convert PowerPoint and OpenDocument presentations in PHP without requiring Microsoft PowerPoint.

  Download Free Trial
  
 

Aspose.Slides for PHP via Java is a presentation processing library that lets PHP applications read, edit, manipulate, and convert PowerPoint and OpenDocument presentations without requiring Microsoft PowerPoint.

Aspose.Slides for PHP via Java provides these popular features:

  • Loading, opening, and viewing presentations.
  • Editing presentations.
  • Converting presentations to PDF, JPG, PNG, HTML, GIF, SVG, and many other formats.
  • Rendering and printing presentations.
  • Encrypting and decrypting presentations; password-protecting presentations and removing passwords.
  • Manipulating presentation elements such as master slides, shapes, charts, picture frames, audio and video frames, OLE objects, VBA macros, and animations.

Aspose.Slides for PHP via Java brings presentation automation to PHP applications through a Java-based API and does not require Microsoft PowerPoint.

Advanced PHP PowerPoint API Features

Create and clone slides

Create and format tables

Apply or remove shape protection

Embed Excel workbooks as OLE objects

Support linked OLE objects

Generate presentations from a database

Protect presentations and generated PDFs

Render presentations for printing

Create and customize charts

System Requirements

  • PHP 7 or later and a supported Java Runtime Environment

How to Install

Use Packagist to install the Aspose.Slides PHP library for presentation processing from the PHP package repository:

composer require aspose/slides

Create a New PowerPoint Presentation in PHP

The following example adds a line shape to the first slide and saves the presentation as a PPTX file.

            
$presentation = new Presentation();
try {
    $slide = $presentation->getSlides()->get_Item(0);
    $slide->getShapes()->addAutoShape(ShapeType::Line, 50, 150, 300, 0);

    $presentation->save("line.pptx", SaveFormat::Pptx);
} finally {
    $presentation->dispose();
}
            
        

Merge Presentations in PHP

The following example clones every slide from a source presentation into a destination presentation.

            
$destinationPresentation = new Presentation("presentation1.pptx");
try {
    $sourcePresentation = new Presentation("presentation2.pptx");
    try {
        $slideCount = java_values($sourcePresentation->getSlides()->size());

        for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
            $slide = $sourcePresentation->getSlides()->get_Item($slideIndex);
            $destinationPresentation->getSlides()->addClone($slide);
        }
    } finally {
        $sourcePresentation->dispose();
    }

    $destinationPresentation->save("combined-presentation.pptx", SaveFormat::Pptx);
} finally {
    $destinationPresentation->dispose();
}
            
        

Import a Presentation from PDF in PHP

The following example imports pages from a PDF document as presentation slides and saves the result as PPTX.

            
$presentation = new Presentation();
try {
    $presentation->getSlides()->removeAt(0);
    $presentation->getSlides()->addFromPdf("welcome-to-powerpoint.pdf");
    $presentation->save("output-presentation.pptx", SaveFormat::Pptx);
} finally {
    $presentation->dispose();
}
            
        

Convert PowerPoint to PDF with Default Options in PHP

The following example converts a PowerPoint or OpenDocument presentation to PDF using the default options.

            
$presentation = new Presentation("presentation.pptx");
try {
    $presentation->save("document.pdf", SaveFormat::Pdf);
} finally {
    $presentation->dispose();
}
            
        

Convert PowerPoint to JPG in PHP

The following example renders each slide in a PowerPoint or OpenDocument presentation as a JPEG image.

            
$presentation = new Presentation("presentation.pptx");
try {
    $slideCount = java_values($presentation->getSlides()->size());

    for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
        $slide = $presentation->getSlides()->get_Item($slideIndex);
        $slideImage = $slide->getImage(1, 1);
        try {
            $filePath = "slide-" . ($slideIndex + 1) . ".jpg";
            $slideImage->save($filePath, ImageFormat::Jpeg);
        } finally {
            $slideImage->dispose();
        }
    }
} finally {
    $presentation->dispose();
}
            
        

FAQ

  • How do I install the PHP library?
    composer require aspose/slides, from the Packagist package . PHP 7 or later and a supported Java Runtime Environment must both be present.
  • Why does a PHP library need Java installed?
    It bridges to the Java build of Aspose.Slides, so a JRE does the presentation work and PHP drives it. If a JVM cannot be installed in your environment, this build will not run.
  • Which formats can PHP read, write and export?
    PPT, PPTX, PPS, POT, PPSX, PPTM, PPSM, POTX, POTM and the OpenDocument formats ODP, FODP and OTP are read and written, plus PDF; PDF/A and XPS are export-only.
  • Does it work under PHP-FPM behind a web server?
    Yes, but each worker starts a JVM bridge, so memory use rises with worker count. For bulk conversion, a queue and a small number of long-lived workers behaves better than converting inside the request.

What People Are Saying

Don't just take our word for it. See what users have to say about PowerPoint APIs.

 
 
View Case Studies
  

Support and Learning Resources