From d0508dd80355abed9eff93eebb85d8817ec6f97f Mon Sep 17 00:00:00 2001 From: "anburasan.saravanan@syncfusion.com" Date: Thu, 18 Jan 2024 11:58:08 +0530 Subject: [PATCH 1/5] ES-818185-Add-cross-platform --- File-Formats/DocIO/Working-with-Charts.md | 51 +++++++- .../Presentation/Assemblies-Required.md | 2 + .../Presentation/Working-with-Charts.md | 122 ++++++++++++++++++ 3 files changed, 174 insertions(+), 1 deletion(-) diff --git a/File-Formats/DocIO/Working-with-Charts.md b/File-Formats/DocIO/Working-with-Charts.md index f5b08d62c..3cebecd5d 100644 --- a/File-Formats/DocIO/Working-with-Charts.md +++ b/File-Formats/DocIO/Working-with-Charts.md @@ -831,6 +831,55 @@ 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). + + + + + + + + + + + + + + + + + + + + + + + +
+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 +987,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..e3afec373 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 +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). + +
+ + + + + + + + + + + + + + + + + + + + + + +
+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,60 @@ 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(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. +//Creates a stream instance to store the image +MemoryStream stream = new MemoryStream(); +pptxDoc.PresentationRenderer.ConvertToImage(chart, stream); +//Closes the presentation +pptxDoc.Close(); +image.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 (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). From b51949f2bf153fe182c3112d82687dd25b0ca074 Mon Sep 17 00:00:00 2001 From: "anburasan.saravanan@syncfusion.com" Date: Thu, 18 Jan 2024 16:38:51 +0530 Subject: [PATCH 2/5] Modified the code snippet --- File-Formats/Presentation/Working-with-Charts.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/File-Formats/Presentation/Working-with-Charts.md b/File-Formats/Presentation/Working-with-Charts.md index e3afec373..ed5f83fbd 100644 --- a/File-Formats/Presentation/Working-with-Charts.md +++ b/File-Formats/Presentation/Working-with-Charts.md @@ -828,18 +828,17 @@ pptxDoc.Close() {% 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(inputStream); +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. +//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(); -image.Close(); inputStream.Close(); //Save the memory stream as file. Save(stream as MemoryStream, "ChartToImage.jpeg"); From c3ff4e5e82077b83a9a082e57656c4c17d034a6d Mon Sep 17 00:00:00 2001 From: "anburasan.saravanan@syncfusion.com" Date: Tue, 23 Jan 2024 16:00:05 +0530 Subject: [PATCH 3/5] Modified the code snippet --- File-Formats/Presentation/Working-with-Charts.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/File-Formats/Presentation/Working-with-Charts.md b/File-Formats/Presentation/Working-with-Charts.md index ed5f83fbd..fe2808521 100644 --- a/File-Formats/Presentation/Working-with-Charts.md +++ b/File-Formats/Presentation/Working-with-Charts.md @@ -842,7 +842,9 @@ pptxDoc.Close(); inputStream.Close(); //Save the memory stream as file. Save(stream as MemoryStream, "ChartToImage.jpeg"); -//Save the image. +/// +/// Save the image. +/// async void Save(MemoryStream streams, string filename) { streams.Position = 0; @@ -862,13 +864,13 @@ async void Save(MemoryStream streams, string filename) } if (stFile != null) { - using (IRandomAccessStream zipStream = await stFile.OpenAsync(FileAccessMode.ReadWrite)) + 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.Write(buffer, 0, buffer.Length); outstream.Flush(); } } From 2572709de42c201b63daf46b4c768afa3f68f02a Mon Sep 17 00:00:00 2001 From: "anburasan.saravanan@syncfusion.com" Date: Wed, 24 Jan 2024 09:39:03 +0530 Subject: [PATCH 4/5] Addressed the feedback --- File-Formats/Presentation/Working-with-Charts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/File-Formats/Presentation/Working-with-Charts.md b/File-Formats/Presentation/Working-with-Charts.md index fe2808521..ed76c5569 100644 --- a/File-Formats/Presentation/Working-with-Charts.md +++ b/File-Formats/Presentation/Working-with-Charts.md @@ -702,7 +702,7 @@ You can download a complete working sample from [GitHub](https://github.com/Sync ## Chart to Image conversion -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 PowerPoint slide as an image, refer the below dependencies in your application. From 49342edbc9e4ed1147a91b23f8823a9160daaa07 Mon Sep 17 00:00:00 2001 From: "anburasan.saravanan@syncfusion.com" Date: Wed, 24 Jan 2024 09:56:36 +0530 Subject: [PATCH 5/5] Addressed the feedback --- File-Formats/DocIO/Working-with-Charts.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/File-Formats/DocIO/Working-with-Charts.md b/File-Formats/DocIO/Working-with-Charts.md index 3cebecd5d..9458e64a8 100644 --- a/File-Formats/DocIO/Working-with-Charts.md +++ b/File-Formats/DocIO/Working-with-Charts.md @@ -831,6 +831,8 @@ 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. +