Convert PowerPoint to Image in ASP.NET

13 Oct 20233 minutes to read

Syncfusion PowerPoint is a .NET PowerPoint library used to create, read, edit and convert PowerPoint presentation programmatically without Microsoft PowerPoint or interop dependencies. Using this library, you can convert a PowerPoint to image in ASP.NET.

Steps to convert PowerPoint to Image programmatically

Step 1: Create a new C# ASP.NET web application project.

Create ASP.NET Web project

Step 2: Select the Empty template to create the project.

Select Web Forms template

Step 3: Install the Syncfusion.PresentationRenderer.Net.Core NuGet package as reference to your .NET Standard applications from NuGet.org.

Install Syncfusion.PresentationRenderer.Net.Core Nuget package

NOTE

Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, you also have to add “Syncfusion.Licensing” assembly reference and include a license key in your projects. Please refer to this link to know about registering Syncfusion license key in your application to use our components.

Step 4: Include the following namespaces in MainPage.aspx.cs.

using Syncfusion.Presentation;
using Syncfusion.PresentationRenderer;

Step 5: Add a new button in the MainPage.aspx as shown below.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MainPage.aspx.cs" Inherits="Convert_PowerPoint_Presentation_to_Image.WebForm1" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
             <asp:Button ID="Button1" runat="server" Text="Convert PPTX to Image" OnClick="OnButtonClicked" />
        </div>
    </form>
</body>
</html>

Step 6: Include the below code snippets in MainPage.aspx.cs to convert a PowerPoint to image in ASP.NET.

string filePath = Server.MapPath("~/App_Data/Input.pptx");
//Open the existing PowerPoint presentation.
using (IPresentation pptxDoc = Presentation.Open(filePath))
{
    //Initialize the PresentationRenderer.
    pptxDoc.PresentationRenderer = new PresentationRenderer();
    //Converts the first slide into image.
    using (Stream stream = pptxDoc.Slides[0].ConvertToImage(ExportImageFormat.Jpeg))
    {
        //Create the output image file stream.
        using (FileStream fileStreamOutput = File.Create(Server.MapPath("~/PPTXtoImage.Jpeg")))
        {
            //Copy the converted image stream into created output image stream.
            stream.CopyTo(fileStreamOutput);
        }
    }
}

You can download a complete working sample from GitHub.

By executing the program, you will get the image as follows.

PowerPoint to Image in ASP.NET

Click here to explore the rich set of Syncfusion PowerPoint Library (Presentation) features.

An online sample link to convert PowerPoint Presentation to image in ASP.NET Core.