Skip to content

Commit 06e3d38

Browse files
Add-readme-file
1 parent ef97406 commit 06e3d38

File tree

1 file changed

+66
-0
lines changed
  • Getting-started/.NET/Create-PowerPoint-presentation

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Create Presentation using C#
2+
3+
The Syncfusion® [.NET PowerPoint Library](https://www.syncfusion.com/document-processing/powerpoint-framework/net/powerpoint-library) (Presentation) enables you to create, read, and edit PowerPoint files programmatically without Microsoft Office or interop dependencies. Using this library, you can **create an PowerPoint Presentation** using C#.
4+
5+
## Steps to create an PowerPoint Presentation programmatically
6+
7+
Step 1: Create a new .NET Core console application project.
8+
9+
Step 2: Install the [Syncfusion.Presentation.Net.Core](https://www.nuget.org/packages/Syncfusion.Presentation.Net.Core) NuGet package as a reference to your project from [NuGet.org](https://www.nuget.org/).
10+
11+
Step 3: Include the following namespaces in the Program.cs file.
12+
13+
```csharp
14+
using Syncfusion.Presentation;
15+
using System.IO;
16+
```
17+
18+
Step 4: Add the following code snippet in Program.cs file to find and replace text in the PowerPoint Presentation.
19+
20+
```csharp
21+
//Create a new instance of PowerPoint Presentation file
22+
using (IPresentation pptxDoc = Presentation.Create())
23+
{
24+
//Add a new slide to file and apply background color
25+
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.TitleOnly);
26+
//Specify the fill type and fill color for the slide background
27+
slide.Background.Fill.FillType = FillType.Solid;
28+
slide.Background.Fill.SolidFill.Color = ColorObject.FromArgb(232, 241, 229);
29+
//Add title content to the slide by accessing the title placeholder of the TitleOnly layout-slide
30+
IShape titleShape = slide.Shapes[0] as IShape;
31+
titleShape.TextBody.AddParagraph("Company History").HorizontalAlignment = HorizontalAlignmentType.Center;
32+
//Add description content to the slide by adding a new TextBox
33+
IShape descriptionShape = slide.AddTextBox(53.22, 141.73, 874.19, 77.70);
34+
descriptionShape.TextBody.Text = "IMN Solutions PVT LTD is the software company, established in 1987, by George Milton. The company has been listed as the trusted partner for many high-profile organizations since 1988 and got awards for quality products from reputed organizations.";
35+
//Add bullet points to the slide
36+
IShape bulletPointsShape = slide.AddTextBox(53.22, 270, 437.90, 116.32);
37+
//Add a paragraph for a bullet point
38+
IParagraph firstPara = bulletPointsShape.TextBody.AddParagraph("The company acquired the MCY corporation for 20 billion dollars and became the top revenue maker for the year 2015.");
39+
//Format how the bullets should be displayed
40+
firstPara.ListFormat.Type = ListType.Bulleted;
41+
firstPara.LeftIndent = 35;
42+
firstPara.FirstLineIndent = -35;
43+
// Add another paragraph for the next bullet point
44+
IParagraph secondPara = bulletPointsShape.TextBody.AddParagraph("The company is participating in top open source projects in automation industry.");
45+
//Format how the bullets should be displayed
46+
secondPara.ListFormat.Type = ListType.Bulleted;
47+
secondPara.LeftIndent = 35;
48+
secondPara.FirstLineIndent = -35;
49+
//Gets a picture as stream.
50+
FileStream pictureStream = new FileStream("Image.jpg", FileMode.Open);
51+
//Adds the picture to a slide by specifying its size and position.
52+
slide.Shapes.AddPicture(pictureStream, 499.79, 238.59, 364.54, 192.16);
53+
//Add an auto-shape to the slide
54+
IShape stampShape = slide.Shapes.AddShape(AutoShapeType.Explosion1, 48.93, 430.71, 104.13, 80.54);
55+
//Format the auto-shape color by setting the fill type and text
56+
stampShape.Fill.FillType = FillType.None;
57+
stampShape.TextBody.AddParagraph("IMN").HorizontalAlignment = HorizontalAlignmentType.Center;
58+
//Save the PowerPoint Presentation as stream
59+
using (FileStream outputStream = new FileStream("Sample.pptx", FileMode.Create))
60+
{
61+
pptxDoc.Save(outputStream);
62+
}
63+
}
64+
```
65+
66+
More information about create an PowerPoint Presentation, you can be refer in this [documentation](https://help.syncfusion.com/document-processing/powerpoint/powerpoint-library/net/working-with-powerpoint-presentation) section.

0 commit comments

Comments
 (0)