Skip to content

Commit 6f313de

Browse files
Changed the Input document
1 parent 235d7a9 commit 6f313de

File tree

4 files changed

+3
-14
lines changed

4 files changed

+3
-14
lines changed

Paragraphs/Change-text-color-of-styles/Change-text-color-of-styles/Change-text-color-of-styles.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
<None Update="Data\Input.docx">
1717
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
1818
</None>
19-
<None Update="Data\Template.docx">
20-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21-
</None>
2219
<None Update="Output\.gitkeep">
2320
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
2421
</None>
Binary file not shown.
Binary file not shown.

Paragraphs/Change-text-color-of-styles/Change-text-color-of-styles/Program.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@
33
using Syncfusion.DocIO;
44
using Syncfusion.Drawing;
55

6-
using (FileStream inputStream = new FileStream(Path.GetFullPath("Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
6+
using (FileStream inputStream = new FileStream(Path.GetFullPath("Data/Input.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
77
{
8-
// Open the Word document
8+
// Open the input Word document
99
WordDocument document = new WordDocument(inputStream, FormatType.Docx);
10-
11-
// Define the new color to apply to the styles
12-
Color newColor = Color.Purple;
13-
1410
// Iterate through all the styles in the document
1511
foreach (Style style in document.Styles)
1612
{
@@ -31,17 +27,13 @@
3127
WCharacterStyle charStyle = style as WCharacterStyle;
3228
if (charStyle != null)
3329
{
34-
charStyle.CharacterFormat.TextColor = Color.Green;
30+
charStyle.CharacterFormat.TextColor = Color.Red;
3531
}
3632
}
3733
}
38-
3934
// Save the modified document
4035
using (FileStream outputStream = new FileStream(Path.GetFullPath("Output/Result.docx"), FileMode.Create, FileAccess.Write))
4136
{
4237
document.Save(outputStream, FormatType.Docx);
4338
}
44-
45-
// Close the document
46-
document.Close();
4739
}

0 commit comments

Comments
 (0)