Simple Way to Export PPT/PPTX as PDF in C#

PDF is a universally accepted transferable file system that provides easy means of document distribution that you can read at any workstation, laptop, tablet or smartphone. At some situations, we convert PowerPoint files to PDF for easy reading or sharing. This article presents how to export PPT/PPTX file as PDF file with its original layout via C# Presentation library. Making the conversion is quick and easy with the following piece of code.

Main Steps:

Step 1: Download this .NET Presentation Component, reference its Dll file to your project.

Step 2: Use Spire.Presentation as name space.

Step 3: Initialize a new instance of Presentation class.

              Presentation presentation = new Presentation();

Step 4: Load PPT/PPTX file from disk.

              presentation.LoadFromFile(“test.ppt”);

Step 5: Save PPT/PPTX as PDF by calling SaveToFile method.

              presentation.SaveToFile(“ToPdf.pdf”, FileFormat.PDF);

Step 6: Open the generated PDF file.

              System.Diagnostics.Process.Start(“ToPdf.pdf”);

Result:

ToPdf

Entire Code:

//create PPT document

Presentation presentation = new Presentation();

//load PPT file from disk

presentation.LoadFromFile(“test.ppt”);

//save the PPT do PDF file formatz

presentation.SaveToFile(“ToPdf.pdf”, FileFormat.PDF);

System.Diagnostics.Process.Start(“ToPdf.pdf”);

Advertisements

One thought on “Simple Way to Export PPT/PPTX as PDF in C#

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s