PowerPointプレゼンテーションは、透かしを適用したり、署名を追加したり、読み取り専用にするなど、さまざまな方法で保護できます。このステップバイステップガイドでは、パスワードを使用してC#.NETでPowerPointプレゼンテーションを保護する方法を示します。
Aspose.Slides for .NET APIは、Microsoft Interopを必要とせずにC#を使用してPowerPoint presentationを保護するのに役立ち、MicrosoftPowerPointをインストールする必要はありません。
C#でPowerPointプレゼンテーションを保護する手順
- Aspose.Slides for .NETNuGetパッケージを使用する
- Aspose.SlidesおよびAspose.Slides.Export名前空間への参照を追加します
- SetLicenseメソッドを使用してAsposeライセンスを適用します
- Presentation Classインスタンスを開始します
- ProtectionManagerクラスのEncryptメソッドを利用して、パスワードでプレゼンテーションを保護します
- 最後に、SaveメソッドとSaveFormat.Pptxプロパティを使用して、パスワードで保護されたプレゼンテーションを保存します
C#でPowerPointプレゼンテーションを保護するためのコード
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); | |
} | |
} | |
} |
上記の手順とコードでは、C#を使用してPPTXを保護する方法を学習しました。このAPIはパスワード保護に限定されるものではなく、C#でPPTXファイルをロックおよびロック解除することもできます。これにより、Aspose.Slides for .NETを使用して、C#を使用したPPTXの保護が非常にシンプルで簡単なタスクになります。