diff --git a/Paragraphs/Fit_an_Image_Inside_a_Shape/.NET/Fit_an_Image_Inside_a_Shape.sln b/Paragraphs/Fit_an_Image_Inside_a_Shape/.NET/Fit_an_Image_Inside_a_Shape.sln new file mode 100644 index 00000000..338ff66f --- /dev/null +++ b/Paragraphs/Fit_an_Image_Inside_a_Shape/.NET/Fit_an_Image_Inside_a_Shape.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.37314.3 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fit_an_Image_Inside_a_Shape", "Fit_an_Image_Inside_a_Shape\Fit_an_Image_Inside_a_Shape.csproj", "{0F048ED5-E2FF-308E-209B-43CBAC97ADE0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0F048ED5-E2FF-308E-209B-43CBAC97ADE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0F048ED5-E2FF-308E-209B-43CBAC97ADE0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0F048ED5-E2FF-308E-209B-43CBAC97ADE0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0F048ED5-E2FF-308E-209B-43CBAC97ADE0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4AEBBB7A-69B5-4810-8907-8C83B82A2BB3} + EndGlobalSection +EndGlobal diff --git a/Paragraphs/Fit_an_Image_Inside_a_Shape/.NET/Fit_an_Image_Inside_a_Shape/Data/Template.docx b/Paragraphs/Fit_an_Image_Inside_a_Shape/.NET/Fit_an_Image_Inside_a_Shape/Data/Template.docx new file mode 100644 index 00000000..10fb3481 Binary files /dev/null and b/Paragraphs/Fit_an_Image_Inside_a_Shape/.NET/Fit_an_Image_Inside_a_Shape/Data/Template.docx differ diff --git a/Paragraphs/Fit_an_Image_Inside_a_Shape/.NET/Fit_an_Image_Inside_a_Shape/Fit_an_Image_Inside_a_Shape.csproj b/Paragraphs/Fit_an_Image_Inside_a_Shape/.NET/Fit_an_Image_Inside_a_Shape/Fit_an_Image_Inside_a_Shape.csproj new file mode 100644 index 00000000..38b8e1e0 --- /dev/null +++ b/Paragraphs/Fit_an_Image_Inside_a_Shape/.NET/Fit_an_Image_Inside_a_Shape/Fit_an_Image_Inside_a_Shape.csproj @@ -0,0 +1,20 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + + Always + + + + diff --git a/Paragraphs/Fit_an_Image_Inside_a_Shape/.NET/Fit_an_Image_Inside_a_Shape/Output/Result.docx b/Paragraphs/Fit_an_Image_Inside_a_Shape/.NET/Fit_an_Image_Inside_a_Shape/Output/Result.docx new file mode 100644 index 00000000..8a4637ef Binary files /dev/null and b/Paragraphs/Fit_an_Image_Inside_a_Shape/.NET/Fit_an_Image_Inside_a_Shape/Output/Result.docx differ diff --git a/Paragraphs/Fit_an_Image_Inside_a_Shape/.NET/Fit_an_Image_Inside_a_Shape/Output/gitkeep.txt b/Paragraphs/Fit_an_Image_Inside_a_Shape/.NET/Fit_an_Image_Inside_a_Shape/Output/gitkeep.txt new file mode 100644 index 00000000..5f282702 --- /dev/null +++ b/Paragraphs/Fit_an_Image_Inside_a_Shape/.NET/Fit_an_Image_Inside_a_Shape/Output/gitkeep.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Paragraphs/Fit_an_Image_Inside_a_Shape/.NET/Fit_an_Image_Inside_a_Shape/Program.cs b/Paragraphs/Fit_an_Image_Inside_a_Shape/.NET/Fit_an_Image_Inside_a_Shape/Program.cs new file mode 100644 index 00000000..d3d809d2 --- /dev/null +++ b/Paragraphs/Fit_an_Image_Inside_a_Shape/.NET/Fit_an_Image_Inside_a_Shape/Program.cs @@ -0,0 +1,34 @@ +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; + + +namespace Fit_an_Image_Inside_a_Shape +{ + class Program + { + static void Main(string[] args) + { + // Open the input Word document as a file stream + using (FileStream inputStream = new FileStream(Path.GetFullPath(@"../../../Data/Template.docx"), FileMode.Open, FileAccess.Read)) + { + // Load the Word document + using (WordDocument document = new WordDocument(inputStream, FormatType.Docx)) + { + Entity entity = document.FindItemByProperty(EntityType.Picture, "Title", "Product"); + WPicture picture = entity as WPicture; + if(picture.OwnerParagraph.OwnerTextBody.Owner is WTextBox shape) + { + picture.Height = shape.TextBoxFormat.Height; + picture.Width = shape.TextBoxFormat.Width; + } + //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); + } + } + } + } + } +}