Render PowerPoint Presentation using C#

MS PowerPoint allows presenting information or data in the form of presentation slides. It also provides a PowerPoint viewer to view all the slides as a slide show. In certain cases, we may need to render PowerPoint presentation slides in other formats such as PDF, JPG images, or HTML. In this article, we will learn how to render a PowerPoint presentation in other formats using C#.

The following topics shall be covered in this article:

C# API to Render PowerPoint Presentation

For rendering PPT or PPTX files in other formats, we will be using GroupDocs.Viewer for .NET API. It allows the rendering and viewing of supported PowerPoint presentation formats programmatically. Please either download the DLL for the API or install it using NuGet.

PM> Install-Package GroupDocs.Viewer

Render PowerPoint Presentation in PDF using C#

We can render a PowerPoint presentation into a PDF document by following the steps given below:

  1. Load a PowerPoint presentation using the Viewer class.
  2. Create an instance of the PdfViewOptions class with the output PDF file path as an argument.
  3. Finally, call the View() method to save the PPTX as PDF. It takes PdfViewOptions object as an argument.

The following code sample shows how to render a PPTX file to a PDF using C#.

Render PowerPoint Presentation in PDF using C#.

Render PowerPoint Presentation in PDF using C#.

View PowerPoint Presentation in HTML using C#

We can also render a PowerPoint presentation in HTML to view in the browser by following the steps given below:

  1. Load a PowerPoint presentation using the Viewer class.
  2. Create an instance of the HtmlViewOptions class using the ForEmbeddedResources method. It takes the output HTML file path as an argument.
  3. Set various HtmlViewOptions such as RenderToSinglePage, etc.
  4. Finally, call the View() method to save the PPTX as HTML. It takes HtmlViewOptions object as an argument.

The following code sample shows how to render a PPTX as HTML using C#.

View PowerPoint Presentation in HTML using C#.

View PowerPoint Presentation in HTML using C#.

Render PowerPoint Notes in HTML using C#

We can render PowerPoint presentation notes in HTML by following the steps mentioned earlier. However, we just need to enable rendering of notes as shown below:

viewOptions.RenderNotes = true;

The following code sample shows how to render PowerPoint presentation notes in HTML using C#.

Render PowerPoint Presentation Notes in HTML using C#.

Render PowerPoint Presentation Notes in HTML using C#.

Convert PowerPoint Slides into JPG Images using C#

We can render a PowerPoint presentation and save all slides as JPG images by following the steps given below:

  1. Load a PowerPoint presentation using the Viewer class.
  2. Create an instance of the ViewInfoOptions class using the ForJpgView method.
  3. Get ViewInfo using the GetViewInfo method.
  4. Read the ViewInfo.Pages.Count property and iterate over all the slides one by one.
  5. Create an instance of the JpgViewOptions class.
  6. Finally, call the View() method to save the slide as JPG. It takes the JpgViewOptions object and Page number as arguments.

The following code sample shows how to render PowerPoint slides into JPG images using C#.

Convert PowerPoint Slides into JPG Images using C#.

Convert PowerPoint Slides into JPG Images using C#.

Get a Free License

Please try the API without evaluation limitations by requesting a free temporary license.

Conclusion

In this article, we have learned how to:

  • render PowerPoint slides from PPTX to a PDF in C#;
  • view PowerPoint slides in the browser programmatically;
  • convert PowerPoint slides into JPG images.

Besides, you can learn more about GroupDocs.Viewer for .NET API using the documentation. In case of any ambiguity, please feel free to contact us on the forum.

See Also