How to convert shapes into PDF in ASP.NET Core PowerPoint?
Syncfusion; Presentation is a .NET PowerPoint Library used to create, read, edit and convert PowerPoint files to PDF and images programmatically without Microsoft Office or interop dependencies. Using this library, you can convert PowerPoint shapes into PDF form fields using C#.
The PreserveFormFields setting allows you to preserve PowerPoint shapes as PDF form fields in the converted PDF document. Any shape with a name beginning with FormField_ will be converted into an editable text form field in the output PDF.
Steps to convert PowerPoint shapes into PDF form fields using C#:
-
Create new C# .NET Core console application.
-
Install the Syncfusion.PresentationRenderer.Net.Core NuGet package as a reference to your .NET Core application from NuGet.org.
Note:
-
The Syncfusion.Compression library is a dependent package of PresentationRenderer NuGet package. Once PresentationRenderer gets installed, the Compression library will automatically be installed as its dependent package.
-
Starting with v16.2.0.x, if you reference Syncfusion® assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion® license key in your application to use the components without trail message.
- Include the following namespace in the Program.cs file.
C#
using Syncfusion.Pdf;
using Syncfusion.Presentation;
using Syncfusion.PresentationRenderer;
- Use the following code snippet to convert PowerPoint shapes into PDF form fields.
C#
//Open the PowerPoint file stream.
using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
//Load an existing PowerPoint Presentation.
using (IPresentation pptxDoc = Presentation.Open(fileStream))
{
// Create new instance for PresentationToPdfConverterSettings
PresentationToPdfConverterSettings settings = new PresentationToPdfConverterSettings();
//Enables a flag to preserve form fields by converting shapes with names starting with 'FormField_' into editable text form fields in the PDF.
settings.PreserveFormFields = true;
//Convert PowerPoint into PDF document.
using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc))
{
//Save the PDF file to file system.
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/PPTXToPDF.pdf"), FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
{
pdfDocument.Save(outputStream);
}
}
}
}
You can download a complete working sample to convert PowerPoint shapes into PDF form fields from GitHub.
Take a moment to peruse the documentation, where you can find basic presentation document processing options along with features like clone and merge slides and encrypt and decrypt PowerPoint presentation and most importantly PDF and image conversion with code examples.
Explore more about the rich set of Syncfusion® PowerPoint Framework features.
Conclusion
I hope you enjoyed learning how to How to convert shapes into PDF in ASP.NET Core PowerPoint.
You can refer to our .NET PowerPoint Library feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!