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
- Render PowerPoint Presentation in PDF
- View PowerPoint Presentation in HTML
- Render PowerPoint Notes in HTML
- Convert PowerPoint Slides into JPG Images
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:
- Load a PowerPoint presentation using the Viewer class.
- Create an instance of the PdfViewOptions class with the output PDF file path as an argument.
- 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#.
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:
- Load a PowerPoint presentation using the Viewer class.
- Create an instance of the HtmlViewOptions class using the ForEmbeddedResources method. It takes the output HTML file path as an argument.
- Set various HtmlViewOptions such as RenderToSinglePage, etc.
- 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#.
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#.
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:
- Load a PowerPoint presentation using the Viewer class.
- Create an instance of the ViewInfoOptions class using the ForJpgView method.
- Get ViewInfo using the GetViewInfo method.
- Read the ViewInfo.Pages.Count property and iterate over all the slides one by one.
- Create an instance of the JpgViewOptions class.
- 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#.
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.