Set modify protection for PPTX files in C# and VB.NET

The following example shows how you protect a PPTX presentation against modification with a password, with the GemBox.Presentation library in C# and VB.NET.

using GemBox.Presentation;

// If using the Professional version, put your serial key below.
ComponentInfo.SetLicense("FREE-LIMITED-KEY");

var presentation = new PresentationDocument();

var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

slide.Content.AddTextBox(ShapeGeometryType.Rectangle, 2, 2, 20, 2, LengthUnit.Centimeter)
.AddParagraph()
.AddRun("This presentation has been opened in read-only mode, no changes can be made to a slide.");

// ModifyProtection class is supported only for PPTX file format.
presentation.ModifyProtection.SetPassword("1234");

presentation.Save("PPTX Modify Protection.pptx");
Imports GemBox.Presentation

Module Program

Sub Main()

' If using the Professional version, put your serial key below.
ComponentInfo.SetLicense("FREE-LIMITED-KEY")

Dim presentation = New PresentationDocument

Dim slide = presentation.Slides.AddNew(SlideLayoutType.Custom)

slide.Content.AddTextBox(ShapeGeometryType.Rectangle, 2, 2, 20, 2, LengthUnit.Centimeter) _
.AddParagraph() _
.AddRun("This presentation has been opened in read-only mode, no changes can be made to a slide.")

' ModifyProtection class is supported only for PPTX file format.
presentation.ModifyProtection.SetPassword("1234")

presentation.Save("PPTX Modify Protection.pptx")
End Sub
End Module
PPTX modify protection set with GemBox.Presentation
Screenshot of PPTX modify protection set with GemBox.Presentation

Next steps

GemBox.Presentation is a .NET library that enables you to read, write, edit, convert, and print presentation files from your .NET applications using one simple API.