@@ -118,6 +118,30 @@ The following code example demonstrates the conversion of an entire Presentation
118118
119119{% tabs %}
120120
121+ {% highlight c# tabtitle="C# [ Cross-platform] " %}
122+ using (FileStream fileStream = new FileStream("Sample.pptx", FileMode.Open, FileAccess.Read))
123+ {
124+ //Open the existing PowerPoint presentation.
125+ using (IPresentation pptxDoc = Presentation.Open(fileStream))
126+ {
127+ //Initialize the PresentationRenderer to perform image conversion.
128+ pptxDoc.PresentationRenderer = new PresentationRenderer();
129+ //Convert PowerPoint to image as stream.
130+ Stream[ ] images = pptxDoc.RenderAsImages(ExportImageFormat.Jpeg);
131+ //Saves the images to file system
132+ foreach (Stream stream in images)
133+ {
134+ //Create the output image file stream
135+ using (FileStream fileStreamOutput = File.Create("Output" + Guid.NewGuid().ToString() + ".jpg"))
136+ {
137+ //Copy the converted image stream into created output stream
138+ stream.CopyTo(fileStreamOutput);
139+ }
140+ }
141+ }
142+ }
143+ {% endhighlight %}
144+
121145{% highlight c# tabtitle="C# [ Windows-specific] " %}
122146//Loads the PowerPoint Presentation
123147IPresentation pptxDoc = Presentation.Open("Sample.pptx");
@@ -471,6 +495,40 @@ The following code sample demonstrates how to set a substitute font for a missin
471495
472496{% tabs %}
473497
498+ {% highlight c# tabtitle="C# [ Cross-platform] " %}
499+ //Load the PowerPoint presentation and convert to image
500+ using (IPresentation pptxDoc = Presentation.Open("Sample.pptx"))
501+ {
502+ //Initialize the PresentationRenderer to perform image conversion.
503+ pptxDoc.PresentationRenderer = new PresentationRenderer();
504+ // Initializes the 'SubstituteFont' event to set the replacement font
505+ pptxDoc.FontSettings.SubstituteFont += FontSettings_SubstituteFont;
506+ //Convert PowerPoint slide to image as stream.
507+ using (Stream stream = pptxDoc.Slides[ 0] .ConvertToImage(ExportImageFormat.Jpeg))
508+ {
509+ //Create the output image file stream
510+ using (FileStream fileStreamOutput = File.Create("Output.jpg"))
511+ {
512+ //Copy the converted image stream into created output stream
513+ stream.CopyTo(fileStreamOutput);
514+ }
515+ }
516+ }
517+ /// <summary >
518+ /// Sets the alternate font when a specified font is unavailable in the production environment
519+ /// </summary >
520+ /// <param name =" sender " >FontSettings type of the Presentation in which the specified font is used but unavailable in production environment. </param >
521+ /// <param name =" args " >Retrieves the unavailable font name and receives the substitute font name for conversion. </param >
522+ private static void FontSettings_SubstituteFont(object sender, SubstituteFontEventArgs args)
523+ {
524+ if (args.OriginalFontName == "Arial Unicode MS")
525+
526+ args.AlternateFontName = "Arial";
527+ else
528+ args.AlternateFontName = "Times New Roman";
529+ }
530+ {% endhighlight %}
531+
474532{% highlight c# tabtitle="C# [ Windows-specific] " %}
475533//Load the PowerPoint presentation and convert to image
476534using (IPresentation pptxDoc = Presentation.Open("Sample.pptx"))
0 commit comments