C#: Change Slide Size in PowerPoint

Changing slide size is one way to maintain the visual integrity of your PowerPoint presentation. By adjusting the slide size to the specific aspect ratio and dimensions of the target screen or projection device, you can avoid issues such as content appearing cropped, stretched, or distorted. In this article, you will learn how to change the slide size of a PowerPoint presentation in C# using Spire.Presentation for .NET.

Install Spire.Presentation for .NET

To begin with, you need to add the DLL files included in the Spire.Presentation for.NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.

PM> Install-Package Spire.Presentation

Change the Slide Size to a Preset Size in C#

Spire.Presentation for .NET provides the Presentation.SlideSize.Type property to set or change the slide size to a preset size. The following are the detailed steps.

  • Create a Presentation instance.
  • Load a PowerPoint presentation using Presentation.LoadFromFile() method.
  • Change the slide type of the presentation using Presentation.SlideSize.Type property.
  • Save the result document using Presentation.SaveToFile() method.
  • C#
using Spire.Presentation;

namespace CreateCombination
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Presentation instance
            Presentation ppt = new Presentation();

            //Load a presentation file
            ppt.LoadFromFile("sample.pptx");

            //Change the slide size of the presentation
            ppt.SlideSize.Type = SlideSizeType.Screen4x3;

            //Save the result file
            ppt.SaveToFile("SlideSize.pptx", FileFormat.Pptx2013);
            ppt.Dispose();
        }
    }
}

C#: Change Slide Size in PowerPoint

Change the Slide Size to a Custom Size in C#

Customizing the size of slides requires changing the slide size type to Custom first, and then you can set a desired size through the Presentation.SlideSize.Size property. The following are the detailed steps.

  • Create a Presentation instance.
  • Load a PowerPoint presentation using Presentation.LoadFromFile() method.
  • Change the slide size type to custom using Presentation.SlideSize.Type property.
  • Customize the slide size using Presentation.SlideSize.Size property.
  • Save the result document using Presentation.SaveToFile() method.
  • C#
using Spire.Presentation;
using System.Drawing;

namespace CreateCombination
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Presentation instance
            Presentation ppt = new Presentation();

            //Load a presentation file
            ppt.LoadFromFile("sample.pptx");

            //Change the slide size type to custom
            ppt.SlideSize.Type = SlideSizeType.Custom;

            //Set the slide size
            ppt.SlideSize.Size = new SizeF(900, 600);

            //Save the presentation file
            ppt.SaveToFile("CustomSize.pptx", FileFormat.Pptx2013);
            ppt.Dispose();
        }
    }
}

C#: Change Slide Size in PowerPoint

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.