diff --git a/File-Formats/DocIO/Working-with-Charts.md b/File-Formats/DocIO/Working-with-Charts.md index f5b08d62c..9458e64a8 100644 --- a/File-Formats/DocIO/Working-with-Charts.md +++ b/File-Formats/DocIO/Working-with-Charts.md @@ -831,6 +831,57 @@ You can download a complete working sample from [GitHub](https://github.com/Sync You can convert the chart in Word document as image using the [SaveAsImage](https://help.syncfusion.com/cr/file-formats/Syncfusion.OfficeChartToImageConverter.ChartToImageConverter.html#Syncfusion_OfficeChartToImageConverter_ChartToImageConverter_SaveAsImage_Syncfusion_OfficeChart_IOfficeChart_System_IO_Stream_) method in [ChartToImageConverter](https://help.syncfusion.com/cr/file-formats/Syncfusion.DocIO.DLS.WordDocument.html#Syncfusion_DocIO_DLS_WordDocument_ChartToImageConverter). +To convert chart in Word document as an image, refer the below dependencies in your application. + + + + + + + + + + + + + + + + + + + + + + + + +
+Platform(s) + +NuGets for Chart to Image + +Assemblies for Chart to image +
+Cross-platform, Xamarin + +{{'[Word to PDF NuGets](https://help.syncfusion.com/file-formats/docio/nuget-packages-required#converting-word-document-to-pdf)' |  markdownify }} + +{{'[Word to PDF assemblies](https://help.syncfusion.com/file-formats/docio/assemblies-required#converting-word-document-to-pdf)' |  markdownify }} +
+Windows-specific + +{{'[Word to PDF NuGets](https://help.syncfusion.com/file-formats/docio/nuget-packages-required#converting-word-document-to-pdf)' |  markdownify }}
{{'[Chart conversion NuGets](https://help.syncfusion.com/file-formats/docio/nuget-packages-required#converting-charts)' |  markdownify }} +
+{{'[Word to PDF assemblies](https://help.syncfusion.com/file-formats/docio/assemblies-required#converting-word-document-to-pdf)' |  markdownify }}
{{'[Chart conversion assemblies](https://help.syncfusion.com/file-formats/docio/assemblies-required#converting-charts)' |  markdownify }} +
+UWP + +{{'[Word to PDF NuGets of cross platform](https://help.syncfusion.com/file-formats/docio/nuget-packages-required#converting-word-document-to-pdf)' |  markdownify }} + +{{'[Word to PDF assemblies of cross platform](https://help.syncfusion.com/file-formats/docio/assemblies-required#converting-word-document-to-pdf)' |  markdownify }} +
+ The following code example shows how to convert chart in the Word document as image. {% tabs %} @@ -938,7 +989,7 @@ using (Stream docStream = typeof(App).GetTypeInfo().Assembly.GetManifestResource {% endhighlight %} {% highlight c# tabtitle="UWP" %} -//DocIO supports chart to image conversion in Windows Forms, WPF, ASP.NET and ASP.NET MVC platform alone. You can convert chart as images in UWP using DocIORenderer. +// You can convert a chart to images in UWP using DocIORenderer, by using cross-platform NuGets or assemblies in a UWP application. //Open the file as Stream. using (Stream docStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("Sample.Assets.TemplateWithChart.docx")) { diff --git a/File-Formats/Presentation/Assemblies-Required.md b/File-Formats/Presentation/Assemblies-Required.md index 2c7225e80..5b07cd692 100644 --- a/File-Formats/Presentation/Assemblies-Required.md +++ b/File-Formats/Presentation/Assemblies-Required.md @@ -101,6 +101,8 @@ Syncfusion.OfficeChart.NET
Syncfusion.PresentationRenderer.NET
Syncfusio +## Converting Charts + The following assemblies are required to be referred in addition to the above mentioned assemblies for converting the chart present in the PowerPoint Presentation into PDF. diff --git a/File-Formats/Presentation/Working-with-Charts.md b/File-Formats/Presentation/Working-with-Charts.md index 5868774f9..ed76c5569 100644 --- a/File-Formats/Presentation/Working-with-Charts.md +++ b/File-Formats/Presentation/Working-with-Charts.md @@ -702,12 +702,80 @@ You can download a complete working sample from [GitHub](https://github.com/Sync ## Chart to Image conversion +To convert chart in PowerPoint slide as an image, refer the below dependencies in your application. + +
+ + + + + + + + + + + + + + + + + + + + + + +
+Platform(s) + +NuGets for Chart to Image + +Assemblies for Chart to image +
+Cross-platform, Xamarin + +{{'[PPTX to PDF NuGets](https://help.syncfusion.com/file-formats/presentation/nuget-packages-required#converting-powerpoint-presentation-into-pdf)' |  markdownify }} + +{{'[PPTX to PDF assemblies](https://help.syncfusion.com/file-formats/presentation/assemblies-required#converting-powerpoint-presentation-to-pdf)' |  markdownify }} +
+Windows-specific + +{{'[PPTX to PDF NuGets](https://help.syncfusion.com/file-formats/presentation/nuget-packages-required#converting-powerpoint-presentation-into-pdf)' |  markdownify }}
{{'[Chart conversion NuGets](https://help.syncfusion.com/file-formats/presentation/nuget-packages-required#converting-charts-in-presentation)' |  markdownify }} +
+{{'[PPTX to PDF assemblies](https://help.syncfusion.com/file-formats/presentation/assemblies-required#converting-powerpoint-presentation-to-pdf)' |  markdownify }}
{{'[Chart conversion assemblies](https://help.syncfusion.com/file-formats/presentation/nuget-packages-required#converting-charts-in-presentation)' |  markdownify }} +
+UWP + +{{'[PPTX to PDF NuGets of cross platform](https://help.syncfusion.com/file-formats/presentation/nuget-packages-required#converting-powerpoint-presentation-into-pdf)' |  markdownify }} + +{{'[PPTX to PDF assemblies of cross platform](https://help.syncfusion.com/file-formats/presentation/assemblies-required#converting-powerpoint-presentation-to-pdf)' |  markdownify }} +
+ The following code example demonstrates how to convert the charts in a Presentation slide to image. T> You can specify the quality of the converted charts by setting the scaling mode. For more details on how to set the scaling mode, see [Converting PowerPoint presentation to Images](/file-formats/presentation/getting-started#converting-powerpoint-presentation-to-images) {% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} +//Loads or open an PowerPoint Presentation +FileStream inputStream = new FileStream("../../../Data/Sample.pptx", FileMode.Open); +IPresentation pptxDoc = Presentation.Open(inputStream); +//Initialize the PresentationRenderer +pptxDoc.PresentationRenderer = new PresentationRenderer(); +//Gets the first instance of chart from slide +IPresentationChart chart = pptxDoc.Slides[0].Charts[0]; +//Converts the chart to image. +Stream image = new FileStream("../../../Data/ChartToImage.jpg", FileMode.Create, FileAccess.ReadWrite); +pptxDoc.PresentationRenderer.ConvertToImage(chart, image); +//Closes the presentation +pptxDoc.Close(); +image.Close(); +inputStream.Close(); +{% endhighlight %} + {% highlight c# tabtitle="C# [Windows-specific]" %} //Opens the Presentation IPresentation pptxDoc = Presentation.Open("Sample.pptx"); @@ -757,6 +825,61 @@ stream.Close() pptxDoc.Close() {% endhighlight %} +{% highlight c# tabtitle="UWP" %} +//You can convert a chart to images in UWP using PresentationRenderer, by using cross-platform NuGets or assemblies in a UWP application. +//Loads or open an PowerPoint Presentation +IPresentation pptxDoc = Presentation.Open(assembly.GetManifestResourceStream("Convert_chart_to_image.Assets.Template.pptx")); +//Initialize the PresentationRenderer +pptxDoc.PresentationRenderer = new PresentationRenderer(); +//Gets the first instance of chart from slide +IPresentationChart chart = pptxDoc.Slides[0].Charts[0]; +//Converts the chart to image. +//Creates a stream instance to store the image +MemoryStream stream = new MemoryStream(); +pptxDoc.PresentationRenderer.ConvertToImage(chart, stream); +//Closes the presentation +pptxDoc.Close(); +inputStream.Close(); +//Save the memory stream as file. +Save(stream as MemoryStream, "ChartToImage.jpeg"); +/// +/// Save the image. +/// +async void Save(MemoryStream streams, string filename) +{ + streams.Position = 0; + StorageFile stFile; + if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))) + { + FileSavePicker savePicker = new FileSavePicker(); + savePicker.DefaultFileExtension = ".jpeg"; + savePicker.SuggestedFileName = filename; + savePicker.FileTypeChoices.Add("Image", new List() { ".jpeg" }); + stFile = await savePicker.PickSaveFileAsync(); + } + else + { + StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder; + stFile = await local.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting); + } + if (stFile != null) + { + using (Windows.Storage.Streams.IRandomAccessStream zipStream = await stFile.OpenAsync(FileAccessMode.ReadWrite)) + { + //Write compressed data from memory to file. + using (Stream outstream = zipStream.AsStreamForWrite()) + { + byte[] buffer = streams.ToArray(); + outstream.Write(buffer, 0, buffer.Length); + outstream.Flush(); + } + } + } + //Launch the saved image file. + await Windows.System.Launcher.LaunchFileAsync(stFile); +} +{% endhighlight %} + {% endtabs %} You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Charts/Convert-chart-to-image).