PDF is no doubt the Portable Document Format, which is one of the most commonly used file formats. PPT and PPTX formats of Microsoft PowerPoint share the popularity in business documents. Due to the popularity of both the document formats and the fixed layout nature of PDF format, there comes the requirement to convert PPT/PPTX to PDF format.
Considering the .NET developers today, this article will be providing the solution to the above-mentioned file format conversion. GroupDocs supports the conversion of 50+ document formats, hence providing On-Premise APIs (.NET & Java), Cloud APIs, and online Conversion Apps. After this article, you will get familiar with different ways to convert Microsoft and OpenOffice presentations using GroupDocs.Conversion for .NET.
The following topics are discussed below:
- How to Convert Complete Presentation to PDF
- Convert Specific PPT slides to PDF
- Convert Sequential Subset of Slides to PDF
- Possible Conversions of PowerPoint PPT/PPTX format
- Convert Presentation with Advanced Options
- Apply Watermark while Conversion to PDF
Convert PPT to PDF in C#
GroupDocs.Conversion has made this so easy; the popular and demanding conversion of presentation files. Just with the below-mentioned two lines of CSharp code, you can quickly convert any type of presentation like PPTX or PPT to PDF.
- Create a new instance of Converter Class with the source document.
- Instantiate PdfConvertOptions object.
- Call Convert() method of Converter class.
The following code sample converts the complete PowerPoint PPTX to PDF in C#.
Convert Specific Slides of PPT to PDF in C#
We could have a requirement to convert only the selected slides instead of converting the whole presentation. GroupDocs.Conversion allows converting the specific slides of a presentation to the resultant PDF document. Below are the steps and C# source code that shows, how to achieve this.
- Load the presentation using Converter class.
- Prepare ConversionOptions for PDF.
- List the selected slide numbers to convert.
- Convert to PDF using Convert() method.
The following source code converts slides number 1, and 3 of a presentation to PDF.
Convert Consecutive Slides of PPTX to PDF using C#
With the little modification in the requirement, below is the little change in the code. Certain consecutive slides of the presentation can be selected to get these converted into PDF format. Just set the starting page number and number of successive pages ahead.
- Load the presentation file using Converter class.
- Set the starting page number and the count of sequentials slides ahead using PDF Conversion Options.
- Save the selected slides in PDF format using Convert() method.
The following code snippet converts the slide numbers 2, 3, and 4 to PDF format in C#.
Possible Conversions of PPT/PPTX
This is not only the PDF that could be the target document format while conversion. You can refer to the documentation for all the possible conversions. More important for developers, we can retrieve all the possible conversion formats of PPT/PPTX presentations by simply calling the GetPossibleConversions() method of the Converter class.
- Define the source format using the Converter class.
- Get all the possible conversions of the source format using GetPossibleConversions() method.
The following source code shows how to retrieve all the possible conversions of the PPTX formats using C#.
Convert PPT to PDF with Advanced Options
There are many more options while converting the presentations. These options are rarely needed, however when required, they prove their importance. PdfConvertOptions gives control over conversion results while converting to PDF. Along with the common conversion options, it has many additional options that can be seen in detail from the documentation. Just for an overview, we can customize the PPT conversion with the mentioned options and much more:
Add Watermark while converting PPTX or PPT to PDF in C#
Want to secure your presentation while converting it to PDF format? Leave a watermark on the resultant PDF. The below-mentioned steps and source code shows how to put a watermark when a PPT/PPTX presentation is converted to PDF format.
-
Load the PPT file using Converter class.
-
Prepare the text watermark options and define:
-
Watermark Text & Font
-
Watermark Color
-
Widht and Height
-
Rotation Angle
-
Tranparency
-
-
Add the prepared watermark to PDF conversion options.
-
Save the presentation to PDF using Convert() method.
The following C# code example adds a watermark with rotation angle and transparency while converting the PPT to PDF.
Conclusion
Let’s summarize what we discussed. We learned different ways to convert PPT to PDF format in C#. We separately looked at the steps and code example for converting a specific list of slides, any successive subset of presentation slides, and conversion of PPT to PDF with a customized watermark and other options. Learn more about GroupDocs.Conversion from the documentation.
Let’s Talk
You can build your own application using the above-highlighted features. We will be delighted if you contact us on the forum to discuss, solve a problem, or share your feedback. Have a nice development time.