Skip to content

Commit 87b7556

Browse files
Merge pull request #557 from SyncfusionExamples/262951-Fontsize
262951-How to set the font size for the text of the highlighted rows
2 parents c513437 + b99e648 commit 87b7556

6 files changed

Lines changed: 87 additions & 0 deletions

File tree

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.14.37314.3 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Change_Font_Size_For_Highlighted_Texts", "Change_Font_Size_For_Highlighted_Texts\Change_Font_Size_For_Highlighted_Texts.csproj", "{F67A30EB-8D8F-454D-47D1-40582F91AFC3}"
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+
{F67A30EB-8D8F-454D-47D1-40582F91AFC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{F67A30EB-8D8F-454D-47D1-40582F91AFC3}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{F67A30EB-8D8F-454D-47D1-40582F91AFC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{F67A30EB-8D8F-454D-47D1-40582F91AFC3}.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 = {18366B0B-7231-4300-AD29-B24C1FAB9785}
24+
EndGlobalSection
25+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
13+
</ItemGroup>
14+
<ItemGroup>
15+
<None Update="Data\Template.docx">
16+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
17+
</None>
18+
<None Update="Output\.gitkeep">
19+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
20+
</None>
21+
</ItemGroup>
22+
23+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
4+
namespace Change_Font_Size_For_Highlighted_Texts
5+
{
6+
class Program
7+
{
8+
static void Main(string[] args)
9+
{
10+
using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"../../../Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
11+
{
12+
//Opens an existing document.
13+
using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx))
14+
{
15+
// Finds all the text ranges in the document which have highlight color.
16+
List<Entity> entities = document.FindAllItemsByProperty(EntityType.TextRange, "CharacterFormat.HighlightColor.IsEmpty", false.ToString());
17+
18+
// Iterates the text ranges.
19+
foreach (Entity entity in entities)
20+
{
21+
// Casts the entity as WTextRange.
22+
WTextRange textRange = entity as WTextRange;
23+
// Get character format of the text
24+
WCharacterFormat charFormat = textRange.CharacterFormat;
25+
// Set text's font size larger
26+
charFormat.FontSize = 14;
27+
}
28+
//Creates file stream.
29+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"../../../Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
30+
{
31+
//Saves the Word document to file stream.
32+
document.Save(outputFileStream, FormatType.Docx);
33+
}
34+
}
35+
}
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)