Skip to content

Commit 1777662

Browse files
1012751: Samples added
1 parent b574d47 commit 1777662

40 files changed

Lines changed: 519 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="Create-ink-with-multipletraces/Create-ink-with-multipletraces.csproj" />
3+
</Solution>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Create_ink_with_multipletraces</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<None Update="Output\.gitkeep">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
<None Update="Output\Result.docx">
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21+
</None>
22+
</ItemGroup>
23+
24+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Binary file not shown.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
using Syncfusion.Drawing;
4+
using Syncfusion.Office;
5+
6+
namespace Create_ink_with_multipletraces
7+
{
8+
class Program
9+
{
10+
static void Main(string[] args)
11+
{
12+
//Creates a new Word document.
13+
using (WordDocument document = new WordDocument())
14+
{
15+
//Adds new section to the document.
16+
IWSection section = document.AddSection();
17+
//Adds new paragraph to the section.
18+
WParagraph paragraph = section.AddParagraph() as WParagraph;
19+
IWTextRange firstText = paragraph.AppendText("Created Ink with multiple traces");
20+
//Apply formatting for first text range
21+
firstText.CharacterFormat.FontSize = 14;
22+
firstText.CharacterFormat.Bold = true;
23+
//Adds new ink to the document.
24+
WInk ink = paragraph.AppendInk(450, 350);
25+
// Sets the horizontal position of the ink object.
26+
ink.HorizontalPosition = 30;
27+
// Sets the Vertical position of the ink object.
28+
ink.VerticalPosition = 50;
29+
// Sets the text wrapping style for the ink object to be in front of text.
30+
ink.WrapFormat.TextWrappingStyle = TextWrappingStyle.InFrontOfText;
31+
// Gets the ink traces collection from the ink object.
32+
IOfficeInkTraces traces = ink.Traces;
33+
// Gets all trace point arrays from the helper method.
34+
List<PointF[]> pointsCollection = GetPoints();
35+
// Adds each trace to the ink object.
36+
foreach (var points in pointsCollection)
37+
{
38+
// Adds the trace to the ink object.
39+
IOfficeInkTrace trace = traces.Add(points);
40+
// Sets the brush color for the trace to red.
41+
trace.Brush.Color = Color.Red;
42+
// Sets the brush size for the ink stroke.
43+
trace.Brush.Size = new SizeF(5f, 5f);
44+
}
45+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"../../../Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
46+
{
47+
//Saves the Word document to file stream.
48+
document.Save(outputFileStream, FormatType.Docx);
49+
}
50+
}
51+
}
52+
/// <summary>
53+
/// A collection where each <see cref="PointF"/> array represents a single stroke.
54+
/// </summary>
55+
static List<PointF[]> GetPoints()
56+
{
57+
return new List<PointF[]>
58+
{
59+
//Trace_i
60+
new PointF[] {
61+
new PointF(20f, 10f),
62+
new PointF(20f, 140f),
63+
},
64+
//Trace_n
65+
new PointF[]
66+
{
67+
new PointF(60f, 80f),
68+
new PointF(60f, 100f),
69+
new PointF(60f, 140f),
70+
new PointF(60f, 92f),
71+
new PointF(70f, 86f),
72+
new PointF(88f, 84f),
73+
new PointF(100f, 92f),
74+
new PointF(106f, 108f),
75+
new PointF(110f, 140f)
76+
},
77+
//Trace_k
78+
new PointF[] {
79+
new PointF(140f, 10f),
80+
new PointF(140f, 140f),
81+
new PointF(140f, 80f),
82+
new PointF(180f, 20f),
83+
new PointF(140f, 80f),
84+
new PointF(180f, 140f)
85+
}
86+
};
87+
}
88+
}
89+
}
90+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="Create-ink/Create-ink.csproj" />
3+
</Solution>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Create_ink</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<None Update="Output\.gitkeep">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
<None Update="Output\Result.docx">
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21+
</None>
22+
</ItemGroup>
23+
24+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

5.89 KB
Binary file not shown.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
using Syncfusion.Drawing;
4+
using Syncfusion.Office;
5+
6+
namespace Create_ink
7+
{
8+
class Program
9+
{
10+
static void Main(string[] args)
11+
{
12+
//Creates a new Word document.
13+
using (WordDocument document = new WordDocument())
14+
{
15+
//Adds new section to the document.
16+
IWSection section = document.AddSection();
17+
//Adds new paragraph to the section.
18+
WParagraph paragraph = section.AddParagraph() as WParagraph;
19+
//Adds new text to the paragraph
20+
IWTextRange firstText = paragraph.AppendText("Created a triangle using Ink");
21+
//Apply formatting for first text range
22+
firstText.CharacterFormat.FontSize = 14;
23+
firstText.CharacterFormat.Bold = true;
24+
//Adds new ink to the document.
25+
WInk ink = paragraph.AppendInk(400, 300);
26+
// Gets the ink traces collection from the ink object.
27+
IOfficeInkTraces traces = ink.Traces;
28+
// Adds new ink stroke with required trace points
29+
PointF[] triangle = new PointF[] { new PointF(0f, 300f), new PointF(200f, 0f), new PointF(400f, 300f), new PointF(0f, 300f) };
30+
// Adds a new ink trace to the ink object using the triangle points.
31+
IOfficeInkTrace trace = traces.Add(triangle);
32+
// Modify the brush effects and size
33+
IOfficeInkBrush brush = trace.Brush;
34+
// Sets the brush size for the ink stroke.
35+
brush.Size = new SizeF(5f, 5f);
36+
// Sets the ink effect to 'Galaxy'.
37+
brush.InkEffect = OfficeInkEffectType.Galaxy;
38+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"../../../Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
39+
{
40+
//Saves the Word document to file stream.
41+
document.Save(outputFileStream, FormatType.Docx);
42+
}
43+
}
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)