From 342d009fcefbc7a30966bd2ab9207af237781a4d Mon Sep 17 00:00:00 2001 From: Venkateshmuruganandam Date: Fri, 6 Oct 2023 18:21:24 +0530 Subject: [PATCH 01/10] Update --- File-Formats/DocIO/Working-with-Paragraph.md | 78 ++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/File-Formats/DocIO/Working-with-Paragraph.md b/File-Formats/DocIO/Working-with-Paragraph.md index dd974f9e5..511bbc3f5 100644 --- a/File-Formats/DocIO/Working-with-Paragraph.md +++ b/File-Formats/DocIO/Working-with-Paragraph.md @@ -1765,6 +1765,84 @@ By executing the above code example, it generates output Word document as follow ![Output of Word document with Image caption](WorkingWithImages_images/ImageCaption.png) +### Add SVG image + +You can append SVG image specified by the byte array to the end of a paragraph using [AppendPicture](https://help.syncfusion.com/cr/file-formats/Syncfusion.DocIO.DLS.IWParagraph.html#Syncfusion_DocIO_DLS_IWParagraph_AppendPicture_System_Byte___System_Byte___) API. + +The following code example shows how to add SVG image in Word document. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} + +///Creates a new Word document. +using (WordDocument document = new WordDocument()) +{ + //Add new section to the document + IWSection section = document.AddSection(); + //Add new paragraph to the section + IWParagraph firstParagraph = section.AddParagraph(); + //Get the image as byte array. + byte[] imageBytes = File.ReadAllBytes(Image.png); + //Get the SVG image as byte array. + byte[] svgData = File.ReadAllBytes(Image.svg"); + //Add SVG image to the paragraph + IWPicture picture = firstParagraph.AppendPicture(svgData, imageBytes); + //Set height and width for the image + picture.Height = 100; + picture.Width = 100; + //Saves the Word document to MemoryStream + MemoryStream stream = new MemoryStream(); + document.Save(stream, FormatType.Docx); +} + +{% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using (WordDocument document = new WordDocument()) +{ + //Add new section to the document. + IWSection section = document.AddSection(); + //Add new paragraph to the section. + IWParagraph firstParagraph = section.AddParagraph(); + //Get the image as byte array. + byte[] imageBytes = File.ReadAllBytes(Image.png); + //Get the SVG image as byte array. + byte[] svgData = File.ReadAllBytes(Image.svg"); + //Add SVG image to the paragraph. + IWPicture picture = firstParagraph.AppendPicture(svgData, imageBytes); + //Set height and width for the image. + picture.Height = 100; + picture.Width = 100; + //Saves the Word document. + document.Save("Sample.docx", FormatType.Docx); +} + +{% endhighlight %} +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + +Using document As New WordDocument() + ' Add new section to the document. + Dim section As IWSection = document.AddSection() + ' Add new paragraph to the section. + Dim firstParagraph As IWParagraph = section.AddParagraph() + ' Get the PNG image as a byte array. + Dim imageBytes As Byte() = File.ReadAllBytes("Image.png") + ' Get the SVG image as a byte array. + Dim svgData As Byte() = File.ReadAllBytes("Image.svg") + ' Add SVG image to the paragraph. + Dim picture As IWPicture = firstParagraph.AppendPicture(svgData, ImageType.Metafile, imageBytes) + ' Set height and width for the image. + picture.Height = 100 + picture.Width = 100 + ' Save the Word document. + document.Save("Sample.docx", FormatType.Docx) +End Using + +{% endhighlight %} +{% endtabs %} + +You can download a complete working sample from GitHub. + ## Working with lists Lists can organize and format the contents of a document in hierarchical way. There are nine levels in the list, starting from level 0 to level 8. DocIO supports both built-in list styles and custom list styles. The following are the types of list supported in DocIO: From 4e61f0ac220c849842605ce275d238805d1d92de Mon Sep 17 00:00:00 2001 From: Venkateshmuruganandam Date: Fri, 6 Oct 2023 18:27:43 +0530 Subject: [PATCH 02/10] Modified --- File-Formats/DocIO/Working-with-Paragraph.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/File-Formats/DocIO/Working-with-Paragraph.md b/File-Formats/DocIO/Working-with-Paragraph.md index 511bbc3f5..6bd0bc614 100644 --- a/File-Formats/DocIO/Working-with-Paragraph.md +++ b/File-Formats/DocIO/Working-with-Paragraph.md @@ -1774,23 +1774,23 @@ The following code example shows how to add SVG image in Word document. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} -///Creates a new Word document. +///Create a new Word document. using (WordDocument document = new WordDocument()) { - //Add new section to the document + //Add new section to the document. IWSection section = document.AddSection(); - //Add new paragraph to the section + //Add new paragraph to the section. IWParagraph firstParagraph = section.AddParagraph(); //Get the image as byte array. byte[] imageBytes = File.ReadAllBytes(Image.png); //Get the SVG image as byte array. byte[] svgData = File.ReadAllBytes(Image.svg"); - //Add SVG image to the paragraph + //Add SVG image to the paragraph. IWPicture picture = firstParagraph.AppendPicture(svgData, imageBytes); - //Set height and width for the image + //Set height and width for the image. picture.Height = 100; picture.Width = 100; - //Saves the Word document to MemoryStream + //Save the Word document to MemoryStream. MemoryStream stream = new MemoryStream(); document.Save(stream, FormatType.Docx); } @@ -1813,7 +1813,7 @@ using (WordDocument document = new WordDocument()) //Set height and width for the image. picture.Height = 100; picture.Width = 100; - //Saves the Word document. + //Save the Word document. document.Save("Sample.docx", FormatType.Docx); } From ac34376b4fe6b0c8d4f4131a41c740f663e6b341 Mon Sep 17 00:00:00 2001 From: Venkateshmuruganandam Date: Mon, 9 Oct 2023 11:18:10 +0530 Subject: [PATCH 03/10] Modified --- File-Formats/DocIO/Working-with-Paragraph.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/File-Formats/DocIO/Working-with-Paragraph.md b/File-Formats/DocIO/Working-with-Paragraph.md index 6bd0bc614..a158ae38e 100644 --- a/File-Formats/DocIO/Working-with-Paragraph.md +++ b/File-Formats/DocIO/Working-with-Paragraph.md @@ -1784,7 +1784,7 @@ using (WordDocument document = new WordDocument()) //Get the image as byte array. byte[] imageBytes = File.ReadAllBytes(Image.png); //Get the SVG image as byte array. - byte[] svgData = File.ReadAllBytes(Image.svg"); + byte[] svgData = File.ReadAllBytes(Buyers.svg"); //Add SVG image to the paragraph. IWPicture picture = firstParagraph.AppendPicture(svgData, imageBytes); //Set height and width for the image. @@ -1807,7 +1807,7 @@ using (WordDocument document = new WordDocument()) //Get the image as byte array. byte[] imageBytes = File.ReadAllBytes(Image.png); //Get the SVG image as byte array. - byte[] svgData = File.ReadAllBytes(Image.svg"); + byte[] svgData = File.ReadAllBytes(Buyers.svg"); //Add SVG image to the paragraph. IWPicture picture = firstParagraph.AppendPicture(svgData, imageBytes); //Set height and width for the image. @@ -1828,7 +1828,7 @@ Using document As New WordDocument() ' Get the PNG image as a byte array. Dim imageBytes As Byte() = File.ReadAllBytes("Image.png") ' Get the SVG image as a byte array. - Dim svgData As Byte() = File.ReadAllBytes("Image.svg") + Dim svgData As Byte() = File.ReadAllBytes("Buyers.svg") ' Add SVG image to the paragraph. Dim picture As IWPicture = firstParagraph.AppendPicture(svgData, ImageType.Metafile, imageBytes) ' Set height and width for the image. From a988fec74516652d8f6bcbb417d4a8461cc28324 Mon Sep 17 00:00:00 2001 From: Venkateshmuruganandam Date: Tue, 10 Oct 2023 11:39:24 +0530 Subject: [PATCH 04/10] Updated. --- File-Formats/DocIO/Working-with-Paragraph.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/File-Formats/DocIO/Working-with-Paragraph.md b/File-Formats/DocIO/Working-with-Paragraph.md index a158ae38e..5cac97b28 100644 --- a/File-Formats/DocIO/Working-with-Paragraph.md +++ b/File-Formats/DocIO/Working-with-Paragraph.md @@ -1782,7 +1782,7 @@ using (WordDocument document = new WordDocument()) //Add new paragraph to the section. IWParagraph firstParagraph = section.AddParagraph(); //Get the image as byte array. - byte[] imageBytes = File.ReadAllBytes(Image.png); + byte[] imageBytes = File.ReadAllBytes(Buyers.png); //Get the SVG image as byte array. byte[] svgData = File.ReadAllBytes(Buyers.svg"); //Add SVG image to the paragraph. @@ -1805,7 +1805,7 @@ using (WordDocument document = new WordDocument()) //Add new paragraph to the section. IWParagraph firstParagraph = section.AddParagraph(); //Get the image as byte array. - byte[] imageBytes = File.ReadAllBytes(Image.png); + byte[] imageBytes = File.ReadAllBytes(Buyers.png); //Get the SVG image as byte array. byte[] svgData = File.ReadAllBytes(Buyers.svg"); //Add SVG image to the paragraph. @@ -1826,7 +1826,7 @@ Using document As New WordDocument() ' Add new paragraph to the section. Dim firstParagraph As IWParagraph = section.AddParagraph() ' Get the PNG image as a byte array. - Dim imageBytes As Byte() = File.ReadAllBytes("Image.png") + Dim imageBytes As Byte() = File.ReadAllBytes("Buyers.png") ' Get the SVG image as a byte array. Dim svgData As Byte() = File.ReadAllBytes("Buyers.svg") ' Add SVG image to the paragraph. From e0b05836060623915f744627155c4766be1e55cc Mon Sep 17 00:00:00 2001 From: Venkateshmuruganandam Date: Wed, 11 Oct 2023 11:26:16 +0530 Subject: [PATCH 05/10] Content modified --- File-Formats/DocIO/Working-with-Paragraph.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/File-Formats/DocIO/Working-with-Paragraph.md b/File-Formats/DocIO/Working-with-Paragraph.md index 5cac97b28..544219d78 100644 --- a/File-Formats/DocIO/Working-with-Paragraph.md +++ b/File-Formats/DocIO/Working-with-Paragraph.md @@ -1767,7 +1767,9 @@ By executing the above code example, it generates output Word document as follow ### Add SVG image -You can append SVG image specified by the byte array to the end of a paragraph using [AppendPicture](https://help.syncfusion.com/cr/file-formats/Syncfusion.DocIO.DLS.IWParagraph.html#Syncfusion_DocIO_DLS_IWParagraph_AppendPicture_System_Byte___System_Byte___) API. +To add an SVG image to a paragraph in a Word document using Syncfusion DocIO, you can use the [AppendPicture](https://help.syncfusion.com/cr/file-formats/Syncfusion.DocIO.DLS.IWParagraph.html#Syncfusion_DocIO_DLS_IWParagraph_AppendPicture_System_Byte___System_Byte___) API. + +N> To preserve the SVG image in the Word document, you need to pass both the SVG image data and the equivalent bitmap image bytes to DocIO. The following code example shows how to add SVG image in Word document. @@ -1841,7 +1843,7 @@ End Using {% endhighlight %} {% endtabs %} -You can download a complete working sample from GitHub. +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main/Paragraphs/Add-svg-image/.NET). ## Working with lists From 21cdc7a8a507e848942040ff828fa87213ac782f Mon Sep 17 00:00:00 2001 From: Venkateshmuruganandam Date: Wed, 11 Oct 2023 14:42:12 +0530 Subject: [PATCH 06/10] PPTXtoPDF for all platform --- ...int-Presentation-to-PDF-in-ASP-NET-Core.md | 92 +++++ ...oint-Presentation-to-PDF-in-ASP-NET-MVC.md | 97 +++++ ...werPoint-Presentation-to-PDF-in-ASP-Net.md | 103 ++++++ ...owerPoint-Presentation-to-PDF-in-Blazor.md | 347 ++++++++++++++++++ ...PowerPoint-Presentation-to-PDF-in-Linux.md | 120 ++++++ ...-PowerPoint-Presentation-to-PDF-in-MAUI.md | 182 +++++++++ ...t-PowerPoint-Presentation-to-PDF-in-Mac.md | 78 ++++ ...t-PowerPoint-Presentation-to-PDF-in-UWP.md | 139 +++++++ ...t-PowerPoint-Presentation-to-PDF-in-WPF.md | 97 +++++ ...PowerPoint-Presentation-to-PDF-in-WinUI.md | 164 +++++++++ ...nt-Presentation-to-PDF-in-Windows-Forms.md | 99 +++++ ...werPoint-Presentation-to-PDF-in-Xamarin.md | 183 +++++++++ .../Nuget-Package-PPTXtoPDF.png | Bin 0 -> 51923 bytes .../Configuration_PPTXtoPDF.png | Bin 0 -> 15304 bytes .../Nuget_Package_PPTXtoPDF.png | Bin 0 -> 52323 bytes .../Nuget-Package-PPTXtoImage.png | Bin 0 -> 63247 bytes .../Nuget-Package-PPTXtoImage.png | Bin 0 -> 62402 bytes .../Nuget_Package_PPTXtoPDF.png | Bin 0 -> 40942 bytes .../Configuration_PPTXtoPDF.png | Bin 0 -> 17423 bytes .../Create-Project-WinUI-PPTXtoPDF.png | Bin 0 -> 33040 bytes .../Nuget-Package-PPTXtoImage.png | Bin 0 -> 53722 bytes .../Nuget-Package-PPTXtoPDF.png | Bin 0 -> 29653 bytes .../Nuget-Packge-PPTXtoPDF.png | Bin 0 -> 28075 bytes 23 files changed, 1701 insertions(+) create mode 100644 File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-ASP-NET-Core.md create mode 100644 File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-ASP-NET-MVC.md create mode 100644 File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-ASP-Net.md create mode 100644 File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-Blazor.md create mode 100644 File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-Linux.md create mode 100644 File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-MAUI.md create mode 100644 File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-Mac.md create mode 100644 File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-UWP.md create mode 100644 File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-WPF.md create mode 100644 File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-WinUI.md create mode 100644 File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-Windows-Forms.md create mode 100644 File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-Xamarin.md create mode 100644 File-Formats/Presentation/Workingwith_Blazor/Nuget-Package-PPTXtoPDF.png create mode 100644 File-Formats/Presentation/Workingwith_MAUI/Configuration_PPTXtoPDF.png create mode 100644 File-Formats/Presentation/Workingwith_MAUI/Nuget_Package_PPTXtoPDF.png create mode 100644 File-Formats/Presentation/Workingwith_MVC/Nuget-Package-PPTXtoImage.png create mode 100644 File-Formats/Presentation/Workingwith_WPF/Nuget-Package-PPTXtoImage.png create mode 100644 File-Formats/Presentation/Workingwith_WPF/Nuget_Package_PPTXtoPDF.png create mode 100644 File-Formats/Presentation/Workingwith_WinUI/Configuration_PPTXtoPDF.png create mode 100644 File-Formats/Presentation/Workingwith_WinUI/Create-Project-WinUI-PPTXtoPDF.png create mode 100644 File-Formats/Presentation/Workingwith_Windows/Nuget-Package-PPTXtoImage.png create mode 100644 File-Formats/Presentation/Workingwith_Windows/Nuget-Package-PPTXtoPDF.png create mode 100644 File-Formats/Presentation/Workingwith_Xamarin/Nuget-Packge-PPTXtoPDF.png diff --git a/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-ASP-NET-Core.md b/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-ASP-NET-Core.md new file mode 100644 index 000000000..efe1ffa89 --- /dev/null +++ b/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-ASP-NET-Core.md @@ -0,0 +1,92 @@ +--- +title: Convert PowerPoint to PDF in ASP.NET Core | Syncfusion +description: Convert PowerPoint to PDF in ASP.NET Core using .NET Core PowerPoint library (Presentation) without Microsoft PowerPoint or interop dependencies. +platform: file-formats +control: PowerPoint +documentation: UG +--- + +# Convert PowerPoint to PDF in ASP.NET Core + +Syncfusion PowerPoint is a [.NET Core PowerPoint library](https://www.syncfusion.com/document-processing/powerpoint-framework/net-core) used to create, read, edit and **convert PowerPoint documents** programmatically without **Microsoft PowerPoint** or interop dependencies. Using this library, you can **convert a PowerPoint to PDF in ASP.NET Core**. + +## Steps to convert PowerPoint to PDF programmatically + +Step 1: Create a new C# ASP.NET Core web application project. + +![Create ASP.NET Core Web project for PowerPoint file](Workingwith_Core/Create-Project-Open-and-Save.png) + +Step 2: Install the [Syncfusion.PresentationRenderer.Net.Core](https://www.nuget.org/packages/Syncfusion.PresentationRenderer.Net.Core) NuGet package as reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org/). + +![Install Syncfusion.PresentationRenderer.Net.Core Nuget Package](Azure_Images/App_Service_Linux/Nuget_Package_PowerPoint_Presentation_to_PDF.png) + +N> Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, you also have to add "Syncfusion.Licensing" assembly reference and include a license key in your projects. Please refer to this [link](https://help.syncfusion.com/common/essential-studio/licensing/overview) to know about registering Syncfusion license key in your application to use our components. +Step 3: Include the following namespaces in **HomeController.cs**. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +using Syncfusion.Presentation; +using Syncfusion.PresentationRenderer; +using Syncfusion.Pdf; + +{% endhighlight %} +{% endtabs %} + +Step 4: A default action method named Index will be present in **HomeController.cs**. Right click on Index method and select **Go To View** where you will be directed to its associated view page **Index.cshtml**. + +Step 5: Add a new button in the **Index.cshtml** as shown below. + +{% tabs %} +{% highlight HTML %} + +@{ + Html.BeginForm("ConvertPPTXtoPDF", "Home", FormMethod.Get); + { +
+ +
+ } + Html.EndForm(); +} + +{% endhighlight %} +{% endtabs %} + +Step 6: Add a new action method **ConvertPPTXtoPDF** in HomeController.cs and include the below code snippet to **convert a PowerPoint to PDF in ASP.NET Core**. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +//Open the file as Stream +using (FileStream fileStream = new FileStream(Path.GetFullPath("Data/Input.pptx"), FileMode.Open, FileAccess.Read)) +{ + //Open the existing PowerPoint presentation with loaded stream. + using (IPresentation pptxDoc = Presentation.Open(fileStream)) + { + //Convert the PowerPoint document to PDF document. + using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc)) + { + //Create the MemoryStream to save the converted PDF. + MemoryStream pdfStream = new MemoryStream(); + //Save the converted PDF document to MemoryStream. + pdfDocument.Save(pdfStream); + pdfStream.Position = 0; + //Download PDF document in the browser. + return File(pdfStream, "application/pdf", "Sample.pdf"); + } + } +} + +{% endhighlight %} +{% endtabs %} + +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/PPTX-to-PDF-conversion/Convert-PowerPoint-presentation-to-PDF/ASP.NET-Core). + +By executing the program, you will get the **PDF document** as follows. + +![PowerPoint to PDF in ASP.NET Core](PPTXtoPDF_images/Output_PowerPoint_Presentation_to-PDF.png) + +Click [here](https://www.syncfusion.com/document-processing/powerpoint-framework/net-core) to explore the rich set of Syncfusion PowerPoint Library (Presentation) features. + +An online sample link to [convert PowerPoint Presentation to PDF](https://ej2.syncfusion.com/aspnetcore/PowerPoint/PPTXToPDF#/material3) in ASP.NET Core. \ No newline at end of file diff --git a/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-ASP-NET-MVC.md b/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-ASP-NET-MVC.md new file mode 100644 index 000000000..7095d9fca --- /dev/null +++ b/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-ASP-NET-MVC.md @@ -0,0 +1,97 @@ +--- +title: Convert PowerPoint to PDF in ASP.NET MVC | Syncfusion +description: Convert PowerPoint to PDF in ASP.NET MVC using .NET PowerPoint library (Presentation) without Microsoft PowerPoint or interop dependencies. +platform: file-formats +control: PowerPoint +documentation: UG +--- + +# Convert PowerPoint to PDF in ASP.NET MVC + +Syncfusion PowerPoint is a [.NET PowerPoint library](https://www.syncfusion.com/document-processing/powerpoint-framework/net) used to create, read, edit and convert PowerPoint documents programmatically without **Microsoft PowerPoint** or interop dependencies. Using this library, you can **convert a PowerPoint to PDF in ASP.NET MVC**. + +## Steps to convert PowerPoint to PDF programmatically + +Step 1: Create a new C# ASP.NET MVC application project. + +![Create ASP.NET MVC project](Workingwith_MVC/Project-Open-and-Save.png) + +Step 2: Select the **MVC** template to create the project. + +![Select MVC template](Workingwith_MVC/MVC-Open-and-Save.png) + +Step 3: Install the [Syncfusion.PresentationToPdfConverter.AspNet.Mvc5](https://www.nuget.org/packages/Syncfusion.PresentationToPdfConverter.AspNet.Mvc5) NuGet package as reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org/). + +![Install Syncfusion.PresentationToPdfConverter.AspNet.Mvc5 Nuget Package](Workingwith_MVC/Nuget-Open-and-Save.png) + +N> Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, you also have to add "Syncfusion.Licensing" assembly reference and include a license key in your projects. Please refer to this [link](https://help.syncfusion.com/common/essential-studio/licensing/overview) to know about registering Syncfusion license key in your application to use our components. + +Step 4: Include the following namespace in that **HomeController.cs** file. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +using Syncfusion.Presentation; +using Syncfusion.PresentationToPdfConverter; +using Syncfusion.Pdf; + +{% endhighlight %} +{% endtabs %} + +Step 5: A default action method named **Index** will be present in HomeController.cs. Right click on this action method and select **Go To View** where you will be directed to its associated view page **Index.cshtml**. + +Step 6: Add a new button in the Index.cshtml as shown below. + +{% tabs %} +{% highlight HTML %} + +@{ + Html.BeginForm("ConvertPPTXtoPDF", "Home", FormMethod.Get); + { +
+
+ +
+ } + Html.EndForm(); +} + +{% endhighlight %} +{% endtabs %} + +Step 7: Add a new action method **ConvertPPTXtoPDF** in HomeController.cs and include the below code snippet to **convert a PowerPoint to PDF in ASP.NET MVC**. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +//Open the file as Stream +using (FileStream pathStream = new FileStream(Server.MapPath("~/App_Data/Input.pptx"), FileMode.Open, FileAccess.Read)) +{ + //Opens a PowerPoint Presentation + using (IPresentation pptxDoc = Presentation.Open(pathStream)) + { + //Converts the PowerPoint Presentation into PDF document + using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc)) + { + //Saves the PDF document to MemoryStream. + MemoryStream stream = new MemoryStream(); + pdfDocument.Save(stream); + stream.Position = 0; + //Download PDF document in the browser. + return File(stream, "application/pdf", "Sample.pdf"); + } + } +} + +{% endhighlight %} +{% endtabs %} + +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/PPTX-to-PDF-conversion/Convert-PowerPoint-presentation-to-PDF/ASP.NET-MVC) + +By executing the program, you will get the **PDF** as follows. + +![Converted PDF from PowerPoint in ASP.NET MVC](PPTXtoPDF_images/Output_PowerPoint_Presentation_to-PDF.png) + +Click [here](https://www.syncfusion.com/document-processing/powerpoint-framework/net) to explore the rich set of Syncfusion PowerPoint Library (Presentation) features. + +An online sample link to [convert PowerPoint Presentation to PDF](https://ej2.syncfusion.com/aspnetmvc/PowerPoint/PPTXToPdf#/material3) in ASP.NET MVC \ No newline at end of file diff --git a/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-ASP-Net.md b/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-ASP-Net.md new file mode 100644 index 000000000..ec8396e5c --- /dev/null +++ b/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-ASP-Net.md @@ -0,0 +1,103 @@ +--- +title: Convert PowerPoint to PDF in ASP.NET | Syncfusion +description: Convert PowerPoint to PDF in ASP.NET using .NET PowerPoint library (Presentation) without Microsoft PowerPoint or interop dependencies. +platform: file-formats +control: PowerPoint +documentation: UG +--- + +# Convert PowerPoint to PDF in ASP.NET + +Syncfusion PowerPoint is a [.NET PowerPoint library](https://www.syncfusion.com/document-processing/powerpoint-framework/net) used to create, read, edit and **convert PowerPoint documents** programmatically without **Microsoft PowerPoint** or interop dependencies. Using this library, you can **convert a PowerPoint to PDF in ASP.NET**. + +## Steps to convert PowerPoint to PDF programmatically + +Step 1: Create a new C# ASP.NET web application project. + +![Create ASP.NET Web project](Workingwith_Web/Project-Open-and-Save.png) + +Step 2: Select the **Empty** template to create the project. + +![Select Web Forms template](Workingwith_Web/Empty-Open-and-Save.png) + +Step 3: Install the [Syncfusion.PresentationRenderer.Net.Core](https://www.nuget.org/packages/Syncfusion.PresentationRenderer.Net.Core) NuGet package as reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org/). + +![Install Syncfusion.PresentationRenderer.Net.Core Nuget package](Azure_Images/App_Service_Linux/Nuget_Package_PowerPoint_Presentation_to_PDF.png) + +N> Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, you also have to add "Syncfusion.Licensing" assembly reference and include a license key in your projects. Please refer to this [link](https://help.syncfusion.com/common/essential-studio/licensing/overview) to know about registering Syncfusion license key in your application to use our components. + +Step 4: Include the following namespaces in **MainPage.aspx.cs**. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +using Syncfusion.Pdf; +using Syncfusion.Presentation; +using Syncfusion.PresentationRenderer; + +{% endhighlight %} +{% endtabs %} + +Step 5: Add a new button in the **MainPage.aspx** as shown below. + +{% tabs %} +{% highlight HTML %} + +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MainPage.aspx.cs" Inherits="Convert_PowerPoint_Presentation_to_PDF.WebForm1" %> + + + + + + +
+
+ +
+
+ + + +{% endhighlight %} +{% endtabs %} + +Step 6: Include the below code snippets in the click event of the button in **MainPage.aspx.cs**, to **convert a PowerPoint to PDF in ASP.NET**. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +string filePath = Server.MapPath("~/App_Data/Input.pptx"); +//Open the existing PowerPoint presentation. +using (IPresentation pptxDoc = Presentation.Open(filePath)) +{ + //Create the MemoryStream to save the converted PDF. + using (MemoryStream pdfStream = new MemoryStream()) + { + //Convert the PowerPoint document to PDF document. + using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc)) + { + //Save the converted PDF document to MemoryStream. + pdfDocument.Save(pdfStream); + pdfStream.Position = 0; + } + //Create the output PDF file stream + using (FileStream fileStreamOutput = File.Create(Server.MapPath("~/Sample.pdf"))) + { + //Copy the converted PDF stream into created output PDF stream + pdfStream.CopyTo(fileStreamOutput); + } + } +} + +{% endhighlight %} +{% endtabs %} + +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/PPTX-to-PDF-conversion/Convert-PowerPoint-presentation-to-PDF/ASP.NET). + +By executing the program, you will get the **PDF** as follows. + +![PowerPoint to PDF in ASP.NET](PPTXtoPDF_images/Output_PowerPoint_Presentation_to-PDF.png) + +Click [here](https://www.syncfusion.com/document-processing/powerpoint-framework/net) to explore the rich set of Syncfusion PowerPoint Library (Presentation) features. + +An online sample link to [convert PowerPoint Presentation to PDF](https://ej2.syncfusion.com/aspnetcore/PowerPoint/PPTXToPDF#/material3) in ASP.NET Core. \ No newline at end of file diff --git a/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-Blazor.md b/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-Blazor.md new file mode 100644 index 000000000..d70d965f2 --- /dev/null +++ b/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-Blazor.md @@ -0,0 +1,347 @@ +--- +title: Convert PowerPoint to PDF in Blazor | Syncfusion +description: Convert PowerPoint to PDF in Blazor using .NET Core PowerPoint library (Presentation) without Microsoft PowerPoint or interop dependencies. +platform: file-formats +control: PowerPoint +documentation: UG +--- + +# Convert PowerPoint to PDF in Blazor + +Syncfusion PowerPoint is a [.NET Core PowerPoint library](https://www.syncfusion.com/document-processing/powerpoint-framework/net-core) used to create, read, edit and convert PowerPoint documents programmatically without **Microsoft PowerPoint** or interop dependencies. Using this library, you can **convert a PowerPoint to PDF in Blazor**. + +## Server app + +Step 1: Create a new C# Blazor Server app project. Select Blazor App from the template and click the Next button. + +![Create ASP.NET Core Web application in Visual Studio for Blazor PowerPoint document ](Workingwith_Blazor/Create_project.png) + +Step 2: Now, the project configuration window will popup. Click Create button to create a new project with the required project name. + +![Create a project name for your new project](Azure_Images/App_Service_Linux/Configure-PowerPoint-Presentation-to-PDF.png) + +Step 3: Choose **Blazor Server App** and click Create button to create a new Blazor Server app for .NET Core 3.0.0-preview9. + +![Select .NET Core, ASP.NET Core 3.0 and Blazor server_side.](Workingwith_Blazor/Core_application_Server.png) + +Step 4: Install the [Syncfusion.PresentationRenderer.Net.Core](https://www.nuget.org/packages/Syncfusion.PresentationRenderer.Net.Core) NuGet package as reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org/). + +![Install Syncfusion.PresentationRenderer.Net.Core Nuget Package](Azure_Images/App_Service_Linux/Nuget_Package_PowerPoint_Presentation_to_PDF.png) + +N> Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, you also have to add "Syncfusion.Licensing" assembly reference and include a license key in your projects. Please refer to this [link](https://help.syncfusion.com/common/essential-studio/licensing/overview) to know about registering Syncfusion license key in your application to use our components. + +Step 5: Create a razor file with name as **Presentation** under **Pages** folder and include the following namespaces in the file. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +@page "/presentation" +@using System.IO; +@using Convert_PowerPoint_Presentation_to_PDF; +@inject Convert_PowerPoint_Presentation_to_PDF.Data.PresentationService service +@inject Microsoft.JSInterop.IJSRuntime JS + +{% endhighlight %} +{% endtabs %} + +Step 6: Add the following code to create a new button. + +{% tabs %} +{% highlight CSHTML %} + +

