Aspose.Slides  for PHP via Java

PHP PowerPoint API for Presentations

Create, read, modify, merge, clone, protect, and convert PowerPoint and OpenOffice presentations in PHP without external software.

  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 OpenOffice presentations without Microsoft PowerPoint or third-party software.

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

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

PHP is a popular general-purpose scripting language, especially for web development purposes. For this reason, the Aspose.Slides team is proud to offer Aspose.Slides for PHP via Java to the PHP community.

Advanced PHP PowerPoint API Features

Create or clone slides from templates

Work with PowerPoint tables via API

Apply or remove shape protection

Add Excel charts as OLE objects to slides

Support linked OLE objects

Generate presentations from a database

Protect presentations and generated PDFs

Print presentations on a physical printer

Create and customize charts

System Requirements

  • Compatible with PHP 7 or later

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

In the example given below, we have added a line to the first slide of the presentation.

            
require_once("http://localhost:8080/JavaBridge/java/Java.inc");
require_once("lib/aspose.slides.php");

use aspose\slides;
use aspose\slides\Presentation;
use aspose\slides\ShapeType;
use aspose\slides\SaveFormat;

$presentation = new Presentation();
try {
    // Get the first slide.
    $slide = $presentation->getSlides()->get_Item(0);

    // Add an autoshape with type set to line.
    $slide->getShapes()->addAutoShape(ShapeType::Line, 50, 150, 300, 0);

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

Merge Presentations in PHP

This PHP code shows you how to merge presentations:

            
require_once("http://localhost:8080/JavaBridge/java/Java.inc");
require_once("lib/aspose.slides.php");

use aspose\slides;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;

$dstPresentation = new Presentation("presentation1.pptx");
$srcPresentation = new Presentation("presentation2.pptx");
try {
    $srcSlideCount = java_values($srcPresentation->getSlides()->size());

    for ($slideIndex = 0; $slideIndex < $srcSlideCount; $slideIndex++) { 
        $slide = $srcPresentation->getSlides()->get_Item($slideIndex);
        $dstPresentation->getSlides()->addClone($slide);
    }

    $dstPresentation->save("combined_presentation.pptx", SaveFormat::Pptx);
}
finally {
    $dstPresentation->dispose();
    $srcPresentation->dispose();
}
            
        

Import a Presentation from PDF in PHP

This PHP code demonstrates the PDF to PowerPoint conversion process:

            
require_once("http://localhost:8080/JavaBridge/java/Java.inc");
require_once("lib/aspose.slides.php");

use aspose\slides;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;

$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

This PHP code shows how to convert a PowerPoint or OpenOffice presentation to PDF using the default options.

            
require_once("http://localhost:8080/JavaBridge/java/Java.inc");
require_once("lib/aspose.slides.php");

use aspose\slides;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;

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

Convert PowerPoint to JPG in PHP

The following example shows you how to convert a PowerPoint PPT, PPTX, and OpenOffice ODP document into a set of JPEG images.

            
require_once("http://localhost:8080/JavaBridge/java/Java.inc");
require_once("lib/aspose.slides.php");

use aspose\slides;
use aspose\slides\Presentation;
use aspose\slides\ImageFormat;

$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 {
            $slideImage->save("slide_". $slideIndex .".jpg", ImageFormat::Jpeg);
        }
        finally {
            $slideImage->dispose();
        }
    }
}
finally {
    $presentation->dispose();
}
            
        

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