With the help of Spire.Presentation for .NET, we can easily save PowerPoint slides as image in C# and VB.NET. Sometimes, we need to use the resulted images for other purpose and the image size becomes very important. To ensure the image is easy and beautiful to use, we need to set the image with specified size beforehand. This example will demonstrate how to save a particular presentation slide as image with specified size by using Spire.Presentation for your .NET applications.
Note: Before Start, please download the latest version of Spire.Presentation and add Spire.Presentation.dll in the bin folder as the reference of Visual Studio.
Step 1: Create a presentation document and load the document from file.
Presentation presentation = new Presentation(); presentation.LoadFromFile("sample.pptx");
Step 2: Save the first slide to Image and set the image size to 600*400.
Image img = presentation.Slides[0].SaveAsImage(600, 400);
Step 3: Save image to file.
img.Save("result.png",System.Drawing.Imaging.ImageFormat.Png);
Effective screenshot of the resulted image with specified size:
Full codes:
using Spire.Presentation; using System.Drawing; namespace SavePowerPointSlideasImage { class Program { static void Main(string[] args) { Presentation presentation = new Presentation(); presentation.LoadFromFile("sample.pptx"); Image img = presentation.Slides[0].SaveAsImage(600, 400); img.Save("result.png", System.Drawing.Imaging.ImageFormat.Png); } }