How to convert PowerPoint to PDF in C#?

PowerPoint is the king of presentation software, but when you want to have it in PDF format for printing or distribution, it is not an easy task to convert it from PPT to PDF in C#. With the help of Spire.Presentation for .NET, the conversion from PPT to PDF becomes quickly and easily. You only need three lines of code to accomplish it in C# and VB.NET.

Make sure Spire.Presentation for .NET has been installed correctly and then add Spire.Presentation.dll as reference in the downloaded Bin folder though the below path: "..\Spire.Presentation\Bin\NET4.0\ Spire. Presentation.dll". Here comes to the details of how to output PowerPoint to PDF:

Step 1: Create a presentation document.

Presentation presentation = new Presentation();

Step 2: Load the PPT file from disk.

presentation.LoadFromFile("ppt.ppt");

Step 3: Save the slide to PDF.

presentation.SaveToFile("ToPdf.pdf", FileFormat.PDF);

Step 4: Launch and view the resulted PDF file.

System.Diagnostics.Process.Start("ToPdf.pdf");

Full code

//create PPT document
Presentation presentation = new Presentation();

//load PPT file from disk
presentation.LoadFromFile("ppt.ppt");

//save the PPT do PDF file format
presentation.SaveToFile("ToPdf.pdf", FileFormat.PDF);

System.Diagnostics.Process.Start("ToPdf.pdf");

Screenshot:

convert PPT to PDF