Skip to main content
All docs
V25.1
  • Merge and Split Presentations with the DevExpress Presentation API Library

    • 5 minutes to read

    Important

    The DevExpress Presentation API Library is currently available as a Community Technology Preview (CTP). Note that we do not recommend that you integrate pre-release libraries into mission-critical software applications. You can try the library and share your feedback so that we can make necessary adjustments before the official release. To start a conversation, submit a ticket via the DevExpress Support Center — we’d love to hear from you.

    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:

    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));
        }
    }
    

    Merge Multiple Presentations

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

    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));
        }
    }
    

    Split Presentations

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

    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));
        }
    }