Get the Entire Presentation Slide Background as an Image
Contents
[
Hide
]
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 .NET 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:
- Load the presentation using the Presentation class.
- Get the slide size from the presentation.
- Select a slide.
- Create a temporary presentation.
- Set the same slide size in the temporary presentation.
- Clone the selected slide into the temporary presentation.
- Delete the shapes from the cloned slide.
- Convert the cloned slide to an image.
The following code example extracts the entire presentation slide background as an image.
var slideIndex = 0;
var imageScale = 1;
using var presentation = new Presentation("sample.pptx");
var slideSize = presentation.SlideSize.Size;
var slide = presentation.Slides[slideIndex];
using var tempPresentation = new Presentation();
tempPresentation.SlideSize.SetSize(slideSize.Width, slideSize.Height, SlideSizeScaleType.DoNotScale);
var clonedSlide = tempPresentation.Slides.AddClone(slide);
clonedSlide.Shapes.Clear();
using var background = clonedSlide.GetImage(imageScale, imageScale);
background.Save("output.png", ImageFormat.Png);