Skip to content

Commit c9919db

Browse files
ES-992091-Changes added
1 parent f9b0b3c commit c9919db

File tree

7 files changed

+45
-73
lines changed

7 files changed

+45
-73
lines changed

Paragraphs/Find-highlight-text/.NET/Find-text-by-highlight-color.sln

Lines changed: 0 additions & 25 deletions
This file was deleted.

Paragraphs/Find-highlight-text/.NET/Find-text-by-highlight-color/Program.cs

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="Remove_highlight_color/Remove_highlight_color.csproj" />
3+
</Solution>

Paragraphs/Find-highlight-text/.NET/Find-text-by-highlight-color/Data/Input.docx renamed to Paragraphs/Remove-highlight-color/.NET/Remove_highlight_color/Data/Input.docx

File renamed without changes.

Paragraphs/Find-highlight-text/.NET/Find-text-by-highlight-color/Output/.gitkeep renamed to Paragraphs/Remove-highlight-color/.NET/Remove_highlight_color/Output/.gitkeep

File renamed without changes.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
using Syncfusion.Drawing;
4+
5+
namespace Remove_highlight_color
6+
{
7+
class Program
8+
{
9+
static void Main(string[] args)
10+
{
11+
using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Input.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
12+
{
13+
//Creates a new Word document.
14+
using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Automatic))
15+
{
16+
// Find all text ranges in the document where the highlight color is Yellow
17+
List<Entity> textRanges = document.FindAllItemsByProperty(EntityType.TextRange, "CharacterFormat.HighlightColor.Name", "Yellow");
18+
// Check if any matching text ranges were found
19+
if (textRanges != null)
20+
{
21+
//Iterate text ranges
22+
foreach (Entity entity in textRanges)
23+
{
24+
WTextRange textRange = entity as WTextRange;
25+
// Clear the highlight color on this text range.
26+
textRange.CharacterFormat.HighlightColor = Color.Empty;
27+
}
28+
}
29+
//Create a file stream.
30+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
31+
{
32+
//Save the Word document to the file stream.
33+
document.Save(outputFileStream, FormatType.Docx);
34+
}
35+
}
36+
}
37+
}
38+
39+
}
40+
}
41+
42+

Paragraphs/Find-highlight-text/.NET/Find-text-by-highlight-color/Find-text-by-highlight-color.csproj renamed to Paragraphs/Remove-highlight-color/.NET/Remove_highlight_color/Remove_highlight_color.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net8.0</TargetFramework>
6-
<RootNamespace>Find_text_by_highlight_color</RootNamespace>
76
<ImplicitUsings>enable</ImplicitUsings>
87
<Nullable>enable</Nullable>
98
</PropertyGroup>

0 commit comments

Comments
 (0)