Skip to content

Commit 4fa22d8

Browse files
Merge pull request #111 from DharanyaSakthivel-SF4210/master
Add README file in Getting started Create-PowerPoint-presentation sample
2 parents 21347ae + 67e534b commit 4fa22d8

File tree

2 files changed

+78
-96
lines changed

2 files changed

+78
-96
lines changed
Lines changed: 40 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,42 @@
1-

2-
using Syncfusion.Presentation;
1+
using Syncfusion.Presentation;
32
using System;
43

5-
namespace Create_PowerPoint_presentation
6-
{
7-
class Program
8-
{
9-
static void Main(string[] args)
10-
{
11-
//Create a new instance of PowerPoint Presentation file
12-
using (IPresentation pptxDoc = Presentation.Create())
13-
{
14-
//Add a new slide to file and apply background color
15-
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.TitleOnly);
16-
//Specify the fill type and fill color for the slide background
17-
slide.Background.Fill.FillType = FillType.Solid;
18-
slide.Background.Fill.SolidFill.Color = ColorObject.FromArgb(232, 241, 229);
19-
//Add title content to the slide by accessing the title placeholder of the TitleOnly layout-slide
20-
IShape titleShape = slide.Shapes[0] as IShape;
21-
titleShape.TextBody.AddParagraph("Company History").HorizontalAlignment = HorizontalAlignmentType.Center;
22-
//Add description content to the slide by adding a new TextBox
23-
IShape descriptionShape = slide.AddTextBox(53.22, 141.73, 874.19, 77.70);
24-
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.";
25-
//Add bullet points to the slide
26-
IShape bulletPointsShape = slide.AddTextBox(53.22, 270, 437.90, 116.32);
27-
//Add a paragraph for a bullet point
28-
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.");
29-
//Format how the bullets should be displayed
30-
firstPara.ListFormat.Type = ListType.Bulleted;
31-
firstPara.LeftIndent = 35;
32-
firstPara.FirstLineIndent = -35;
33-
// Add another paragraph for the next bullet point
34-
IParagraph secondPara = bulletPointsShape.TextBody.AddParagraph("The company is participating in top open source projects in automation industry.");
35-
//Format how the bullets should be displayed
36-
secondPara.ListFormat.Type = ListType.Bulleted;
37-
secondPara.LeftIndent = 35;
38-
secondPara.FirstLineIndent = -35;
39-
//Gets a picture as stream.
40-
FileStream pictureStream = new FileStream(Path.GetFullPath(@"Data/Image.jpg"), FileMode.Open);
41-
//Adds the picture to a slide by specifying its size and position.
42-
slide.Shapes.AddPicture(pictureStream, 499.79, 238.59, 364.54, 192.16);
43-
//Add an auto-shape to the slide
44-
IShape stampShape = slide.Shapes.AddShape(AutoShapeType.Explosion1, 48.93, 430.71, 104.13, 80.54);
45-
//Format the auto-shape color by setting the fill type and text
46-
stampShape.Fill.FillType = FillType.None;
47-
stampShape.TextBody.AddParagraph("IMN").HorizontalAlignment = HorizontalAlignmentType.Center;
48-
//Save the PowerPoint Presentation as stream
49-
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Sample.pptx"), FileMode.Create))
50-
{
51-
pptxDoc.Save(outputStream);
52-
}
53-
}
54-
}
55-
}
56-
}
4+
//Create a new instance of PowerPoint Presentation file
5+
IPresentation pptxDoc = Presentation.Create();
6+
//Add a new slide to file and apply background color
7+
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.TitleOnly);
8+
//Specify the fill type and fill color for the slide background
9+
slide.Background.Fill.FillType = FillType.Solid;
10+
slide.Background.Fill.SolidFill.Color = ColorObject.FromArgb(232, 241, 229);
11+
//Add title content to the slide by accessing the title placeholder of the TitleOnly layout-slide
12+
IShape titleShape = slide.Shapes[0] as IShape;
13+
titleShape.TextBody.AddParagraph("Company History").HorizontalAlignment = HorizontalAlignmentType.Center;
14+
//Add description content to the slide by adding a new TextBox
15+
IShape descriptionShape = slide.AddTextBox(53.22, 141.73, 874.19, 77.70);
16+
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.";
17+
//Add bullet points to the slide
18+
IShape bulletPointsShape = slide.AddTextBox(53.22, 270, 437.90, 116.32);
19+
//Add a paragraph for a bullet point
20+
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.");
21+
//Format how the bullets should be displayed
22+
firstPara.ListFormat.Type = ListType.Bulleted;
23+
firstPara.LeftIndent = 35;
24+
firstPara.FirstLineIndent = -35;
25+
// Add another paragraph for the next bullet point
26+
IParagraph secondPara = bulletPointsShape.TextBody.AddParagraph("The company is participating in top open source projects in automation industry.");
27+
//Format how the bullets should be displayed
28+
secondPara.ListFormat.Type = ListType.Bulleted;
29+
secondPara.LeftIndent = 35;
30+
secondPara.FirstLineIndent = -35;
31+
//Gets a picture as stream.
32+
FileStream pictureStream = new FileStream(Path.GetFullPath(@"Data/Image.jpg"), FileMode.Open);
33+
//Adds the picture to a slide by specifying its size and position.
34+
slide.Shapes.AddPicture(pictureStream, 499.79, 238.59, 364.54, 192.16);
35+
//Add an auto-shape to the slide
36+
IShape stampShape = slide.Shapes.AddShape(AutoShapeType.Explosion1, 48.93, 430.71, 104.13, 80.54);
37+
//Format the auto-shape color by setting the fill type and text
38+
stampShape.Fill.FillType = FillType.None;
39+
stampShape.TextBody.AddParagraph("IMN").HorizontalAlignment = HorizontalAlignmentType.Center;
40+
//Save the PowerPoint Presentation as stream
41+
using FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Sample.pptx"), FileMode.Create);
42+
pptxDoc.Save(outputStream);

