Skip to content

Commit 2587e04

Browse files
Merge pull request #1 from SyncfusionExamples/Task-895640-Blog-Convert-PowerPoint-to-Images
Task-895640-Blog-Convert-PowerPoint-to-Images
2 parents 9c20267 + 5b06aee commit 2587e04

34 files changed

+813
-2
lines changed

README.md

+55-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,55 @@
1-
# convert-powerpoint-to-images-c-sharp
2-
This repository contains the examples of converting PowerPoint to Images in C# using Syncfusion .NET PowerPoint library
1+
# Convert PowerPoint to Images in C#
2+
3+
This repository contains examples that demonstrate how to programmatically convert PowerPoint to images using C#. The examples utilize the Syncfusion® [.NET Core PowerPoint library]( https://www.syncfusion.com/document-processing/powerpoint-framework/net-core), which provides a seamless way to convert PowerPoint presentation to images with just five lines of code. It preserves the original appearance of the PowerPoint in the converted image.
4+
5+
## Key Features
6+
7+
- [Preview the PowerPoint](https://github.com/SyncfusionExamples/convert-powerpoint-to-images-c-sharp/blob/master/convert-entire-powerpoint-to-images/.NET) - Convert an entire PowerPoint to images
8+
- [Thumbnail of PowerPoint](https://github.com/SyncfusionExamples/convert-powerpoint-to-images-c-sharp/blob/master/convert-powerpoint-slide-to-image/.NET) - Convert first slide of PowerPoint slide to image
9+
- [Print particular slides in PowerPoint](https://github.com/SyncfusionExamples/convert-powerpoint-to-images-c-sharp/blob/master/convert-specific-range-of-slides-to-images/.NET) - Convert specific range of slides to images
10+
11+
## Syncfusion® .NET PowerPoint Library
12+
13+
The Syncfusion® [.NET PowerPoint library](https://www.syncfusion.com/document-processing/powerpoint-framework/net/powerpoint-library?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples) (Presentation) allows you to add advanced PowerPoint presentation processing functionalities to any .NET application and does not require Microsoft PowerPoint application to be installed in the machine. It is a non-UI component that provides a full-fledged PowerPoint presentation instance model similar to the Microsoft Office COM libraries to iterate with the presentation elements explicitly and perform necessary manipulation.
14+
15+
Take a moment to peruse the [documentation](https://help.syncfusion.com/file-formats/presentation/getting-started?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples), where you can find basic PowerPoint presentation processing options along with the features like create and edit [charts](https://help.syncfusion.com/file-formats/presentation/working-with-charts?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples), [clone](https://help.syncfusion.com/file-formats/presentation/working-with-slide?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples#cloning-slide) and [merge](https://help.syncfusion.com/file-formats/presentation/working-with-slide?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples#merging-slide) slides in presentation, create and edit [animations](https://help.syncfusion.com/file-formats/presentation/working-with-animation?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples#edit-existing-animation-effect) and [transistion](https://help.syncfusion.com/file-formats/presentation/create-edit-slide-transitions-in-powerpoint-presentation-slides-cs-vb-net?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples#modify-a-transition-effect-applied-to-a-powerpoint-slide) effects, [protect](https://help.syncfusion.com/file-formats/presentation/security?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples) the PowerPoint presentation, and most importantly, the [PDF](https://help.syncfusion.com/file-formats/presentation/presentation-to-pdf?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples) and [Image](https://help.syncfusion.com/file-formats/presentation/presentation-to-image?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples) conversions with code examples.
16+
17+
## Compatible Microsoft PowerPoint Versions
18+
19+
- Microsoft PowerPoint 2007
20+
- Microsoft PowerPoint 2010
21+
- Microsoft PowerPoint 2013
22+
- Microsoft PowerPoint 2016
23+
- Microsoft PowerPoint 2019
24+
- Microsoft 365
25+
26+
## Supported File Formats
27+
28+
* Creates, reads, and edits popular presentation file formats like .PPTX, .PPTM, .POTX, and .POTM.
29+
* Converts PowerPoint presentation documents also to [PDF](https://help.syncfusion.com/file-formats/presentation/presentation-to-pdf?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples) and [Image](https://help.syncfusion.com/file-formats/presentation/presentation-to-image?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples) files.
30+
31+
## How to run the examples
32+
33+
* Download this project to a location in your disk.
34+
* Open the solution file using Visual Studio.
35+
* Rebuild the solution to install the required NuGet packages.
36+
* Run the application.
37+
38+
## Resources
39+
40+
- **Product page:** [Syncfusion® PowerPoint Framework](https://www.syncfusion.com/document-processing/powerpoint-framework/net?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples)
41+
- **Documentation:** [Syncfusion® PowerPoint library](https://help.syncfusion.com/file-formats/presentation/presentation-to-pdf/smartart?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples)
42+
- **GitHub Examples:** [Syncfusion® PowerPoint library examples](https://github.com/SyncfusionExamples/PowerPoint-Examples?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples)
43+
- **Online demo:** [Syncfusion® PowerPoint library - Online demos](https://ej2.syncfusion.com/aspnetcore/PowerPoint/Default#/material3?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples)
44+
45+
## Support and feedback
46+
47+
- For any other queries, reach our [Syncfusion® support team](https://support.syncfusion.com/agent/tickets/create?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples) or post the queries through the [community forums](https://www.syncfusion.com/forums?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples).
48+
- Request new feature through [Syncfusion® feedback portal](https://www.syncfusion.com/feedback/home?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples).
49+
50+
## License
51+
52+
This is a commercial product and requires a paid license for possession or use. Syncfusion's licensed software, including this component, is subject to the terms and conditions of [Syncfusion's EULA](https://www.syncfusion.com/license/studio/22.2.5/syncfusion_essential_studio_eula.pdf). You can purchase a licnense [here](https://www.syncfusion.com/sales/products?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples) or start a free 30-day trial [here](https://www.syncfusion.com/account/manage-trials/start-trials?utm_source=github&utm_medium=listing&utm_campaign=github-powerpoint-examples).
53+
54+
55+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35527.113 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "convert-entire-powerpoint-to-images", "convert-entire-powerpoint-to-images\convert-entire-powerpoint-to-images.csproj", "{1D26AC76-3D3E-4626-929E-D0936F49C5CB}"
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+
{1D26AC76-3D3E-4626-929E-D0936F49C5CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{1D26AC76-3D3E-4626-929E-D0936F49C5CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{1D26AC76-3D3E-4626-929E-D0936F49C5CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{1D26AC76-3D3E-4626-929E-D0936F49C5CB}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
5+
</startup>
6+
</configuration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using Syncfusion.Drawing;
2+
using Syncfusion.OfficeChartToImageConverter;
3+
using Syncfusion.Presentation;
4+
using System.IO;
5+
6+
namespace convert_entire_powerpoint_to_images
7+
{
8+
internal class Program
9+
{
10+
static void Main(string[] args)
11+
{
12+
//Open the file as Stream.
13+
using (FileStream fileStream = new FileStream(Path.GetFullPath(@"../../Template.pptx"), FileMode.Open, FileAccess.Read))
14+
{
15+
//Load an existing PowerPoint presentation.
16+
using (IPresentation pptxDoc = Presentation.Open(fileStream))
17+
{
18+
//Initialize ChartToImageConverter
19+
pptxDoc.ChartToImageConverter = new ChartToImageConverter();
20+
//Convert PowerPoint to images.
21+
Stream[] images = pptxDoc.RenderAsImages((ImageFormat)ImageType.Metafile);
22+
//Save the images to file.
23+
for (int i = 0; i < images.Length; i++)
24+
{
25+
using (Stream stream = images[i])
26+
{
27+
using (FileStream fileStreamOutput = File.Create(Path.GetFullPath("../../Image-" + i + ".jpg")))
28+
{
29+
stream.CopyTo(fileStreamOutput);
30+
}
31+
}
32+
}
33+
}
34+
}
35+
}
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("convert-entire-powerpoint-to-images")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("convert-entire-powerpoint-to-images")]
13+
[assembly: AssemblyCopyright("Copyright © 2024")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("1d26ac76-3d3e-4626-929e-d0936f49c5cb")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
[assembly: AssemblyVersion("1.0.0.0")]
33+
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{1D26AC76-3D3E-4626-929E-D0936F49C5CB}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>convert_entire_powerpoint_to_images</RootNamespace>
10+
<AssemblyName>convert-entire-powerpoint-to-images</AssemblyName>
11+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="Syncfusion.Compression.Base, Version=28.1462.33.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
37+
<HintPath>..\packages\Syncfusion.Compression.Base.28.1.33\lib\net462\Syncfusion.Compression.Base.dll</HintPath>
38+
</Reference>
39+
<Reference Include="Syncfusion.Licensing, Version=28.1462.33.0, Culture=neutral, PublicKeyToken=632609b4d040f6b4, processorArchitecture=MSIL">
40+
<HintPath>..\packages\Syncfusion.Licensing.28.1.33\lib\net462\Syncfusion.Licensing.dll</HintPath>
41+
</Reference>
42+
<Reference Include="Syncfusion.OfficeChart.Base, Version=28.1462.33.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
43+
<HintPath>..\packages\Syncfusion.OfficeChart.Base.28.1.33\lib\net462\Syncfusion.OfficeChart.Base.dll</HintPath>
44+
</Reference>
45+
<Reference Include="Syncfusion.OfficeChartToImageConverter.Wpf, Version=28.1462.33.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
46+
<HintPath>..\packages\Syncfusion.OfficeChartToImageConverter.WinForms.28.1.33\lib\net462\Syncfusion.OfficeChartToImageConverter.Wpf.dll</HintPath>
47+
</Reference>
48+
<Reference Include="Syncfusion.Presentation.Base, Version=28.1462.33.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
49+
<HintPath>..\packages\Syncfusion.Presentation.WinForms.28.1.33\lib\net462\Syncfusion.Presentation.Base.dll</HintPath>
50+
</Reference>
51+
<Reference Include="Syncfusion.SfChart.WPF, Version=28.1462.33.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
52+
<HintPath>..\packages\Syncfusion.SfChart.WPF.28.1.33\lib\net462\Syncfusion.SfChart.WPF.dll</HintPath>
53+
</Reference>
54+
<Reference Include="System" />
55+
<Reference Include="System.Core" />
56+
<Reference Include="System.Drawing" />
57+
<Reference Include="System.Xml.Linq" />
58+
<Reference Include="System.Data.DataSetExtensions" />
59+
<Reference Include="Microsoft.CSharp" />
60+
<Reference Include="System.Data" />
61+
<Reference Include="System.Net.Http" />
62+
<Reference Include="System.Xml" />
63+
</ItemGroup>
64+
<ItemGroup>
65+
<Compile Include="Program.cs" />
66+
<Compile Include="Properties\AssemblyInfo.cs" />
67+
</ItemGroup>
68+
<ItemGroup>
69+
<None Include="App.config" />
70+
<None Include="packages.config" />
71+
</ItemGroup>
72+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
73+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Syncfusion.Compression.Base" version="28.1.33" targetFramework="net48" />
4+
<package id="Syncfusion.Licensing" version="28.1.33" targetFramework="net48" />
5+
<package id="Syncfusion.OfficeChart.Base" version="28.1.33" targetFramework="net48" />
6+
<package id="Syncfusion.OfficeChartToImageConverter.WinForms" version="28.1.33" targetFramework="net48" />
7+
<package id="Syncfusion.Presentation.WinForms" version="28.1.33" targetFramework="net48" />
8+
<package id="Syncfusion.SfChart.WPF" version="28.1.33" targetFramework="net48" />
9+
</packages>
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.6.33829.357
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "convert-entire-powerpoint-to-images", "convert-entire-powerpoint-to-images\convert-entire-powerpoint-to-images.csproj", "{F700D3CC-9F5B-4BE8-8EFF-6902E14FE96D}"
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+
{F700D3CC-9F5B-4BE8-8EFF-6902E14FE96D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{F700D3CC-9F5B-4BE8-8EFF-6902E14FE96D}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{F700D3CC-9F5B-4BE8-8EFF-6902E14FE96D}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{F700D3CC-9F5B-4BE8-8EFF-6902E14FE96D}.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 = {C3F11A05-D51E-4786-9786-C6BBE869DECD}
24+
EndGlobalSection
25+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using Syncfusion.Presentation;
2+
using Syncfusion.PresentationRenderer;
3+
4+
namespace convert_entire_powerpoint_to_images
5+
{
6+
internal class Program
7+
{
8+
static void Main(string[] args)
9+
{
10+
//Open the file as Stream.
11+
using (FileStream fileStream = new FileStream(Path.GetFullPath(@"../../../Template.pptx"), FileMode.Open, FileAccess.Read))
12+
{
13+
//Load an existing PowerPoint presentation.
14+
using (IPresentation pptxDoc = Presentation.Open(fileStream))
15+
{
16+
//Initialize PresentationRenderer.
17+
pptxDoc.PresentationRenderer = new PresentationRenderer();
18+
//Convert PowerPoint to images.
19+
Stream[] images = pptxDoc.RenderAsImages(ExportImageFormat.Jpeg);
20+
//Save the images to file.
21+
for (int i = 0; i < images.Length; i++)
22+
{
23+
using (Stream stream = images[i])
24+
{
25+
using (FileStream fileStreamOutput = File.Create(Path.GetFullPath("../../../Image-" + i + ".jpg")))
26+
{
27+
stream.CopyTo(fileStreamOutput);
28+
}
29+
}
30+
}
31+
}
32+
}
33+
}
34+
}
35+
}
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>convert_entire_powerpoint_to_images</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.PresentationRenderer.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35527.113 d17.12
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", "{84FAA810-55ED-43B0-A597-2F38C8A30AAC}"
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+
{84FAA810-55ED-43B0-A597-2F38C8A30AAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{84FAA810-55ED-43B0-A597-2F38C8A30AAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{84FAA810-55ED-43B0-A597-2F38C8A30AAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{84FAA810-55ED-43B0-A597-2F38C8A30AAC}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

0 commit comments

Comments
 (0)