Skip to content

Commit 66b3d73

Browse files
Merge pull request #204 from SyncfusionExamples/KB_Samples
KB samples
2 parents 7ebbdaa + 06b99da commit 66b3d73

File tree

14 files changed

+221
-0
lines changed

14 files changed

+221
-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 17
4+
VisualStudioVersion = 17.10.34928.147
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Find-text-and-add-comments", "Find-text-and-add-comments\Find-text-and-add-comments.csproj", "{8B2E34B8-B23D-4717-A86A-34EB32012EC3}"
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+
{8B2E34B8-B23D-4717-A86A-34EB32012EC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{8B2E34B8-B23D-4717-A86A-34EB32012EC3}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{8B2E34B8-B23D-4717-A86A-34EB32012EC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{8B2E34B8-B23D-4717-A86A-34EB32012EC3}.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 = {6140D05B-D8BA-4632-A04A-84100359C4AF}
24+
EndGlobalSection
25+
EndGlobal
Binary file not shown.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Find_text_and_add_comments</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+
</Project>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
4+
using (FileStream inputStream = new FileStream(@"../../../Data/InsertComment.docx", FileMode.Open, FileAccess.Read))
5+
{
6+
//Open the existing Word document.
7+
using (WordDocument document = new WordDocument(inputStream, FormatType.Docx))
8+
{
9+
//Find all occurrence of a particular text ending with comma in the document using regex.
10+
TextSelection[] textSelection = document.FindAll("panda", true, true);
11+
if (textSelection != null)
12+
{
13+
//Iterates through each occurrence and comment it.
14+
for (int i = 0; i < textSelection.Count(); i++)
15+
{
16+
WTextRange textRange = textSelection[i].GetAsOneRange();
17+
18+
//Get the index of the found text.
19+
int textIndex = textRange.OwnerParagraph.ChildEntities.IndexOf(textRange);
20+
//Add comment to a paragraph.
21+
WComment comment = textRange.OwnerParagraph.AppendComment("comment test_" + i);
22+
//Specify the author of the comment.
23+
comment.Format.User = "Peter";
24+
//Set the date and time for the comment.
25+
comment.Format.DateTime = DateTime.Now;
26+
//Insert the comment next to the textrange.
27+
textRange.OwnerParagraph.ChildEntities.Insert(textIndex + 1, comment);
28+
//Add the paragraph items to the commented items.
29+
comment.AddCommentedItem(textRange);
30+
}
31+
}
32+
33+
//Save the Word document
34+
using (FileStream outputStream = new FileStream(@"../../../Output.docx", FileMode.Create, FileAccess.Write))
35+
{
36+
document.Save(outputStream, FormatType.Docx);
37+
}
38+
}
39+
}
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 17
4+
VisualStudioVersion = 17.10.34928.147
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Remove_all_page_breaks", "Remove_all_page_breaks\Remove_all_page_breaks.csproj", "{BBAF7F96-C858-4CE2-AEA5-5192110B8CB8}"
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+
{BBAF7F96-C858-4CE2-AEA5-5192110B8CB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{BBAF7F96-C858-4CE2-AEA5-5192110B8CB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{BBAF7F96-C858-4CE2-AEA5-5192110B8CB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{BBAF7F96-C858-4CE2-AEA5-5192110B8CB8}.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 = {5AA2BDB5-3AE9-4E8D-8115-E0B1DF21850D}
24+
EndGlobalSection
25+
EndGlobal
Binary file not shown.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
4+
using (FileStream inputStream = new FileStream(@"../../../Data/Template.docx", FileMode.Open, FileAccess.Read))
5+
{
6+
//Open the existing Word document.
7+
using (WordDocument document = new WordDocument(inputStream, FormatType.Docx))
8+
{
9+
//Get the list of page breaks
10+
List<Entity> entities = document.FindAllItemsByProperty(EntityType.Break, "BreakType", "PageBreak");
11+
12+
//Iterate through all page breaks and remove it from the owner paragraph
13+
foreach (Entity entity in entities)
14+
(entity as Break).OwnerParagraph.ChildEntities.Remove(entity);
15+
16+
//Save the Word document
17+
using (FileStream outputStream = new FileStream(@"../../../Output.docx", FileMode.Create, FileAccess.Write))
18+
{
19+
document.Save(outputStream, FormatType.Docx);
20+
}
21+
}
22+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
12+
</ItemGroup>
13+
14+
</Project>
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 17
4+
VisualStudioVersion = 17.10.34928.147
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Add_toc_in_merged_documents", "Add_toc_in_merged_documents\Add_toc_in_merged_documents.csproj", "{78D9D0A1-4467-4A3C-8C45-3F90EE69EC36}"
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+
{78D9D0A1-4467-4A3C-8C45-3F90EE69EC36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{78D9D0A1-4467-4A3C-8C45-3F90EE69EC36}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{78D9D0A1-4467-4A3C-8C45-3F90EE69EC36}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{78D9D0A1-4467-4A3C-8C45-3F90EE69EC36}.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 = {CF8B010D-A0FC-4D30-8767-8B601222372E}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
12+
<PackageReference Include="Syncfusion.DocIORenderer.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
</Project>

0 commit comments

Comments
 (0)