Slide Transitions

Various effects can be executed when moving to the next slide in a slideshow. These effects are called slide transitions.

The following example shows how to create and customize slide transitions 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();

        string pathToResources = "Resources";

        // Create new slide.
        Slide slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

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

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

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

        // Get slide transition information.
        SlideShowTransition transition = slide.Transition;

        // Set the transition type.
        transition.TransitionType = TransitionType.Fade;

        // Set the transition effect.
        transition.Effect = TransitionEffect.Smoothly;

        // Slide should advance automatically after 1 second.
        transition.AdvanceOnTime = true;
        transition.AdvanceAfterTime = 1000;

        // Slide should advance on mouse click.
        transition.AdvanceOnClick = true;

        // Set the transition speed.
        transition.Speed = TransitionSpeed.Slow;

        // Specify the sound to be played when the transition is activated.
        using (var stream = File.OpenRead(Path.Combine(pathToResources, "Applause.wav")))
            transition.PlaySound(stream);

        presentation.Save("SlideTransition.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

        Dim pathToResources As String = "Resources"

        ' Create new slide.
        Dim slide As Slide = presentation.Slides.AddNew(SlideLayoutType.Custom)

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

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

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

        ' Get slide transition information.
        Dim transition As SlideShowTransition = slide.Transition

        ' Set the transition type.
        transition.TransitionType = TransitionType.Fade

        ' Set the transition effect.
        transition.Effect = TransitionEffect.Smoothly

        ' Slide should advance automatically after 1 second.
        transition.AdvanceOnTime = True
        transition.AdvanceAfterTime = 1000

        ' Slide should advance on mouse click.
        transition.AdvanceOnClick = True

        ' Set the transition speed.
        transition.Speed = TransitionSpeed.Slow

        ' Specify the sound to be played when the transition is activated.
        Using stream As Stream = File.OpenRead(Path.Combine(pathToResources, "Applause.wav"))
            transition.PlaySound(stream)
        End Using

        presentation.Save("SlideTransition.pptx")

    End Sub

End Module