Restrict Editing

This kind of protection in DOC and DOCX formats is used to prevent unintentional changes to all or part of a document.

Since this protection does not encrypt the document, malicious applications may circumvent its use (it is not intended as a security feature and may be ignored).

Following sample shows how to start enforcing editing restriction protection and how to stop enforcing it.

Screenshot

Restrict Editing Screenshot

See the full code below, use RUN EXAMPLE to execute.

Upload your file (Drag files here)

1using System;
2using GemBox.Document;
3using GemBox.Document.Drawing;
4using System.IO;
5using System.Linq;
6
7class Sample
8{
9    [STAThread]
10    static void Main(string[] args)
11    {
12        // If using Professional version, put your serial key below.
13        ComponentInfo.SetLicense("FREE-LIMITED-KEY");
14
15        var document = DocumentModel.Load("Reading.docx");
16
17        // Disallow all editing in the document (document is read-only).
18        // Since password is not specified, all users can stop enforcing protection in MS Word.
19        document.Protection.StartEnforcingProtection(EditingRestrictionType.NoChanges, null);
20
21        document.Save("Restrict Editing.docx");
22    }
23}
1Imports System
2Imports GemBox.Document
3Imports GemBox.Document.Drawing
4Imports System.IO
5Imports System.Linq
6
7Module Samples
8
9    Sub Main()
10
11        ' If using Professional version, put your serial key below.
12        ComponentInfo.SetLicense("FREE-LIMITED-KEY")
13
14        Dim document = DocumentModel.Load("Reading.docx")
15
16        ' Disallow all editing in the document (document is read-only).
17        ' Since password is not specified, all users can stop enforcing protection in MS Word.
18        document.Protection.StartEnforcingProtection(EditingRestrictionType.NoChanges, Nothing)
19
20        document.Save("Restrict Editing.docx")
21
22    End Sub
23
24End Module

Check next sample or find out more about GemBox.Document and GemBox Software.