News Category

C#/VB.NET: Convert PowerPoint Presentations to PDF

PDF files have many advantages for document sharing. For example, they can be viewed on almost any application without the need for a specific viewer. In addition, they can preserve all the formatting applied by the author, regardless of the software or system that the recipient uses. If you want to make your PowerPoint Presentations cross-platform and readable on as many devices as possible, converting them to PDF would be a good idea. This article will demonstrate how to convert PowerPoint presentations to PDF in C# and VB.NET using Spire.Presentation for .NET.

Install Spire.Presentation for .NET

To begin with, you need to add the DLL files included in the Spire.Presentation for.NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.

PM> Install-Package Spire.Presentation

Convert a Whole PowerPoint Presentation to PDF in C# and VB.NET

The following steps show you how to convert a whole PowerPoint presentation to PDF:

  • Initialize an instance of Presentation class.
  • Load the PowerPoint presentation using Presentation.LoadFromFile() method.
  • Save it to PDF using Presentation.SaveToFile(filePath, FileFormat.PDF) method.
  • C#
  • VB.NET
using Spire.Presentation;

namespace ConvertPowerPointToPdf
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Presentation instance
            Presentation ppt = new Presentation();
            //Load a PowerPoint Presentation
            ppt.LoadFromFile(@"Sample.pptx");

            //Save it to PDF
            ppt.SaveToFile("ToPdf1.pdf", FileFormat.PDF);
        }
    }
}

C#/VB.NET: Convert PowerPoint Presentations to PDF

Convert Specific Slide of a PowerPoint Presentation to PDF in C# and VB.NET

The following steps show you how to convert a specific slide of a PowerPoint presentation to PDF:

  • Initialize an instance of Presentation class.
  • Load the PowerPoint presentation using Presentation.LoadFromFile() method.
  • Get the desired slide by its index through Presentation.Slides[slideIndex] property.
  • Save it to PDF using ISlide.SaveToFile(filePath, FileFormat.PDF) method.
  • C#
  • VB.NET
using Spire.Presentation;

namespace ConvertSlidesToPdf
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Presentation instance
            Presentation ppt = new Presentation();
            //Load a PowerPoint Presentation
            ppt.LoadFromFile(@"Sample.pptx");

            //Get the second slide
            ISlide slide = ppt.Slides[1];

            //Save the slide to PDF
            slide.SaveToFile("ToPdf2.pdf", FileFormat.PDF);
        }
    }
}

C#/VB.NET: Convert PowerPoint Presentations to PDF

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.

Additional Info

  • tutorial_title:
Last modified on Friday, 15 July 2022 01:08