GemBox.Document
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    DocumentProtection Class

    Namespace:
    GemBox.Document
    Assembly:
    GemBox.Document.dll

    Represents a set of document protection restrictions which have been applied to the contents of a document.

    • C#
    • VB.NET
    public sealed class DocumentProtection
    Public NotInheritable Class DocumentProtection
    Inheritance:
    System.Object
    DocumentProtection
    Remarks

    Document protection is a set of restrictions 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. This protection is not intended as a security feature and may be ignored.

    Properties

    EditingRestriction

    Gets or sets the set of editing restrictions which shall be enforced on a given document.

    • C#
    • VB.NET
    public EditingRestrictionType EditingRestriction { get; set; }
    Public Property EditingRestriction As EditingRestrictionType
    Property Value
    EditingRestrictionType

    The set of editing restrictions which shall be enforced on a given document.

    EnforceEditingRestriction

    Gets or sets a value indicating whether document protection settings shall be enforced for a given document.

    • C#
    • VB.NET
    public bool EnforceEditingRestriction { get; set; }
    Public Property EnforceEditingRestriction As Boolean
    Property Value
    System.Boolean

    true if document protection settings shall be enforced; otherwise, false.

    HasPassword

    Gets a value indicating whether document protection has password.

    • C#
    • VB.NET
    public bool HasPassword { get; }
    Public ReadOnly Property HasPassword As Boolean
    Property Value
    System.Boolean

    true if document protection has password; otherwise, false.

    LimitFormatting

    Gets or sets a value indicating whether formatting is limited just to unlocked styles.

    • C#
    • VB.NET
    public bool LimitFormatting { get; set; }
    Public Property LimitFormatting As Boolean
    Property Value
    System.Boolean

    true if formatting is limited just to unlocked styles; otherwise, false.

    Methods

    SetPassword(String)

    Sets the password. If password is null or empty, any existing password will be cleared.

    • C#
    • VB.NET
    public void SetPassword(string password)
    Public Sub SetPassword(password As String)
    Parameters
    password
    System.String

    The password.

    StartEnforcingProtection(EditingRestrictionType, String)

    Starts enforcing protection by restricting document editing actions to those specified by editingRestriction parameter with optional password which must be specified to stop protection in consumer application such as MS Word.

    • C#
    • VB.NET
    public void StartEnforcingProtection(EditingRestrictionType editingRestriction, string password)
    Public Sub StartEnforcingProtection(editingRestriction As EditingRestrictionType, password As String)
    Parameters
    editingRestriction
    EditingRestrictionType

    The editing restriction enforced upon the document in consumer application such as MS Word.

    password
    System.String

    The optional password which must be specified to stop protection in consumer application such as MS Word.

    StopProtection()

    Stops enforcing protection and clears password, if there is any.

    • C#
    • VB.NET
    public void StopProtection()
    Public Sub StopProtection

    ToString()

    Returns a System.String that represents this DocumentProtection instance.

    • C#
    • VB.NET
    public override string ToString()
    Public Overrides Function ToString As String
    Returns
    System.String

    A System.String that represents this DocumentProtection instance.

    Overrides
    System.Object.ToString()
    Remarks

    This method should be used primarily for debugging purposes and should be considered volatile (format of its return value might change in future versions).

    Examples

    Restrict Editing example
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.