Are you looking for a reliable yet easy solution for converting PowerPoint PPT or PPTX to PDF? Do you want to accurately convert PowerPoint presentations to PDF with high quality? If yes then you are at the right place because, in this article, I am going to showcase a bunch of features to seamlessly convert PowerPoint PPT to PDF or PPTX to PDF programmatically in C#.
This article is composed of the following PowerPoint to PDF conversion features.
- Convert PowerPoint (PPT or PPTX) to PDF in C#
- Customized conversion of PPT or PPTX to PDF
- Convert hidden slides in PPT or PPTX to PDF
- Convert particular slides of PowerPoint presentation to PDF
- Convert PowerPoint presentation to a password-protected PDF with desired access permissions
Prerequisite for PowerPoint to PDF Conversion in C#
Aspose.Slides for .NET is a powerful PowerPoint automation API to create, edit, parse and convert presentation documents and we’ll use this API throughout this article. You can install Aspose.Slides for .NET using one of the following ways in Visual Studio.
Installing via NuGet Package Manager
Installing via Package Manager Console
PM> Install-Package Aspose.Slides.NET
Convert PPT or PPTX to PDF in C#
The following are the simple steps to convert a PowerPoint presentation to PDF using Aspose.Slides for .NET.
- Create an object of Presentation class and initialize it with the path of the PowerPoint presentation file.
- Use Presentation.Save(string outputFilePath, SaveFormat.Pdf) method to save file as PDF.
The following code sample shows how to convert PPT to PDF in C#.
Convert PPT or PPTX to PDF with Custom Options in C#
You can also customize PowerPoint to PDF conversion by defining different options such as Jpeg quality, text compression level, the behavior of metafiles and etc. You can set these options using the PdfOptions class.
The following code sample shows how to convert PowerPoint to PDF with custom options in C#.
Convert Hidden Slides of PowerPoint Presentation to PDF in C#
The PowerPoint presentations may also contain hidden slides. By default, hidden slides are not included in PPT or PPTX to PDF conversion. In case you want to convert a presentation including hidden slides, you can specify it using PdfOptions.ShowHiddenSlides property.
The following code sample shows how to convert a PPTX to PDF including hidden slides in C#.
Convert Selected Slides of PowerPoint PPT or PPTX to PDF in C#
Instead of converting the whole presentation, you can also convert the selected slides of the presentation to PDF. For this, you can define the integer array containing the slide numbers and then pass that array to the Save(String,Int32, SaveFormat.Pdf) method.
The following code sample shows how to convert selected slides of PowerPoint PPT/PPTX to PDF in C#.
Convert PowerPoint Presentation to a Password-protected PDF with Access Permissions
PDF format supports setting the password and access permissions to protect the document. In case you want to apply such a protection mechanism while converting PowerPoint to PDF, you can do it using PdfOptions class.
The following code sample shows how to set a password and specify access permissions while converting PPTX to PDF in C#.
Try Aspose.Slides for .NET for Free
You can try and use Aspose.Slides for .NET for free by requesting a temporary license.