Jak zabezpečit prezentaci v PowerPointu v C# .NET

PowerPointovou prezentaci lze zabezpečit různými způsoby, například použitím vodoznaku, přidáním podpisu nebo nastavením pouze pro čtení. V tomto průvodci krok za krokem vám ukážeme, jak zabezpečit PowerPoint prezentaci v C# .NET pomocí hesla.

Aspose.Slides for .NET API vám pomáhá zabezpečit PowerPoint presentation pomocí C# bez potřeby Microsoft Interop a nevyžaduje instalaci Microsoft PowerPoint.

Kroky k bezpečné prezentaci PowerPoint v C#

  1. Použijte Aspose.Slides for .NET balíček NuGet
  2. Přidejte odkaz na jmenné prostory Aspose.Slides a Aspose.Slides.Export
  3. Použijte licenci Aspose pomocí metody SetLicense
  4. Spusťte instanci Presentation Class
  5. Použijte metodu Encrypt třídy ProtectionManager k zabezpečení prezentace heslem
  6. Nakonec uložte heslem chráněnou prezentaci pomocí metody Save a vlastnosti SaveFormat.Pptx

Kód pro zabezpečenou prezentaci PowerPoint v 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);
}
}
}

Ve výše uvedených krocích a kódu jste se naučili, jak zabezpečit PPTX pomocí C#. Toto API není omezeno na ochranu heslem, spíše můžete také zamknout a odemknout soubor PPTX v C#. Díky tomu je zabezpečení PPTX pomocí C# velmi jednoduchým a snadným úkolem s pomocí Aspose.Slides pro .NET.

 Čeština