Hoe PowerPoint-presentatie te beveiligen in C# .NET

Een PowerPoint-presentatie kan op verschillende manieren worden beveiligd, bijvoorbeeld door een watermerk toe te passen, een handtekening toe te voegen of deze alleen-lezen te maken. In deze stapsgewijze handleiding laten we u zien hoe u PowerPoint-presentaties in C# .NET kunt beveiligen met een wachtwoord.

De Aspose.Slides for .NET API helpt u bij het beveiligen van PowerPoint presentation met C# zonder Microsoft Interop en vereist geen installatie van Microsoft PowerPoint.

Stappen om PowerPoint-presentatie in C# te beveiligen

  1. Gebruik Aspose.Slides for .NET NuGet-pakket
  2. Verwijzing naar Aspose.Slides en Aspose.Slides.Export naamruimten toevoegen
  3. Pas de Aspose-licentie toe met behulp van de SetLicense-methode
  4. Start een Presentation Class instantie
  5. Gebruik de versleutelingsmethode van de klasse ProtectionManager om de presentatie te beveiligen met een wachtwoord
  6. Sla ten slotte een met een wachtwoord beveiligde presentatie op met behulp van de methode Opslaan en de eigenschap SaveFormat.Pptx

Code om PowerPoint-presentatie in C# te beveiligen

using System;
//Install Aspose.Slides for .NET NuGet package
//and then utilize the following namespace to
//secure PowerPoint presentation
using Aspose.Slides;
using Aspose.Slides.Export;
namespace SecurePowerPointPresentation
{
class Program
{
static void Main(string[] args)
{
//Set Aspose license before securing PowerPoint presentation
//using Aspose.Slides for .NET
Aspose.Slides.License AsposeSlidesLicense = new Aspose.Slides.License();
AsposeSlidesLicense.SetLicense(@"c:\asposelicense\license.lic");
//create an object of Presentation class from Aspose.Slides namespace
//and provide the PowerPoint presentation to secure in the constructor
Presentation PowerPointPresentationToSecure = new Presentation("PowerPointPresentationToSecure.pptx");
//specify the password with which you want to secure the presentation
//this can be taken as input password from the user/admin etc.
String PasswordForPresentationSecurity = "8ma2bzdqgo";
//Encrypt or secure the presentation with the password using Encrypt method
//with the help of ProtectionManager
PowerPointPresentationToSecure.ProtectionManager.Encrypt(PasswordForPresentationSecurity);
//Finally, save the output presentation secured with password
//provide PPTX as save format
PowerPointPresentationToSecure.Save("PresentationSecuredWithPassword.pptx",Aspose.Slides.Export.SaveFormat.Pptx);
}
}
}

In de bovenstaande stappen en code heb je geleerd hoe je PPTX kunt beveiligen met C#. Deze API is niet beperkt tot wachtwoordbeveiliging, maar u kunt ook PPTX-bestanden in C# vergrendelen en ontgrendelen. Dit maakt het beveiligen van PPTX met C# een zeer eenvoudige en gemakkelijke taak met behulp van Aspose.Slides voor .NET.

 Nederlands