Getting-started/.NET/Create-PowerPoint-presentation/README.md

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,48 +19,44 @@ Step 4: Add the following code snippet in Program.cs file to find and replace te
1919

2020
```csharp
2121
//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
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(Path.GetFullPath(@"Data/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(Path.GetFullPath(@"Output/Sample.pptx"), FileMode.Create))
60-
{
61-
pptxDoc.Save(outputStream);
62-
}
63-
}
22+
IPresentation pptxDoc = Presentation.Create();
23+
//Add a new slide to file and apply background color
24+
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.TitleOnly);
25+
//Specify the fill type and fill color for the slide background
26+
slide.Background.Fill.FillType = FillType.Solid;
27+
slide.Background.Fill.SolidFill.Color = ColorObject.FromArgb(232, 241, 229);
28+
//Add title content to the slide by accessing the title placeholder of the TitleOnly layout-slide
29+
IShape titleShape = slide.Shapes[0] as IShape;
30+
titleShape.TextBody.AddParagraph("Company History").HorizontalAlignment = HorizontalAlignmentType.Center;
31+
//Add description content to the slide by adding a new TextBox
32+
IShape descriptionShape = slide.AddTextBox(53.22, 141.73, 874.19, 77.70);
33+
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.";
34+
//Add bullet points to the slide
35+
IShape bulletPointsShape = slide.AddTextBox(53.22, 270, 437.90, 116.32);
36+
//Add a paragraph for a bullet point
37+
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.");
38+
//Format how the bullets should be displayed
39+
firstPara.ListFormat.Type = ListType.Bulleted;
40+
firstPara.LeftIndent = 35;
41+
firstPara.FirstLineIndent = -35;
42+
// Add another paragraph for the next bullet point
43+
IParagraph secondPara = bulletPointsShape.TextBody.AddParagraph("The company is participating in top open source projects in automation industry.");
44+
//Format how the bullets should be displayed
45+
secondPara.ListFormat.Type = ListType.Bulleted;
46+
secondPara.LeftIndent = 35;
47+
secondPara.FirstLineIndent = -35;
48+
//Gets a picture as stream.
49+
FileStream pictureStream = new FileStream(Path.GetFullPath(@"Data/Image.jpg"), FileMode.Open);
50+
//Adds the picture to a slide by specifying its size and position.
51+
slide.Shapes.AddPicture(pictureStream, 499.79, 238.59, 364.54, 192.16);
52+
//Add an auto-shape to the slide
53+
IShape stampShape = slide.Shapes.AddShape(AutoShapeType.Explosion1, 48.93, 430.71, 104.13, 80.54);
54+
//Format the auto-shape color by setting the fill type and text
55+
stampShape.Fill.FillType = FillType.None;
56+
stampShape.TextBody.AddParagraph("IMN").HorizontalAlignment = HorizontalAlignmentType.Center;
57+
//Save the PowerPoint Presentation as stream
58+
using FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Sample.pptx"), FileMode.Create);
59+
pptxDoc.Save(outputStream);
6460
```
6561

6662
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)