Articles in this section
Category / Section

How to create a ASP.NET WebForms PowerPoint file in C#?

6 mins read

The following steps demonstrate how to create a simple PowerPoint presentation in a Windows forms application using Presentation library.

Step 1: Create a new Windows Forms application. Name it as GettingStarted.

Step 2: Install Presentation assemblies with NuGet

In Visual Studio, select Tools > NuGet Package Manager > Package Manager Console and execute the below command for the project.

install-package Syncfusion.Presentation.Base

Step 3: Add a new button in the form editor.

Step 4: Include the below code snippet in the click event of the button in Form.cs, to create a PowerPoint presentation and save it as a file.

//Creates a new instance of PowerPoint Presentation
IPresentation presentation = Presentation.Create();
 
//Adds a slide to the PowerPoint Presentation
ISlide firstSlide = presentation.Slides.Add(SlideLayoutType.Blank);
 
//Adds a textbox in a slide by specifying its position and size
IShape textShape = firstSlide.AddTextBox(100, 75, 756, 200);
 
//Adds a paragraph into the textShape
IParagraph paragraph = textShape.TextBody.AddParagraph();
 
//Set the horizontal alignment of paragraph
paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
 
//Adds a textPart in the paragraph
ITextPart textPart = paragraph.AddTextPart("Hello Presentation");
 
//Applies font formatting to the text
textPart.Font.FontSize = 80;
textPart.Font.Bold = true;
 
//Adds a new paragraph with text.
paragraph = textShape.TextBody.AddParagraph("Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets");
 
//Sets the list type as bullet
paragraph.ListFormat.Type = ListType.Bulleted;
 
//Sets the bullet character for this list
paragraph.ListFormat.BulletCharacter = Convert.ToChar(183);
 
//Sets the font of the bullet character
paragraph.ListFormat.FontName = "Symbol";
 
//Sets the hanging value as 20
paragraph.FirstLineIndent = -20;
 
//Adds a new paragraph
paragraph = textShape.TextBody.AddParagraph("In 2000, Adventure Works Cycles bought a small manufacturing plant, Importadores Neptuno, located in Mexico.");
 
//Sets the list type as bullet
paragraph.ListFormat.Type = ListType.Bulleted;
 
//Sets the list level as 2. Possible values can range from 0 to 8
paragraph.IndentLevelNumber = 2;
 
//Gets the image from file path
Image image = Image.FromFile(@"image.jpg");
 
// Adds the image to the slide by specifying position and size
firstSlide.Pictures.AddPicture(new MemoryStream(image.ImageData), 300, 270, 410, 250);
 
//Saves the Presentation in the given name
presentation.Save("Output.pptx");
 
//Releases the resources occupied
presentation.Close();
 

Step 5: Compile & execute the application. Now this application creates a simple PowerPoint presentation.

 

See Also:

Create a PowerPoint file in ASP.NET MVC

Create a PowerPoint file in ASP.NET

Create a PowerPoint file in Xamarin

Create a PowerPoint file in WPF

Create a PowerPoint file in UWP

Create a PowerPoint file in ASP.NET Core


Note:

A new version of Essential Studio for ASP.NET is available. Versions prior to the release of Essential Studio 2014, Volume 2 will now be referred to as a classic versions.The new ASP.NET suite is powered by Essential Studio for JavaScript providing client-side rendering of HTML 5-JavaScript controls, offering better performance, and better support for touch interactivity. The new version includes all the features of the old version, so migration is easy.

The Classic controls can be used in existing projects; however, if you are starting a new project, we recommend using the latest version of Essential Studio for ASP.NET. Although Syncfusion will continue to support all Classic Versions, we are happy to assist you in migrating to the newest edition.

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 sign in to leave a comment
Access denied
Access denied