Spire.Presentation for .NET is designed to help .NET developers to create, access, copy and edit PowerPoint documents as well as protect PowerPoint documents. By using Spire.Presentation, developers can save PowerPoint files with write protection to allow the presentation to be read in read only mode. This section aims to provide guidance for how to save PowerPoint documents as ReadOnly using Spire.Presentation component.
To begin with, create or open a .NET class application in Visual Studio 2005 or above versions, add Spire.Presentation.dll to your .NET project assemblies. Then, you are able to set a PPT documents to ReadOnly using the sample demo C# code we have offered below.
Step 1: Create a PPT document
Presentation presentation = new Presentation();
Step 2: Load PPT file from disk
presentation.LoadFromFile(@"..\..\..\..\..\..\Data\sample.pptx");
Step 3: Protect the document with a string password
presentation.Protect("test");
Step 4: Save and preview
presentation.SaveToFile("readonly.pptx", FileFormat.Pptx2007); System.Diagnostics.Process.Start("readonly.pptx");
Screen effect:
Full code:
//create PPT document Presentation presentation = new Presentation(); //load PPT file from disk presentation.LoadFromFile(@"..\..\..\..\..\..\Data\sample.pptx"); //protect the document with password "test" presentation.Protect("test"); //save the document presentation.SaveToFile("readonly.ppt", FileFormat.PPT); System.Diagnostics.Process.Start("readonly.ppt");
'create PPT document Dim presentation As New Presentation() 'load PPT file from disk presentation.LoadFromFile("..\..\..\..\..\..\Data\sample.pptx") protect the document with password "test" presentation.Protect("test") 'save the document presentation.SaveToFile("readonly.ppt", FileFormat.PPT) System.Diagnostics.Process.Start("readonly.ppt")