Syncfusion PowerPoint library (Essential Presentation)

+

Syncfusion Blazor PowerPoint library (Essential Presentation) used to create, read, edit, and convert PowerPoint files in your applications without Microsoft Office dependencies.

+ + +{% endhighlight %} +{% endtabs %} + +Step 7: Add the following code in **Presentation.razor** file to **convert PowerPoint to PDF** and download the **PDF document**. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +@code { + MemoryStream documentStream; + /// + /// Download the PDF document. + /// + protected async void ConvertPPTXtoPDF() + { + documentStream = service.ConvertPPTXtoPDF(); + await JS.SaveAs("Sample.pdf", documentStream.ToArray()); + } +} + +{% endhighlight %} +{% endtabs %} + +Step 8: Create a new cs file with name as **PowerPointService** under Data folder and include the following namespaces in the file. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +using Syncfusion.Presentation; +using Syncfusion.PresentationRenderer; +using Syncfusion.Pdf; + +{% endhighlight %} +{% endtabs %} + +Step 9: Create a new MemoryStream method with name as **ConvertPPTXtoPDF** in **PowerPointService** class and include the following code snippet to **convert a PowerPoint to PDF in Blazor Server app**. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +//Open the file as Stream +using (FileStream sourceStreamPath = new FileStream(@"wwwroot/Input.pptx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) +{ + //Open the existing PowerPoint presentation with loaded stream. + using (IPresentation pptxDoc = Presentation.Open(sourceStreamPath)) + { + //Convert the PowerPoint document to PDF document. + using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc)) + { + //Create the MemoryStream to save the converted PDF. + MemoryStream pdfStream = new MemoryStream(); + //Save the converted PDF document to MemoryStream. + pdfDocument.Save(pdfStream); + pdfStream.Position = 0; + + //Download PDF document in the browser. + return pdfStream; + } + } +} + +{% endhighlight %} +{% endtabs %} + +Step 10: Create a new class file in the project, with name as FileUtils and add the following code to invoke the JavaScript action to download the file in the browser. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +public static class FileUtils +{ + public static ValueTask SaveAs(this IJSRuntime js, string filename, byte[] data) + => js.InvokeAsync( + "saveAsFile", + filename, + Convert.ToBase64String(data)); +} + +{% endhighlight %} +{% endtabs %} + +Step 11: Add the following JavaScript function in the **_Host.cshtml** in the Pages folder. + +{% tabs %} +{% highlight HTML %} + + + +{% endhighlight %} +{% endtabs %} + +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/PPTX-to-PDF-conversion/Convert-PowerPoint-presentation-to-PDF/Blazor/Server-app). + +By executing the program, you will get the **PDF** as follows. + +![Converted PDF from PowerPoint in Blazor server app](PPTXtoPDF_images/Output_PowerPoint_Presentation_to-PDF.png) + +Click [here](https://www.syncfusion.com/document-processing/powerpoint-framework/blazor) to explore the rich set of Syncfusion PowerPoint Library (Presentation) features. + +An online sample link to [convert PowerPoint Presentation to PDF](https://blazor.syncfusion.com/demos/powerpoint/pptx-to-pdf?theme=fluent) in Blazor. + +## WASM app + +Step 1: Create a new C# Blazor WASM app project. Select Blazor App from the template and click the Next button. + +![Create ASP.NET Core Web application in Visual Studio for Blazor PowerPoint document](Workingwith_Blazor/Create_project.png) + +Step 2: Now, the project configuration window will popup. Click Create button to create a new project with the required project name. + +![Create a project name for your new project](Workingwith_Blazor/Configure_project.png) + +Step 3: Choose Blazor WebAssembly App and click Create button to create a new Blazor WASM app for .NET Core 3.0.0-preview9. + +![Select .NET Core, ASP.NET Core 3.0 and Blazor server_side.](Workingwith_Blazor/Core_application_Client.png) + +Step 4: Install the following **Nuget packages** in your application from [Nuget.org](https://www.nuget.org/). + +* [Syncfusion.PresentationRenderer.Net.Core](https://www.nuget.org/packages/Syncfusion.PresentationRenderer.Net.Core) +* [SkiaSharp.NativeAssets.WebAssembly v2.88.2](https://www.nuget.org/packages/SkiaSharp.NativeAssets.WebAssembly/2.88.2) + +![Install Syncfusion.PresentationRenderer.Net.Core Nuget Package](Azure_Images/App_Service_Linux/Nuget_Package_PowerPoint_Presentation_to_PDF.png) + +![Install SkiaSharp.NativeAssets.WebAssembly v2.88.2 Nuget Package](Workingwith_Blazor/Nuget-Package-PPTXtoPDF.png) + +N> Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, you also have to add "Syncfusion.Licensing" assembly reference and include a license key in your projects. Please refer to this [link](https://help.syncfusion.com/common/essential-studio/licensing/overview) to know about registering Syncfusion license key in your application to use our components. + +Step 5: Add the following ItemGroup tag in the **Blazor WASM csproj** file. + +{% tabs %} +{% highlight XAML %} + + + + + +{% endhighlight %} +{% endtabs %} + +N> Install this wasm-tools and wasm-tools-net6 by using the "dotnet workload install wasm-tools" and "dotnet workload install wasm-tools-net6" commands in your command prompt respectively if you are facing issues related to Skiasharp during runtime. + +Step 6: Enable the following property in the **Blazor WASM csproj** file. + +{% tabs %} +{% highlight XAML %} + + + true + + +{% endhighlight %} +{% endtabs %} + +Step 7: Create a razor file with name as ``Presentation`` under ``Pages`` folder and add the following namespaces in the file. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +@page "/presentation" +@inject Microsoft.JSInterop.IJSRuntime JS +@inject HttpClient client +@using System.IO +@using Syncfusion.Presentation +@using Syncfusion.PresentationRenderer +@using Syncfusion.Pdf + +{% endhighlight %} +{% endtabs %} + +Step 8: Add the following code to create a new button. + +{% tabs %} +{% highlight CSHTML %} + +

Syncfusion PowerPoint library (Essential Presentation)

+

Syncfusion Blazor PowerPoint library (Essential Presentation) used to create, read, edit, and convert PowerPoint files in your applications without Microsoft Office dependencies.

+ + +{% endhighlight %} +{% endtabs %} + +Step 9: Create a new async method with name as ``PPTXToPDF`` and include the following code snippet to **convert a PowerPoint to PDF in Blazor WASM app**. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +//Input data file is inside the wwwroot folder. +using (Stream inputStream = await client.GetStreamAsync("sample-data/Input.pptx")) +{ + //Open an existing PowerPoint Presentation file. + using (IPresentation pptxDoc = Syncfusion.Presentation.Presentation.Open(inputStream)) + { + //Convert PowerPoint into PDF document. + using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc)) + { + //Save the PDF document to MemoryStream. + using (MemoryStream outputStream = new MemoryStream()) + { + pdfDocument.Save(outputStream); + outputStream.Position = 0; + //Download PDF file in the browser. + await JS.SaveAs("Output.pdf", outputStream.ToArray()); + } + } + } +} + +{% endhighlight %} +{% endtabs %} + +Step 10: To download the PowerPoint document in browser, create a class file with FileUtils name and add the following code to invoke the JavaScript action to download the file in the browser. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +public static class FileUtils +{ + public static ValueTask SaveAs(this IJSRuntime js, string filename, byte[] data) + => js.InvokeAsync( + "saveAsFile", + filename, + Convert.ToBase64String(data)); +} + +{% endhighlight %} +{% endtabs %} + +Step 11: Add the following JavaScript function in the **Index.html** file present under ``wwwroot``. + +{% tabs %} +{% highlight HTML %} + + + +{% endhighlight %} +{% endtabs %} + +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/PPTX-to-PDF-conversion/Convert-PowerPoint-presentation-to-PDF/Blazor/WASM-app). + +By executing the program, you will get the **PDF** as follows. + +![Converted PDF from PowerPoint in Blazor WASM app](PPTXtoPDF_images/Output_PowerPoint_Presentation_to-PDF.png) + +N> Even though PowerPoint library works in WASM app, it is recommended to use server deployment. Since the WASM app deployment increases the application payload size. You can also explore our [Blazor PowerPoint library demo](https://blazor.syncfusion.com/demos/powerpoint/getting-started) that shows how to create and modify PowerPoint files from C# with just five lines of code. + +Click [here](https://www.syncfusion.com/document-processing/powerpoint-framework/blazor) to explore the rich set of Syncfusion PowerPoint Library (Presentation) features. + +An online sample link to [convert PowerPoint Presentation to PDF](https://blazor.syncfusion.com/demos/powerpoint/pptx-to-pdf?theme=fluent) in Blazor. diff --git a/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-Linux.md b/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-Linux.md new file mode 100644 index 000000000..699007189 --- /dev/null +++ b/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-Linux.md @@ -0,0 +1,120 @@ +--- +title: Convert PowerPoint to PDF in Linux | Syncfusion +description: Convert PowerPoint to PDF in Linux using .NET Core PowerPoint library (Presentation) without Microsoft PowerPoint or interop dependencies. +platform: file-formats +control: PowerPoint +documentation: UG +--- + +# Convert PowerPoint to PDF in Linux + +Syncfusion PowerPoint is a [.NET Core PowerPoint library](https://www.syncfusion.com/document-processing/powerpoint-framework/net-core) used to create, read, edit and **convert PowerPoint documents** programmatically without **Microsoft PowerPoint** or interop dependencies. Using this library, you can **convert a PowerPoint to PDF in .NET Core application on Linux**. + +## Steps to convert PowerPoint to PDF in .NET Core application on Linux + +Step 1: Execute the following command in **Linux terminal** to create a new .NET Core Console application. + +{% tabs %} +{% highlight KCONFIG %} + +dotnet new console + +{% endhighlight %} +{% endtabs %} + +![Create .NET Core console application on Linux](Workingwith_Linux/CreateCore.png) + +Step 2: Install the following **Nuget packages** in your application from [Nuget.org](https://www.nuget.org/) by execute the following command. + +* [Syncfusion.PresentationRenderer.Net.Core](https://www.nuget.org/packages/Syncfusion.PresentationRenderer.Net.Core) +* [SkiaSharp.NativeAssets.Linux v2.88.2](https://www.nuget.org/packages/SkiaSharp.NativeAssets.Linux/2.88.2) +* [HarfBuzzSharp.NativeAssets.Linux v2.8.2.2](https://www.nuget.org/packages/HarfBuzzSharp.NativeAssets.Linux/2.8.2.2) + +{% tabs %} +{% highlight KCONFIG %} + +dotnet add package Syncfusion.PresentationRenderer.Net.Core -v 22.1.38 -s https://www.nuget.org/ +dotnet add package SkiaSharp.NativeAssets.Linux -v 2.88.2 -s https://www.nuget.org/ +dotnet add package HarfBuzzSharp.NativeAssets.Linux -v 2.8.2.2 -s https://www.nuget.org/ + +{% endhighlight %} +{% endtabs %} + +N> Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, you also have to add "Syncfusion.Licensing" assembly reference and include a license key in your projects. Please refer to this [link](https://help.syncfusion.com/common/essential-studio/licensing/overview) to know about registering Syncfusion license key in your applications to use our components. + +Step 3: Add the following Namespaces in **Program.cs** file. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +using Syncfusion.Presentation; +using Syncfusion.PresentationRenderer; +using Syncfusion.Pdf; + +{% endhighlight %} +{% endtabs %} + +Step 4: Add the following code snippet in **Program.cs** file. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +//Open the file as Stream +using (FileStream fileStreamInput = new FileStream(Path.GetFullPath(@"../../../Data/Input.pptx"), FileMode.Open, FileAccess.Read)) +{ + //Open the existing PowerPoint presentation with loaded stream. + using (IPresentation pptxDoc = Presentation.Open(fileStreamInput)) + { + //Convert the PowerPoint document to PDF document. + using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc)) + { + //Save the converted PDF document to MemoryStream. + MemoryStream pdfStream = new MemoryStream(); + pdfDocument.Save(pdfStream); + pdfStream.Position = 0; + //Create FileStream to save the PDF file. + using (FileStream outputStream = new FileStream("Sample.pdf", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite)) + { + //Saves the PDF file. + pdfDocument.Save(outputStream); + } + } + } +} + +{% endhighlight %} +{% endtabs %} + +Step 5: Execute the following command to **restore** the NuGet packages. + +{% tabs %} +{% highlight KCONFIG %} + +dotnet restore + +{% endhighlight %} +{% endtabs %} + +![Restore the NuGet packages](Workingwith_Linux/Restore.png) + +Step 6: Execute the following command in **terminal** to **run the application**. + +{% tabs %} +{% highlight KCONFIG %} + +dotnet run + +{% endhighlight %} +{% endtabs %} + +![Run the Applcation](Workingwith_Linux/Run.png) + +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/PPTX-to-PDF-conversion/Convert-PowerPoint-presentation-to-PDF/Linux). + +By executing the program, you will get the **PDF** as follows. The output will be saved in **bin** foleder. + +![PowerPoint to PDF in Linux](PPTXtoPDF_images/Output_PowerPoint_Presentation_to-PDF.png) + +Click [here](https://www.syncfusion.com/document-processing/powerpoint-framework/net-core) to explore the rich set of Syncfusion PowerPoint Library (Presentation) features. + +An online sample link to [convert PowerPoint Presentation to PDF](https://ej2.syncfusion.com/aspnetcore/PowerPoint/PPTXToPDF#/material3) in ASP.NET Core. \ No newline at end of file diff --git a/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-MAUI.md b/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-MAUI.md new file mode 100644 index 000000000..74a2558b9 --- /dev/null +++ b/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-MAUI.md @@ -0,0 +1,182 @@ +--- +title: Convert PowerPoint to PDF in .NET MAUI | Syncfusion +description: Convert PowerPoint to PDF in .NET MAUI using .NET MAUI PowerPoint library (Presentation) without Microsoft PowerPoint or interop dependencies. +platform: file-formats +control: PowerPoint +documentation: UG +--- + +# Convert PowerPoint to PDF in .NET MAUI + +Syncfusion PowerPoint is a [.NET MAUI PowerPoint library](https://www.syncfusion.com/powerpoint-framework/maui/powerpoint-library) used to create, read, edit and convert PowerPoint documents programmatically without **Microsoft PowerPoint** or interop dependencies. Using this library, you can **convert a PowerPoint to PDF in .NET MAUI**. + +## Prerequisites +To create .NET Multi-platform App UI (.NET MAUI) apps, you need the latest versions of Visual Studio 2022 and .NET 6. For more details, refer [here](https://docs.microsoft.com/en-us/dotnet/maui/get-started/installation). + +## Steps to convert PowerPoint to PDF programmatically + +Step 1: Create a new C# .NET MAUI app. Select **.NET MAUI App (Preview)** from the template and click the **Next** button. + +![Create the MAUI app in Visual Studio](Workingwith_MAUI/Create_Project.png) + +Step 2: Enter the project name and click **Create**. + +![Create a project name for your new project](Workingwith_MAUI/Configuration_PPTXtoPDF.png) + +Step 3: Install the [Syncfusion.PresentationRenderer.NET](https://www.nuget.org/packages/Syncfusion.PresentationRenderer.NET) NuGet package as a reference to your project from [NuGet.org](https://www.nuget.org/). + +![Install Syncfusion.PresentationRenderer.NET NuGet package](Workingwith_MAUI/Nuget_Package_PPTXtoPDF.png) + +N> Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, you also have to add "Syncfusion.Licensing" assembly reference and include a license key in your projects. Please refer to this [link](https://help.syncfusion.com/common/essential-studio/licensing/overview) to know about registering Syncfusion license key in your application to use our components. + +Step 4: Add a new button to the **MainPage.xaml** as shown below. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + + + + + + + + + + +{% endhighlight %} +{% endtabs %} + +Step 4: Include the following namespaces in the **MainWindow.xaml.cs** file. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +using Syncfusion.Presentation; +using Syncfusion.PresentationToPdfConverter; +using Syncfusion.Pdf; + +{% endhighlight %} +{% endtabs %} + +Step 5: Add the following code in **btnConvert_Click** to **convert PowerPoint to PDF in WPF**. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +//Opens a PowerPoint Presentation +using (IPresentation pptxDoc = Presentation.Open(Path.GetFullPath(@"../../Data/Input.pptx"))) +{ + //Converts the PowerPoint Presentation into PDF document + using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc)) + { + //Saves the PDF document + pdfDocument.Save(Path.GetFullPath(@"../../Sample.pdf")); + } +} + +{% endhighlight %} +{% endtabs %} + +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/PPTX-to-PDF-conversion/Convert-PowerPoint-presentation-to-PDF/WPF). + +By executing the program, you will get the **PDF** as follows. + +![Converted PDF from PowerPoint in WPF](PPTXtoPDF_images/Output_PowerPoint_Presentation_to-PDF.png) + +Click [here](https://www.syncfusion.com/document-processing/powerpoint-framework/net) to explore the rich set of Syncfusion PowerPoint Library (Presentation) features. + +An online sample link to [convert PowerPoint Presentation to PDF](https://ej2.syncfusion.com/aspnetcore/PowerPoint/PPTXToPDF#/material3) in ASP.NET Core. diff --git a/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-WinUI.md b/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-WinUI.md new file mode 100644 index 000000000..c4b5354e8 --- /dev/null +++ b/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-WinUI.md @@ -0,0 +1,164 @@ +--- +title: Convert PowerPoint to PDF in WinUI | Syncfusion +description: Convert PowerPoint to PDF in WinUI using WinUI PowerPoint library (Presentation) without Microsoft PowerPoint or interop dependencies. +platform: file-formats +control: PowerPoint +documentation: UG +--- + +# Convert PowerPoint to PDF in WinUI + +Syncfusion PowerPoint is a [WinUI PowerPoint library](https://www.syncfusion.com/document-processing/powerpoint-framework/winui/powerpoint-library) used to create, read, edit and convert PowerPoint documents programmatically without **Microsoft PowerPoint** or interop dependencies. Using this library, you can **convert a PowerPoint to PDF in WinUI**. + +## Prerequisites +To use the WinUI 3 project templates, install the Windows App SDK extension for Visual Studio. For more details, refer [here](https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/set-up-your-development-environment?tabs=cs-vs-community%2Ccpp-vs-community%2Cvs-2022-17-1-a%2Cvs-2022-17-1-b). + +## WinUI Desktop app + +Step 1: Create a new C# WinUI Desktop app. Select Blank App, Packaged with WAP (WinUI 3 in Desktop) from the template and click the **Next** button. + +![Create the WinUI Desktop app in Visual Studio](Workingwith_WinUI/Create-Project-WinUI-PPTXtoPDF.png) + +Step 2: Enter the project name and click **Create**. + +![Create a project name for your new project](Workingwith_WinUI/Configuration_PPTXtoPDF.png) + +Step 3: Install the [Syncfusion.PresentationRenderer.NET](https://www.nuget.org/packages/Syncfusion.Presentation.NET) NuGet package as a reference to your project from [NuGet.org](https://www.nuget.org/). + +![Install Syncfusion.PresentationRenderer.NET NuGet package](Workingwith_MAUI/Nuget_Package_PPTXtoPDF.png) + +N> Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, you also have to add "Syncfusion.Licensing" assembly reference and include a license key in your projects. Please refer to this [link](https://help.syncfusion.com/common/essential-studio/licensing/overview) to know about registering a Syncfusion license key in your application to use our components. + +Step 4: Add a new button to the **MainWindow.xaml** as shown below. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + + + + + + + + +{% endhighlight %} +{% endtabs %} + +Step 5: Include the following namespaces in the **MainWindow.xaml.cs** file. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +using Syncfusion.Pdf; +using Syncfusion.Presentation; +using Syncfusion.PresentationRenderer; + +{% endhighlight %} +{% endtabs %} + +Step 6: Add a new action method **ConvertPPTXtoPDF** in MainWindow.xaml.cs and include the below code snippet to **convert a PowerPoint to PDF in WinUI**. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +//Loading an existing PowerPoint document +Assembly assembly = typeof(App).GetTypeInfo().Assembly; +//Open the existing PowerPoint presentation with loaded stream. +using (IPresentation pptxDoc = Presentation.Open(assembly.GetManifestResourceStream("Convert_PowerPoint_Presentation_to_PDF.Assets.Input.pptx"))) +{ + //Convert the PowerPoint document to PDF document. + using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc)) + { + //Save the converted PDF document to MemoryStream. + MemoryStream pdfStream = new MemoryStream(); + pdfDocument.Save(pdfStream); + //Save the stream as a PDF document file in the local machine. + SaveHelper.SaveAndLaunch("Sample.pdf", pdfStream); + } +} + +{% endhighlight %} +{% endtabs %} + +## Save PDF document in WinUI + +{% tabs %} + +{% highlight c# tabtitle="C#" %} + +public static async void SaveAndLaunch(string filename, MemoryStream stream) +{ + StorageFile storageFile; + string extension = Path.GetExtension(filename); + //Gets process windows handle to open the dialog in application process. + IntPtr windowHandle = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle; + if (!Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) + { + FileSavePicker savePicker = new(); + + if (extension == ".pdf") + { + savePicker.DefaultFileExtension = ".pdf"; + savePicker.SuggestedFileName = filename; + //Saves the file as Pdf file. + savePicker.FileTypeChoices.Add("PDF", new List() { ".pdf" }); + } + + WinRT.Interop.InitializeWithWindow.Initialize(savePicker, windowHandle); + storageFile = await savePicker.PickSaveFileAsync(); + } + else + { + StorageFolder local = ApplicationData.Current.LocalFolder; + storageFile = await local.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting); + } + if (storageFile != null) + { + using (IRandomAccessStream zipStream await storageFile.OpenAsync(FileAccessMode.ReadWrite)) + { + //Writes compressed data from memory to file. + using Stream outstream = zipStream.AsStreamForWrite(); + outstream.SetLength(0); + byte[] buffer = stream.ToArray(); + outstream.Write(buffer, 0, buffer.Length); + outstream.Flush(); + } + + //Creates message dialog box. + MessageDialog msgDialog = new("Do you want to view the Document?", "File has been converted successfully"); + UICommand yesCmd = new("Yes"); + msgDialog.Commands.Add(yesCmd); + UICommand noCmd = new("No"); + msgDialog.Commands.Add(noCmd); + + WinRT.Interop.InitializeWithWindow.Initialize(msgDialog, windowHandle); + + //Showing a dialog box. + IUICommand cmd = await msgDialog.ShowAsync(); + if (cmd.Label == yesCmd.Label) + { + //Launch the saved file. + await Windows.System.Launcher.LaunchFileAsync(storageFile); + } + } +} + +{% endhighlight %} +{% endtabs %} + +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/PPTX-to-PDF-conversion/Convert-PowerPoint-presentation-to-PDF/WinUI). + +By executing the program, you will get the **PDF document** as follows. + +![PowerPoint to PDF in WinUI Desktop](PPTXtoPDF_images/Output_PowerPoint_Presentation_to-PDF.png) + +Click [here](https://www.syncfusion.com/document-processing/powerpoint-framework/winui) to explore the rich set of Syncfusion PowerPoint Library (Presentation) features. + +An online sample link to [convert PowerPoint Presentation to PDF](https://ej2.syncfusion.com/aspnetcore/PowerPoint/PPTXToPDF#/material3) in ASP.NET Core. \ No newline at end of file diff --git a/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-Windows-Forms.md b/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-Windows-Forms.md new file mode 100644 index 000000000..149e6e7f5 --- /dev/null +++ b/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-Windows-Forms.md @@ -0,0 +1,99 @@ +--- +title: Convert PowerPoint to PDF in Windows Forms | Syncfusion +description: Convert PowerPoint to PDF in Windows Forms using .NET PowerPoint library (Presentation) without Microsoft PowerPoint or interop dependencies. +platform: file-formats +control: PowerPoint +documentation: UG +--- + +# Convert PowerPoint to PDF in Windows Forms + +Syncfusion PowerPoint is a [.NET PowerPoint library](https://www.syncfusion.com/document-processing/powerpoint-framework/net) used to create, read, edit and convert PowerPoint documents programmatically without **Microsoft PowerPoint** or interop dependencies. Using this library, you can **convert a PowerPoint to PDF in Windows Forms**. + +## Steps to convert PowerPoint to PDF programmatically + +Step 1: Create a new C# Windows Forms application project. + +![Create Windows Forms project](Workingwith_Windows/Project-Open-and-Save.png) + +Step 2: Install the [Syncfusion.PresentationToPdfConverter.WinForms](https://www.nuget.org/packages/Syncfusion.PresentationToPdfConverter.WinForms) NuGet package as reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org/). + +![Install Syncfusion.PresentationToPdfConverter.WinForms Nuget Package](Workingwith_Windows/Nuget-Package-PPTXtoPDF.png) + +N> Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, you also have to add "Syncfusion.Licensing" assembly reference and include a license key in your projects. Please refer to this [link](https://help.syncfusion.com/common/essential-studio/licensing/overview) to know about registering Syncfusion license key in your application to use our components. + +Step 3: Include the following namespaces in the **Form1.cs** file. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +using Syncfusion.Pdf; +using Syncfusion.Presentation; +using Syncfusion.PresentationToPdfConverter; + +{% endhighlight %} +{% endtabs %} + +Step 4: Add a new button in **Form1.Designer.cs** file. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +private Button btnCreate; +private Label label; +private void InitializeComponent() +{ + this.label = new System.Windows.Forms.Label(); + this.btnCreate = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label + // + this.label.Location = new System.Drawing.Point(0, 40); + this.label.Name = "label"; + this.label.Size = new System.Drawing.Size(426, 35); + this.label.TabIndex = 0; + this.label.Text = "Click the button to convert PowerPoint to PDF"; + this.label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // btnCreate + // + this.btnCreate.Location = new System.Drawing.Point(180, 110); + this.btnCreate.Name = "btnCreate"; + this.btnCreate.Size = new System.Drawing.Size(85, 36); + this.btnCreate.TabIndex = 1; + this.btnCreate.Text = "Convert PPTX to PDF"; + this.btnCreate.Click += new System.EventHandler(this.btnConvert_Click); +} + +{% endhighlight %} +{% endtabs %} + +Step 5: Add the following code in **btnConvert_Click** to **convert a PowerPoint to PDF in Windows Forms**. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + +//Opens a PowerPoint Presentation +using (IPresentation pptxDoc = Presentation.Open("Data/Input.pptx")) +{ + //Converts the PowerPoint Presentation into PDF document + using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc)) + { + //Saves the PDF document + pdfDocument.Save("Sample.pdf"); + } +} + +{% endhighlight %} +{% endtabs %} + +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/PPTX-to-PDF-conversion/Convert-PowerPoint-presentation-to-PDF/WindowForms). + +By executing the program, you will get the **PDF** as follows. + +![PowerPoint to PDF in Windows Forms](PPTXtoPDF_images/Output_PowerPoint_Presentation_to-PDF.png) + +Click [here](https://www.syncfusion.com/document-processing/powerpoint-framework/net) to explore the rich set of Syncfusion PowerPoint Library (Presentation) features. + +An online sample link to [convert PowerPoint Presentation to PDF](https://ej2.syncfusion.com/aspnetcore/PowerPoint/PPTXToPDF#/material3) in ASP.NET Core. \ No newline at end of file diff --git a/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-Xamarin.md b/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-Xamarin.md new file mode 100644 index 000000000..e35b5163b --- /dev/null +++ b/File-Formats/Presentation/Convert-PowerPoint-Presentation-to-PDF-in-Xamarin.md @@ -0,0 +1,183 @@ +--- +title: Convert PowerPoint to PDF in Xamarin | Syncfusion +description: Convert PowerPoint to PDF in Xamarin using Xamarin PowerPoint library (Presentation) without Microsoft PowerPoint or interop dependencies. +platform: file-formats +control: PowerPoint +documentation: UG +--- + +# Convert PowerPoint to PDF in Xamarin + +Syncfusion PowerPoint is a [Xamarin PowerPoint library](https://www.syncfusion.com/document-processing/powerpoint-framework/xamarin/powerpoint-library) used to create, read, edit and convert PowerPoint documents programmatically without **Microsoft PowerPoint** or interop dependencies. Using this library, you can **convert a PowerPoint to PDF in Xamarin**. + +## Steps to convert PowerPoint to PDF programmatically + +Step 1: Create a new C# **Xamarin.Forms** application project. + +![Create Xamarin project](Workingwith_Xamarin/Project-Open-and-Save.png) + +Step 2: Select a project template and required platforms to deploy the application. In this application the portable assemblies to be shared across multiple platforms, the .NET Standard code sharing strategy has been selected. For more details about code sharing refer [here](https://docs.microsoft.com/en-us/xamarin/cross-platform/app-fundamentals/code-sharing). + +![Create Xamarin CodeSharing Option](Workingwith_Xamarin/Template-Project-Open-and-Save.png) + +Step 3: Install [Syncfusion.Xamarin.PresentationRenderer](https://www.nuget.org/packages/Syncfusion.Xamarin.PresentationRenderer) NuGet package as a reference to the .NET Standard project in your Xamarin applications from [NuGet.org](https://www.nuget.org/). + +![Install Syncfusion.Xamarin.PresentationRenderer Nuget Package](Workingwith_Xamarin/Nuget-Packge-PPTXtoPDF.png) + +N> Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, you also have to add "Syncfusion.Licensing" assembly reference and include a license key in your projects. Please refer to this [link](https://help.syncfusion.com/common/essential-studio/licensing/overview) to know about registering Syncfusion license key in your application to use our components. + +Step 4: Add new Forms XAML page in portable project If there is no XAML page is defined in the App class. Otherwise proceed to the next step. +
    +
  • To add the new XAML page, right click on the project and select Add > New Item and add a Forms XAML Page from the list. Name it as MainXamlPage.
  • +
  • In App class of portable project (App.cs), replace the existing constructor of App class with the code snippet given below which invokes the MainXamlPage.
  • +
+ +{% tabs %} +{% highlight c# tabtitle="C#" %} + +public App() +{ + // The root page of your application + MainPage = new MainXamlPage(); +} + +{% endhighlight %} +{% endtabs %} + +Step 5: In the **MainXamlPage.xaml** add new button as shown below. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + + + + + +