Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Images/Extract-EMF-Images-In-PPTX/.NET/Extract-EMF-Images.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.35327.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Extract-EMF-Images", "Extract-EMF-Images\Extract-EMF-Images.csproj", "{82E919F2-6EA6-4E54-BF73-9D3133B56F4A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{82E919F2-6EA6-4E54-BF73-9D3133B56F4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{82E919F2-6EA6-4E54-BF73-9D3133B56F4A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{82E919F2-6EA6-4E54-BF73-9D3133B56F4A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82E919F2-6EA6-4E54-BF73-9D3133B56F4A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {446047E7-FDD0-4F0E-A910-B67785529857}
EndGlobalSection
EndGlobal
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Extract_EMF_Images</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.PresentationRenderer.Net.Core" Version="*" />
</ItemGroup>
<ItemGroup>
<None Update="Data\Input.pptx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\.gitkeep">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Syncfusion.Presentation;
using Syncfusion.Drawing;

public static class Program
{
public static void Main()
{
// Open the PowerPoint file as a stream.
using (FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Input.pptx", FileMode.Open, FileAccess.Read))
{
// Load the presentation from the stream.
using (IPresentation presentation = Presentation.Open(inputStream))
{
int imageIndex = 0;

// Iterate through each slide in the presentation.
foreach (ISlide slide in presentation.Slides)
{
// Iterate through each shape in the slide.
foreach (IShape shape in slide.Shapes)
{
// Check if the shape is an image.
if (shape is IPicture picture && picture.ImageFormat== ImageFormat.Emf)
{
// Retrieve the raw image data.
byte[] imageData = picture.ImageData;

// Proceed only if image data is valid.
if (imageData != null && imageData.Length > 0)
{
// Determine the image format extension.
string extension = picture.ImageFormat.ToString();
string outputPath = Path.Combine($"Output/Slide{slide.SlideNumber}_Image{++imageIndex}.{extension}");
// Save the image data to the specified path.
File.WriteAllBytes(outputPath, imageData);
}
}
}
}
}
}
}
}