.NET PowerPoint Examples
Work with Shapes Using Syncfusion .NET PowerPoint Library
The Syncfusion® .NET PowerPoint Library enables the seamless creation, customization, and removal of shapes in PowerPoint presentations programmatically using C#. It eliminates the need for Microsoft PowerPoint or interop dependencies and offers a lightweight and efficient solution for managing shapes.
Watch this video to learn how to create shapes in a PowerPoint presentation using the Syncfusion .NET PowerPoint library.
Create PowerPoint shapes using C#
Learn how to create and customize shapes in PowerPoint presentations programmatically using C# with the Syncfusion .NET PowerPoint library. This guide demonstrates adding various shapes and managing visual elements to enhance presentation design effectively.
Step 1: Create a new project
Start by creating a new C# Console Application project.
Step 2: Install the NuGet package
Add the Syncfusion.Presentation.Net.Core package to your project from NuGet.org.
Step 3: Add required namespaces to create PowerPoint shapes
Add the following namespaces to your Program.cs file:
using Syncfusion.Presentation;Step 4: Create a PowerPoint presentation
Create a new presentation and add a blank slide.
//Create a new instance of PowerPoint Presentation file
IPresentation pptxDoc = Presentation.Create();
//Add a blank slide to Presentation
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);Step 5: Add a shape
Add a cube shape to the slide.
//Add normal shape to slide
slide.Shapes.AddShape(AutoShapeType.Cube, 50, 200, 300, 300);Step 6: Add an image
Add a picture to the slide from a file stream.
//Get a picture as stream
FileStream imageStream = new FileStream(Path.GetFullPath(@"Data/Image.jpg"), FileMode.Open);
//Add picture to the shape collection
IPicture picture = slide.Shapes.AddPicture(imageStream, 373, 83, 526, 382);Step 7: Save the PowerPoint presentation
Save the presentation with shapes and images to a file stream.
FileStream outputStream = new(Path.GetFullPath(@"Output/Result.pptx"), FileMode.Create, FileAccess.ReadWrite);
pptxDoc.Save(outputStream);
//Close streams and presentation
outputStream.Close();
imageStream.Close();
pptxDoc.Close();GitHub project
NuGet installation
Get started quickly by downloading the installer and checking license information on the Downloads page.
Table of contents
Explore these resources for comprehensive guides, knowledge base articles, insightful blogs, and ebooks.
Learning
Technical Support
