Convert PPT (PowerPoint) to PDF in C# (Example Tutorial)

As any business knows, PowerPoint presentations are crucial in day-to-day operations. They help communicate information clearly and concisely, and they can be used to pitch ideas, sell products, and train employees. However, presentations can also be time-consuming to create, and they can be difficult to update and share. One way to overcome these challenges is to convert PowerPoint presentations to PDFs programmatically using C#.

Doing so enables you to create presentations quickly, allowing you to update and share them easily. Additionally, converting PowerPoint presentations to PDFs ensures that your presentations are compatible with a wide range of devices and programs. As a result, converting PowerPoint presentations to PDFs can save you time and improve the efficiency of your business operations.

Let's see how we can convert a PowerPoint presentation to PDF in C# using the IronPDF library.

IronPDF: .NET PDF Library

IronPDF is a .NET PDF library that makes it simple for C# and VB developers to create, edit, and manipulate PDF documents within .NET applications. IronPDF provides excellent rendering capabilities with support for HTML to PDF, URL to PDF, SVG to Image, HTML File to PDF, and much more. IronPDF excels at producing PDFs of reports, invoices, statements, and receipts from web pages or existing HTML/CSS templates.

One critical feature is that IronPDF library can be used to fill out existing PDF forms or create new PDF forms from scratch. This allows businesses to streamline their document workflow by automating the creation and filling out of forms. In addition, IronPDF makes it easy to add headers, footers, watermarks, and page numbers to PDF files. This makes it an ideal solution for creating professional-looking PDFs. Let's see how we can use IronPDF to convert a PowerPoint presentation to a PDF document.

Prerequisites

There are some prerequisites to converting a .ppt file to a PDF document.

  1. Visual Studio 2022 (Recommended)
  2. A running .NET application with the latest .NET framework (Recommended)
  3. Microsoft Office installed
  4. A stable internet connection to install the IronPDF library for PDF conversion

Let's move to the main steps to convert .ppt files to PDFs.

Step 1: Export your PowerPoint Presentation as HTML

We have to convert PowerPoint files to HTML, and then we'll use the exported HTML to convert it to a PDF document.

To export your .ppt file to HTML format, do the following:

  • Open the Zamzar PPT to HTML converter online tool.
  • Upload the PowerPoint document to the Zamzar website.
  • Click on the "Convert Now" button.

    How to Convert PowerPoint Presentations to PDFs, Figure 1: Convert PPT to HTML

    Convert PPT to HTML

It'll start converting the PPTX file to HTML.

Step 2: Add IronPDF to the solution

IronPDF can be installed using NuGet package manager or the NuGet package manager console.

Let's use the package manager console method to install IronPDF.

Go to "Tools" in the toolbar and select the "Package Manage Console" option from the side menu.

How to Convert PowerPoint Presentations to PDFs, Figure 2: NuGet Package Manager shown in VS

NuGet Package Manager shown in VS

Enter the following command in the console to install IronPDF.

Install-Package IronPdf
How to Convert PowerPoint Presentations to PDFs, Figure 3: Installation of IronPDF Library

Installation of the IronPDF Library

Now, it's time to write the code to convert a PowerPoint to PDF using the IronPDF library.

Step 4: Convert the PowerPoint File to PDF

As we have the HTML file converted from a PowerPoint file, we'll use IronPDF to convert the HTML file to a PDF file using IronPDF.

Add IronPDF to the Code file

First, add the following line of code to the top of the source file to import IronPDF.

using IronPdf;
using IronPdf;
Imports IronPdf
VB   C#

Instantiate ChromePdfRenderer Object

Now, instantiate the ChromePdfRenderer object. It'll help to create and customize the PDF file.

var renderer = new ChromePdfRenderer();
var renderer = new ChromePdfRenderer();
Dim renderer = New ChromePdfRenderer()
VB   C#

Convert HTML file (Exported from PowerPoint file) to PDF

Let's use the RenderHtmlFileAsPdf method to convert the HTML file to the PDF.

var pdf = IronRenderer.RenderHtmlFileAsPdf(@"C:\Presentation\Presentation.html");
var pdf = IronRenderer.RenderHtmlFileAsPdf(@"C:\Presentation\Presentation.html");
Dim pdf = IronRenderer.RenderHtmlFileAsPdf("C:\Presentation\Presentation.html")
VB   C#

We've just converted the PowerPoint .ppt files to PDF. Let's see how we can customize the generated PDF with a watermark, password, and headers.

Step 3: Add watermark, password, and headers in the PDF file

Add Watermarks in PDFs using IronPDF

We can add a watermark in the PDF as a stamped image. Below, we use the ApplyStamp method to apply watermarks in the PDF file.

