Skip to content

Commit bf09118

Browse files
Merge pull request #100 from SureshGanesanSF4645/master
Update GitHub for FT samples
2 parents 6209edf + d16ca46 commit bf09118

File tree

35 files changed

+227
-70
lines changed

35 files changed

+227
-70
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.11.35327.3
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Create-simple-pie-chart", "Create-simple-pie-chart\Create-simple-pie-chart.csproj", "{FC263D1D-3AA3-4B8E-B158-B02C0FF627CB}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{FC263D1D-3AA3-4B8E-B158-B02C0FF627CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{FC263D1D-3AA3-4B8E-B158-B02C0FF627CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{FC263D1D-3AA3-4B8E-B158-B02C0FF627CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{FC263D1D-3AA3-4B8E-B158-B02C0FF627CB}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {C73989D0-3A0F-40E1-9FAA-E04EB4173B7A}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Create_simple_pie_chart</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.Presentation.NET" Version="*" />
13+
</ItemGroup>
14+
<ItemGroup>
15+
<None Update="Output\.gitkeep">
16+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
17+
</None>
18+
</ItemGroup>
19+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Binary file not shown.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Syncfusion.OfficeChart;
2+
using Syncfusion.Presentation;
3+
4+
//Create an instance of presentation.
5+
using IPresentation presentation = Presentation.Create();
6+
//Add a blank slide to the presentation.
7+
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
8+
//Add a chart to the slide with position and size.
9+
IPresentationChart chart = slide.Charts.AddChart(100, 10, 700, 500);
10+
//Select the chart type.
11+
chart.ChartType = OfficeChartType.Pie;
12+
//Assign data range.
13+
chart.DataRange = chart.ChartData[1, 1, 6, 2];
14+
chart.IsSeriesInRows = false;
15+
//Set the values for the chart data.
16+
chart.ChartData.SetValue(1, 1, "Food");
17+
chart.ChartData.SetValue(2, 1, "Fruits");
18+
chart.ChartData.SetValue(3, 1, "Vegetables");
19+
chart.ChartData.SetValue(4, 1, "Dairy");
20+
chart.ChartData.SetValue(5, 1, "Protein");
21+
chart.ChartData.SetValue(6, 1, "Grains");
22+
chart.ChartData.SetValue(1, 2, "Percentage");
23+
chart.ChartData.SetValue(2, 2, 36);
24+
chart.ChartData.SetValue(3, 2, 14);
25+
chart.ChartData.SetValue(4, 2, 13);
26+
chart.ChartData.SetValue(5, 2, 28);
27+
chart.ChartData.SetValue(6, 2, 9);
28+
//Set data labels.
29+
chart.Series[0].DataPoints.DefaultDataPoint.DataLabels.IsValue = true;
30+
//Save the presentation.
31+
using FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Result.pptx"), FileMode.Create, FileAccess.ReadWrite);
32+
presentation.Save(outputStream);

PPTX-to-Image-conversion/Convert-PowerPoint-presentation-to-Image/.NET/Convert-PowerPoint-presentation-to-Image/Program.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@ static void Main(string[] args)
1414
//Open the existing PowerPoint presentation.
1515
using (IPresentation pptxDoc = Presentation.Open(fileStream))
1616
{
17-
//Initialize the PresentationRenderer to perform image conversion.
17+
//Initialize PresentationRenderer.
1818
pptxDoc.PresentationRenderer = new PresentationRenderer();
1919
//Convert PowerPoint to image as stream.
2020
Stream[] images = pptxDoc.RenderAsImages(ExportImageFormat.Jpeg);
21-
//Saves the images to file system
22-
foreach (Stream stream in images)
21+
//Save the images to file.
22+
for (int i = 0; i < images.Length; i++)
2323
{
24-
//Create the output image file stream
25-
using (FileStream fileStreamOutput = File.Create(Path.GetFullPath("Output/Output" + Guid.NewGuid().ToString() + ".jpg")))
24+
using (Stream stream = images[i])
2625
{
27-
//Copy the converted image stream into created output stream
28-
stream.CopyTo(fileStreamOutput);
26+
//Save the image stream to a file.
27+
using (FileStream fileStreamOutput = File.Create(Path.GetFullPath("Output/Output" + i + ".jpg")))
28+
{
29+
stream.CopyTo(fileStreamOutput);
30+
}
2931
}
3032
}
3133
}
Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
using Syncfusion.Presentation;
22
using Syncfusion.PresentationRenderer;
33

4-
//Load or open an PowerPoint Presentation.
5-
using FileStream inputStream = new(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
6-
//Open an existing PowerPoint presentation.
7-
using IPresentation pptxDoc = Presentation.Open(inputStream);
8-
//Initialize the PresentationRenderer to perform image conversion.
9-
pptxDoc.PresentationRenderer = new PresentationRenderer();
10-
//Convert PowerPoint slide to image as stream.
11-
using Stream stream = pptxDoc.Slides[0].ConvertToImage(ExportImageFormat.Jpeg);
12-
//Create the output image file stream.
13-
using FileStream fileStreamOutput = File.Create(Path.GetFullPath(@"Output/Output.jpg"));
14-
//Copy the converted image stream into created output stream.
15-
stream.CopyTo(fileStreamOutput);
4+
//Open an existing presentation.
5+
using (FileStream inputStream = new(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
6+
{
7+
//Load the presentation.
8+
using (IPresentation pptxDoc = Presentation.Open(inputStream))
9+
{
10+
//Initialize PresentationRenderer.
11+
pptxDoc.PresentationRenderer = new PresentationRenderer();
12+
//Convert the PowerPoint slide as an image stream.
13+
using (Stream stream = pptxDoc.Slides[0].ConvertToImage(ExportImageFormat.Jpeg))
14+
{
15+
//Save the image stream to a file.
16+
using (FileStream fileStreamOutput = File.Create(Path.GetFullPath(@"Output/Output.jpg")))
17+
{
18+
stream.CopyTo(fileStreamOutput);
19+
}
20+
}
21+
}
22+
}

PPTX-to-Image-conversion/Convert-PowerPoint-slide-to-Image/.NET/Convert-PowerPoint-slide-to-Image/README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,25 @@ Step 4: Add the following code snippet in Program.cs file to convert a PowerPoin
2020

2121
```csharp
2222
//Load or open an PowerPoint Presentation.
23-
using FileStream inputStream = new(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
24-
//Open an existing PowerPoint presentation.
25-
using IPresentation pptxDoc = Presentation.Open(inputStream);
26-
//Initialize the PresentationRenderer to perform image conversion.
27-
pptxDoc.PresentationRenderer = new PresentationRenderer();
28-
//Convert PowerPoint slide to image as stream.
29-
using Stream stream = pptxDoc.Slides[0].ConvertToImage(ExportImageFormat.Jpeg);
30-
//Create the output image file stream.
31-
using FileStream fileStreamOutput = File.Create(Path.GetFullPath(@"Output/Output.jpg"));
32-
//Copy the converted image stream into created output stream.
33-
stream.CopyTo(fileStreamOutput);
23+
using (FileStream inputStream = new(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
24+
{
25+
//Open an existing PowerPoint presentation.
26+
using (IPresentation pptxDoc = Presentation.Open(inputStream))
27+
{
28+
//Initialize the PresentationRenderer to perform image conversion.
29+
pptxDoc.PresentationRenderer = new PresentationRenderer();
30+
//Convert the PowerPoint slide as an image stream .
31+
using (Stream stream = pptxDoc.Slides[0].ConvertToImage(ExportImageFormat.Jpeg))
32+
{
33+
//Create the output image file stream.
34+
using (FileStream fileStreamOutput = File.Create(Path.GetFullPath(@"Output/Output.jpg")))
35+
{
36+
//Copy the converted image stream into created output stream.
37+
stream.CopyTo(fileStreamOutput);
38+
}
39+
}
40+
}
41+
}
3442
```
3543

3644
More information about PPTX to Image conversion can be found in this [documentation](https://help.syncfusion.com/document-processing/powerpoint/conversions/powerpoint-to-image/net/presentation-to-image) section.

PPTX-to-PDF-conversion/Convert-PowerPoint-presentation-to-PDF/.NET/Convert-PowerPoint-presentation-to-PDF/Program.cs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22
using Syncfusion.Presentation;
33
using Syncfusion.PresentationRenderer;
44

5-
//Load or open an PowerPoint Presentation.
6-
using FileStream inputStream = new(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
7-
//Open an existing PowerPoint presentation.
8-
using IPresentation pptxDoc = Presentation.Open(inputStream);
9-
//Create the MemoryStream to save the converted PDF.
10-
using MemoryStream pdfStream = new();
11-
//Convert the PowerPoint document to PDF document.
12-
using PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc);
13-
//Save the converted PDF document to MemoryStream.
14-
pdfDocument.Save(pdfStream);
15-
pdfStream.Position = 0;
16-
//Create the output PDF file stream.
17-
using FileStream fileStreamOutput = File.Create(Path.GetFullPath(@"Output/PPTXToPDF.pdf"));
18-
//Copy the converted PDF stream into created output PDF stream.
19-
pdfStream.CopyTo(fileStreamOutput);
5+
//Open the PowerPoint file stream.
6+
using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
7+
{
8+
//Load an existing PowerPoint Presentation.
9+
using (IPresentation pptxDoc = Presentation.Open(fileStream))
10+
{
11+
//Convert PowerPoint into PDF document.
12+
using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc))
13+
{
14+
//Save the PDF file to file system.
15+
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/PPTXToPDF.pdf"), FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
16+
{
17+
pdfDocument.Save(outputStream);
18+
}
19+
}
20+
}
21+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.11.35327.3
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Simple-text-and-paragraph-formatting", "Simple-text-and-paragraph-formatting\Simple-text-and-paragraph-formatting.csproj", "{AAA91223-CD0E-4333-BC4C-F98D29CC228A}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{AAA91223-CD0E-4333-BC4C-F98D29CC228A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{AAA91223-CD0E-4333-BC4C-F98D29CC228A}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{AAA91223-CD0E-4333-BC4C-F98D29CC228A}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{AAA91223-CD0E-4333-BC4C-F98D29CC228A}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {879355F6-5C8B-4DE1-9A87-B35CF94F090B}
24+
EndGlobalSection
25+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Syncfusion.Presentation;
2+
3+
//Load PowerPoint Presentation.
4+
using FileStream inputStream = new(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
5+
//Open an existing PowerPoint presentation.
6+
using IPresentation pptxDoc = Presentation.Open(inputStream);
7+
//Retrieve the first slide from Presentation
8+
ISlide slide = pptxDoc.Slides[0];
9+
//Retrieve the first shape.
10+
IShape shape = slide.Shapes[0] as IShape;
11+
//Retrieve the first paragraph of the shape.
12+
IParagraph paragraph = shape.TextBody.Paragraphs[0];
13+
//Set center alignment for the paragraph.
14+
paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
15+
//Retrieve the first TextPart of the shape.
16+
ITextPart textPart = paragraph.TextParts[0];
17+
//Set bold for the text.
18+
textPart.Font.Bold = true;
19+
//Save the PowerPoint Presentation.
20+
using FileStream outputStream = new(Path.GetFullPath(@"Output/Result.pptx"), FileMode.Create, FileAccess.ReadWrite);
21+
pptxDoc.Save(outputStream);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Simple_text_and_paragraph_formatting</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.Presentation.NET" Version="*" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<None Update="Data\Template.pptx">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
<None Update="Output\.gitkeep">
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21+
</None>
22+
</ItemGroup>
23+
</Project>

Security/Encrypt-PowerPoint-with-password/.NET/Encrypt-PowerPoint-with-password/Encrypt-PowerPoint-with-password.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
</ItemGroup>
1414

1515
<ItemGroup>
16+
<None Update="Data\Template.pptx">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
1619
<None Update="Output\.gitkeep">
1720
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
1821
</None>
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
using Syncfusion.Presentation;
22

3-
//Load or open an PowerPoint Presentation.
4-
using IPresentation presentation = Presentation.Create();
5-
//Add slide to Presentation.
6-
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
7-
//Add textbox to slide.
8-
IShape shape = slide.Shapes.AddTextBox(100, 30, 200, 300);
9-
//Add a paragraph with text content.
10-
IParagraph paragraph = shape.TextBody.AddParagraph("Password Protected.");
11-
//Protects the file with password.
12-
presentation.Encrypt("PASSWORD!@1#$");
13-
using FileStream outputStream = new(Path.GetFullPath(@"Output/Result.pptx"), FileMode.Create, FileAccess.ReadWrite);
3+
//Open an existing presentation.
4+
using FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read);
5+
using IPresentation presentation = Presentation.Open(inputStream);
6+
//Encrypt the presentation with a password.
7+
presentation.Encrypt("syncfusion");
8+
using FileStream outputStream = new (Path.GetFullPath(@"Output/Result.pptx"), FileMode.Create, FileAccess.ReadWrite);
149
presentation.Save(outputStream);

Security/Encrypt-PowerPoint-with-password/.NET/Encrypt-PowerPoint-with-password/README.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,17 @@ Step 3: Include the following namespaces in the Program.cs file.
1212

1313
```csharp
1414
using Syncfusion.Presentation;
15-
using System.IO;
1615
```
1716

1817
Step 4: Add the following code snippet in Program.cs file to encrypt the PowerPoint Presentation.
1918

2019
```csharp
21-
//Load or open an PowerPoint Presentation.
22-
using IPresentation presentation = Presentation.Create();
23-
//Add slide to Presentation.
24-
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
25-
//Add textbox to slide.
26-
IShape shape = slide.Shapes.AddTextBox(100, 30, 200, 300);
27-
//Add a paragraph with text content.
28-
IParagraph paragraph = shape.TextBody.AddParagraph("Password Protected.");
29-
//Protects the file with password.
30-
presentation.Encrypt("PASSWORD!@1#$");
31-
using FileStream outputStream = new(Path.GetFullPath(@"Output/Result.pptx"), FileMode.Create, FileAccess.ReadWrite);
20+
//Open an existing presentation.
21+
using FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read);
22+
using IPresentation presentation = Presentation.Open(inputStream);
23+
//Encrypt the presentation with a password.
24+
presentation.Encrypt("syncfusion");
25+
using FileStream outputStream = new (Path.GetFullPath(@"Output/Result.pptx"), FileMode.Create, FileAccess.ReadWrite);
3226
presentation.Save(outputStream);
3327
```
3428

Binary file not shown.
Binary file not shown.

Security/Remove-encryption/.NET/Remove-encryption/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//Load or open an PowerPoint Presentation.
44
using FileStream inputStream = new(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
55
//Open an existing Presentation from file system and it can be decrypted by using the provided password.
6-
using IPresentation presentation = Presentation.Open(inputStream, "PASSWORD!@1#$");
6+
using IPresentation presentation = Presentation.Open(inputStream, "syncfusion");
77
//Decrypt the document.
88
presentation.RemoveEncryption();
99
using FileStream outputStream = new(Path.GetFullPath(@"Output/Result.pptx"), FileMode.Create, FileAccess.ReadWrite);

Security/Remove-encryption/.NET/Remove-encryption/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ Step 3: Include the following namespaces in the Program.cs file.
1212

1313
```csharp
1414
using Syncfusion.Presentation;
15-
using System.IO;
1615
```
1716

1817
Step 4: Add the following code snippet in Program.cs file to decrypt the PowerPoint Presentation.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)