Skip to content

Commit 73ff5c8

Browse files
Added the performance metric folder with samples.
1 parent dea31c2 commit 73ff5c8

32 files changed

+376
-0
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.4.33110.190
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Clone-and-merge-slides", "Clone-and-merge-slides\Clone-and-merge-slides.csproj", "{200E55BD-87C8-4D42-A14E-290C0AB1EF00}"
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+
{200E55BD-87C8-4D42-A14E-290C0AB1EF00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{200E55BD-87C8-4D42-A14E-290C0AB1EF00}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{200E55BD-87C8-4D42-A14E-290C0AB1EF00}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{200E55BD-87C8-4D42-A14E-290C0AB1EF00}.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 = {5944F990-AC83-4E81-AEB9-28E7F2EE876D}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Clone_and_merge_slides</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+
</Project>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System.Diagnostics;
2+
using Syncfusion.Presentation;
3+
4+
class Program
5+
{
6+
static void Main()
7+
{
8+
string sourceFolder = Path.GetFullPath("../../../Data/SourceDocument/");
9+
string destinationFolder = Path.GetFullPath("../../../Data/DestinationDocument/");
10+
string outputFolder = Path.GetFullPath("../../../Output/");
11+
12+
Directory.CreateDirectory(outputFolder);
13+
14+
// Get all source files
15+
string[] sourceFiles = Directory.GetFiles(sourceFolder, "*.pptx");
16+
17+
foreach (string sourcePath in sourceFiles)
18+
{
19+
string fileName = Path.GetFileName(sourcePath);
20+
string destinationPath = Path.Combine(destinationFolder, fileName);
21+
22+
if (!File.Exists(destinationPath))
23+
{
24+
Console.WriteLine($"Skipping {fileName} - No matching destination file found.");
25+
continue;
26+
}
27+
28+
string outputPath = Path.Combine(outputFolder, fileName);
29+
30+
Stopwatch stopwatch = Stopwatch.StartNew();
31+
32+
try
33+
{
34+
// Open source and destination presentations
35+
using FileStream sourceStream = new(sourcePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
36+
using IPresentation sourcePresentation = Presentation.Open(sourceStream);
37+
38+
using FileStream destinationStream = new(destinationPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
39+
using IPresentation destinationPresentation = Presentation.Open(destinationStream);
40+
41+
// Clone and merge all slides
42+
foreach (ISlide slide in sourcePresentation.Slides)
43+
{
44+
ISlide clonedSlide = slide.Clone();
45+
destinationPresentation.Slides.Add(clonedSlide, PasteOptions.UseDestinationTheme);
46+
}
47+
48+
// Save the merged presentation
49+
using FileStream outputStream = new(outputPath, FileMode.Create, FileAccess.ReadWrite);
50+
destinationPresentation.Save(outputStream);
51+
52+
stopwatch.Stop();
53+
Console.WriteLine($"{fileName} is cloned and merged in {stopwatch.Elapsed.TotalSeconds} seconds.");
54+
}
55+
catch (Exception ex)
56+
{
57+
Console.WriteLine($"Error processing {fileName}: {ex.Message}");
58+
}
59+
}
60+
}
61+
}
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.4.33110.190
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Open-and-save-PowerPoint", "Open-and-save-PowerPoint\Open-and-save-PowerPoint.csproj", "{200E55BD-87C8-4D42-A14E-290C0AB1EF00}"
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+
{200E55BD-87C8-4D42-A14E-290C0AB1EF00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{200E55BD-87C8-4D42-A14E-290C0AB1EF00}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{200E55BD-87C8-4D42-A14E-290C0AB1EF00}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{200E55BD-87C8-4D42-A14E-290C0AB1EF00}.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 = {5944F990-AC83-4E81-AEB9-28E7F2EE876D}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Open_and_save_PowerPoint</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+
</Project>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System.Diagnostics;
2+
using Syncfusion.Presentation;
3+
4+
class Program
5+
{
6+
static void Main()
7+
{
8+
string inputFolder = Path.GetFullPath("../../../Data/");
9+
string outputFolder = Path.GetFullPath("../../../Output/");
10+
11+
Directory.CreateDirectory(outputFolder);
12+
13+
// Get all .pptx files in the Data folder
14+
string[] files = Directory.GetFiles(inputFolder, "*.pptx");
15+
16+
foreach (string inputPath in files)
17+
{
18+
string fileName = Path.GetFileName(inputPath);
19+
string outputPath = Path.Combine(outputFolder, fileName);
20+
21+
Stopwatch stopwatch = Stopwatch.StartNew();
22+
23+
try
24+
{
25+
// Load or open PowerPoint Presentation
26+
using FileStream inputStream = new(inputPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
27+
using IPresentation pptxDoc = Presentation.Open(inputStream);
28+
29+
// Save the presentation to Output folder
30+
using FileStream outputStream = new(outputPath, FileMode.Create, FileAccess.ReadWrite);
31+
pptxDoc.Save(outputStream);
32+
33+
stopwatch.Stop();
34+
Console.WriteLine($"{fileName} open and saved in {stopwatch.Elapsed.TotalSeconds} seconds");
35+
}
36+
catch (Exception ex)
37+
{
38+
Console.WriteLine($"Error processing {fileName}: {ex.Message}");
39+
}
40+
}
41+
}
42+
}
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.4.33110.190
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Convert-PowerPoint-slide-to-Image", "Convert-PowerPoint-slide-to-Image\Convert-PowerPoint-slide-to-Image.csproj", "{200E55BD-87C8-4D42-A14E-290C0AB1EF00}"
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+
{200E55BD-87C8-4D42-A14E-290C0AB1EF00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{200E55BD-87C8-4D42-A14E-290C0AB1EF00}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{200E55BD-87C8-4D42-A14E-290C0AB1EF00}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{200E55BD-87C8-4D42-A14E-290C0AB1EF00}.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 = {5944F990-AC83-4E81-AEB9-28E7F2EE876D}
24+
EndGlobalSection
25+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Convert_PowerPoint_slide_to_Image</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.Presentation.NET" Version="*" />
13+
<PackageReference Include="Syncfusion.PresentationRenderer.NET" Version="*" />
14+
</ItemGroup>
15+
16+
</Project>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System.Diagnostics;
2+
using Syncfusion.Presentation;
3+
using Syncfusion.PresentationRenderer;
4+
5+
class Program
6+
{
7+
static void Main()
8+
{
9+
string inputFolder = Path.GetFullPath("../../../Data/");
10+
string outputFolder = Path.GetFullPath("../../../Output/");
11+
12+
Directory.CreateDirectory(outputFolder);
13+
14+
// Get all .pptx files in the Data folder
15+
string[] files = Directory.GetFiles(inputFolder, "*.pptx");
16+
17+
foreach (string inputPath in files)
18+
{
19+
string fileName = Path.GetFileName(inputPath);
20+
string slideOutputFolder = Path.Combine(outputFolder, Path.GetFileNameWithoutExtension(fileName));
21+
Directory.CreateDirectory(slideOutputFolder);
22+
23+
Stopwatch stopwatch = Stopwatch.StartNew();
24+
25+
try
26+
{
27+
// Open presentation
28+
using (FileStream inputStream = new(inputPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
29+
{
30+
using (IPresentation pptxDoc = Presentation.Open(inputStream))
31+
{
32+
pptxDoc.PresentationRenderer = new PresentationRenderer();
33+
34+
// Convert each slide to an image
35+
for (int i = 0; i < pptxDoc.Slides.Count; i++)
36+
{
37+
using (Stream stream = pptxDoc.Slides[i].ConvertToImage(ExportImageFormat.Jpeg))
38+
{
39+
string imagePath = Path.Combine(slideOutputFolder, $"Slide_{i + 1}.jpg");
40+
using (FileStream fileStreamOutput = new(imagePath, FileMode.Create, FileAccess.Write))
41+
{
42+
stream.CopyTo(fileStreamOutput);
43+
}
44+
}
45+
}
46+
}
47+
}
48+
stopwatch.Stop();
49+
Console.WriteLine($"{fileName} processed in {stopwatch.Elapsed.TotalSeconds} seconds");
50+
}
51+
catch (Exception ex)
52+
{
53+
Console.WriteLine($"Error processing {fileName}: {ex.Message}");
54+
}
55+
}
56+
}
57+
}
58+
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.4.33110.190
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PPTX-to-PDF", "PPTX-to-PDF\PPTX-to-PDF.csproj", "{200E55BD-87C8-4D42-A14E-290C0AB1EF00}"
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+
{200E55BD-87C8-4D42-A14E-290C0AB1EF00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{200E55BD-87C8-4D42-A14E-290C0AB1EF00}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{200E55BD-87C8-4D42-A14E-290C0AB1EF00}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{200E55BD-87C8-4D42-A14E-290C0AB1EF00}.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 = {5944F990-AC83-4E81-AEB9-28E7F2EE876D}
24+
EndGlobalSection
25+
EndGlobal
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>PPTX_to_PDF</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.Presentation.NET" Version="*" />
13+
<PackageReference Include="Syncfusion.PresentationRenderer.NET" Version="*" />
14+
</ItemGroup>
15+
</Project>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using System.Diagnostics;
2+
using Syncfusion.Presentation;
3+
using Syncfusion.PresentationRenderer;
4+
using Syncfusion.Pdf;
5+
6+
class Program
7+
{
8+
static void Main()
9+
{
10+
string inputFolder = Path.GetFullPath("../../../Data/");
11+
string outputFolder = Path.GetFullPath("../../../Output/");
12+
13+
Directory.CreateDirectory(outputFolder);
14+
15+
// Get all .pptx files in the Data folder
16+
string[] files = Directory.GetFiles(inputFolder, "*.pptx");
17+
18+
foreach (string inputPath in files)
19+
{
20+
string fileName = Path.GetFileName(inputPath);
21+
string outputPath = Path.Combine(outputFolder, Path.GetFileNameWithoutExtension(fileName) + ".pdf");
22+
23+
Stopwatch stopwatch = Stopwatch.StartNew();
24+
25+
try
26+
{
27+
// Open and convert presentation to PDF
28+
using (FileStream inputStream = new(inputPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
29+
{
30+
using (IPresentation pptxDoc = Presentation.Open(inputStream))
31+
{
32+
pptxDoc.PresentationRenderer = new PresentationRenderer();
33+
34+
// Convert PowerPoint to PDF
35+
using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc))
36+
{
37+
using (FileStream outputStream = new(outputPath, FileMode.Create, FileAccess.Write))
38+
{
39+
pdfDocument.Save(outputStream);
40+
}
41+
}
42+
}
43+
}
44+
stopwatch.Stop();
45+
Console.WriteLine($"{fileName} taken time to convert as PDF: {stopwatch.Elapsed.TotalSeconds} seconds");
46+
}
47+
catch (Exception ex)
48+
{
49+
Console.WriteLine($"Error processing {fileName}: {ex.Message}");
50+
}
51+
}
52+
}
53+
}
54+

0 commit comments

Comments
 (0)