Skip to content

Commit 8d56982

Browse files
Merge pull request #486 from SyncfusionExamples/996267-get-used-font-names-in-document
996267 - Add DocIO Sample for Get Used Font Names in Word document.
2 parents 7c29bb8 + 09fc394 commit 8d56982

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="Find-list-of-fontnames-used-in-word-document/Find-list-of-fontnames-used-in-word-document.csproj" />
3+
</Solution>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Find_list_of_fontnames_used_in_word_document</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+
</ItemGroup>
20+
21+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
4+
namespace Find_list_of_fontnames_used_in_word_document
5+
{
6+
class Program
7+
{
8+
static void Main(string[] args)
9+
{
10+
// Load the Word document
11+
WordDocument document = new WordDocument(Path.GetFullPath("Data/Template.docx"));
12+
// Get all font names used in the document
13+
List<string> fontNames = document.FontSettings.GetUsedFontNames();
14+
foreach (string fontName in fontNames)
15+
{
16+
Console.WriteLine(fontName);
17+
}
18+
// Closes the Word document
19+
document.Close();
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)