Una presentación de PowerPoint se puede proteger de diferentes maneras, como aplicar una marca de agua, agregar una firma o hacer que sea de solo lectura. En esta guía paso a paso, le mostraremos cómo asegurar una presentación de PowerPoint en C# .NET usando una contraseña.
Aspose.Slides for .NET API lo ayuda a proteger PowerPoint presentation mediante C# sin necesidad de Microsoft Interop y no requiere la instalación de Microsoft PowerPoint.
Pasos para asegurar la presentación de PowerPoint en C#
- Usar Aspose.Slides for .NET paquete NuGet
- Agregue una referencia a los espacios de nombres Aspose.Slides y Aspose.Slides.Export
- Aplicar la licencia de Aspose con la ayuda del método SetLicense
- Iniciar una instancia de Presentation Class
- Utilice el método Encrypt de la clase ProtectionManager para proteger la presentación con una contraseña
- Finalmente, guarde la presentación protegida con contraseña usando el método Guardar y la propiedad SaveFormat.Pptx
Código para asegurar la presentación de PowerPoint en 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); | |
} | |
} | |
} |
En los pasos y el código anteriores, aprendió a proteger PPTX con C#. Esta API no se limita a la protección con contraseña, sino que también puede bloquear y desbloquear archivos PPTX en C#. Esto hace que asegurar PPTX usando C# sea una tarea muy simple y fácil con la ayuda de Aspose.Slides para .NET.