Skip to content
Merged
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
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.14.36908.2 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Convert_Word_to_Thumbnail-Image", "Convert_Word_to_Thumbnail-Image\Convert_Word_to_Thumbnail-Image.csproj", "{B7A7EDE2-1818-4C6A-9DBF-E1DEF995A6C3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B7A7EDE2-1818-4C6A-9DBF-E1DEF995A6C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B7A7EDE2-1818-4C6A-9DBF-E1DEF995A6C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B7A7EDE2-1818-4C6A-9DBF-E1DEF995A6C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B7A7EDE2-1818-4C6A-9DBF-E1DEF995A6C3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {ABE93116-3AB5-4CD8-87C0-8C646A6CDC8C}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
<PackageReference Include="Syncfusion.DocIORenderer.Net.Core" Version="*" />
<PackageReference Include="System.Drawing.Common" Version="*" />
</ItemGroup>
<ItemGroup>
<None Update="Data\Input.docx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\.gitkeep">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Binary file not shown.
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,40 @@
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using Syncfusion.DocIORenderer;
using System.Drawing;

namespace Convert_Word_document_to_Thumbnail_Image
{
class Program
{
static void Main(string[] args)
{
//Open the Word document file stream.
using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/Input.docx"), FileMode.Open))
{
//Loads an existing Word document.
using (WordDocument wordDocument = new WordDocument(fileStream, FormatType.Automatic))
{
//Creates an instance of DocIORenderer.
using (DocIORenderer renderer = new DocIORenderer())
{
//Convert the first page of the Word document into an image.
Stream imageStream = wordDocument.RenderAsImages(0, ExportImageFormat.Png);
//Reset the stream position.
imageStream.Position = 0;

//Resize image to thumbnail size.
Image image = Image.FromStream(imageStream);
Image thumbnail = image.GetThumbnailImage(600, 700, () => false, IntPtr.Zero);

//Save the image.
thumbnail.Save(Path.GetFullPath(@"Output/Image1.png"), System.Drawing.Imaging.ImageFormat.Png);
thumbnail.Dispose();
imageStream.Dispose();
image.Dispose();
}
}
}
}
}
}