1. Home
  2. /
  3. GroupDocs.Conversion.LowCode
  4. /
  5. Developer Guide
  6. /
  7. Using PPT to PDF Converter

Using PPT to PDF Converter

This topic shows how to use the PptToPdfConverter with examples that demonstrate common use cases for converting PowerPoint PPT files to PDF.

Prerequisites

Refer to the Developer Guide to learn how to set up your environment and run code examples in this section.

You can also check two related topics on Loading Source Documents and Saving Converted Documents to learn how to specify input and output documents.

Basic Example

The following example shows the most common use case for converting PowerPoint PPT document to PDF. The source PPT file is loaded from a current folder. The converted file is saved to the same folder.

using System;
using GroupDocs.Conversion.LowCode;

// Load license keys
var publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");
var privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");

// Apply the license
License.Set(publicKey, privateKey);

// Create a converter for the PPT file
var converter = new PptToPdfConverter("presentation.ppt");

// Convert PPT to PDF
converter.Convert("converted.pdf");
Imports System
Imports GroupDocs.Conversion.LowCode

Module Program
    Sub Main()
        ' Load license keys
        Dim publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
        Dim privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

        ' Apply the license
        License.Set(publicKey, privateKey)

        ' Create a converter from file path
        Dim converter As New PptToPdfConverter("presentation.ppt")

        ' Convert PPT to PDF
        converter.Convert("converted.pdf")
    End Sub
End Module
open System
open GroupDocs.Conversion.LowCode

[<EntryPoint>]
let main _ =
    // Load license keys
    let publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
    let privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

    // Apply the license
    License.Set(publicKey, privateKey)

    // Create a converter from file path
    let converter = new PptToPdfConverter("presentation.ppt")

    // Convert PPT to PDF
    converter.Convert("converted.pdf")
    0

Sample input file: Download presentation.ppt

Expected output: Download converted.pdf

Presentation Load Options

This section covers only the main scenarios. You can also refer to the API references for the PresentationLoadOptions for a complete list of options that you can specify.

Convert Protected PPT to PDF

The following example shows how to convert protected PPT file and save it to unprotected PDF file.

In case you do not specify password for protected document PasswordRequiredException is going to be thrown.

using System;
using GroupDocs.Conversion.LowCode;

// Load license keys
var publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");
var privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");

// Apply license
License.Set(publicKey, privateKey);

// Provide password through load options
var converter = new PptToPdfConverter("protected.ppt", options =>
{
    options.Password = "12345";
});

// Convert PPT to PDF
converter.Convert("unprotected.pdf");
Imports GroupDocs.Conversion.LowCode

Module Program
    Sub Main()
        ' Load license keys
        Dim publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
        Dim privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

        ' Apply license
        License.Set(publicKey, privateKey)

        ' Provide password through load options
        Dim converter As New PptToPdfConverter("protected.ppt", Sub(options)
            options.Password = "12345"
        End Sub)

        ' Convert PPT to PDF
        converter.Convert("unprotected.pdf")
    End Sub
End Module
open System
open GroupDocs.Conversion.LowCode

[<EntryPoint>]
let main _ =
    // Load license keys
    let publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
    let privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")
    
    // Apply license
    License.Set(publicKey, privateKey)

    // Provide password through load options
    let converter = new PptToPdfConverter("protected.ppt", fun options ->
        options.Password <- "12345"
    )
    
    // Convert PPT to PDF
    converter.Convert("unprotected.pdf")
    0

Sample input: Download protected.ppt (Password: 12345)

Expected output: Download unprotected.pdf

Convert PPT with Hidden Slides

By default hidden slides are not added to the converted PDF document.

The following example shows how to include hidden slides when converting PPT to PDF using the ShowHiddenSlides property.

using System;
using GroupDocs.Conversion.LowCode;

// Load license keys
var publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");
var privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");

// Apply license
License.Set(publicKey, privateKey);

// Show hidden slides through load options
var converter = new PptToPdfConverter("with-hidden-slides.ppt", options =>
{
    options.ShowHiddenSlides = true;
});

// Convert PPT to PDF
converter.Convert("with-hidden-slides.pdf");
Imports GroupDocs.Conversion.LowCode

Module Program
    Sub Main()
        ' Load license keys
        Dim publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
        Dim privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

        ' Apply license
        License.Set(publicKey, privateKey)

        ' Show hidden slides through load options
        Dim converter As New PptToPdfConverter("with-hidden-slides.ppt", Sub(options)
            options.ShowHiddenSlides = True
        End Sub)

        ' Convert PPT to PDF
        converter.Convert("with-hidden-slides.pdf")
    End Sub
End Module
open System
open GroupDocs.Conversion.LowCode

[<EntryPoint>]
let main _ =
    // Load license keys
    let publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
    let privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")
    
    // Apply license
    License.Set(publicKey, privateKey)

    // Show hidden slides through load options
    let converter = new PptToPdfConverter("with-hidden-slides.ppt", fun options ->
        options.ShowHiddenSlides <- true
    )
    
    // Convert PPT to PDF
    converter.Convert("with-hidden-slides.pdf")
    0

Sample input: Download with-hidden-slides.ppt (Contains hidden slides)

Expected output: Download with-hidden-slides.pdf (Hidden slides included)

Convert PPT with Preserved Document Structure for Accessible PDF

The following example shows how to convert a PPT file to an accessible PDF by preserving the document structure using the PreserveDocumentStructure property. This is useful for creating PDFs that are more accessible to screen readers and assistive technologies.

using System;
using GroupDocs.Conversion.LowCode;

// Load license keys
var publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");
var privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");

// Apply license
License.Set(publicKey, privateKey);

// Preserve document structure for accessible PDF
var converter = new PptToPdfConverter("presentation.ppt", options =>
{
    options.PreserveDocumentStructure = true;
});

// Convert PPT to accessible PDF
converter.Convert("accessible.pdf");
Imports GroupDocs.Conversion.LowCode

Module Program
    Sub Main()
        ' Load license keys
        Dim publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
        Dim privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

        ' Apply license
        License.Set(publicKey, privateKey)

        ' Preserve document structure for accessible PDF
        Dim converter As New PptToPdfConverter("presentation.ppt", Sub(options)
            options.PreserveDocumentStructure = True
        End Sub)

        ' Convert PPT to accessible PDF
        converter.Convert("accessible.pdf")
    End Sub
End Module
open System
open GroupDocs.Conversion.LowCode

[<EntryPoint>]
let main _ =
    // Load license keys
    let publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
    let privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")
    
    // Apply license
    License.Set(publicKey, privateKey)

    // Preserve document structure for accessible PDF
    let converter = new PptToPdfConverter("presentation.ppt", fun options ->
        options.PreserveDocumentStructure <- true
    )
    
    // Convert PPT to accessible PDF
    converter.Convert("accessible.pdf")
    0

Expected output: Download accessible.pdf (Accessible PDF with preserved structure)

PDF Convert Options

The examples in this section shows how you can adjust the output using PdfConvertOptions.

Convert Specific PPT Slides to PDF

To convert only a portion of the presentation instead of all slides. You can specify which slides to include in the output PDF using the Pages property of PdfConvertOptions class.

As an alternative you can use PageNumber to specify the slide number to start conversion from and PagesCount to set number of slides to convert starting from PageNumber.

The following example shows how to convert the first three slides of a PPT file to PDF:

using System;
using System.Collections.Generic;
using GroupDocs.Conversion.LowCode;

// Load license keys
var publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");
var privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");

// Apply license
License.Set(publicKey, privateKey);

// Create the converter
var converter = new PptToPdfConverter("presentation.ppt");

// Save first three slides to PDF
converter.Convert("slides-1-2-3.pdf", (convertOptions) => {
    convertOptions.Pages = new List<int> { 1, 2, 3 };
});
Imports System
Imports System.Collections.Generic
Imports GroupDocs.Conversion.LowCode

Module Program
    Sub Main()
        ' Load license keys
        Dim publicKey As String = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
        Dim privateKey As String = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

        ' Apply license
        License.Set(publicKey, privateKey)

        ' Create the converter
        Dim converter As New PptToPdfConverter("presentation.ppt")

        ' Save first three slides to PDF
        converter.Convert("slides-1-2-3.pdf", Sub(convertOptions)
                                                convertOptions.Pages = New List(Of Integer) From {1, 2, 3}
                                            End Sub)
    End Sub
End Module
open System
open System.Collections.Generic
open GroupDocs.Conversion.LowCode

[<EntryPoint>]
let main argv =
    // Load license keys
    let publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
    let privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

    // Apply license
    License.Set(publicKey, privateKey)

    // Create the converter
    let converter = new PptToPdfConverter("presentation.ppt")

    // Save first three slides to PDF
    converter.Convert("slides-1-2-3.pdf", fun convertOptions ->
        convertOptions.Pages <- List<int>([1; 2; 3])
    )

    0 // return exit code

Expected output: Download slides-1-2-3.pdf

Convert PPT to Password-Protected PDF

You can protect the output PDF with a password by setting the Password property in PdfConvertOptions class.

using System;
using GroupDocs.Conversion.LowCode;

// Load license keys
var publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");
var privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");

// Apply license
License.Set(publicKey, privateKey);

// Create the converter
var converter = new PptToPdfConverter("presentation.ppt");

// Convert to password-protected PDF
converter.Convert("protected.pdf", convertOptions =>
{
    convertOptions.Password = "12345";
});
Imports GroupDocs.Conversion.LowCode

Module Program
    Sub Main()
        ' Load license keys
        Dim publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
        Dim privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

        ' Apply license
        License.Set(publicKey, privateKey)

        ' Create the converter
        Dim converter As New PptToPdfConverter("presentation.ppt")

        ' Convert to password-protected PDF
        converter.Convert("protected.pdf", Sub(convertOptions)
            convertOptions.Password = "12345"
        End Sub)
    End Sub
End Module
open System
open GroupDocs.Conversion.LowCode

[<EntryPoint>]
let main _ =
    // Load license keys
    let publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
    let privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

    // Apply license
    License.Set(publicKey, privateKey)

    // Create the converter
    let converter = new PptToPdfConverter("presentation.ppt")

    // Convert to password-protected PDF
    converter.Convert("protected.pdf", fun convertOptions ->
        convertOptions.Password <- "12345"
    )

    0

Expected output: Download protected.pdf (Password: 12345)