.NET PowerPoint Examples
Protect PowerPoint Files Using Syncfusion .NET PowerPoint Library
Protect sensitive information and control document access easily. The Syncfusion® .NET PowerPoint Library lets you programmatically encrypt and decrypt presentations in C# without relying on Microsoft PowerPoint or interop dependencies.
Watch this video to learn how to encrypt and decrypt PowerPoint files using the Syncfusion .NET PowerPoint library.
Encrypt and decrypt PowerPoint using C#
Learn how to encrypt and decrypt PowerPoint presentations programmatically using C# with the Syncfusion .NET PowerPoint library. This guide demonstrates applying password protection to secure presentations and removing encryption to control document access effectively.
Step 1: Create a new project
Start by creating a new C# Console Application project.
Step 2: Install the NuGet package
Add the Syncfusion.Presentation.Net.Core package to your project from NuGet.org.
Step 3: Add required namespaces to encrypt and decrypt PowerPoint
Add the following namespaces to your Program.cs file:
using Syncfusion.Presentation;Step 4: Open a PowerPoint file for encryption
Open an existing PowerPoint presentation from a file stream.
//Open an existing presentation
using FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read);
using IPresentation presentation = Presentation.Open(inputStream);Step 5: Encrypt the PowerPoint file
Apply password-based encryption to protect the presentation.
//Encrypt the presentation with a password
presentation.Encrypt("syncfusion");Step 6: Save the encrypted PowerPoint file
Save the encrypted presentation to a file stream.
using FileStream outputStream = new(Path.GetFullPath(@"Output/Result.pptx"), FileMode.Create, FileAccess.ReadWrite);
presentation.Save(outputStream);Step 7: Open an encrypted PowerPoint file
Open an encrypted PowerPoint presentation by providing the password.
//Load or open an PowerPoint Presentation
using FileStream inputStream = new(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
//Open an existing Presentation from file system and it can be decrypted by using the provided password
using IPresentation presentation = Presentation.Open(inputStream, "syncfusion");Step 8: Decrypt the PowerPoint file
Remove the encryption from the presentation.
//Decrypt the document
presentation.RemoveEncryption();Step 9: Save the decrypted PowerPoint file
Save the decrypted presentation to a file stream.
using FileStream outputStream = new(Path.GetFullPath(@"Output/Result.pptx"), FileMode.Create, FileAccess.ReadWrite);
presentation.Save(outputStream);GitHub project
NuGet installation
Get started quickly by downloading the installer and checking license information on the Downloads page.
Table of contents
Explore these resources for comprehensive guides, knowledge base articles, insightful blogs, and ebooks.
Learning
Technical Support
