Simple Steps to View a PowerPoint Presentation in an ASP.NET Core Application
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (175).NET Core  (29).NET MAUI  (208)Angular  (109)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (41)Black Friday Deal  (1)Blazor  (220)BoldSign  (14)DocIO  (24)Essential JS 2  (107)Essential Studio  (200)File Formats  (66)Flutter  (133)JavaScript  (221)Microsoft  (119)PDF  (81)Python  (1)React  (101)Streamlit  (1)Succinctly series  (131)Syncfusion  (919)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (51)Windows Forms  (61)WinUI  (68)WPF  (159)Xamarin  (161)XlsIO  (36)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (150)Chart  (132)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (633)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (40)Extensions  (22)File Manager  (7)Gantt  (18)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (508)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (43)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)Security  (3)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (11)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (387)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (597)What's new  (333)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Simple Steps to View a PowerPoint Presentation in an ASP.NET Core Application

Simple Steps to View a PowerPoint Presentation in an ASP.NET Core Application

In this blog, we will walk through how to create simple PowerPoint viewer functionality in an ASP.NET Core application using Syncfusion components. The interface will have the following basic options:

  • Browse and open PowerPoint presentation (PPTX) files.
  • Thumbnail view.
  • Print the entire presentation or a specific slide from the browser.
  • Download the PowerPoint presentation as a PDF.
PowerPoint Viewer in ASP.NET Core
PowerPoint Viewer in ASP.NET Core

By integrating PowerPoint viewing capability into your ASP.NET Core application, users can view PowerPoint presentation files without leaving the application or needing any external application. It results in improved security for your PowerPoint files.

We will use Syncfusion’s .NET PowerPoint Library and PDF Viewer control to achieve this functionality. We need to convert a PowerPoint file into a PDF with the former, and then view the resultant PDF using the PDF Viewer:

  • .NET PowerPoint Library: Used to create, read, edit, and convert PPTX files without using Microsoft Office or PowerPoint.
  • PDF Viewer: Used to view, print, and annotate PDF files.

Create eye-catching presentations with the user-friendly features of the Syncfusion PowerPoint Framework!

Design PowerPoint viewer in ASP.NET Core application

Step 1: First, clone the getting started with the PDF Viewer application from the GitHub repository.

Step 2: As we are designing a PowerPoint viewer using the Syncfusion .NET PowerPoint Library and ASP.NET Core PDF Viewer, we must install these NuGet packages in the application:

Note: If you plan to deploy your application to Linux or macOS, install Syncfusion.EJ2.PdfViewer.AspNet.Core.Linux or Syncfusion.EJ2.PdfViewer.AspNet.Core.OSX, respectively, instead of Syncfusion.EJ2.PdfViewer.AspNet.Core.Windows.

Step 3: Open Index.cshtml and set the accept value of the input type as .pptx to accept uploading the PowerPoint presentation files.

<input type=”file” id=”fileUpload” accept=”.pptx” style=”display:block;visibility:hidden;width:0;height:0;”>

Step 4: Modify the onload function script in Index.cshtml like in the following code to load the PowerPoint presentation template as the default instead of the PDF template.

window.onload = function () {
    disableSpinner();
    var pdfViewer = document.getElementById('pdfviewer').ej2_instances[0];
    pdfViewer.serviceUrl = 'api/PowerPointViewer';
    document.getElementById('fileUpload').addEventListener('change', readFile, false);
}

The features of Syncfusion’s PowerPoint Library are documented with clear code examples for multiple scenarios.

Step 5: In the Controller class, include the following namespaces.

using Syncfusion.Pdf;
using Syncfusion.Presentation;
using Syncfusion.PresentationRenderer;

Step 6: Then, replace the existing code with the following Load() method in the Controller class to convert the PowerPoint presentation to PDF using the .NET PowerPoint Library and send the converted PDF to the PDF Viewer.

public IActionResult Load([FromBody] Dictionary<string, string> jsonObject)
{
     PdfRenderer pdfviewer = new PdfRenderer(_cache);
     MemoryStream stream = new MemoryStream();
object jsonResult = new object();
if (jsonObject != null && jsonObject.ContainsKey("document")) { if (bool.Parse(jsonObject["isFileName"])) { string documentPath = GetDocumentPath(jsonObject["document"]); if (!string.IsNullOrEmpty(documentPath))
{ byte[] bytes = System.IO.File.ReadAllBytes(documentPath); stream = new MemoryStream(bytes); } else { return this.Content(jsonObject["document"] + " is not found"); } } else { byte[] bytes = Convert.FromBase64String(jsonObject["document"]); stream = new MemoryStream(bytes); } } try { //Open the PowerPoint Presentation using the Syncfusion Presentation library using (IPresentation presentation = Presentation.Open(stream)) { stream.Dispose(); //Convert a PowerPoint Presentation as PDF to view the generated PDF file in our Syncfusion PdfViewer using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(presentation)) { //Save the converted Pdf document to get a physical DOM of PDF document. stream = new MemoryStream(); pdfDocument.Save(stream); //Reset the pdf stream position. stream.Position = 0; } } } catch { } jsonResult = pdfviewer.Load(stream, jsonObject); return Content(JsonConvert.SerializeObject(jsonResult)); }

Step 7: Now, the application is ready. Launch it and upload the PowerPoint presentation file to display the slides in the PowerPoint viewer.

Syncfusion’s PowerPoint Framework is cross-platform compatible. Explore its features by platform with interactive demos.

GitHub reference

You can find the example of this code in the GitHub repository.

Convert PowerPoint presentations into images

To make the PowerPoint presentation accessible on virtually any platform (Windows, Linux, macOS, mobile, Docker, cloud), you might occasionally want to share or show each slide as an image. Furthermore, it is a handy format to guard against content alteration. Our Syncfusion .NET Core PowerPoint Library provides the APIs to convert an entire PowerPoint presentation or just specific slides to images with just a few lines of code in C# without Microsoft PowerPoint.

Conclusion

Thank you for reading this blog. I hope this information helps you create a PowerPoint viewer using the Syncfusion .NET PowerPoint Library. Take a moment to peruse its documentation, where you’ll find other options and features, all with accompanying code examples.

Our Syncfusion .NET PowerPoint Library has the following significant functionalities:

To learn about all the features supported, please check our product page. If you are new to our PowerPoint Library, it is highly recommended that you follow our Getting Started guide.

Are you already a Syncfusion user? You can download the product setup here. If you’re not a Syncfusion user, you can download a free 30-day trial here.

If you have questions, contact us through our support forumsupport portal, or feedback portal. We are happy to assist you!

Step into a world of boundlessly creative presentations with Syncfusion’s C# PowerPoint Library!

Related blogs

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed