Your search did not match any results.

Document Protection

Backend API
<script src="~/DemosScripts/documentProtection.js"></script> @(Html.DevExpress().RichEdit("DemoRichEdit") .Open("Documents/DocumentProtection.docx") .Ribbon(r => r .Tabs(tabs => { tabs.Add("Review") .Items(items => { items.AddButton() .Text("Protect Document") .CommandName("protectDocument") .ShowText(true) .Icon("dxre-icon-ProtectDocument"); items.AddButton() .Text("Unprotect Document") .CommandName("unprotectDocument") .ShowText(true) .Icon("dxre-icon-UnprotectDocument"); items.AddSelectBox() .Width(280) .BeginGroup(true) .CommandName("user") .Value("lawyer@somecompany.com") .ShowClearButton(true) .Placeholder("Select user") .Items(i => i .Add("lawyer@somecompany.com", "lawyer@somecompany.com") .Add("projectmanager@somecompany.com", "projectmanager@somecompany.com") .Add("senior@somecompany.com", "senior@somecompany.com") .Add("novice@somecompany.com", "novice@somecompany.com") ); items.AddToggleButton(true) .BeginGroup(true) .CommandName("highlightRanges") .Text("Highlight Ranges"); items.AddColorBox() .CommandName("highlightColor") .Color("rgb(150, 200, 150)"); items.AddToggleButton(true) .BeginGroup(true) .CommandName("showBrackets") .Text("Show Brackets"); items.AddColorBox() .CommandName("bracketsColor") .Color("rgb(127, 127, 127)"); }); }) .ActiveTabIndex(7) ) .OnDocumentLoaded("onDocumentLoaded") .OnCustomCommandExecuted("onCustomCommandExecuted") .Authentication(a => a.UserName("lawyer@somecompany.com")) .Height(600) .ConfirmOnLosingChanges(c => c.Enabled(false)) )
using Microsoft.AspNetCore.Mvc; namespace AspNetCoreDemos.RichEdit { [Route("[action]")] public class RichEditController : Controller { public IActionResult DocumentProtection() { return View(); } } }
var protectDocumentCommandId = 'protectDocument'; var unprotectDocumentCommandId = 'unprotectDocument'; function onCustomCommandExecuted(s, e) { switch (e.commandName) { case protectDocumentCommandId: if (!s.document.isProtected) { const password = window.prompt('enter new password(optional):', ''); if (password != undefined && password != null) s.document.protect(password); } updateCommandsState(s); break; case unprotectDocumentCommandId: const password = window.prompt('enter password:', ''); if (password != undefined && password != null) { if (s.document.checkProtectionPassword(password)) s.document.unprotect(); else window.alert('The password incorrect!'); } updateCommandsState(s); break; case 'user': s.authenticationOptions.userName = e.parameter; break; case 'highlightRanges': s.rangePermissionOptions.highlightRanges = e.parameter; break; case 'showBrackets': s.rangePermissionOptions.showBrackets = e.parameter; break; case 'highlightColor': s.rangePermissionOptions.highlightColor = e.parameter; break; case 'bracketsColor': s.rangePermissionOptions.bracketsColor = e.parameter; break; } } function onDocumentLoaded(s, e) { updateCommandsState(s); } function updateCommandsState(rich) { rich.setCommandEnabled(protectDocumentCommandId, !rich.document.isProtected); rich.setCommandEnabled(unprotectDocumentCommandId, rich.document.isProtected); }