pdf.ApplyStamp(new ImageStamper("https://ironpdf.com/img/products/ironpdf-logo-text-dotnet.svg"));
pdf.ApplyStamp(new ImageStamper("https://ironpdf.com/img/products/ironpdf-logo-text-dotnet.svg"));
pdf.ApplyStamp(New ImageStamper("https://ironpdf.com/img/products/ironpdf-logo-text-dotnet.svg"))
VB   C#

Add Password Protection to PDFs

Adding a password to the PDF protects it from unauthorized access. IronPDF supports adding passwords for both users and owners. You can set a different password for the user and admin to allow customization of PDF files.

pdf.Password = "EasyPassword";
pdf.Password = "EasyPassword";
pdf.Password = "EasyPassword"
VB   C#

Add HTML headers

HTML headers are a good functionality for PDFs. It makes it easy to customize the header stylishly. Use the HtmlHeaderFooter object to add headers in the PDF file.

renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter()
{
    MaxHeight = 20, //millimeters
    HtmlFragment = "<h1>Headers are easy with IronPDF!</h1>",
};
renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter()
{
    MaxHeight = 20, //millimeters
    HtmlFragment = "<h1>Headers are easy with IronPDF!</h1>",
};
renderer.RenderingOptions.HtmlHeader = New HtmlHeaderFooter() With {
	.MaxHeight = 20,
	.HtmlFragment = "<h1>Headers are easy with IronPDF!</h1>"
}
VB   C#

Step 4: Save PDF File

After all customizations are done, it's now time to save the PDF file on the local machine. Use IronPDF's SaveAs method to save the PDF file.

pdf.SaveAs("C:\\PptToPdf.pdf");
pdf.SaveAs("C:\\PptToPdf.pdf");
pdf.SaveAs("C:\PptToPdf.pdf")
VB   C#

Let's look at the "Program.cs" file.

using IronPdf;
using IronPdf.Editing;

var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter()
{
    MaxHeight = 20, //millimeters
    HtmlFragment = "<h1>Headers are easy with IronPDF!</h1>",
};

var pdf = renderer.RenderHtmlFileAsPdf(@"C:\Presentation\Presentation.html");

pdf.ApplyStamp(new ImageStamper("https://ironpdf.com/img/products/ironpdf-logo-text-dotnet.svg"));

pdf.Password = "EasyPassword";

pdf.SaveAs("C:\\PptToPdf.pdf");
using IronPdf;
using IronPdf.Editing;

var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter()
{
    MaxHeight = 20, //millimeters
    HtmlFragment = "<h1>Headers are easy with IronPDF!</h1>",
};

var pdf = renderer.RenderHtmlFileAsPdf(@"C:\Presentation\Presentation.html");

pdf.ApplyStamp(new ImageStamper("https://ironpdf.com/img/products/ironpdf-logo-text-dotnet.svg"));

pdf.Password = "EasyPassword";

pdf.SaveAs("C:\\PptToPdf.pdf");
Imports IronPdf
Imports IronPdf.Editing

Private renderer = New ChromePdfRenderer()
renderer.RenderingOptions.HtmlHeader = New HtmlHeaderFooter() With {
	.MaxHeight = 20,
	.HtmlFragment = "<h1>Headers are easy with IronPDF!</h1>"
}

Dim pdf = renderer.RenderHtmlFileAsPdf("C:\Presentation\Presentation.html")

pdf.ApplyStamp(New ImageStamper("https://ironpdf.com/img/products/ironpdf-logo-text-dotnet.svg"))

pdf.Password = "EasyPassword"

pdf.SaveAs("C:\PptToPdf.pdf")
VB   C#

Output PDF File

The following PowerPoint presentation was converted to a PDF file.

How to Convert PowerPoint Presentations to PDFs, Figure 4: PowerPoint Presentation

PowerPoint Presentation

The generated PDF file is saved at the given location when the project is run. Open the file, and when it asks for a password, enter the password given in the project.

How to Convert PowerPoint Presentations to PDFs, Figure 5: Password Dialog Box

Password Dialog Box

After entering the correct password, the output PDF file looks like this.

How to Convert PowerPoint Presentations to PDFs, Figure 6: Output of the Generated PDF

Output of the Generated PDF

IronPDF renders the PDF file while preserving the formatting and responsiveness of the PowerPoint presentation. Headers and watermarks have been applied from the code we entered in the project.

Summary

That's how you convert a .ppt to PDF using IronPDF in C#. If you need more information about IronPDF, be sure to check out our website. We have a wealth of resources that can help you with all PDF-related operations.

Cheap and functional, IronPDF is the perfect solution for those who need to create PDF documents in .NET applications. IronPDF starts from $749, making it one of the more affordable PDF libraries on the market.

Purchase Iron Software's complete suite of five product for only the price of two of them!