diff --git a/Paragraphs/Change-font-size/.NET/Change-font-size.sln b/Paragraphs/Change-font-size/.NET/Change-font-size.sln new file mode 100644 index 00000000..fb31f389 --- /dev/null +++ b/Paragraphs/Change-font-size/.NET/Change-font-size.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35327.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Change-font-size", "Change-font-size\Change-font-size.csproj", "{3CCAD0D1-6179-416B-9D42-CBA03AFA6860}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3CCAD0D1-6179-416B-9D42-CBA03AFA6860}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3CCAD0D1-6179-416B-9D42-CBA03AFA6860}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3CCAD0D1-6179-416B-9D42-CBA03AFA6860}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3CCAD0D1-6179-416B-9D42-CBA03AFA6860}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6FE8F7C4-D529-497F-B14B-6FA99BBD9F3A} + EndGlobalSection +EndGlobal diff --git a/Paragraphs/Change-font-size/.NET/Change-font-size/Change-font-size.csproj b/Paragraphs/Change-font-size/.NET/Change-font-size/Change-font-size.csproj new file mode 100644 index 00000000..c208ef13 --- /dev/null +++ b/Paragraphs/Change-font-size/.NET/Change-font-size/Change-font-size.csproj @@ -0,0 +1,24 @@ + + + + Exe + net8.0 + Change_font_size + enable + enable + + + + + + + + + Always + + + Always + + + + diff --git a/Paragraphs/Change-font-size/.NET/Change-font-size/Data/Template.docx b/Paragraphs/Change-font-size/.NET/Change-font-size/Data/Template.docx new file mode 100644 index 00000000..34913a91 Binary files /dev/null and b/Paragraphs/Change-font-size/.NET/Change-font-size/Data/Template.docx differ diff --git a/Paragraphs/Change-font-size/.NET/Change-font-size/Output/.gitkeep b/Paragraphs/Change-font-size/.NET/Change-font-size/Output/.gitkeep new file mode 100644 index 00000000..5f282702 --- /dev/null +++ b/Paragraphs/Change-font-size/.NET/Change-font-size/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Paragraphs/Change-font-size/.NET/Change-font-size/Program.cs b/Paragraphs/Change-font-size/.NET/Change-font-size/Program.cs new file mode 100644 index 00000000..5bea56d3 --- /dev/null +++ b/Paragraphs/Change-font-size/.NET/Change-font-size/Program.cs @@ -0,0 +1,37 @@ +using Syncfusion.DocIO.DLS; +using Syncfusion.DocIO; + +namespace Change_font_size +{ + class Program + { + static void Main(string[] args) + { + // Open the Word document from the file system for reading. + using (FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read)) + { + // Initialize the WordDocument object with the input stream. + using (WordDocument document = new WordDocument(inputStream, FormatType.Automatic)) + { + // Find all text ranges (instances of text) in the document + List textRanges = document.FindAllItemsByProperty(EntityType.TextRange, null, null); + + // Loop through each text range and change the font size. + for (int i = 0; i < textRanges.Count; i++) + { + WTextRange textRange = textRanges[i] as WTextRange; + // Set font size to 15. + textRange.CharacterFormat.FontSize = 15; + } + + // Create an output stream to save the modified document. + using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.OpenOrCreate, FileAccess.ReadWrite)) + { + // Save the modified document in DOCX format. + document.Save(outputStream, FormatType.Docx); + } + } + } + } + } +}