Skip to content

Commit c03ad04

Browse files
committed
ES-262921-How to extract images from the PowerPoint Presentation sample added
1 parent 43274bd commit c03ad04

File tree

6 files changed

+78
-0
lines changed

6 files changed

+78
-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 16
4+
VisualStudioVersion = 16.0.31911.196
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Extract-images-from-all-slides", "Extract-images-from-all-slides\Extract-images-from-all-slides.csproj", "{C17B90BC-F559-456B-B189-90B53FF6CDD4}"
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+
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.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 = {EF357FC6-E9E5-4E3C-B932-43F727BE1DE4}
24+
EndGlobalSection
25+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net5.0</TargetFramework>
6+
<RootNamespace>Extract_images_from_all_slides</RootNamespace>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Syncfusion.Presentation.Net.Core" Version="*" />
11+
</ItemGroup>
12+
13+
</Project>
Loading
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Syncfusion.Presentation;
2+
using System.IO;
3+
4+
namespace Extract_images_from_all_slides
5+
{
6+
class Program
7+
{
8+
static void Main(string[] args)
9+
{
10+
using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"../../../Data/Template.pptx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
11+
{
12+
//Opens an existing Presentation.
13+
using (IPresentation pptxDoc = Presentation.Open(fileStreamPath))
14+
{
15+
int i = 0;
16+
//Iterates through the slides collection.
17+
foreach (ISlide slide in pptxDoc.Slides)
18+
{
19+
//Iterates through the pictures collection and extract the picture.
20+
foreach (IPicture picture in slide.Pictures)
21+
{
22+
byte[] imageBytes = picture.ImageData;
23+
Stream stream = new MemoryStream(imageBytes);
24+
//Resets the stream position.
25+
stream.Position = 0;
26+
string imageFileName = "Image_" + i + "." + picture.ImageFormat.ToString().ToLower();
27+
//Creates the output image file stream.
28+
using (FileStream fileStreamOutput = new FileStream(Path.GetFullPath(@"../../../Output/" + imageFileName), FileMode.Create, FileAccess.ReadWrite))
29+
{
30+
//Copies the converted image stream into created output stream.
31+
stream.CopyTo(fileStreamOutput);
32+
}
33+
i++;
34+
}
35+
}
36+
}
37+
}
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)