We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Converting presentation to pdf

I am trying to convert a pptx into a pdf and thought I have followed the example found at https://help.syncfusion.com/file-formats/presentation/presentation-to-pdf


packagereference include="Syncfusion.PresentationToPDFConverter.WinForms" version="20.3.0.57">
packagereference include="Syncfusion.OfficeChartToImageConverter.WinForms" version="20.3.0.57">packagereference include="Syncfusion.Presentation.WinForms" version="20.3.0.57">

private static async Task Main(string[] args) {
var powerpointDoc = Presentation.Open("d:\\_tmp\\Output.pptx");
powerpointDoc.ChartToImageConverter = new ChartToImageConverter();
PdfDocument pdfDocument = PresentationToPdfConverter.Convert(powerpointDoc);
pdfDocument.Save("d:\\_tmp\\Output.pdf");
pdfDocument.Close(true);
powerpointDoc.Close();
}

I also had to install

But I am running into the following error. I cant see to fathom this one out, can anyone help?


2022-11-16_15-32-41.png


1 Reply

AA Akash Arul Syncfusion Team November 17, 2022 01:31 PM

From the given details, we have found that you have installed the Syncfusion.PresentationToPdfConverter.WinForms NuGet package in your Console Application targeting .NET 6.0.

To resolve the reported issue, we recommend you to uninstall all the Syncfusion NuGet packages from your application and install the Syncfusion.PresentationRenderer.Net.Core NuGet package in your Console Application targeting .NET 6.0 to perform Presentation to PDF conversion.

Platform(s)

NuGet Package

UWP, ASP.NET Core, Console Application (Targeting .NET Core) and Blazor

Syncfusion.PresentationRenderer.Net.Core

Windows Forms, Console Application (Targeting .NET Framework)

Syncfusion.PresentationToPDFConverter.WinForms


Please refer our UG documentation link to know what are the NuGet packages that need to be installed in application based on the platform to perform Presentation to PDF conversion,
https://help.syncfusion.com/file-formats/presentation/nuget-packages-required#converting-powerpoint-presentation-into-pdf

Note: For .NET Framework, creating an instance of the ChartToImageConverter class is mandatory to convert the charts present in the Presentation document to PDF. Otherwise, the charts are not preserved in the converted PDF. Whereas this is not necessary for .NET Core, as ChartToImageConverter is initialized internally in Syncfusion.PresentationRenderer assembly.

Please refer the below code snippet to convert Presentation document to PDF in .NET Core application.

//Load the PowerPoint presentation into stream.

using (FileStream fileStreamInput = new FileStream(@"Template.pptx", FileMode.Open, FileAccess.Read))

{

//Open the existing PowerPoint presentation with loaded stream.

using (IPresentation pptxDoc = Presentation.Open(fileStreamInput))

{

//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("Output.pdf"))

{

//Copy the converted PDF stream into created output PDF stream

pdfStream.CopyTo(fileStreamOutput);

}

}

}

}


Please refer our documentation links to know more about Presentation to PDF conversion,
https://help.syncfusion.com/file-formats/presentation/presentation-to-pdf

If the reported issue is still not resolved, please share us the following details to check issue from our side,

1.List of Syncfusion NuGet packages\assemblies used and its version,
2.TargetFrameWork and Platform of your application.


Loader.
Live Chat Icon For mobile
Up arrow icon