Skip to content

Commit 7eb5bd5

Browse files
Merge pull request #264 from SyncfusionExamples/Change-font-size
Change-font-size
2 parents 2cc04a6 + ae8755a commit 7eb5bd5

File tree

5 files changed

+87
-0
lines changed

5 files changed

+87
-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.11.35327.3
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Change-font-size", "Change-font-size\Change-font-size.csproj", "{3CCAD0D1-6179-416B-9D42-CBA03AFA6860}"
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+
{3CCAD0D1-6179-416B-9D42-CBA03AFA6860}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{3CCAD0D1-6179-416B-9D42-CBA03AFA6860}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{3CCAD0D1-6179-416B-9D42-CBA03AFA6860}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{3CCAD0D1-6179-416B-9D42-CBA03AFA6860}.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 = {6FE8F7C4-D529-497F-B14B-6FA99BBD9F3A}
24+
EndGlobalSection
25+
EndGlobal
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>Change_font_size</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="Data\Template.docx">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
<None Update="Output\.gitkeep">
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21+
</None>
22+
</ItemGroup>
23+
24+
</Project>
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using Syncfusion.DocIO.DLS;
2+
using Syncfusion.DocIO;
3+
4+
namespace Change_font_size
5+
{
6+
class Program
7+
{
8+
static void Main(string[] args)
9+
{
10+
// Open the Word document from the file system for reading.
11+
using (FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read))
12+
{
13+
// Initialize the WordDocument object with the input stream.
14+
using (WordDocument document = new WordDocument(inputStream, FormatType.Automatic))
15+
{
16+
// Find all text ranges (instances of text) in the document
17+
List<Entity> textRanges = document.FindAllItemsByProperty(EntityType.TextRange, null, null);
18+
19+
// Loop through each text range and change the font size.
20+
for (int i = 0; i < textRanges.Count; i++)
21+
{
22+
WTextRange textRange = textRanges[i] as WTextRange;
23+
// Set font size to 15.
24+
textRange.CharacterFormat.FontSize = 15;
25+
}
26+
27+
// Create an output stream to save the modified document.
28+
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.OpenOrCreate, FileAccess.ReadWrite))
29+
{
30+
// Save the modified document in DOCX format.
31+
document.Save(outputStream, FormatType.Docx);
32+
}
33+
}
34+
}
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)