Convert PowerPoint to PDF in Windows Forms

13 Jun 20243 minutes to read

Syncfusion PowerPoint is a .NET PowerPoint library used to create, read, edit and convert PowerPoint presentation programmatically without Microsoft PowerPoint or interop dependencies. Using this library, you can convert a PowerPoint to PDF in Windows Forms.

Steps to convert PowerPoint to PDF programmatically

Step 1: Create a new C# Windows Forms application project.

Create Windows Forms project

Step 2: Install the Syncfusion.PresentationToPdfConverter.WinForms NuGet package as reference to your .NET Standard applications from NuGet.org.

Install Syncfusion.PresentationToPdfConverter.WinForms Nuget Package

NOTE

Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, you also have to add “Syncfusion.Licensing” assembly reference and include a license key in your projects. Please refer to this link to know about registering Syncfusion license key in your application to use our components.

Step 3: Include the following namespaces in the Form1.cs file.

using Syncfusion.Pdf;
using Syncfusion.Presentation;
using Syncfusion.PresentationToPdfConverter;

Step 4: Add a new button in Form1.Designer.cs file.

private Button btnCreate;
private Label label;
private void InitializeComponent()
{
    this.label = new System.Windows.Forms.Label();
    this.btnCreate = new System.Windows.Forms.Button();
    this.SuspendLayout();
    // 
    // label
    // 
    this.label.Location = new System.Drawing.Point(0, 40);
    this.label.Name = "label";
    this.label.Size = new System.Drawing.Size(426, 35);
    this.label.TabIndex = 0;
    this.label.Text = "Click the button to convert PowerPoint to PDF";
    this.label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    // 
    // btnCreate
    // 
    this.btnCreate.Location = new System.Drawing.Point(180, 110);
    this.btnCreate.Name = "btnCreate";
    this.btnCreate.Size = new System.Drawing.Size(85, 36);
    this.btnCreate.TabIndex = 1;
    this.btnCreate.Text = "Convert PPTX to PDF";
    this.btnCreate.Click += new System.EventHandler(this.btnConvert_Click);
}

Step 5: Add the following code in btnConvert_Click to convert a PowerPoint to PDF in Windows Forms.

//Opens a PowerPoint Presentation.
using (IPresentation pptxDoc = Presentation.Open("Data/Input.pptx"))
{
    //Converts the PowerPoint Presentation into PDF document.
    using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc))
    {
        //Saves the PDF document.
        pdfDocument.Save("Sample.pdf");
    }
}

You can download a complete working sample from GitHub.

By executing the program, you will get the PDF as follows.

Converted PDF from PowerPoint in Windows Forms

Click here to explore the rich set of Syncfusion PowerPoint Library (Presentation) features.

An online sample link to convert PowerPoint Presentation to PDF in ASP.NET Core.