Convert PPT to PDF – Complete Guide to Convert PowerPoint and OpenOffice Presentations in C#

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 shares the popularity in business documents. Due to the popularity of both the document formats and fixed layout nature of PDF format, there comes the need to convert PPT/PPTX to PDF format.

Convert PPT to PDF

Considering the .NET developers today, this article will be providing the solution to the above-mentioned famous and needed file format conversion. GroupDocs supports the conversion of 50+ document formats, hence provides 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.

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.

using (Converter converter = new Converter("sample.pptx"))
{
    PdfConvertOptions options = new PdfConvertOptions();
    converter.Convert("converted.pdf", options);
}

Convert Specific Slides of PPT to PDF

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 is the C# source code that shows, how to achieve this.

using (Converter converter = new Converter("sample.ppt"))
{
    PdfConvertOptions options = new PdfConvertOptions
    {
        Pages = new List<int>{ 1, 3 }
    };
    converter.Convert("converted.pdf", options);
}

Convert Consecutive Pages of PPTX to PDF

With the little modification in the requirement, below is the little change in the code. Certain consecutive pages of the presentation can be selected to get these converted into PDF format. Just set the PageNumber and PageCount properties of the ConverOptions Class.

using (Converter converter = new Converter("sample.pptx"))
{
    PdfConvertOptions options = new PdfConvertOptions
    {
        PageNumber = 2,
        PagesCount = 3
    };
    converter.Convert("converted.pdf", options);
}

Possible Conversions of PPT/PPTX

This is not only the PDF that could be the target document format while conversion. We 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.

const string sourceFile = "sample.pptx";
using (Converter converter = new Converter(sourceFile))
{
    PossibleConversions conversions = converter.GetPossibleConversions();
    Console.WriteLine("{0} is of type {1} and could be converted to:", sourceFile, conversions.Source.Extension);
    foreach (var conversion in conversions.All)
    {
        Console.WriteLine("\t {0} as {1} conversion.", conversion.Format, conversion.IsPrimary?"primary": "secondary");
    }
}

PPT to PDF Conversion 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, PdfConvertOptions 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:

using (Converter converter = new Converter("sample.ppt"))
{
    PdfConvertOptions options = new PdfConvertOptions
    {
        PageNumber = 2,
        PagesCount = 1,
        Rotate = Rotation.On180,
        Dpi = 300,
        Width = 1024,
        Height = 768
    };
    converter.Convert("converted.pdf", options);
}

Add Watermark while converting PPTX or PPT to PDF

Want to secure your presentation while converting it to PDF format? Leave a watermark on the resultant PDF. Below mentioned source code shows how to put a watermark when a PPT/PPTX presentation is converted to PDF format.

using (Converter converter = new Converter("sample.ppt"))
{
    WatermarkOptions watermark = new WatermarkOptions
    {
        Text = "GroupDocs Watermark",
        Color = Color.Red,
        Width = 100,
        Height = 100,
        Background = true
    };
    PdfConvertOptions options = new PdfConvertOptions
    {
        Watermark = watermark
    };
    converter.Convert("converted.pdf", options);
}

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, solving a problem or share your feedback.