Come proteggere la presentazione di PowerPoint in C# .NET

Una presentazione PowerPoint può essere protetta in diversi modi, ad esempio applicando una filigrana, aggiungendo una firma o rendendola di sola lettura. In questa guida passo passo, ti mostreremo come proteggere la presentazione di PowerPoint in C# .NET usando una password.

Aspose.Slides for .NET API ti aiuta a proteggere PowerPoint presentation utilizzando C# senza la necessità di Microsoft Interop e non richiede l’installazione di Microsoft PowerPoint.

Passaggi per proteggere la presentazione di PowerPoint in C#

  1. Usa Aspose.Slides for .NET pacchetto NuGet
  2. Aggiungi riferimento agli spazi dei nomi Aspose.Slides e Aspose.Slides.Export
  3. Applicare la licenza Aspose con l’aiuto del metodo SetLicense
  4. Avvia un’istanza Presentation Class
  5. Utilizzare il metodo Encrypt della classe ProtectionManager per proteggere la presentazione con una password
  6. Infine, salva la presentazione protetta da password utilizzando il metodo Save e la proprietà SaveFormat.Pptx

Codice per proteggere la presentazione di PowerPoint in C#

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);
}
}
}

Nei passaggi e nel codice precedenti, hai appreso come proteggere PPTX utilizzando C#. Questa API non si limita alla protezione con password, ma puoi anche bloccare e sbloccare il file PPTX anche in C#. Ciò rende la protezione di PPTX utilizzando C# un’attività molto semplice e facile con l’aiuto di Aspose.Slides per .NET.

 Italiano