Skip to content

Commit f6e6c92

Browse files
Merge pull request #144 from LokeshBaskar/main
ES-853397-Add fallback font code snippets in UG documentation
2 parents c44c0e1 + b1fbade commit f6e6c92

File tree

33 files changed

+620
-2
lines changed

33 files changed

+620
-2
lines changed

Charts/Refresh-chart-data/.NET-Standard/Refresh-chart-data/Program.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ static void Main(string[] args)
1717
WParagraph paragraph = document.LastParagraph;
1818
//Gets the chart entity from the paragraph items.
1919
WChart chart = paragraph.ChildEntities[0] as WChart;
20-
//Refreshes chart data.
21-
chart.Refresh();
20+
// Refreshes the chart data. Set `true` to evaluate Excel formulas before refreshing,
21+
// or `false` to refresh only the data without evaluating formulas.
22+
chart.Refresh(false);
2223
//Creates file stream.
2324
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"../../../Result.docx"), FileMode.Create, FileAccess.ReadWrite))
2425
{
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.9.34310.174
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fallback-fonts-based-on-scripttype", "Fallback-fonts-based-on-scripttype\Fallback-fonts-based-on-scripttype.csproj", "{7A92A19E-25AA-402E-9B55-B17D47A2E4FC}"
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+
{7A92A19E-25AA-402E-9B55-B17D47A2E4FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{7A92A19E-25AA-402E-9B55-B17D47A2E4FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{7A92A19E-25AA-402E-9B55-B17D47A2E4FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{7A92A19E-25AA-402E-9B55-B17D47A2E4FC}.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 = {53467DEC-3706-4667-8D26-98B415B23F63}
24+
EndGlobalSection
25+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net6.0</TargetFramework>
6+
<RootNamespace>Fallback_fonts_based_on_scripttype</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.DocIORenderer.Net.Core" Version="*" />
13+
</ItemGroup>
14+
</Project>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using Syncfusion.DocIO.DLS;
2+
using Syncfusion.DocIORenderer;
3+
using Syncfusion.Office;
4+
namespace Fallback_fonts_based_on_scripttype
5+
{
6+
internal class Program
7+
{
8+
static void Main(string[] args)
9+
{
10+
//Opens the file as stream.
11+
using FileStream inputStream = new FileStream(@"../../../Template.docx", FileMode.Open, FileAccess.Read);
12+
//Loads an existing Word document file stream.
13+
using WordDocument wordDocument = new WordDocument(inputStream, Syncfusion.DocIO.FormatType.Docx);
14+
//Adds fallback font for "Arabic" script type.
15+
wordDocument.FontSettings.FallbackFonts.Add(ScriptType.Arabic, "Arial, Times New Roman");
16+
//Adds fallback font for "Hebrew" script type.
17+
wordDocument.FontSettings.FallbackFonts.Add(ScriptType.Hebrew, "Arial, Courier New");
18+
//Adds fallback font for "Hindi" script type.
19+
wordDocument.FontSettings.FallbackFonts.Add(ScriptType.Hindi, "Mangal, Nirmala UI");
20+
//Adds fallback font for "Chinese" script type.
21+
wordDocument.FontSettings.FallbackFonts.Add(ScriptType.Chinese, "DengXian, MingLiU");
22+
//Adds fallback font for "Japanese" script type.
23+
wordDocument.FontSettings.FallbackFonts.Add(ScriptType.Japanese, "Yu Mincho, MS Mincho");
24+
//Adds fallback font for "Thai" script type.
25+
wordDocument.FontSettings.FallbackFonts.Add(ScriptType.Thai, "Tahoma, Microsoft Sans Serif");
26+
//Adds fallback font for "Korean" script type.
27+
wordDocument.FontSettings.FallbackFonts.Add(ScriptType.Korean, "Malgun Gothic, Batang");
28+
//Instantiation of DocIORenderer for Word to Image conversion.
29+
using DocIORenderer render = new DocIORenderer();
30+
//Convert the entire Word document to images.
31+
Stream[] imageStreams = wordDocument.RenderAsImages();
32+
int i = 0;
33+
foreach (Stream stream in imageStreams)
34+
{
35+
//Reset the stream position.
36+
stream.Position = 0;
37+
//Save the stream as file.
38+
using FileStream fileStreamOutput = File.Create(@"../../../WordToImage_" + i + ".jpeg");
39+
stream.CopyTo(fileStreamOutput);
40+
i++;
41+
}
42+
}
43+
}
44+
}
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.9.34310.174
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fallback-fonts-for-Unicode-range", "Fallback-fonts-for-Unicode-range\Fallback-fonts-for-Unicode-range.csproj", "{5339BECC-6DDE-48E9-9A7A-C77C7E47A70B}"
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+
{5339BECC-6DDE-48E9-9A7A-C77C7E47A70B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{5339BECC-6DDE-48E9-9A7A-C77C7E47A70B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{5339BECC-6DDE-48E9-9A7A-C77C7E47A70B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{5339BECC-6DDE-48E9-9A7A-C77C7E47A70B}.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 = {4A3A606F-7765-48E8-B87A-3B06A1D8918D}
24+
EndGlobalSection
25+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net6.0</TargetFramework>
6+
<RootNamespace>Fallback_fonts_for_Unicode_range</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.DocIORenderer.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
</Project>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using Syncfusion.DocIO.DLS;
2+
using Syncfusion.DocIORenderer;
3+
using Syncfusion.Office;
4+
5+
namespace Fallback_fonts_for_Unicode_range
6+
{
7+
internal class Program
8+
{
9+
static void Main(string[] args)
10+
{
11+
//Opens the file as stream.
12+
using FileStream inputStream = new FileStream(@"../../../Template.docx", FileMode.Open, FileAccess.Read);
13+
//Loads an existing Word document file stream.
14+
using WordDocument wordDocument = new WordDocument(inputStream, Syncfusion.DocIO.FormatType.Docx);
15+
//Adds fallback font for "Arabic" specific unicode range.
16+
wordDocument.FontSettings.FallbackFonts.Add(new FallbackFont(0x0600, 0x06ff, "Arial"));
17+
//Adds fallback font for "Hebrew" specific unicode range.
18+
wordDocument.FontSettings.FallbackFonts.Add(new FallbackFont(0x0590, 0x05ff, "Times New Roman"));
19+
//Adds fallback font for "Hindi" specific unicode range.
20+
wordDocument.FontSettings.FallbackFonts.Add(new FallbackFont(0x0900, 0x097F, "Nirmala UI"));
21+
//Adds fallback font for "Chinese" specific unicode range.
22+
wordDocument.FontSettings.FallbackFonts.Add(new FallbackFont(0x4E00, 0x9FFF, "DengXian"));
23+
//Adds fallback font for "Japanese" specific unicode range.
24+
wordDocument.FontSettings.FallbackFonts.Add(new FallbackFont(0x3040, 0x309F, "MS Gothic"));
25+
//Adds fallback font for "Thai" specific unicode range.
26+
wordDocument.FontSettings.FallbackFonts.Add(new FallbackFont(0x0E00, 0x0E7F, "Tahoma"));
27+
//Adds fallback font for "Korean" specific unicode range.
28+
wordDocument.FontSettings.FallbackFonts.Add(new FallbackFont(0xAC00, 0xD7A3, "Malgun Gothic"));
29+
//Instantiation of DocIORenderer for Word to Image conversion.
30+
using DocIORenderer render = new DocIORenderer();
31+
//Convert the entire Word document to images.
32+
Stream[] imageStreams = wordDocument.RenderAsImages();
33+
int i = 0;
34+
foreach (Stream stream in imageStreams)
35+
{
36+
//Reset the stream position.
37+
stream.Position = 0;
38+
//Save the stream as file.
39+
using FileStream fileStreamOutput = File.Create(@"../../../WordToImage_" + i + ".jpeg");
40+
stream.CopyTo(fileStreamOutput);
41+
i++;
42+
}
43+
}
44+
}
45+
}
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.9.34310.174
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Initialize-default-fallback-fonts", "Initialize-default-fallback-fonts\Initialize-default-fallback-fonts.csproj", "{AA4B5A73-E9A4-465D-98A9-33450B770972}"
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+
{AA4B5A73-E9A4-465D-98A9-33450B770972}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{AA4B5A73-E9A4-465D-98A9-33450B770972}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{AA4B5A73-E9A4-465D-98A9-33450B770972}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{AA4B5A73-E9A4-465D-98A9-33450B770972}.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 = {C3D990B9-C4A8-4095-99DB-1199DDFB8423}
24+
EndGlobalSection
25+
EndGlobal

0 commit comments

Comments
 (0)