Skip to content

Commit aaad2d2

Browse files
Merge pull request #468 from GOPINATH-SF4767/main
ES-983556-Add sample for resize images to fit owner element while opening word document
2 parents d8005a2 + 9499373 commit aaad2d2

File tree

5 files changed

+78
-0
lines changed

5 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 17
4+
VisualStudioVersion = 17.14.36518.9 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Resize_Images_to_fit_Owner_Element", "Resize_Images_to_fit_Owner_Element\Resize_Images_to_fit_Owner_Element.csproj", "{B86AC942-C5FE-4288-B63D-9A371371FE5D}"
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+
{B86AC942-C5FE-4288-B63D-9A371371FE5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{B86AC942-C5FE-4288-B63D-9A371371FE5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{B86AC942-C5FE-4288-B63D-9A371371FE5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{B86AC942-C5FE-4288-B63D-9A371371FE5D}.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 = {DDC2C844-5ECF-4167-929E-7BD09AD37F20}
24+
EndGlobalSection
25+
EndGlobal
146 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
4+
namespace Resize_Images_to_fit_Owner_Element
5+
{
6+
internal class Program
7+
{
8+
static void Main(string[] args)
9+
{
10+
// Create a new Word document
11+
using (WordDocument document = new WordDocument())
12+
{
13+
// Enable automatic image resizing
14+
document.Settings.ResizeImageToFitInContainer = true;
15+
// Open the template document
16+
using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/InputDocument.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
17+
{
18+
document.Open(fileStreamPath, FormatType.Automatic);
19+
}
20+
//Creates file stream.
21+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
22+
{
23+
//Saves the Word document to file stream.
24+
document.Save(outputFileStream, FormatType.Docx);
25+
}
26+
}
27+
}
28+
}
29+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Resize_Images_to_fit_Owner_Element</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
13+
</ItemGroup>
14+
<ItemGroup>
15+
<None Update="Data\InputDocument.docx">
16+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
17+
</None>
18+
<None Update="Output\.gitkeep">
19+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
20+
</None>
21+
</ItemGroup>
22+
23+
</Project>

0 commit comments

Comments
 (0)