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
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.37216.2 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fit_an_Image_Inside_a_Rectangle_Shape", "Fit_an_Image_Inside_a_Rectangle_Shape\Fit_an_Image_Inside_a_Rectangle_Shape.csproj", "{AF30512B-BF73-E738-E1D6-179374198043}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AF30512B-BF73-E738-E1D6-179374198043}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AF30512B-BF73-E738-E1D6-179374198043}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AF30512B-BF73-E738-E1D6-179374198043}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AF30512B-BF73-E738-E1D6-179374198043}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {49E18A89-A198-41B2-9245-2940167C1CA3}
EndGlobalSection
EndGlobal
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

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


<ItemGroup>
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
</ItemGroup>
<ItemGroup>
<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,42 @@
using Syncfusion.DocIO.DLS;
using Syncfusion.DocIO;


namespace Fit_an_Image_Inside_a_Rectangle_Shape
{
class Program
{
static void Main(string[] args)
{
//Create a new Word document
using (WordDocument document = new WordDocument())
{
//Add a new section
WSection section = document.AddSection() as WSection;
//Add a new paragraph to the section.
WParagraph paragraph = section.AddParagraph() as WParagraph;
//Add a new rectangle shape
Shape rectangle = paragraph.AppendShape(AutoShapeType.Rectangle, 150, 100);
//Format the rectangle shape
rectangle.VerticalPosition = 72;
rectangle.HorizontalPosition = 72;
//Add a new paragraph to a rectangle shape
WParagraph para = rectangle.TextBody.AddParagraph() as WParagraph;
//Append the picture to the paragraph
WPicture picture = para.AppendPicture(File.ReadAllBytes("../../../Data/Mountain-200.jpg")) as WPicture;
//Resize the picture according to rectangle shape
picture.Width = rectangle.Width;
picture.Height = rectangle.Height;
picture.VerticalPosition = rectangle.VerticalPosition;
picture.HorizontalPosition = rectangle.HorizontalPosition;
//document.Settings.ResizeImageToFitInContainer = true;
//Creates file stream.
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"../../../Output/Result.docx"), FileMode.Create))
{
//Saves the Word document to file stream.
document.Save(outputStream, FormatType.Docx);
}
}
}
}
}
Loading