Slideshows

A presentation can have more than one slideshow defined (for example, if multiple speakers would like to use different slides of the same presentation for their talks).

The following example shows how to create and customize slideshows using the GemBox.Presentation API.

Screenshot
PowerPoint Library for C# / VB.NET Screenshot

See the full code below, use Run Example to execute.

using System;
using System.IO;
using System.Text;
using GemBox.Presentation;

class Sample
{
    [STAThread]
    static void Main(string[] args)
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        PresentationDocument presentation = new PresentationDocument();

        // Create first slide used in custom slideshows.
        Slide slide1 = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Create a text box.
        TextBox textBox = slide1.Content.AddTextBox(ShapeGeometryType.RoundedRectangle, 2, 2, 12, 4, LengthUnit.Centimeter);

        // Set shape fill and outline format.
        textBox.Shape.Format.Fill.SetSolid(Color.FromName(ColorName.BlueViolet));
        textBox.Shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.Violet));

        // Create a paragraph with single run element.
        TextRun run = textBox.AddParagraph().AddRun("Shows how to create and customize slide shows using GemBox.Presentation API.");
        run.Format.Fill.SetSolid(Color.FromName(ColorName.White));
        run.Format.Bold = true;

        // Create other two slides used in custom slideshows.
        Slide slide2 = presentation.Slides.AddNew(SlideLayoutType.Custom);
        Slide slide3 = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Get presentation slide show settings.
        SlideShowSettings settings = presentation.SlideShow;

        // Create first custom slideshow.
        CustomSlideShow slideShow1 = settings.CustomShows.AddNew("CustomShow1");
        slideShow1.Slides.Add(slide1);
        slideShow1.Slides.Add(slide2);
        slideShow1.Slides.Add(slide3);

        // Create first custom slideshow.
        CustomSlideShow slideShow2 = settings.CustomShows.AddNew("CustomShow2");
        slideShow2.Slides.Add(slide3);
        slideShow2.Slides.Add(slide2);
        slideShow2.Slides.Add(slide1);

        // Show the slides from the first custom show.
        settings.ShowCustomShowSlides("CustomShow1");

        // Slides should be manually advanced when presenting.
        settings.AdvanceMode = SlideShowAdvanceMode.Manually;

        // Slide show should loop at the end.
        settings.LoopContinuously = true;

        // Slides should be browsed at a kiosk (full screen).
        settings.ShowType = SlideShowType.Kiosk;

        presentation.Save("SlideShow.pptx");
    }
}
Imports System.IO
Imports System.Text
Imports GemBox.Presentation

Module Samples

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        Dim presentation As PresentationDocument = New PresentationDocument

        ' Create first slide used in custom slideshows.
        Dim slide1 As Slide = presentation.Slides.AddNew(SlideLayoutType.Custom)

        ' Create a text box.
        Dim textBox As TextBox = slide1.Content.AddTextBox(ShapeGeometryType.RoundedRectangle, 2, 2, 12, 4, LengthUnit.Centimeter)

        ' Set shape fill and outline format.
        textBox.Shape.Format.Fill.SetSolid(Color.FromName(ColorName.BlueViolet))
        textBox.Shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.Violet))

        ' Create a paragraph with single run element.
        Dim run As TextRun = textBox.AddParagraph().AddRun("Shows how to create and customize slide shows using GemBox.Presentation API.")
        run.Format.Fill.SetSolid(Color.FromName(ColorName.White))
        run.Format.Bold = True

        ' Create other two slides used in custom slideshows.
        Dim slide2 As Slide = presentation.Slides.AddNew(SlideLayoutType.Custom)
        Dim slide3 As Slide = presentation.Slides.AddNew(SlideLayoutType.Custom)

        ' Get presentation slide show settings.
        Dim settings As SlideShowSettings = presentation.SlideShow

        ' Create first custom slideshow.
        Dim slideShow1 As CustomSlideShow = settings.CustomShows.AddNew("CustomShow1")
        slideShow1.Slides.Add(slide1)
        slideShow1.Slides.Add(slide2)
        slideShow1.Slides.Add(slide3)

        ' Create first custom slideshow.
        Dim slideShow2 As CustomSlideShow = settings.CustomShows.AddNew("CustomShow2")
        slideShow2.Slides.Add(slide3)
        slideShow2.Slides.Add(slide2)
        slideShow2.Slides.Add(slide1)

        ' Show the slides from the first custom show.
        settings.ShowCustomShowSlides("CustomShow1")

        ' Slides should be manually advanced when presenting.
        settings.AdvanceMode = SlideShowAdvanceMode.Manually

        ' Slide show should loop at the end.
        settings.LoopContinuously = True

        ' Slides should be browsed at a kiosk (full screen).
        settings.ShowType = SlideShowType.Kiosk

        presentation.Save("SlideShow.pptx")

    End Sub

End Module