Simple Steps to View a PowerPoint Presentation in an ASP.NET Core Application
Tags: fileformats, aspnetcore, webdev, powerpoint
Published: 2023-05-17 15:22:27

---
title: Simple Steps to View a PowerPoint Presentation in an ASP.NET Core Application
published: true
date: 2023-05-16 11:00:00 UTC
tags: fileformats, aspnetcore, webdev, powerpoint
canonical_url: https://www.syncfusion.com/blogs/post/view-powerpoint-asp-dotnet-core.aspx
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9yeub1sx5u71s9iqfzs1.png
---
In this blog, we will walk through how to create simple PowerPoint viewer functionality in an [ASP.NET Core](https://www.syncfusion.com/aspnet-core-ui-controls "ASP.NET Core UI Controls Library") 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.
<figure>

  <img src="https://www.syncfusion.com/blogs/wp-content/uploads/2023/05/PowerPoint-Viewer-in-ASP.NET-Core.png" alt="PowerPoint Viewer in ASP.NET Core" style="width:100%">

  <figcaption>PowerPoint Viewer in ASP.NET Core</figcaption>

</figure>

By integrating PowerPoint viewing capability into your [ASP.NET Core](https://www.syncfusion.com/aspnet-core-ui-controls "ASP.NET Core UI Controls Library") 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](https://www.syncfusion.com/document-processing/powerpoint-framework/net "Syncfusion .NET PowerPoint Library") and [PDF Viewer control](https://www.syncfusion.com/aspnet-core-ui-controls/pdf-viewer "Syncfusion ASP.NET Core PDF Viewer") 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](https://www.syncfusion.com/document-processing/powerpoint-framework/net "Syncfusion .NET PowerPoint Library"): Used to create, read, edit, and convert PPTX files without using Microsoft Office or PowerPoint.
- [PDF Viewer](https://www.syncfusion.com/aspnet-core-ui-controls/pdf-viewer "Syncfusion ASP.NET Core PDF Viewer"): Used to view, print, and annotate PDF files.

## Design PowerPoint viewer in ASP.NET Core application

**Step 1:** First, clone the getting started with the PDF Viewer application from the [GitHub](https://github.com/syncfusion/ej2-aspnetcore-samples "ASP.NET Core controls demo on GitHub") repository.

**Step 2:** As we are designing a PowerPoint viewer using the [Syncfusion .NET PowerPoint Library](https://www.syncfusion.com/document-processing/powerpoint-framework/net "Syncfusion .NET PowerPoint Library") and ASP.NET Core PDF Viewer, we must install these NuGet packages in the application:

- [Syncfusion.PresentationRenderer.Net.Core](https://www.nuget.org/packages/Syncfusion.PresentationRenderer.Net.Core "Syncfusion.PresentationRenderer.Net.Core NuGet Package")
- [Syncfusion.EJ2.AspNet.Core](https://www.nuget.org/packages/Syncfusion.EJ2.AspNet.Core/ "Syncfusion.EJ2.AspNet.Core NuGet Package")
- [Syncfusion.EJ2.PdfViewer.AspNet.Core.Windows](https://www.nuget.org/packages/Syncfusion.EJ2.PdfViewer.AspNet.Core.Windows/ "Syncfusion.EJ2.PdfViewer.AspNet.Core.Windows NuGet Package")

**Note:** If you plan to deploy your application to Linux or macOS, install [Syncfusion.EJ2.PdfViewer.AspNet.Core.Linux](https://www.nuget.org/packages/Syncfusion.EJ2.PdfViewer.AspNet.Core.Linux/ "Syncfusion.EJ2.PdfViewer.AspNet.Core.Linux NuGet Package") or [Syncfusion.EJ2.PdfViewer.AspNet.Core.OSX](https://www.nuget.org/packages/Syncfusion.EJ2.PdfViewer.AspNet.Core.OSX/ "Syncfusion.EJ2.PdfViewer.AspNet.Core.OSX NuGet Package"), respectively, instead of [Syncfusion.EJ2.PdfViewer.AspNet.Core.Windows](https://www.nuget.org/packages/Syncfusion.EJ2.PdfViewer.AspNet.Core.Windows/ "Syncfusion.EJ2.PdfViewer.AspNet.Core.Windows NuGet Package").

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

```xml
<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.

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

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

```csharp
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.

```csharp
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.

## GitHub reference

You can find the example of [this code](https://github.com/SyncfusionExamples/create-powerpoint-viewer-in-aspnet-core "Powerpoint Viewer in ASP.NET Core GitHub demo") 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](https://www.syncfusion.com/document-processing/powerpoint-framework/net-core "Syncfusion PowerPoint Library") provides the APIs to convert an entire [PowerPoint presentation or just specific slides to image](https://help.syncfusion.com/file-formats/presentation/presentation-to-image?cs-save-lang=1&cs-lang=csharp "Presentation to image conversion in PowerPoint Library documentation")s 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](https://help.syncfusion.com/file-formats/presentation "Getting Started with PowerPoint Library"), where you’ll find other options and features, all with accompanying code examples.

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

- Create, read, and edit PowerPoint presentations programmatically.
- [Clone](https://help.syncfusion.com/file-formats/presentation/working-with-slide#cloning-slide "Cloning slides in PowerPoint Library") and [merge](https://help.syncfusion.com/file-formats/presentation/working-with-slide#merging-slide "Merging slides in PowerPoint Library") slides in PowerPoint presentations.
- Create and edit [animations](https://help.syncfusion.com/file-formats/presentation/working-with-animation "Animations in PowerPoint Library") and [transition effects](https://help.syncfusion.com/file-formats/presentation/create-edit-slide-transitions-in-powerpoint-presentation-slides-cs-vb-net "Transition effects in PowerPoint Library").
- [Find and replace](https://help.syncfusion.com/file-formats/presentation/working-with-find-and-replace "Finding and replacing text in PowerPoint Library") the text in all PowerPoint slides or specific slides.
- Convert PowerPoint files to [PDF](https://help.syncfusion.com/file-formats/presentation/presentation-to-pdf "Presentation to PDF conversion in PowerPoint Library") and [images](https://help.syncfusion.com/file-formats/presentation/presentation-to-image "Presentation to image conversion in PowerPoint Library").
- [Encrypt](https://help.syncfusion.com/file-formats/presentation/security?#encrypting-with-password "Encrypting with password in PowerPoint Library") and [decrypt](https://help.syncfusion.com/file-formats/presentation/security?#decrypting-the-powerpoint-presentation "Decrypting the PowerPoint Presentation") PowerPoint presentations.

To learn about all the features supported, please check our [product page](https://www.syncfusion.com/document-processing/powerpoint-framework/net "Syncfusion .NET PowerPoint Library"). If you are new to our PowerPoint Library, it is highly recommended that you follow our [Getting Started guide](https://help.syncfusion.com/file-formats/presentation/getting-started "Getting started with PowerPoint Presentation Library").

Are you already a Syncfusion user? You can download the product setup [here](https://www.syncfusion.com/account/downloads/studio/ "Essential Studio Licence and Downloads page"). If you’re not a Syncfusion user, you can download a free 30-day trial [here](https://www.syncfusion.com/downloads/fileformats/confirm "Free evaluation of the Essential Studio for File Formats").

If you have questions, contact us through our [support forum](https://www.syncfusion.com/forums "Syncfusion Support Forum"), [support portal](https://support.syncfusion.com/ "Syncfusion Support Portal"), or [feedback portal](https://www.syncfusion.com/feedback/powerpoint "Syncfusion Feedback Portal"). We are happy to assist you!

## Related blogs

- [Adding Animation to PowerPoint Slide Elements in C#](https://www.syncfusion.com/blogs/post/adding-animations-to-the-powerpoint-slide-elements-in-c.aspx "Blog: Adding Animation to PowerPoint Slide Elements in C#")
- [Seamlessly Import and Export CSV Data in Excel Using C#](https://www.syncfusion.com/blogs/post/import-export-csv-data-in-excel-csharp.aspx "Blog: Seamlessly Import and Export CSV Data in Excel Using C#")
- [View Word, Excel, and PowerPoint Files in Angular Application](https://www.syncfusion.com/blogs/post/view-word-excel-powerpoint-in-angular.aspx "Blog: View Word, Excel, and PowerPoint Files in Angular Application")
- [Create a PDF Digital Signature Web Service Using Azure Key Vault and the Syncfusion C# PDF Library](https://www.syncfusion.com/blogs/post/pdf-digital-signature-web-service-using-azure-key-vault-and-csharp-pdf-library.aspx "Blog: Create a PDF Digital Signature Web Service Using Azure Key Vault and the Syncfusion C# PDF Library")