We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to create a PowerPoint presentation in ASP.NET MVC

The following steps demonstrate how to create a simple PowerPoint presentation in a ASP.NET MVC web application using Presentation library.

Step 1: Create a new ASP.NET MVC web application. Name it as GettingStarted.

Step 2: Install Presentation assemblies with NuGet

In Visual Studio, select Tools > NuGet Package Manager > Package Manager Console and execute any of the below commands for the project.

MVC version

Command

MVC 3

install-package Syncfusion.AspNet.Mvc3.FileFormats

source - http://nuget.syncfusion.com/aspnetmvc

MVC 4

install-package Syncfusion.AspNet.Mvc4.FileFormats

source - http://nuget.syncfusion.com/aspnetmvc

MVC 5

install-package Syncfusion.AspNet.Mvc5.FileFormats

source - http://nuget.syncfusion.com/aspnetmvc

Step 3: Add a new button in the web page.

Step 4: Include the below code snippet in the controller of the application, to create a PowerPoint presentation and save it as a file.

 

The following code snippet demonstrates the class “PresentationResult” used in the above code snippet.

 

public class PresentationResult : ActionResult

{

//private members

private IPresentation m_source;

private string m_filename;

private HttpResponse m_response;

 

//Get/Set the filename of Presentation

public string FileName

{

get

 

{

return m_filename;

}

set

{

m_filename = value;

}

}

 

//Get the Presentation

public IPresentation Source

{

get

{

return m_source as IPresentation;

}

}

 

//Get the http response

public HttpResponse Response

{

get

{

return m_response;

}

}

 

public PresentationResult(IPresentation source, string fileName, HttpResponse response)

{

//Assign values using the constructor

this.FileName = fileName;

this.m_source = source;

m_response = response;

}

 

public override void ExecuteResult(ControllerContext context)

{

//Throw exception if context is null

if (context == null)

throw new ArgumentNullException("Context is null");

//Save the Presentation to the client browser

this.m_source.Save(FileName, FormatType.Pptx, Response);

}

}

 

Step 5: Compile & execute the application. Now this application creates a simple PowerPoint presentation.

Step 6: Using this NuGet package, the PowerPoint presentation can also be converted to PDF document or image. For more details, See Conversion.

 

 

Article ID: Published Date: Last Revised Date: Platform: Control:
8167 11/20/2017 11/20/2017 ASP.NET MVC Presentation
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon