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

Using PPTX to PDF Converter

This topic shows how to use the PptxToPdfConverter with examples that demonstrate common use cases for converting PowerPoint presentations 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 presentation to PDF. The source PPTX 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 PPTX file
var converter = new PptxToPdfConverter("presentation.pptx");

// Convert PPTX 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 PptxToPdfConverter("presentation.pptx")

        ' Convert PPTX 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 PptxToPdfConverter("presentation.pptx")

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

Sample input file: Download presentation.pptx

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 PPTX to PDF

The following example shows how to convert protected PPTX 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 PptxToPdfConverter("protected.pptx", options =>
{
    options.Password = "12345";
});

// Convert PPTX 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 PptxToPdfConverter("protected.pptx", Sub(options)
            options.Password = "12345"
        End Sub)

        ' Convert PPTX 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 PptxToPdfConverter("protected.pptx", fun options ->
        options.Password <- "12345"
    )
    
    // Convert PPTX to PDF
    converter.Convert("unprotected.pdf")
    0

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

Expected output: Download unprotected.pdf

Convert PPTX 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 PPTX 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 PptxToPdfConverter("with-hidden-slides.pptx", options =>
{
    options.ShowHiddenSlides = true;
});

// Convert PPTX 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 PptxToPdfConverter("with-hidden-slides.pptx", Sub(options)
            options.ShowHiddenSlides = True
        End Sub)

        ' Convert PPTX 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 PptxToPdfConverter("with-hidden-slides.pptx", fun options ->
        options.ShowHiddenSlides <- true
    )
    
    // Convert PPTX to PDF
    converter.Convert("with-hidden-slides.pdf")
    0

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

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

Preserve Document Structure for Accessible PDF

The following example shows how to preserve the document structure when converting PPTX to PDF using the PreserveDocumentStructure property. When this option is enabled, the structure will be preserved for accessible PDF.

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 through load options
var converter = new PptxToPdfConverter("presentation.pptx", options =>
{
    options.PreserveDocumentStructure = true;
});

// Convert PPTX to 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 through load options
        Dim converter As New PptxToPdfConverter("presentation.pptx", Sub(options)
            options.PreserveDocumentStructure = True
        End Sub)

        ' Convert PPTX to 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 through load options
    let converter = new PptxToPdfConverter("presentation.pptx", fun options ->
        options.PreserveDocumentStructure <- true
    )
    
    // Convert PPTX to PDF
    converter.Convert("accessible.pdf")
    0

Expected output: Download accessible.pdf (Document structure preserved)

PDF Convert Options

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

Convert Specific PPTX 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 PPTX presentation 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 PptxToPdfConverter("presentation.pptx");

// 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 PptxToPdfConverter("presentation.pptx")

        ' 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 PptxToPdfConverter("presentation.pptx")

    // 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 PPTX 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 PptxToPdfConverter("presentation.pptx");

// 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 PptxToPdfConverter("presentation.pptx")

        ' 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 PptxToPdfConverter("presentation.pptx")

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

    0

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