diff --git a/Paragraphs/Apply-image-border/.NET/Apply-image-border.sln b/Paragraphs/Apply-image-border/.NET/Apply-image-border.sln new file mode 100644 index 000000000..3febce0de --- /dev/null +++ b/Paragraphs/Apply-image-border/.NET/Apply-image-border.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31911.196 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apply-image-border", "Apply-image-border\Apply-image-border.csproj", "{C17B90BC-F559-456B-B189-90B53FF6CDD4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EF357FC6-E9E5-4E3C-B932-43F727BE1DE4} + EndGlobalSection +EndGlobal diff --git a/Paragraphs/Apply-image-border/.NET/Apply-image-border/Apply-image-border.csproj b/Paragraphs/Apply-image-border/.NET/Apply-image-border/Apply-image-border.csproj new file mode 100644 index 000000000..d4820c07b --- /dev/null +++ b/Paragraphs/Apply-image-border/.NET/Apply-image-border/Apply-image-border.csproj @@ -0,0 +1,22 @@ + + + + Exe + net8.0 + Apply_image_border + + + + + + + + + Always + + + Always + + + + diff --git a/Paragraphs/Apply-image-border/.NET/Apply-image-border/Data/Picture.png b/Paragraphs/Apply-image-border/.NET/Apply-image-border/Data/Picture.png new file mode 100644 index 000000000..dfdedc844 Binary files /dev/null and b/Paragraphs/Apply-image-border/.NET/Apply-image-border/Data/Picture.png differ diff --git a/Paragraphs/Apply-image-border/.NET/Apply-image-border/Output/.gitkeep b/Paragraphs/Apply-image-border/.NET/Apply-image-border/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Paragraphs/Apply-image-border/.NET/Apply-image-border/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Paragraphs/Apply-image-border/.NET/Apply-image-border/Program.cs b/Paragraphs/Apply-image-border/.NET/Apply-image-border/Program.cs new file mode 100644 index 000000000..a74354bd6 --- /dev/null +++ b/Paragraphs/Apply-image-border/.NET/Apply-image-border/Program.cs @@ -0,0 +1,53 @@ +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; +using Syncfusion.Drawing; +using System.IO; + +namespace Apply_image_border +{ + class Program + { + static void Main(string[] args) + { + //Create an word document. + using (WordDocument document = new WordDocument()) + { + document.EnsureMinimal(); + //Appends new textbox to the paragraph + IWTextBox textbox = document.LastParagraph.AppendTextBox(150, 75); + //Set color to the text box's line. + textbox.TextBoxFormat.LineColor = Color.Purple; + //Set size of the text box's border. + textbox.TextBoxFormat.LineWidth = 2; + //Sets text box's margin values as Zero. + textbox.TextBoxFormat.InternalMargin.Top = 0f; + textbox.TextBoxFormat.InternalMargin.Bottom = 0f; + textbox.TextBoxFormat.InternalMargin.Left = 0f; + textbox.TextBoxFormat.InternalMargin.Right = 0f; + //Set text trapping style to the text box. + textbox.TextBoxFormat.TextWrappingStyle = TextWrappingStyle.Inline; + + //Adds new text to the textbox body + IWParagraph textboxParagraph = textbox.TextBoxBody.AddParagraph(); + FileStream imageStream = new FileStream(Path.GetFullPath(@"Data/Picture.png"), FileMode.Open, FileAccess.ReadWrite); + WPicture picture = textboxParagraph.AppendPicture(imageStream) as WPicture; + //sets the picture width scale factor in percent. + picture.WidthScale = 80; + //sets the picture height scale factor in percent. + picture.HeightScale = 80; + + //Set picture size as text box size. + textbox.TextBoxFormat.Width = picture.Width; + textbox.TextBoxFormat.Height = picture.Height; + + //Creates file stream. + using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite)) + { + //Saves the Word document to file stream. + document.Save(outputFileStream, FormatType.Docx); + } + } + } + } +} +