Articles in this section
Category / Section

How to create a PowerPoint presentation in ASP.NET

2 mins read

Syncfusion Essential PowerPoint is a .NET PowerPoint library used to create, read, and edit PowerPoint documents. Using this library, you can create a PowerPoint document in ASP.NET Web Forms.

 

Steps to create a PowerPoint file programmatically:

 

  1. Create a new ASP.NET Web application project.

A screenshot of a cell phone

Description generated with very high confidence

 

 

  1. Install the Syncfusion.Presentation.AspNet NuGet package as reference to your .NET Framework application from NuGet.org.

 

A screenshot of a social media post

Description generated with very high confidence

 

  1. Add a new Web Form in ASP .NET project. Right click on the project and select Add > New Item and add a Web Form from the list. Name it as MainPage.

 

  1. Add a new button in the MainPage.aspx as shown below.

 

<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="Create Document" OnClick="OnButtonClicked" />
       </div>
    </form>
</body>
</html>

 

  1. Include the following namespace in your MainPage.aspx.cs file.

 

using Syncfusion.Presentation;

 

Imports Syncfusion.Presentation

 

  1. Include the below code snippet in the click event of the button in MainPage.aspx.cs, to create a PowerPoint file and download it.

C#:

//Creates a PowerPoint instance
IPresentation pptxDoc = Presentation.Create();
 
//Adds a slide to the PowerPoint presentation
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);
 
//Add a textbox to the slide
IShape shape = slide.AddTextBox(10, 10, 500, 100);
 
//Add a text to the textbox.
shape.TextBody.AddParagraph("Hello World!!!");
 
//Save the PowerPoint Presentation
pptxDoc.Save("Sample.pptx", FormatType.Pptx, Response);
 
//Close the PowerPoint presentation
pptxDoc.Close();

 

VB:

'Creates a PowerPoint instance
Dim pptxDoc As IPresentation = Presentation.Create()
 
'Adds a slide to the PowerPoint presentation
Dim slide As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank)
 
'Add a textbox to the slide.
Dim shape As IShape = slide.AddTextBox(10, 10, 500, 100)
 
'Add a text to the textbox.
shape.TextBody.AddParagraph("Hello World!!!")
 
'Save the PowerPoint Presentation
pptxDoc.Save("Sample.pptx", FormatType.Pptx, Response)
 
'Close the PowerPoint presentation
pptxDoc.Close()

 

A complete working example of how to create PowerPoint file in ASP.NET can be downloaded from Create PowerPoint file.zip

By executing the program, you will get the PowerPoint file as follows.

 

A screenshot of a cell phone

Description generated with very high confidence

 

Take a moment to peruse the documentation, where you will find other options like create and edit PowerPoint tables, create and edit PowerPoint charts, convert PowerPoint slides to images, and convert PowerPoint file to PDF with code examples.

 

Refer here to explore the rich set of Syncfusion Essential PowerPoint features.

See Also:

Create a PowerPoint file in Windows Forms

Create a PowerPoint file in UWP

Create a PowerPoint file in WPF

Create a PowerPoint file in Xamarin

Create a PowerPoint file in Azure function

Create a PowerPoint file in ASP.NET Core

 

Note:

Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.

 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied