Skip to content

Commit d54c8a1

Browse files
committed
Added Supported Fallback content on DocIO and PPTX
1 parent 103775f commit d54c8a1

File tree

4 files changed

+185
-11
lines changed

4 files changed

+185
-11
lines changed

Document-Processing/PowerPoint/Conversions/PowerPoint-To-Image/NET/Fallback-Fonts-in-PPTXtoImage-Conversion.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,45 @@ using (FileStream fileStreamInput = new FileStream("Template.pptx", FileMode.Ope
103103

104104
You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/PPTX-to-Image-conversion/Fallback-fonts-based-on-scripttype).
105105

106+
## Fallback Symbols based on script type
107+
108+
The following code example demonstrates how a user can add fallback fonts based on the script types, which Presentation considers internally when converting a PowerPoint presentation to an Image.
109+
110+
{% tabs %}
111+
112+
{% highlight C# tabtitle="C# [Cross-platform]" %}
113+
//Load the PowerPoint presentation into stream.
114+
using (FileStream fileStreamInput = new FileStream("Template.pptx", FileMode.Open, FileAccess.Read))
115+
{
116+
//Open the existing PowerPoint presentation with loaded stream.
117+
using (IPresentation pptxDoc = Presentation.Open(fileStreamInput))
118+
{
119+
//Adds fallback font for basic symbols like bullet characters.
120+
pptxDoc.FontSettings.FallbackFonts.Add(ScriptType.Symbols, "Segoe UI Symbol, Arial Unicode MS, Wingdings");
121+
//Adds fallback font for mathematics symbols.
122+
pptxDoc.FontSettings.FallbackFonts.Add(ScriptType.Mathematics, "Cambria Math, Noto Sans Math, Segoe UI Symbol, Arial Unicode MS");
123+
//Adds fallback font for emojis.
124+
pptxDoc.FontSettings.FallbackFonts.Add(ScriptType.Emoji, "Segoe UI Emoji, Noto Color Emoji, Arial Unicode MS");
125+
//Initialize the PresentationRenderer to perform image conversion.
126+
pptxDoc.PresentationRenderer = new PresentationRenderer();
127+
//Convert PowerPoint slide to image as stream.
128+
using (Stream stream = pptxDoc.Slides[0].ConvertToImage(ExportImageFormat.Jpeg))
129+
{
130+
//Reset the stream position.
131+
stream.Position = 0;
132+
//Create the output image file stream.
133+
using (FileStream fileStreamOutput = File.Create("Output.jpg"))
134+
{
135+
//Copy the converted image stream into created output stream.
136+
stream.CopyTo(fileStreamOutput);
137+
}
138+
}
139+
}
140+
}
141+
{% endhighlight %}
142+
143+
{% endtabs %}
144+
106145
## Fallback fonts for range of Unicode text
107146

108147
Users can set fallback fonts for specific Unicode range of text to be used in Presentation to Image conversion.
@@ -500,8 +539,9 @@ Malgun Gothic, Batang
500539
<tr>
501540
<td>Symbols</td>
502541
<td>0x2000 - 0x27BF<br>
503-
0x2300 - 0x23FF</td>
504-
<td>Segoe UI Symbol, Arial Unicode MS</td>
542+
0x2300 - 0x23FF<br>
543+
0xF000 - 0xF104</td>
544+
<td>Segoe UI Symbol, Arial Unicode MS, Wingdings</td>
505545
</tr>
506546
<tr>
507547
<td>Mathematics</td>

Document-Processing/PowerPoint/Conversions/PowerPoint-To-PDF/NET/Fallback-Fonts-in-PPTXtoPDF-Conversion.md

Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,94 @@ pptxDoc.Close()
210210

211211
You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/PPTX-to-PDF-conversion/Fallback-fonts-based-on-scripttype).
212212

213+
## Fallback Symbols based on script type
214+
215+
The following code example demonstrates how a user can add fallback fonts based on the script types, which Presentation considers internally when converting a PowerPoint presentation to PDF.
216+
217+
{% tabs %}
218+
219+
{% highlight C# tabtitle="C# [Cross-platform]" %}
220+
//Load the PowerPoint presentation into stream.
221+
using (FileStream fileStreamInput = new FileStream("Template.pptx", FileMode.Open, FileAccess.Read))
222+
{
223+
//Open the existing PowerPoint presentation with loaded stream.
224+
using (IPresentation pptxDoc = Presentation.Open(fileStreamInput))
225+
{
226+
//Adds fallback font for basic symbols like bullet characters.
227+
pptxDoc.FontSettings.FallbackFonts.Add(ScriptType.Symbols, "Segoe UI Symbol, Arial Unicode MS, Wingdings");
228+
//Adds fallback font for mathematics symbols.
229+
pptxDoc.FontSettings.FallbackFonts.Add(ScriptType.Mathematics, "Cambria Math, Noto Sans Math, Segoe UI Symbol, Arial Unicode MS");
230+
//Adds fallback font for emojis.
231+
pptxDoc.FontSettings.FallbackFonts.Add(ScriptType.Emoji, "Segoe UI Emoji, Noto Color Emoji, Arial Unicode MS");
232+
//Create the MemoryStream to save the converted PDF.
233+
using (MemoryStream pdfStream = new MemoryStream())
234+
{
235+
//Convert the PowerPoint document to PDF document.
236+
using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc))
237+
{
238+
//Save the converted PDF document to MemoryStream.
239+
pdfDocument.Save(pdfStream);
240+
pdfStream.Position = 0;
241+
}
242+
//Create the output PDF file stream.
243+
using (FileStream fileStreamOutput = File.Create("Output.pdf"))
244+
{
245+
//Copy the converted PDF stream into created output PDF stream.
246+
pdfStream.CopyTo(fileStreamOutput);
247+
}
248+
}
249+
}
250+
}
251+
{% endhighlight %}
252+
253+
{% highlight C# tabtitle="C# [Windows-specific]" %}
254+
//Opens a PowerPoint Presentation.
255+
IPresentation pptxDoc = Presentation.Open("Sample.pptx");
256+
//Initialize the conversion settings.
257+
PresentationToPdfConverterSettings pdfConverterSettings = new PresentationToPdfConverterSettings();
258+
//Enable the portable rendering.
259+
pdfConverterSettings.EnablePortableRendering = true;
260+
//Adds fallback font for basic symbols like bullet characters.
261+
pptxDoc.FontSettings.FallbackFonts.Add(ScriptType.Symbols, "Segoe UI Symbol, Arial Unicode MS, Wingdings");
262+
//Adds fallback font for mathematics symbols.
263+
pptxDoc.FontSettings.FallbackFonts.Add(ScriptType.Mathematics, "Cambria Math, Noto Sans Math, Segoe UI Symbol, Arial Unicode MS");
264+
//Adds fallback font for emojis.
265+
pptxDoc.FontSettings.FallbackFonts.Add(ScriptType.Emoji, "Segoe UI Emoji, Noto Color Emoji, Arial Unicode MS");
266+
//Converts the PowerPoint Presentation into PDF document with Portable rendering option.
267+
PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc);
268+
//Saves the PDF document.
269+
pdfDocument.Save("Sample.pdf");
270+
//Closes the PDF document.
271+
pdfDocument.Close(true);
272+
//Closes the Presentation.
273+
pptxDoc.Close();
274+
{% endhighlight %}
275+
276+
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
277+
'Opens a PowerPoint Presentation.
278+
Dim pptxDoc As IPresentation = Presentation.Open("Sample.pptx")
279+
'Initialize the conversion settings.
280+
Dim pdfConverterSettings As PresentationToPdfConverterSettings = new PresentationToPdfConverterSettings()
281+
'Enable the portable rendering.
282+
pdfConverterSettings.EnablePortableRendering = true
283+
'Adds fallback font for basic symbols Like bullet characters.
284+
pptxDoc.FontSettings.FallbackFonts.Add(ScriptType.Symbols, "Segoe UI Symbol, Arial Unicode MS, Wingdings")
285+
'Adds fallback font for mathematics symbols.
286+
pptxDoc.FontSettings.FallbackFonts.Add(ScriptType.Mathematics, "Cambria Math, Noto Sans Math, Segoe UI Symbol, Arial Unicode MS")
287+
'Adds fallback font for emojis.
288+
pptxDoc.FontSettings.FallbackFonts.Add(ScriptType.Emoji, "Segoe UI Emoji, Noto Color Emoji, Arial Unicode MS")
289+
'Converts the PowerPoint Presentation into PDF document.
290+
Dim pdfDocument As PdfDocument = PresentationToPdfConverter.Convert(pptxDoc)
291+
'Saves the PDF document.
292+
pdfDocument.Save("Sample.pdf")
293+
'Closes the PDF document.
294+
pdfDocument.Close(True)
295+
'Closes the Presentation.
296+
pptxDoc.Close()
297+
{% endhighlight %}
298+
299+
{% endtabs %}
300+
213301
## Fallback fonts for range of Unicode text
214302

215303
Users can set fallback fonts for specific Unicode range of text to be used in presentation to PDF conversion.
@@ -726,8 +814,9 @@ Malgun Gothic, Batang
726814
<tr>
727815
<td>Symbols</td>
728816
<td>0x2000 - 0x27BF<br>
729-
0x2300 - 0x23FF</td>
730-
<td>Segoe UI Symbol, Arial Unicode MS</td>
817+
0x2300 - 0x23FF<br>
818+
0xF000 - 0xF104</td>
819+
<td>Segoe UI Symbol, Arial Unicode MS, Wingdings</td>
731820
</tr>
732821
<tr>
733822
<td>Mathematics</td>

Document-Processing/Word/Conversions/Word-To-Image/NET/Fallback-fonts-word-to-image.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,49 @@ using (FileStream inputStream = new FileStream("Template.docx", FileMode.Open, F
111111

112112
You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main/Word-to-Image-conversion/Fallback-fonts-based-on-scripttype).
113113

114+
## Fallback Symbols based on script type
115+
116+
The following code example demonstrates how a user can add fallback fonts based on the script types, which DocIO considers internally when converting a Word document to image.
117+
118+
{% tabs %}
119+
120+
{% highlight c# tabtitle="C# [Cross-platform]" %}
121+
//Opens the file as stream.
122+
using (FileStream inputStream = new FileStream("Template.docx", FileMode.Open, FileAccess.Read))
123+
{
124+
//Loads an existing Word document file stream.
125+
using (WordDocument wordDocument = new WordDocument(inputStream, Syncfusion.DocIO.FormatType.Docx))
126+
{
127+
//Adds fallback font for basic symbols like bullet characters.
128+
wordDocument.FontSettings.FallbackFonts.Add(ScriptType.Symbols, "Segoe UI Symbol, Arial Unicode MS, Wingdings");
129+
//Adds fallback font for mathematics symbols.
130+
wordDocument.FontSettings.FallbackFonts.Add(ScriptType.Mathematics, "Cambria Math, Noto Sans Math, Segoe UI Symbol, Arial Unicode MS");
131+
//Adds fallback font for emojis.
132+
wordDocument.FontSettings.FallbackFonts.Add(ScriptType.Emoji, "Segoe UI Emoji, Noto Color Emoji, Arial Unicode MS");
133+
//Instantiation of DocIORenderer for Word to image conversion.
134+
using (DocIORenderer render = new DocIORenderer())
135+
{
136+
//Convert the entire Word document to images.
137+
Stream[] imageStreams = wordDocument.RenderAsImages();
138+
int i = 0;
139+
foreach (Stream stream in imageStreams)
140+
{
141+
//Reset the stream position.
142+
stream.Position = 0;
143+
//Save the stream as file.
144+
using (FileStream fileStreamOutput = File.Create("WordToImage_" + i + ".jpeg"))
145+
{
146+
stream.CopyTo(fileStreamOutput);
147+
}
148+
i++;
149+
}
150+
}
151+
}
152+
}
153+
{% endhighlight %}
154+
155+
{% endtabs %}
156+
114157
## Fallback fonts for range of Unicode text
115158

116159
Users can set fallback fonts for specific Unicode range of text to be used in Word to Image conversion.
@@ -518,8 +561,9 @@ Malgun Gothic, Batang
518561
<tr>
519562
<td>Symbols</td>
520563
<td>0x2000 - 0x27BF<br>
521-
0x2300 - 0x23FF</td>
522-
<td>Segoe UI Symbol, Arial Unicode MS</td>
564+
0x2300 - 0x23FF<br>
565+
0xF000 - 0xF104</td>
566+
<td>Segoe UI Symbol, Arial Unicode MS, Wingdings</td>
523567
</tr>
524568
<tr>
525569
<td>Mathematics</td>

Document-Processing/Word/Conversions/Word-To-PDF/NET/Fallback-fonts-word-to-pdf.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ using (FileStream inputStream = new FileStream("Template.docx", FileMode.Open, F
209209
using (WordDocument wordDocument = new WordDocument(inputStream, Syncfusion.DocIO.FormatType.Docx))
210210
{
211211
//Adds fallback font for basic symbols like bullet characters.
212-
wordDocument.FontSettings.FallbackFonts.Add(ScriptType.Symbols, "Segoe UI Symbol, Arial Unicode MS");
212+
wordDocument.FontSettings.FallbackFonts.Add(ScriptType.Symbols, "Segoe UI Symbol, Arial Unicode MS, Wingdings");
213213
//Adds fallback font for mathematics symbols.
214214
wordDocument.FontSettings.FallbackFonts.Add(ScriptType.Mathematics, "Cambria Math, Noto Sans Math, Segoe UI Symbol, Arial Unicode MS");
215215
//Adds fallback font for emojis.
@@ -236,7 +236,7 @@ using (FileStream inputStream = new FileStream("Template.docx", FileMode.Open, F
236236
using (WordDocument wordDocument = new WordDocument("Template.docx", Syncfusion.DocIO.FormatType.Docx))
237237
{
238238
//Adds fallback font for basic symbols like bullet characters.
239-
wordDocument.FontSettings.FallbackFonts.Add(ScriptType.Symbols, "Segoe UI Symbol, Arial Unicode MS");
239+
wordDocument.FontSettings.FallbackFonts.Add(ScriptType.Symbols, "Segoe UI Symbol, Arial Unicode MS, Wingdings");
240240
//Adds fallback font for mathematics symbols.
241241
wordDocument.FontSettings.FallbackFonts.Add(ScriptType.Mathematics, "Cambria Math, Noto Sans Math, Segoe UI Symbol, Arial Unicode MS");
242242
//Adds fallback font for emojis.
@@ -258,7 +258,7 @@ using (WordDocument wordDocument = new WordDocument("Template.docx", Syncfusion.
258258
'Loads an existing Word document.
259259
Using wordDocument As WordDocument = New WordDocument("Template.docx", FormatType.Docx)
260260
'Adds fallback font for basic symbols Like bullet characters.
261-
wordDocument.FontSettings.FallbackFonts.Add(ScriptType.Symbols, "Segoe UI Symbol, Arial Unicode MS")
261+
wordDocument.FontSettings.FallbackFonts.Add(ScriptType.Symbols, "Segoe UI Symbol, Arial Unicode MS, Wingdings")
262262
'Adds fallback font for mathematics symbols.
263263
wordDocument.FontSettings.FallbackFonts.Add(ScriptType.Mathematics, "Cambria Math, Noto Sans Math, Segoe UI Symbol, Arial Unicode MS")
264264
'Adds fallback font for emojis.
@@ -789,8 +789,9 @@ Malgun Gothic, Batang
789789
<tr>
790790
<td>Symbols</td>
791791
<td>0x2000 - 0x27BF<br>
792-
0x2300 - 0x23FF</td>
793-
<td>Segoe UI Symbol, Arial Unicode MS</td>
792+
0x2300 - 0x23FF<br>
793+
0xF000 - 0xF104</td>
794+
<td>Segoe UI Symbol, Arial Unicode MS, Wingdings</td>
794795
</tr>
795796
<tr>
796797
<td>Mathematics</td>

0 commit comments

Comments
 (0)