Microsoft PowerPoint presentations of PPT and PPTX formats are widely used for slideshows that contain rich multimedia materials and as a modern software replacement for old slide projector devices. Microsoft Office suite includes PowerPoint and other tools, like Word and Excel, for better office productivity. Although Microsoft Office provides a possibility to save PPT or PPTX presentations to other formats like images, HTML, XML, etc. It may be boring, time-consuming, and ineffective to save numerous files manually.
In such a situation, GroupDocs.Conversion for .NET will help you with converting presentations into a wide range of output file formats. And you don’t even need to install any third-party software for that! Everything can be made with just several lines of C# code.
This article explains how to convert PPT (or PPTX) presentations to other file formats programmatically using C# language.
Before we will take a deeper look at transforming PPT/PPTX presentations into other formats let’s learn how to convert PPT to PPTX (and vice versa).
The key difference between these two formats is that PPT specifies the Binary File Format used by Microsoft PowerPoint 97-2003, and the PPTX format is based on the Microsoft PowerPoint Open XML presentation file format that you can open on a PC in PowerPoint 2007 (or Mac in PowerPoint 2008) and newer versions.
The basic PPT to PPTX conversion could be performed using the code snippet below. The sequence of required steps is quite intuitive - load the source PPT file into the Converter object and call the Convert method to save the converted PPTX file. The PPTX format is chosen as the default format when instantiating the PresentationConvertOptions object without specifying the Format property explicitly.
// Load the source PPT fileusing(varconverter=newGroupDocs.Conversion.Converter("sample.ppt")){varoptions=newPresentationConvertOptions();// Save converted PPTX fileconverter.Convert("converted.pptx",options);}
An opposite conversion from PPTX to PPT is also could be implemented with a minimum of C# code. The main difference is that the Format property should be set to FileTypes.PresentationFileType.Ppt. Please take a look at the code example below:
// Load the source PPTX fileusing(varconverter=newGroupDocs.Conversion.Converter("sample.pptx")){PresentationConvertOptionsoptions=newPresentationConvertOptions{Format=GroupDocs.Conversion.FileTypes.PresentationFileType.Ppt};// Save converted PPT fileconverter.Convert("converted.ppt",options);}
Convert PowerPoint to PDF
Portable Document Format (PDF) is very popular nowadays for many reasons, therefore converting PowerPoint presentations to PDF format is also quite a demanding feature for customers from different areas. PowerPoint presentations could be presented in multiple file formats like PPT, PPTX, PPSM, PPS, etc. So let’s see how to convert them into PDF using C# code.
The actual process of conversion is very simple - provide your presentation file to the Converter class, call the Convert method which will do all necessary transformations and save the output PDF file where you want it to be saved. Let’s review just several code examples of PDF conversion, as for other presentation formats it’s almost the same - the only difference is a file extension of your input presentation file.
Convert PPTX to PDF
Here is an example of converting a PPTX presentation to PDF format. As you can see it’s pretty simple and straightforward.
// Load the source PPTX fileusing(varconverter=newGroupDocs.Conversion.Converter("sample.pptx")){varoptions=newPdfConvertOptions();// Save converted PDF fileconverter.Convert("converted.pdf",options);}
Convert PPSM to PDF
Files with PPSM extension represent Macro-enabled Slide Show file format created with Microsoft PowerPoint 2007 or higher. Another similar file format is PPTM which differs in opening with Microsoft PowerPoint in editable format instead of running as Slide Show. When run as a slideshow, the PPSM file shows the presentation slides with contents intact in the slide show and is in read-only mode by default. PPSM files can still be edited in Microsoft PowerPoint by opening them in PowerPoint.
The C# code required for converting PPSM into PDF is provided below.
// Load the source PPSM fileusing(varconverter=newGroupDocs.Conversion.Converter("sample.ppsm")){varoptions=newPdfConvertOptions();// Save converted PDF fileconverter.Convert("converted.pdf",options);}
Convert presentation to image
There is often a need to transform a PowerPoint presentation into a collection of images. Of course, it could be manually exported with the help of Microsoft PowerPoint, but in case you don’t have it at hand or when there is a big number of presentations to be converted, it’s more convenient to convert the presentation to images programmatically. No matter which image format you choose - GroupDocs.Conversion supports a wide range of them - PNG, JPG/JPEG, TIF/TIFF, GIF (and many others).
Here is a code snippet that shows how to convert PPTX to PNG image in C# programming language:
GroupDocs.Conversion.Contracts.SavePageStreamgetPageStream=page=>newFileStream(string.Format("converted-slide-{0}.png",page),FileMode.Create);// Load the source PPTX fileusing(Converterconverter=newGroupDocs.Conversion.Converter("sample.pptx")){// Set the convert options for PNG formatImageConvertOptionsoptions=newImageConvertOptions{Format=GroupDocs.Conversion.FileTypes.ImageFileType.Png};// Convert to PNG formatconverter.Convert(getPageStream,options);}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.