1. Home
  2. /
  3. GroupDocs.Merger.LowCode
  4. /
  5. Developer Guide
  6. /
  7. Split PPTX (SplitPptx)

Using SplitPptx to Split PPTX Documents

This topic shows how to use the SplitPptx plugin to split a PPTX document into several PPTX documents. You select the slides in the constructor, and Save writes one document per part. The part number is added to the output file name: slide.pptx becomes slide_1.pptx, slide_2.pptx, and so on.

Prerequisites

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

The Loading Source Documents and Saving Output Documents topics explain how to specify input and output documents.

Split Specific Slides into Separate Documents

The following example puts slides 1, 2, and 3 into documents of their own. Each part is numbered after the source slide it holds: slide_1.pptx, slide_2.pptx, and slide_3.pptx.

using System;
using GroupDocs.Merger.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);

// Select slides 1, 2, and 3
var splitter = new SplitPptx("presentation.pptx", new[] { 1, 2, 3 });

// Save one document per part
splitter.Save("output/slide.pptx");
Imports System
Imports GroupDocs.Merger.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)

        ' Select slides 1, 2, and 3
        Dim splitter As New SplitPptx("presentation.pptx", {1, 2, 3})

        ' Save one document per part
        splitter.Save("output/slide.pptx")
    End Sub
End Module
open System
open GroupDocs.Merger.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)

    // Select slides 1, 2, and 3
    let splitter = SplitPptx("presentation.pptx", [| 1; 2; 3 |])

    // Save one document per part
    splitter.Save("output/slide.pptx")
    0

Expected output: Download slides.zip (3 documents)

Split a Document into Parts at Specific Slides

In SplitMode.Interval, the slides you list mark where each new part starts. The following example cuts a 13-slide presentation before slide 8: deck_0.pptx holds slides 1 to 7 and deck_1.pptx holds slides 8 to 13. Interval parts are numbered from 0.

using System;
using GroupDocs.Merger.Domain.Options;
using GroupDocs.Merger.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);

// Start a new part at slide 8
var splitter = new SplitPptx("presentation.pptx", new[] { 8 }, SplitMode.Interval);

// Save one document per part
splitter.Save("output/deck.pptx");
Imports System
Imports GroupDocs.Merger.Domain.Options
Imports GroupDocs.Merger.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)

        ' Start a new part at slide 8
        Dim splitter As New SplitPptx("presentation.pptx", {8}, SplitMode.Interval)

        ' Save one document per part
        splitter.Save("output/deck.pptx")
    End Sub
End Module
open System
open GroupDocs.Merger.Domain.Options
open GroupDocs.Merger.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)

    // Start a new part at slide 8
    let splitter = SplitPptx("presentation.pptx", [| 8 |], SplitMode.Interval)

    // Save one document per part
    splitter.Save("output/deck.pptx")
    0

Expected output: Download decks.zip (2 documents)

Split a Range of Slides

Pass the first and the last slide of a range to put every slide of the range into a document of its own. The following example splits out slides 2 to 4.

using System;
using GroupDocs.Merger.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);

// Select slides 2 to 4
var splitter = new SplitPptx("presentation.pptx", 2, 4);

// Save one document per part
splitter.Save("output/slide.pptx");
Imports System
Imports GroupDocs.Merger.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)

        ' Select slides 2 to 4
        Dim splitter As New SplitPptx("presentation.pptx", 2, 4)

        ' Save one document per part
        splitter.Save("output/slide.pptx")
    End Sub
End Module
open System
open GroupDocs.Merger.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)

    // Select slides 2 to 4
    let splitter = SplitPptx("presentation.pptx", 2, 4)

    // Save one document per part
    splitter.Save("output/slide.pptx")
    0

Expected output: Download range.zip (3 documents)

Split Odd or Even Slides of a Range

Add a RangeMode to narrow the range to its odd or even slides. The following example splits out the even slides from 1 to 6: slides 2, 4, and 6.

using System;
using GroupDocs.Merger.Domain.Options;
using GroupDocs.Merger.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);

// Select the even slides from 1 to 6
var splitter = new SplitPptx("presentation.pptx", 1, 6, RangeMode.EvenPages);

// Save one document per part
splitter.Save("output/even-slide.pptx");
Imports System
Imports GroupDocs.Merger.Domain.Options
Imports GroupDocs.Merger.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)

        ' Select the even slides from 1 to 6
        Dim splitter As New SplitPptx("presentation.pptx", 1, 6, RangeMode.EvenPages)

        ' Save one document per part
        splitter.Save("output/even-slide.pptx")
    End Sub
End Module
open System
open GroupDocs.Merger.Domain.Options
open GroupDocs.Merger.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)

    // Select the even slides from 1 to 6
    let splitter = SplitPptx("presentation.pptx", 1, 6, RangeMode.EvenPages)

    // Save one document per part
    splitter.Save("output/even-slide.pptx")
    0

Expected output: Download even-slides.zip (3 documents)