Skip to content

Commit a71fa75

Browse files
Merge pull request #128 from Karan-SF4772/master
995109 - Add fallback symbol sample in PowerPoint Presentation
2 parents 263576b + 271ddec commit a71fa75

File tree

10 files changed

+124
-0
lines changed

10 files changed

+124
-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="Fallback-symbols-based-on-scripttype/Fallback-symbols-based-on-scripttype.csproj" />
3+
</Solution>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Fallback_symbols_based_on_scripttype</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.PresentationRenderer.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<None Update="Data\Template.pptx">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
<None Update="Output\.gitkeep">
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21+
</None>
22+
</ItemGroup>
23+
24+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using Syncfusion.Office;
2+
using Syncfusion.Presentation;
3+
using Syncfusion.Office;
4+
using Syncfusion.PresentationRenderer;
5+
namespace Fallback_fonts_based_on_scripttype
6+
{
7+
internal class Program
8+
{
9+
static void Main(string[] args)
10+
{
11+
//Load the PowerPoint presentation into stream.
12+
using FileStream fileStreamInput = new FileStream(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read);
13+
//Open the existing PowerPoint presentation with loaded stream.
14+
using IPresentation pptxDoc = Presentation.Open(fileStreamInput);
15+
//Adds fallback font for basic symbols like bullet characters.
16+
pptxDoc.FontSettings.FallbackFonts.Add(ScriptType.Symbols, "Segoe UI Symbol, Arial Unicode MS, Wingdings");
17+
//Adds fallback font for mathematics symbols.
18+
pptxDoc.FontSettings.FallbackFonts.Add(ScriptType.Mathematics, "Cambria Math, Noto Sans Math, Segoe UI Symbol, Arial Unicode MS");
19+
//Adds fallback font for emojis.
20+
pptxDoc.FontSettings.FallbackFonts.Add(ScriptType.Emoji, "Segoe UI Emoji, Noto Color Emoji, Arial Unicode MS");
21+
//Initialize the PresentationRenderer to perform image conversion.
22+
pptxDoc.PresentationRenderer = new PresentationRenderer();
23+
//Convert PowerPoint slide to image as stream.
24+
using Stream stream = pptxDoc.Slides[0].ConvertToImage(ExportImageFormat.Jpeg);
25+
//Reset the stream position.
26+
stream.Position = 0;
27+
//Create the output image file stream.
28+
using FileStream fileStreamOutput = File.Create(Path.GetFullPath(@"../../../Output/Output.jpg"));
29+
//Copy the converted image stream into created output stream.
30+
stream.CopyTo(fileStreamOutput);
31+
}
32+
}
33+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="Fallback-symbols-based-on-scripttype/Fallback-symbols-based-on-scripttype.csproj" />
3+
</Solution>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Fallback_symbols_based_on_scripttype</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.PresentationRenderer.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<None Update="Data\Template.pptx">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
<None Update="Output\.gitkeep">
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21+
</None>
22+
</ItemGroup>
23+
24+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using Syncfusion.Office;
2+
using Syncfusion.Pdf;
3+
using Syncfusion.Presentation;
4+
using Syncfusion.PresentationRenderer;
5+
6+
namespace Fallback_symbols_based_on_scripttype
7+
{
8+
internal class Program
9+
{
10+
static void Main(string[] args)
11+
{
12+
//Load the PowerPoint presentation into stream.
13+
using FileStream fileStreamInput = new FileStream(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read);
14+
//Open the existing PowerPoint presentation with loaded stream.
15+
using IPresentation pptxDoc = Presentation.Open(fileStreamInput);
16+
//Adds fallback font for basic symbols like bullet characters.
17+
pptxDoc.FontSettings.FallbackFonts.Add(ScriptType.Symbols, "Segoe UI Symbol, Arial Unicode MS, Wingdings");
18+
//Adds fallback font for mathematics symbols.
19+
pptxDoc.FontSettings.FallbackFonts.Add(ScriptType.Mathematics, "Cambria Math, Noto Sans Math, Segoe UI Symbol, Arial Unicode MS");
20+
//Adds fallback font for emojis.
21+
pptxDoc.FontSettings.FallbackFonts.Add(ScriptType.Emoji, "Segoe UI Emoji, Noto Color Emoji, Arial Unicode MS");
22+
//Create the MemoryStream to save the converted PDF.
23+
using MemoryStream pdfStream = new MemoryStream();
24+
//Convert the PowerPoint document to PDF document.
25+
using PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc);
26+
//Save the converted PDF document to MemoryStream.
27+
pdfDocument.Save(pdfStream);
28+
pdfStream.Position = 0;
29+
//Create the output PDF file stream.
30+
using FileStream fileStreamOutput = File.Create(Path.GetFullPath(@"../../../Output/PPTXToPDF.pdf"));
31+
//Copy the converted PDF stream into created output PDF stream.
32+
pdfStream.CopyTo(fileStreamOutput);
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)