diff --git a/Paragraphs/Fit_an_Image_Inside_a_Rectangle_Shape/.NET/Fit_an_Image_Inside_a_Rectangle_Shape.sln b/Paragraphs/Fit_an_Image_Inside_a_Rectangle_Shape/.NET/Fit_an_Image_Inside_a_Rectangle_Shape.sln new file mode 100644 index 000000000..7681eb996 --- /dev/null +++ b/Paragraphs/Fit_an_Image_Inside_a_Rectangle_Shape/.NET/Fit_an_Image_Inside_a_Rectangle_Shape.sln @@ -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 diff --git a/Paragraphs/Fit_an_Image_Inside_a_Rectangle_Shape/.NET/Fit_an_Image_Inside_a_Rectangle_Shape/Data/Mountain-200.jpg b/Paragraphs/Fit_an_Image_Inside_a_Rectangle_Shape/.NET/Fit_an_Image_Inside_a_Rectangle_Shape/Data/Mountain-200.jpg new file mode 100644 index 000000000..21ee3adf8 Binary files /dev/null and b/Paragraphs/Fit_an_Image_Inside_a_Rectangle_Shape/.NET/Fit_an_Image_Inside_a_Rectangle_Shape/Data/Mountain-200.jpg differ diff --git a/Paragraphs/Fit_an_Image_Inside_a_Rectangle_Shape/.NET/Fit_an_Image_Inside_a_Rectangle_Shape/Fit_an_Image_Inside_a_Rectangle_Shape.csproj b/Paragraphs/Fit_an_Image_Inside_a_Rectangle_Shape/.NET/Fit_an_Image_Inside_a_Rectangle_Shape/Fit_an_Image_Inside_a_Rectangle_Shape.csproj new file mode 100644 index 000000000..38b8e1e03 --- /dev/null +++ b/Paragraphs/Fit_an_Image_Inside_a_Rectangle_Shape/.NET/Fit_an_Image_Inside_a_Rectangle_Shape/Fit_an_Image_Inside_a_Rectangle_Shape.csproj @@ -0,0 +1,20 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + + Always + + + + diff --git a/Paragraphs/Fit_an_Image_Inside_a_Rectangle_Shape/.NET/Fit_an_Image_Inside_a_Rectangle_Shape/Output/Result.docx b/Paragraphs/Fit_an_Image_Inside_a_Rectangle_Shape/.NET/Fit_an_Image_Inside_a_Rectangle_Shape/Output/Result.docx new file mode 100644 index 000000000..b1c2d7043 Binary files /dev/null and b/Paragraphs/Fit_an_Image_Inside_a_Rectangle_Shape/.NET/Fit_an_Image_Inside_a_Rectangle_Shape/Output/Result.docx differ diff --git a/Paragraphs/Fit_an_Image_Inside_a_Rectangle_Shape/.NET/Fit_an_Image_Inside_a_Rectangle_Shape/Output/gitkeep.txt b/Paragraphs/Fit_an_Image_Inside_a_Rectangle_Shape/.NET/Fit_an_Image_Inside_a_Rectangle_Shape/Output/gitkeep.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Paragraphs/Fit_an_Image_Inside_a_Rectangle_Shape/.NET/Fit_an_Image_Inside_a_Rectangle_Shape/Output/gitkeep.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Paragraphs/Fit_an_Image_Inside_a_Rectangle_Shape/.NET/Fit_an_Image_Inside_a_Rectangle_Shape/Program.cs b/Paragraphs/Fit_an_Image_Inside_a_Rectangle_Shape/.NET/Fit_an_Image_Inside_a_Rectangle_Shape/Program.cs new file mode 100644 index 000000000..8986ffdf9 --- /dev/null +++ b/Paragraphs/Fit_an_Image_Inside_a_Rectangle_Shape/.NET/Fit_an_Image_Inside_a_Rectangle_Shape/Program.cs @@ -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); + } + } + } + } +}