Introduction
The PresentationConverter class in the Slidize.Plugins library is designed to simplify the conversion of PowerPoint and OpenDocument presentations into various formats. This class supports a broad range of formats including standard PowerPoint files such as PPTX and PPT, macro-enabled formats like PPTM, as well as open-source formats like ODP. The ability to convert presentations to these different formats makes this class particularly useful in environments where presentations need to be shared across platforms or converted to formats that support specific use cases.
Here we will explore how to use the PresentationConverter class to perform various types of conversions with detailed examples in C#.
Convert a Presentation to PPTX
The most common use case for the PresentationConverter is converting presentations into the PPTX format, the modern PowerPoint format introduced by Microsoft. Converting to this format ensures compatibility with most versions of Microsoft PowerPoint.
using Slidize;
PresentationConverter.Process("input.ppt", "output.pptx");
In this example, the method Process takes the input PowerPoint file (input.ppt) and converts it to a modern PPTX format (output.pptx). This is useful for upgrading older PowerPoint files or ensuring compatibility with newer systems.
Convert to ODP Format
The OpenDocument Presentation (ODP) format is an open-source alternative to Microsoft's proprietary formats. Converting a PowerPoint presentation to ODP is important when you need to share presentations with users who rely on open-source office suites like LibreOffice or OpenOffice.
using Slidize;
PresentationConverter.Process("input.pptx", "output.odp");
This example shows how to convert a PPTX file to ODP, making the presentation accessible in open-source office environments.
Convert Streams Instead of Files
In some scenarios, you might be working with streams rather than physical files. This is especially common when dealing with files from cloud storage or databases. The PresentationConverter class also provides methods for converting presentations directly from streams.
using Slidize;
using var inputStream = new FileStream("input.pptx", FileMode.Open);
using var outputStream = new MemoryStream();
PresentationConverter.Process(inputStream, outputStream, ConvertFormat.Potx);
In this example, the presentation is read from a FileStream and converted into a MemoryStream in POTX format, demonstrating how to handle presentations in scenarios where file storage isn’t used directly.
Supported Formats
The PresentationConverter class in Slidize.Plugins supports a wide range of presentation formats, providing flexibility for converting PowerPoint files across various platforms and use cases. Below are the supported formats:
| Format | Description |
| ---- | --- |
| PPT | Legacy PowerPoint format used in older versions of Microsoft PowerPoint. |
| PPTX | Standard PowerPoint format used by modern versions of Microsoft PowerPoint. |
| PPTM | Macro-enabled PowerPoint format, retaining any embedded macros. |
| PPS | Legacy PowerPoint Show format for older PowerPoint versions. |
| PPSX | PowerPoint Show format, which opens presentations directly in slideshow mode. |
| PPSM | Macro-enabled PowerPoint Show format, combining slideshow functionality with macro support. |
| POT | Legacy PowerPoint template format. |
| POTX | PowerPoint template format for reusable slide designs. |
| POTM | Macro-enabled PowerPoint template format for reusable designs with embedded macros. |
| ODP | OpenDocument Presentation format, an open-source alternative compatible with LibreOffice and OpenOffice. |
| FODP | Flat XML version of the OpenDocument Presentation format, suitable for workflows requiring an uncompressed ODP version. |
| OTP | OpenDocument Template format, providing a reusable template for presentations in ODP format. |
| XML | PowerPoint XML Presentation format, useful for structured data processing and transformation in XML-based workflows. |
With this extensive range of supported formats, PresentationConverter allows for conversions between Microsoft PowerPoint formats, open-source alternatives, and XML-based formats, meeting the needs of diverse workflows.