Back to Devexpress

Merge and Split Presentations with the DevExpress Presentation API Library

officefileapi-405406-presentation-api-merge-split.md

latest7.6 KB
Original Source

Merge and Split Presentations with the DevExpress Presentation API Library

  • Nov 07, 2025
  • 4 minutes to read

This topic contains examples that implement the following merge and split tasks:

  • Reuse slides in multiple presentations
  • Combine multiple presentations into one presentation
  • Split presentations

Notes on Presentation Merge Operations

  • Slide size may change when you merge presentations. The target presentation defines the size. If you merge a slide into a presentation with smaller slide size, some shapes may fall outside the visible area. However, these shapes remain in the presentation and keep their original coordinates.
  • Merged slides keep their original formatting and style settings.
  • Slide masters used by source presentation slides are automatically transferred to the target presentation (along with their theme and all their layouts).

Copy a Slide from Another Presentation

The following code snippet extracts a slide from a presentation and inserts it into another presentation:

csharp
using DevExpress.Docs.Presentation;

namespace PptxSample;

public class Program {
    public static void Main(string[] _) {

        // Load the first presentation from a file
        Presentation presentation1 = new Presentation(File.ReadAllBytes(@"..\..\..\data\my-presentation.pptx"));

        // Load the second presentation from a file
        Presentation presentation2 = new Presentation(File.ReadAllBytes(@"..\..\..\data\NorthwindPresentation.pptx"));

        // Clone the first slide from the first presentation, so you can edit the copy not the original slide, if necessary
        Slide slide1 = presentation1.Slides[0].Clone();

        // Insert the cloned slide at the beginning of the second presentation
        presentation2.Slides.Insert(0, slide1);

        // Export the modified second presentation to a PDF file
        presentation2.ExportToPdf(new FileStream(@"D:\exported-document.pdf", FileMode.Create));
    }
}
vb
Imports DevExpress.Docs.Presentation

Namespace PptxSample

    Public Class Program
        Public Shared Sub Main(__ As String())
            ' Load the first presentation from a file
            Dim presentation1 As Presentation = New Presentation(File.ReadAllBytes("..\..\..\data\my-presentation.pptx"))
            ' Load the second presentation from a file
            Dim presentation2 As Presentation = New Presentation(File.ReadAllBytes("..\..\..\data\NorthwindPresentation.pptx"))

            ' Clone the first slide from the first presentation, so you can edit the copy not the original slide, if necessary
            Dim slide1 As Slide = presentation1.Slides(0).Clone()

            ' Insert the cloned slide at the beginning of the second presentation
            presentation2.Slides.Insert(0, slide1)

            ' Export the modified second presentation to a PDF file
            presentation2.ExportToPdf(New FileStream("D:\exported-document.pdf", FileMode.Create))
        End Sub
    End Class
End Namespace

Merge Multiple Presentations

The following code snippet adds slides to a presentation from another presentation to merge two presentations:

csharp
using DevExpress.Docs.Presentation;

namespace PptxSample;

public class Program {
    public static void Main(string[] _) {

        // Load the first presentation from a file
        Presentation presentation1 = new Presentation(File.ReadAllBytes(@"..\..\..\data\my-presentation.pptx"));

        // Load the second presentation from a file
        Presentation presentation2 = new Presentation(File.ReadAllBytes(@"..\..\..\data\NorthwindPresentation.pptx"));

        // Append all slides from the second presentation to the first presentation
        foreach (Slide slide in presentation2.Slides) {
            presentation1.Slides.Add(slide);
        }

        // Export the resulting presentation to PDF
        presentation1.ExportToPdf(new FileStream(@"D:\exported-document.pdf", FileMode.Create));
    }
}
vb
Imports DevExpress.Docs.Presentation

Namespace PptxSample

    Public Class Program
        Public Shared Sub Main(__ As String())
            ' Load the first presentation from a file
            Dim presentation1 As Presentation = New Presentation(File.ReadAllBytes("..\..\..\data\my-presentation.pptx"))

            ' Load the second presentation from a file
            Dim presentation2 As Presentation = New Presentation(File.ReadAllBytes("..\..\..\data\NorthwindPresentation.pptx"))

            ' Append all slides from the second presentation to the first presentation
            For Each slide In presentation2.Slides
                presentation1.Slides.Add(slide)
            Next

            ' Export the resulting presentation to PDF
            presentation1.ExportToPdf(New FileStream("D:\exported-document.pdf", FileMode.Create))

        End Sub
    End Class
End Namespace

Split Presentations

The following code snippet extracts slides from a presentation and puts them into an empty presentation:

csharp
using DevExpress.Docs.Presentation;

namespace PptxSample;

public class Program {
    public static void Main(string[] _) {

        // Load the Northwind presentation from a file
        Presentation presentation1 = new Presentation(File.ReadAllBytes(@"..\..\..\data\NorthwindPresentation.pptx"));

        // Create a new empty presentation
        Presentation presentation2 = new Presentation();

        // Remove default slides in presentation 
        presentation2.Slides.Clear();

        // Set the presentation1 slide size to match presentation2
        presentation2.SlideSize = presentation1.SlideSize;

        // Move the first three slides from presentation1 to presentation2
        for (int i = 0; i < 3; i++)
        {
            presentation2.Slides.Add(presentation1.Slides[i]);
            presentation1.Slides.RemoveAt(i);
        }

        // Export the modified presentation1 (with the remaining slides) to PDF
        presentation1.ExportToPdf(new FileStream(@"D:\exported-document1.pdf", FileMode.Create));
        // Export presentation2 (with the first three slides) to PDF
        presentation2.ExportToPdf(new FileStream(@"D:\exported-document2.pdf", FileMode.Create));
    }
}
vb
Imports DevExpress.Docs.Presentation

Namespace PptxSample

    Public Class Program
        Public Shared Sub Main(__ As String())

            ' Load the Northwind presentation from a file
            Dim presentation1 As Presentation = New Presentation(File.ReadAllBytes("..\..\..\data\NorthwindPresentation.pptx"))

            ' Create a new empty presentation
            Dim presentation2 As Presentation = New Presentation()
            ' Remove default slides in presentation 
            presentation2.Slides.Clear()
            ' Set the slide size to match presentation2
            presentation2.SlideSize = presentation1.SlideSize

            ' Move the first three slides from presentation1 to presentation2
            For i = 0 To 2
                presentation2.Slides.Add(presentation1.Slides(i))
                presentation1.Slides.RemoveAt(i)
            Next

            ' Export the modified presentation1 (with the remaining slides) to PDF
            presentation1.ExportToPdf(New FileStream("D:\exported-document1.pdf", FileMode.Create))
            ' Export presentation2 (with the first three slides) to PDF
            presentation2.ExportToPdf(New FileStream("D:\exported-document2.pdf", FileMode.Create))

        End Sub
    End Class
End Namespace