Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change-font-size #264

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Paragraphs/Change-font-size/.NET/Change-font-size.sln
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Change_font_size</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
</ItemGroup>

<ItemGroup>
<None Update="Data\Template.docx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\.gitkeep">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

37 changes: 37 additions & 0 deletions Paragraphs/Change-font-size/.NET/Change-font-size/Program.cs
Original file line number Diff line number Diff line change
@@ -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<Entity> 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);
}
}
}
}
}
}
Loading