Skip to content

Commit b79db59

Browse files
Merge pull request #375 from SyncfusionExamples/ES-935070-Apply-image-border
ES-935070- Add the sample Apply-image-border
2 parents f9bc39c + b0d4bcf commit b79db59

File tree

5 files changed

+101
-0
lines changed

5 files changed

+101
-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 16
4+
VisualStudioVersion = 16.0.31911.196
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apply-image-border", "Apply-image-border\Apply-image-border.csproj", "{C17B90BC-F559-456B-B189-90B53FF6CDD4}"
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+
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.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 = {EF357FC6-E9E5-4E3C-B932-43F727BE1DE4}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Apply_image_border</RootNamespace>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<None Update="Data\Picture.png">
15+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
16+
</None>
17+
<None Update="Output\.gitkeep">
18+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
19+
</None>
20+
</ItemGroup>
21+
22+
</Project>
10.4 KB
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
using Syncfusion.Drawing;
4+
using System.IO;
5+
6+
namespace Apply_image_border
7+
{
8+
class Program
9+
{
10+
static void Main(string[] args)
11+
{
12+
//Create an word document.
13+
using (WordDocument document = new WordDocument())
14+
{
15+
document.EnsureMinimal();
16+
//Appends new textbox to the paragraph
17+
IWTextBox textbox = document.LastParagraph.AppendTextBox(150, 75);
18+
//Set color to the text box's line.
19+
textbox.TextBoxFormat.LineColor = Color.Purple;
20+
//Set size of the text box's border.
21+
textbox.TextBoxFormat.LineWidth = 2;
22+
//Sets text box's margin values as Zero.
23+
textbox.TextBoxFormat.InternalMargin.Top = 0f;
24+
textbox.TextBoxFormat.InternalMargin.Bottom = 0f;
25+
textbox.TextBoxFormat.InternalMargin.Left = 0f;
26+
textbox.TextBoxFormat.InternalMargin.Right = 0f;
27+
//Set text trapping style to the text box.
28+
textbox.TextBoxFormat.TextWrappingStyle = TextWrappingStyle.Inline;
29+
30+
//Adds new text to the textbox body
31+
IWParagraph textboxParagraph = textbox.TextBoxBody.AddParagraph();
32+
FileStream imageStream = new FileStream(Path.GetFullPath(@"Data/Picture.png"), FileMode.Open, FileAccess.ReadWrite);
33+
WPicture picture = textboxParagraph.AppendPicture(imageStream) as WPicture;
34+
//sets the picture width scale factor in percent.
35+
picture.WidthScale = 80;
36+
//sets the picture height scale factor in percent.
37+
picture.HeightScale = 80;
38+
39+
//Set picture size as text box size.
40+
textbox.TextBoxFormat.Width = picture.Width;
41+
textbox.TextBoxFormat.Height = picture.Height;
42+
43+
//Creates file stream.
44+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
45+
{
46+
//Saves the Word document to file stream.
47+
document.Save(outputFileStream, FormatType.Docx);
48+
}
49+
}
50+
}
51+
}
52+
}
53+

0 commit comments

Comments
 (0)