Articles in this section
Category / Section

How to set slide size for PowerPoint after cloning and merging a PowerPoint slide in C#?

9 mins read
Syncfusion PowerPoint is a .NET Core PowerPoint library used to create, read, and edit PowerPoint presentation programmatically without Microsoft PowerPoint or interop dependencies. When cloning and merging a PowerPoint slide from a source presentation to a destination presentation with the source formatting paste option, the slide size of the source slides may not be applied correctly to the merged slides. However, this behavior can be achieved using our library by setting the slide size for PowerPoint after cloning and merging a PowerPoint slide using C#.

Steps to set slide size for PowerPoint after cloning and merging a PowerPoint slide using C#

Step 1: Create a new .NET console application project.
NET_Console
Step 2: Install the Syncfusion.Presentation.Net.Core NuGet package as a reference to your project from NuGet.org.
nuget-package_open_and_save
Note: Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.
Step 3: Include the following namespaces in Program.cs file.
using Syncfusion.Presentation;
Step 4: Include the below code snippet in Program.cs to set slide size for PowerPoint after cloning and merging a PowerPoint slide.
//Open the existing source PowerPoint presentation.
using (Presentation? sourcePresentation = Presentation.Open(@"Template.pptx") as Presentation) 
{   //Create a destination PowerPoint presentation.
    using (Presentation? destinationPresentation = Presentation.Create() as Presentation)
    {
        //Set the source presentation slide size to the destination presentation slide size.
        destinationPresentation.SlideSize.Type = sourcePresentation.SlideSize.Type;
        destinationPresentation.SlideSize.SlideOrientation = sourcePresentation.SlideSize.SlideOrientation;
        destinationPresentation.SlideSize.Width = sourcePresentation.SlideSize.Width;
        destinationPresentation.SlideSize.Height = sourcePresentation.SlideSize.Height;
        //Clone and merge the PowerPoint slides with PasteOptions.SourceFormatting.
        foreach (ISlide slide in sourcePresentation.Slides)
            destinationPresentation.Slides.Add(slide, PasteOptions.SourceFormatting);
        //Save the PowerPoint Presentation.
        destinationPresentation.Save("Output.pptx");
    }          
}
A complete working sample to set slide size for PowerPoint after cloning and merging a PowerPoint slide using C# can be downloaded from GitHub.

Conclusion

I hope you enjoyed learning about how to check fonts available for conversion in .NET PowerPoint.

You can refer to our .NET PowerPoint feature tour page to know about its other groundbreaking feature representations. You can also explore our documentation to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied