Get the Entire Presentation Slide Background as an Image

Contents
[ ]

In PowerPoint presentations, the slide background can consist of many elements. In addition to the image set as the slide background, the final background can be influenced by the presentation theme, color scheme, and the shapes placed on the master slide and layout slide.

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 class.
  2. Get the slide size from the presentation.
  3. Select a slide.
  4. Create a temporary presentation.
  5. Set the same slide size in the temporary presentation.
  6. Clone the selected slide into the temporary presentation.
  7. Delete the shapes from the cloned slide.
  8. Convert the cloned slide to an image.

The following code example extracts the entire presentation slide background as an image.

$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();